with self._use_driver(account) as drv:
vm_id = drv.nova_server_create(**kwargs)
if floating_ip:
- self.prepare_vdu_on_boot(account, vm_id, floating_ip)
-
+ self.prepare_vdu_on_boot(account, vm_id, floating_ip, mgmt_network = None)
return vm_id
@rwstatus
return link
@staticmethod
- def _fill_vdu_info(vm_info, flavor_info, mgmt_network, port_list, server_group, volume_list = None):
+ def _fill_vdu_info(vm_info, flavor_info, mgmt_network, port_list, server_group, volume_list=None):
"""Create a GI object for VDUInfoParams
Converts VM information dictionary object returned by openstack
for network_name, network_info in vm_info['addresses'].items():
if network_info and network_name == mgmt_network:
for interface in network_info:
- if 'OS-EXT-IPS:type' in interface:
- if interface['OS-EXT-IPS:type'] == 'fixed':
- vdu.management_ip = interface['addr']
- elif interface['OS-EXT-IPS:type'] == 'floating':
- vdu.public_ip = interface['addr']
+ for interface in network_info:
+ if 'OS-EXT-IPS:type' in interface:
+ if interface['OS-EXT-IPS:type'] == 'fixed':
+ vdu.management_ip = interface['addr']
+ elif interface['OS-EXT-IPS:type'] == 'floating':
+ vdu.public_ip = interface['addr']
# Look for any metadata
for key, value in vm_info['metadata'].items():
raise OpenstackCALOperationFailure("Create-flavor operation failed for cloud account: %s" %(account.name))
return flavor_id
- def _create_vm(self, account, vduinfo, pci_assignement=None, server_group=None, port_list=None, network_list=None, imageinfo_list=None):
+ def _create_vm(self, account, vduinfo, pci_assignement=None, server_group=None, port_list=None, network_list=None, imageinfo_list=None, mgmt_network = None):
"""Create a new virtual machine.
Arguments:
with self._use_driver(account) as drv:
vm_id = drv.nova_server_create(**kwargs)
if floating_ip:
- self.prepare_vdu_on_boot(account, vm_id, floating_ip)
+ self.prepare_vdu_on_boot(account, vm_id, floating_ip, mgmt_network)
return vm_id
"""
### First create required number of ports aka connection points
# Add the mgmt_ntwk by default.
+
mgmt_network_id = None
with self._use_driver(account) as drv:
mgmt_network_id = drv._mgmt_network_id
floating_ip = self._allocate_floating_ip(drv, pool_name)
else:
floating_ip = None
-
port_list = []
network_list = []
imageinfo_list = []
- is_explicit_mgmt_defined = False
- for c_point in vdu_init.connection_points:
+ explicit_mgmt_network = None
+ vdu_connection_points = []
+ #This check is to identify the c_point of overriding management network first
+ if vdu_init.get_mgmt_network() is not None:
+ explicit_mgmt_network = vdu_init.get_mgmt_network()
+ with self._use_driver(account) as drv:
+ overridding_mgmt_network = drv.neutron_network_by_name(explicit_mgmt_network)
+ mgmt_network_conn_point_names = []
+ for c_point in vdu_init.connection_points:
+ if overridding_mgmt_network["id"] == c_point.virtual_link_id:
+ vdu_connection_points.append(c_point)
+ mgmt_network_conn_point_names.append(c_point.name)
+
+ for c_point in vdu_init.connection_points:
+ if c_point.name not in mgmt_network_conn_point_names:
+ vdu_connection_points.append(c_point)
+ else:
+ vdu_connection_points = vdu_init.connection_points
+
+ for c_point in vdu_connection_points:
# if the user has specified explicit mgmt_network connection point
# then remove the mgmt_network from the VM list
- if c_point.virtual_link_id == mgmt_network_id:
- is_explicit_mgmt_defined = True
if c_point.virtual_link_id in network_list:
assert False, "Only one port per network supported. Refer: http://specs.openstack.org/openstack/nova-specs/specs/juno/implemented/nfv-multiple-if-1-net.html"
else:
with self._use_driver(account) as drv:
### Now Create VM
vm_network_list = []
- if not is_explicit_mgmt_defined:
+ if explicit_mgmt_network is None:
vm_network_list.append(drv._mgmt_network_id)
if vdu_init.has_field('volumes'):
if pci_assignement != '':
vm.user_tags.pci_assignement = pci_assignement
- vm_id = self._create_vm(account, vdu_init, pci_assignement=pci_assignement, server_group=server_group, port_list=port_list, network_list=vm_network_list, imageinfo_list = imageinfo_list)
- self.prepare_vdu_on_boot(account, vm_id, floating_ip)
+ vm_id = self._create_vm(account, vdu_init, pci_assignement=pci_assignement, server_group=server_group, port_list=port_list, network_list=vm_network_list, imageinfo_list = imageinfo_list, mgmt_network = explicit_mgmt_network)
return vm_id
def prepare_vpci_metadata(self, drv, vdu_init):
- def prepare_vdu_on_boot(self, account, server_id, floating_ip):
- cmd = PREPARE_VM_CMD.format(auth_url = account.openstack.auth_url,
+ def prepare_vdu_on_boot(self, account, server_id, floating_ip, mgmt_network = None):
+
+ if(mgmt_network is None):
+ cmd = PREPARE_VM_CMD.format(auth_url = account.openstack.auth_url,
username = account.openstack.key,
password = account.openstack.secret,
tenant_name = account.openstack.tenant,
mgmt_network = account.openstack.mgmt_network,
server_id = server_id)
+ else:
+ cmd = PREPARE_VM_CMD.format(auth_url = account.openstack.auth_url,
+ username = account.openstack.key,
+ password = account.openstack.secret,
+ tenant_name = account.openstack.tenant,
+ mgmt_network = mgmt_network,
+ server_id = server_id)
if floating_ip is not None:
cmd += (" --floating_ip "+ floating_ip.ip)
@rwstatus(ret_on_failure=[None])
- def do_get_vdu(self, account, vdu_id):
+ def do_get_vdu(self, account, vdu_id, mgmt_network=None):
"""Get information about a virtual deployment unit.
Arguments:
openstack_group_list = drv.nova_server_group_list()
server_group = [ i['name'] for i in openstack_group_list if vm['id'] in i['members']]
openstack_srv_volume_list = drv.nova_volume_list(vm['id'])
+
+ if mgmt_network is None:
+ mgmt_network = account.openstack.mgmt_network
vdu_info = RwcalOpenstackPlugin._fill_vdu_info(vm,
flavor_info,
- account.openstack.mgmt_network,
+ mgmt_network,
port_list,
server_group,
volume_list = openstack_srv_volume_list)