Skip to content

Commit

Permalink
add ironic support:
Browse files Browse the repository at this point in the history
 * Add new network 'ironic'
 * Add new role 'ironic_slave'. This VM looks like
   current 'slave' node, but it is connected ONLY
   to "ironic" network.
 * fix Node.interface_by_name method. Rename it to
   interface_by_network_name

Partially Implements: blueprint integrate-ironic-to-test-tools

Change-Id: Idd9ebca53c2cfd0df088c7d516f6285ad58fe7db
  • Loading branch information
jumpojoy committed Sep 21, 2015
1 parent f665896 commit 4f2b8b4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
20 changes: 18 additions & 2 deletions devops/models/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ def describe_environment(cls, boot_from='cdrom'):
]

environment.describe_empty_node(name, networks_to_describe)
for name in environment.node_roles.ironic_names:
ironic_net = []
for net in networks:
if net.name == 'ironic':
ironic_net.append(net)
environment.describe_empty_node(name, ironic_net)
return environment

def create_networks(self, name):
Expand Down Expand Up @@ -251,6 +257,10 @@ def node_roles(self):
admin_names=['admin'],
other_names=[
'slave-%02d' % x for x in range(1, settings.NODES_COUNT)
],
ironic_names=[
'ironic-slave-%02d' % x for x in range(
1, settings.IRONIC_NODES_COUNT + 1)
]
)

Expand Down Expand Up @@ -365,9 +375,11 @@ def get_ssh_to_remote_by_key(self, ip, keyfile):
class NodeRoles(object):
def __init__(self,
admin_names=None,
other_names=None):
other_names=None,
ironic_names=None):
self.admin_names = admin_names or []
self.other_names = other_names or []
self.ironic_names = ironic_names or []


class Nodes(object):
Expand All @@ -380,8 +392,12 @@ def __init__(self, environment, node_roles):
list(environment.get_nodes(name__in=node_roles.other_names)),
key=lambda node: node.name
)
self.ironics = sorted(
list(environment.get_nodes(name__in=node_roles.ironic_names)),
key=lambda node: node.name
)
self.slaves = self.others
self.all = self.slaves + self.admins
self.all = self.slaves + self.admins + self.ironics
self.admin = self.admins[0]

def __iter__(self):
Expand Down
5 changes: 3 additions & 2 deletions devops/models/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ def interfaces(self):
def vnc_password(self):
return settings.VNC_PASSWORD

def interface_by_name(self, name):
self.interfaces.filter(name=name)
def interface_by_network_name(self, network_name):
return self.interface_set.filter(
network__name=network_name)

def get_ip_address_by_network_name(self, name, interface=None):
interface = interface or self.interface_set.filter(
Expand Down
11 changes: 11 additions & 0 deletions devops/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
}

NODES_COUNT = int(os.environ.get('NODES_COUNT', 10))
IRONIC_NODES_COUNT = int(os.environ.get('IRONIC_NODES_COUNT', 0))

HARDWARE = {
"admin_node_memory": int(os.environ.get("ADMIN_NODE_MEMORY", 2048)),
Expand All @@ -190,6 +191,16 @@
USE_ALL_DISKS = os.environ.get('USE_ALL_DISKS', 'true') == 'true'
ISO_PATH = os.environ.get('ISO_PATH')

IRONIC_ENABLED = os.environ.get('IRONIC_ENABLED', False) == 'true'

if IRONIC_ENABLED:
POOL_IRONIC = os.environ.get('POOL_IRONIC', POOL_DEFAULT)
IRONIC_FORWARD = os.environ.get('IRONIC_FORWARD', FORWARD_DEFAULT)
FORWARDING['ironic'] = IRONIC_FORWARD
DHCP['ironic'] = False
POOLS['ironic'] = POOL_IRONIC.split(':')
INTERFACE_ORDER.append('ironic')

if MULTIPLE_NETWORKS:
FORWARDING['admin2'] = ADMIN_FORWARD
FORWARDING['public2'] = PUBLIC_FORWARD
Expand Down

0 comments on commit 4f2b8b4

Please sign in to comment.