diff --git a/devops/models/environment.py b/devops/models/environment.py index 43897d8f..5c621604 100644 --- a/devops/models/environment.py +++ b/devops/models/environment.py @@ -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): @@ -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) ] ) @@ -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): @@ -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): diff --git a/devops/models/node.py b/devops/models/node.py index d2369773..4093faa2 100644 --- a/devops/models/node.py +++ b/devops/models/node.py @@ -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( diff --git a/devops/settings.py b/devops/settings.py index 01595b13..ba13d1cf 100644 --- a/devops/settings.py +++ b/devops/settings.py @@ -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)), @@ -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