From: Hashir Mohammed Date: Thu, 22 Dec 2016 14:35:25 +0000 (-0500) Subject: RIFT-14562 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fstatic_ip;p=osm%2FSO.git RIFT-14562 Minor changes * Changed the logic to identify the conn_point of the overriding mgmt_network * Identation fixes * Refactored a method Reviewer: TBD Philip Signed-off-by: Hashir Mohammed --- diff --git a/rwcal/plugins/vala/rwcal_aws/rwcal_aws.py b/rwcal/plugins/vala/rwcal_aws/rwcal_aws.py index 8854b17b..9a0ab091 100644 --- a/rwcal/plugins/vala/rwcal_aws/rwcal_aws.py +++ b/rwcal/plugins/vala/rwcal_aws/rwcal_aws.py @@ -1071,7 +1071,7 @@ class RwcalAWSPlugin(GObject.Object, RwCal.Cloud): @rwstatus(ret_on_failure=[None]) - def do_get_vdu(self, account, vdu_id, mgmt_network = None): + def do_get_vdu(self, account, vdu_id, mgmt_network=None): """Get information about a virtual deployment unit. Arguments: diff --git a/rwcal/plugins/vala/rwcal_cloudsim/rwcal_cloudsim.py b/rwcal/plugins/vala/rwcal_cloudsim/rwcal_cloudsim.py index ac81a3e8..5cb9572c 100644 --- a/rwcal/plugins/vala/rwcal_cloudsim/rwcal_cloudsim.py +++ b/rwcal/plugins/vala/rwcal_cloudsim/rwcal_cloudsim.py @@ -1390,7 +1390,7 @@ class CloudSimPlugin(GObject.Object, RwCal.Cloud): return vdu @rwstatus(ret_on_failure=[None]) - def do_get_vdu(self, account, vdu_id, mgmt_network = None): + def do_get_vdu(self, account, vdu_id, mgmt_network=None): """Get information about a virtual deployment unit. Arguments: diff --git a/rwcal/plugins/vala/rwcal_cloudsimproxy/rwcal_cloudsimproxy.py b/rwcal/plugins/vala/rwcal_cloudsimproxy/rwcal_cloudsimproxy.py index d81c6f36..4a9ba758 100644 --- a/rwcal/plugins/vala/rwcal_cloudsimproxy/rwcal_cloudsimproxy.py +++ b/rwcal/plugins/vala/rwcal_cloudsimproxy/rwcal_cloudsimproxy.py @@ -682,7 +682,7 @@ class CloudSimProxyPlugin(GObject.Object, RwCal.Cloud): return self._proxy_rpc_call("delete_vdu", vdu_id=vdu_id) @rwstatus(ret_on_failure=[None]) - def do_get_vdu(self, account, vdu_id, mgmt_network = None): + def do_get_vdu(self, account, vdu_id, mgmt_network=None): """Get information about a virtual deployment unit. Arguments: diff --git a/rwcal/plugins/vala/rwcal_mock/rwcal_mock.py b/rwcal/plugins/vala/rwcal_mock/rwcal_mock.py index 13cc403a..182e366d 100644 --- a/rwcal/plugins/vala/rwcal_mock/rwcal_mock.py +++ b/rwcal/plugins/vala/rwcal_mock/rwcal_mock.py @@ -599,7 +599,7 @@ class MockPlugin(GObject.Object, RwCal.Cloud): logger.debug('deleted vdu: {}'.format(vdu_id)) @rwstatus(ret_on_failure=[None]) - def do_get_vdu(self, account, vdu_id, mgmt_network = None): + def do_get_vdu(self, account, vdu_id, mgmt_network=None): vdu = self.resources[account.name].vdus[vdu_id] logger.debug('Returning vdu-info for : {}'.format(vdu_id)) return vdu.copy() diff --git a/rwcal/plugins/vala/rwcal_openmano/rwcal_openmano.py b/rwcal/plugins/vala/rwcal_openmano/rwcal_openmano.py index 93d6d2fc..57827000 100644 --- a/rwcal/plugins/vala/rwcal_openmano/rwcal_openmano.py +++ b/rwcal/plugins/vala/rwcal_openmano/rwcal_openmano.py @@ -246,7 +246,7 @@ class RwcalOpenmanoPlugin(GObject.Object, RwCal.Cloud): raise NotImplementedError() @rwstatus(ret_on_failure=[None]) - def do_get_vdu(self, account, vdu_id, mgmt_network = None): + def do_get_vdu(self, account, vdu_id, mgmt_network=None): raise NotImplementedError() @rwstatus(ret_on_failure=[""]) diff --git a/rwcal/plugins/vala/rwcal_openmano_vimconnector/rwcal_openmano_vimconnector.py b/rwcal/plugins/vala/rwcal_openmano_vimconnector/rwcal_openmano_vimconnector.py index f39662cf..374f1a48 100644 --- a/rwcal/plugins/vala/rwcal_openmano_vimconnector/rwcal_openmano_vimconnector.py +++ b/rwcal/plugins/vala/rwcal_openmano_vimconnector/rwcal_openmano_vimconnector.py @@ -646,7 +646,7 @@ class RwcalOpenmanoVimConnector(GObject.Object, RwCal.Cloud): return vdu @rwstatus(ret_on_failure=[None]) - def do_get_vdu(self, account, vdu_id, mgmt_network = None): + def do_get_vdu(self, account, vdu_id, mgmt_network=None): with self._use_driver(account) as drv: vm_info = drv.get_vminstance(vdu_id) return RwcalOpenmanoVimConnector._fill_vdu_info(drv,account,vm_info) diff --git a/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/openstack_drv.py b/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/openstack_drv.py index 5f44e5e0..e30919f9 100644 --- a/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/openstack_drv.py +++ b/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/openstack_drv.py @@ -1843,6 +1843,13 @@ class OpenstackDriver(object): def neutron_network_get(self, network_id): return self.neutron_drv.network_get(network_id) + def neutron_network_by_name(self, network_name): + networks = self.neutron_network_list() + for network in networks: + if network_name == network["name"]: + return network + return None + def neutron_network_create(self, **kwargs): return self.neutron_drv.network_create(**kwargs) diff --git a/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py b/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py index 8f2678f2..b430886f 100644 --- a/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py +++ b/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py @@ -500,7 +500,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): vm.state = vm_info['status'] for network_name, network_info in vm_info['addresses'].items(): if network_info: - if network_name == mgmt_network : + if network_name == mgmt_network: vm.public_ip = next((item['addr'] for item in network_info if item['OS-EXT-IPS:type'] == 'floating'), @@ -1227,7 +1227,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): return link @staticmethod - def _fill_vdu_info(vm_info, flavor_info, mgmt_network, port_list, server_group, volume_list = None, overridden_mgmt_network = 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 @@ -1246,7 +1246,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): vdu.name = vm_info['name'] vdu.vdu_id = vm_info['id'] for network_name, network_info in vm_info['addresses'].items(): - if network_info and network_name == mgmt_network or network_name == overridden_mgmt_network : + if network_info and network_name == mgmt_network: for interface in network_info: for interface in network_info: if 'OS-EXT-IPS:type' in interface: @@ -2034,10 +2034,25 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): network_list = [] imageinfo_list = [] 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() - - for c_point in reversed(vdu_init.connection_points): + 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 in network_list: @@ -2274,7 +2289,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): @rwstatus(ret_on_failure=[None]) - def do_get_vdu(self, account, vdu_id, mgmt_network = None): + def do_get_vdu(self, account, vdu_id, mgmt_network=None): """Get information about a virtual deployment unit. Arguments: @@ -2299,13 +2314,15 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): 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, - overridden_mgmt_network = mgmt_network) + volume_list = openstack_srv_volume_list) if vdu_info.state == 'active': try: console_info = drv.nova_server_console(vdu_info.vdu_id) diff --git a/rwcal/plugins/vala/rwcal_vsphere/rwcal_vsphere.py b/rwcal/plugins/vala/rwcal_vsphere/rwcal_vsphere.py index cda38674..0a39ea02 100644 --- a/rwcal/plugins/vala/rwcal_vsphere/rwcal_vsphere.py +++ b/rwcal/plugins/vala/rwcal_vsphere/rwcal_vsphere.py @@ -230,7 +230,7 @@ class RwcalVspherePlugin(GObject.Object, RwCal.Cloud): raise NotImplementedError() @rwstatus(ret_on_failure=[None]) - def do_get_vdu(self, account, vdu_id, mgmt_network = None): + def do_get_vdu(self, account, vdu_id, mgmt_network=None): raise NotImplementedError() @rwstatus(ret_on_failure=[""]) diff --git a/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py b/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py index 460b2739..495491a1 100755 --- a/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py +++ b/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py @@ -855,6 +855,7 @@ class VirtualDeploymentUnitRecord(object): if (query_action == rwdts.QueryAction.UPDATE or query_action == rwdts.QueryAction.CREATE): self._vm_resp = msg + if msg.resource_state == "active": # Move this VDU to ready state yield from self.vdu_is_active() @@ -883,6 +884,7 @@ class VirtualDeploymentUnitRecord(object): vm_resp = yield from self.create_resource(xact, vnfr, config) self._vm_resp = vm_resp + self._state = VDURecordState.RESOURCE_ALLOC_PENDING self._log.debug("Requested VM from resource manager response %s", vm_resp) @@ -1257,6 +1259,7 @@ class VirtualNetworkFunctionRecord(object): mgmt_intf = VnfrYang.YangData_Vnfr_VnfrCatalog_Vnfr_MgmtInterface() ip_address, port = self.mgmt_intf_info() + if ip_address is not None: mgmt_intf.ip_address = ip_address if port is not None: