commit 32132415706b2c80efc58d3f78499e96d4d42963 Author: Aldinson Esto Date: Wed Oct 7 10:31:50 2020 +0900 Add vimConnectionId in Type:ResourceHandle This patch adds support for vimConnectionId parameter in the ResourceHandle. Change-Id: Ie90d046108d14a30f0e7c269042a0c0ea39da857 diff --git a/tacker/api/schemas/vnf_lcm.py b/tacker/api/schemas/vnf_lcm.py index 37ff802..179a6d1 100644 --- a/tacker/api/schemas/vnf_lcm.py +++ b/tacker/api/schemas/vnf_lcm.py @@ -28,7 +28,8 @@ _extManagedVirtualLinkData = { 'properties': { 'id': parameter_types.identifier, 'vnfVirtualLinkDescId': parameter_types.identifier_in_vnfd, - 'resourceId': parameter_types.identifier_in_vim + 'resourceId': parameter_types.identifier_in_vim, + 'vimConnectionId': parameter_types.identifier }, 'required': ['id', 'vnfVirtualLinkDescId', 'resourceId'], 'additionalProperties': False, @@ -124,6 +125,7 @@ _resourceHandle = { 'type': 'object', 'properties': { 'resourceId': parameter_types.identifier_in_vim, + 'vimConnectionId': parameter_types.identifier, 'vimLevelResourceType': {'type': 'string', 'maxLength': 255}, }, 'required': ['resourceId'], @@ -150,6 +152,7 @@ _extVirtualLinkData = { 'properties': { 'id': parameter_types.identifier, 'resourceId': parameter_types.identifier_in_vim, + 'vimConnectionId': parameter_types.identifier, 'extCps': _vnfExtCpData, 'extLinkPorts': _extLinkPortData, diff --git a/tacker/objects/instantiate_vnf_req.py b/tacker/objects/instantiate_vnf_req.py index a539c11..6aa2f89 100644 --- a/tacker/objects/instantiate_vnf_req.py +++ b/tacker/objects/instantiate_vnf_req.py @@ -42,7 +42,8 @@ def _get_ext_managed_virtual_links(vnf_instantiated_info): ext_mng_vl_data = objects.ExtManagedVirtualLinkData( id=ext_mng_vl_info.id, vnf_virtual_link_desc_id=ext_mng_vl_info.vnf_virtual_link_desc_id, - resource_id=network_resource.resource_id) + resource_id=network_resource.resource_id, + vim_connection_id=network_resource.vim_connection_id) ext_managed_virtual_links.append(ext_mng_vl_data) @@ -170,7 +171,8 @@ def _get_ext_virtual_link_data(vnf_instantiated_info): resource_handle = ext_vl_info.resource_handle ext_vl_data = objects.ExtVirtualLinkData( id=ext_vl_info.id, - resource_id=resource_handle.resource_id) + resource_id=resource_handle.resource_id, + vim_connection_id=resource_handle.vim_connection_id) # call vnf virtual link resource info cp_instances = _get_cp_instance_id(ext_vl_info.id, @@ -293,12 +295,14 @@ class InstantiateVnfRequest(base.TackerObject): @base.TackerObjectRegistry.register class ExtManagedVirtualLinkData(base.TackerObject): # Version 1.0: Initial version - VERSION = '1.0' + # Version 1.1: Added field for vim_connection_id + VERSION = '1.1' fields = { 'id': fields.StringField(nullable=False), 'vnf_virtual_link_desc_id': fields.StringField(nullable=False), 'resource_id': fields.StringField(nullable=False), + 'vim_connection_id': fields.StringField(nullable=True) } @classmethod @@ -307,19 +311,22 @@ class ExtManagedVirtualLinkData(base.TackerObject): vnf_virtual_link_desc_id = data_dict.get( 'vnf_virtual_link_desc_id') resource_id = data_dict.get('resource_id') + vim_connection_id = data_dict.get('vim_connection_id') obj = cls(id=id, vnf_virtual_link_desc_id=vnf_virtual_link_desc_id, - resource_id=resource_id) + resource_id=resource_id, vim_connection_id=vim_connection_id) return obj @base.TackerObjectRegistry.register class ExtVirtualLinkData(base.TackerObject): # Version 1.0: Initial version - VERSION = '1.0' + # Version 1.1: Added field for vim_connection_id + VERSION = '1.1' fields = { 'id': fields.StringField(nullable=False), 'resource_id': fields.StringField(nullable=False), + 'vim_connection_id': fields.StringField(nullable=True), 'ext_cps': fields.ListOfObjectsField( 'VnfExtCpData', nullable=True, default=[]), 'ext_link_ports': fields.ListOfObjectsField( @@ -354,11 +361,13 @@ class ExtVirtualLinkData(base.TackerObject): def _from_dict(cls, data_dict): id = data_dict.get('id') resource_id = data_dict.get('resource_id') + vim_connection_id = data_dict.get('vim_connection_id') ext_cps = data_dict.get('ext_cps', []) ext_link_ports = data_dict.get('ext_link_ports', []) obj = cls(id=id, resource_id=resource_id, ext_cps=ext_cps, - ext_link_ports=ext_link_ports) + ext_link_ports=ext_link_ports, + vim_connection_id=vim_connection_id) return obj diff --git a/tacker/objects/vnf_instantiated_info.py b/tacker/objects/vnf_instantiated_info.py index 7c3abed..e99db0b 100644 --- a/tacker/objects/vnf_instantiated_info.py +++ b/tacker/objects/vnf_instantiated_info.py @@ -1151,7 +1151,6 @@ class ResourceHandle(base.TackerObject, # Version 1.0: Initial version VERSION = '1.0' - # TODO(esto-aln):Add vimConnectionId in Type:ResourceHandle fields = { 'vim_connection_id': fields.StringField(nullable=True, default=None), diff --git a/tacker/tests/unit/vnflcm/fakes.py b/tacker/tests/unit/vnflcm/fakes.py index f1a81da..7ab707e 100644 --- a/tacker/tests/unit/vnflcm/fakes.py +++ b/tacker/tests/unit/vnflcm/fakes.py @@ -477,6 +477,8 @@ def get_instantiate_vnf_request_obj(): ext_managed_virtual_link_data.vnf_virtual_link_desc_id = 'VL3' ext_managed_virtual_link_data.resource_id = \ 'f8c35bd0-4d67-4436-9f11-14b8a84c92aa' + ext_managed_virtual_link_data.vim_connection_id = \ + 'f8c35bd0-4d67-4436-9f11-14b8a84c92aa' instantiate_vnf_req.additional_params = None instantiate_vnf_req.deleted = 0 instantiate_vnf_req.ext_managed_virtual_links = \ diff --git a/tacker/vnflcm/utils.py b/tacker/vnflcm/utils.py index 169679c..ca32dd9 100644 --- a/tacker/vnflcm/utils.py +++ b/tacker/vnflcm/utils.py @@ -661,6 +661,8 @@ def _build_vnf_virtual_link_resource_info(node_templates, instantiate_vnf_req, for ext_mg_vl in instantiate_vnf_req.ext_managed_virtual_links: if ext_mg_vl.vnf_virtual_link_desc_id == vl_node: resource_handle.resource_id = ext_mg_vl.resource_id + resource_handle.vim_connection_id = \ + ext_mg_vl.vim_connection_id # TODO(tpatil): This cannot be set here. resource_handle.vim_level_resource_type = \ 'OS::Neutron::Net' @@ -672,6 +674,8 @@ def _build_vnf_virtual_link_resource_info(node_templates, instantiate_vnf_req, for ext_virt_link in instantiate_vnf_req.ext_virtual_links: if ext_virt_link.id == vl_node: resource_handle.resource_id = ext_virt_link.resource_id + resource_handle.vim_connection_id = \ + ext_virt_link.vim_connection_id # TODO(tpatil): This cannot be set here. resource_handle.vim_level_resource_type = \ 'OS::Neutron::Net' @@ -692,6 +696,8 @@ def _build_vnf_virtual_link_resource_info(node_templates, instantiate_vnf_req, if cpconfig.link_port_id: resource_handle.resource_id = \ cpconfig.link_port_id + resource_handle.vim_connection_id = \ + ext_virt_link.vim_connection_id # TODO(tpatil): This shouldn't be set here. resource_handle.vim_level_resource_type = \ 'OS::Neutron::Port' @@ -910,6 +916,7 @@ def _set_ext_virtual_link_info(instantiate_vnf_req, ext_cp_info): for ext_virtual_link in instantiate_vnf_req.ext_virtual_links: res_handle = objects.ResourceHandle() res_handle.resource_id = ext_virtual_link.resource_id + res_handle.vim_connection_id = ext_virtual_link.vim_connection_id ext_virtual_link_info = objects.ExtVirtualLinkInfo( id=ext_virtual_link.id, @@ -953,6 +960,8 @@ def _build_ext_managed_virtual_link_info(instantiate_vnf_req, inst_vnf_info): # driver. It could be different for other infra drivers like # Kubernetes. resource_handle.vim_level_resource_type = 'OS::Neutron::Net' + resource_handle.vim_connection_id = \ + ext_managed_vl.vim_connection_id return resource_handle diff --git a/tacker/vnfm/infra_drivers/openstack/openstack.py b/tacker/vnfm/infra_drivers/openstack/openstack.py index 6bea16f..b5bfbc5 100644 --- a/tacker/vnfm/infra_drivers/openstack/openstack.py +++ b/tacker/vnfm/infra_drivers/openstack/openstack.py @@ -894,11 +894,13 @@ class OpenStack(abstract_driver.VnfAbstractDriver, stack_resources = self._get_stack_resources( inst_vnf_info.instance_id, heatclient) - self._update_vnfc_resources(vnf_instance, stack_resources) + self._update_vnfc_resources(vnf_instance, stack_resources, + vim_connection_info) self._update_vnfc_info(vnf_instance) def _update_resource_handle(self, vnf_instance, resource_handle, - stack_resources, resource_name): + stack_resources, resource_name, + vim_connection_info): if not stack_resources: LOG.warning("Failed to set resource handle for resource " "%(resource)s for vnf %(id)s", {"resource": resource_name, @@ -912,13 +914,15 @@ class OpenStack(abstract_driver.VnfAbstractDriver, {"resource": resource_name, "id": vnf_instance.id}) return + resource_handle.vim_connection_id = vim_connection_info.id resource_handle.resource_id = resource_data.get( 'physical_resource_id') resource_handle.vim_level_resource_type = resource_data.get( 'resource_type') def _update_vnfc_resource_info(self, vnf_instance, vnfc_res_info, - stack_resources, update_network_resource=True): + stack_resources, vim_connection_info, + update_network_resource=True): inst_vnf_info = vnf_instance.instantiated_vnf_info def _pop_stack_resources(resource_name): @@ -949,6 +953,7 @@ class OpenStack(abstract_driver.VnfAbstractDriver, vnf_virtual_link_desc_id) resource_handle = vnf_vl_resource_info.network_resource + resource_handle.vim_connection_id = vim_connection_info.id resource_handle.resource_id = \ vl_resource_data.get('physical_resource_id') resource_handle.vim_level_resource_type = \ @@ -964,7 +969,8 @@ class OpenStack(abstract_driver.VnfAbstractDriver, vl_link_port_found = True self._update_resource_handle(vnf_instance, vl_link_port.resource_handle, pop_resources, - vnfc_cp_info.cpd_id) + vnfc_cp_info.cpd_id, + vim_connection_info) if vl_link_port_found: yield vnf_vl_resource_info.vnf_virtual_link_desc_id @@ -978,7 +984,8 @@ class OpenStack(abstract_driver.VnfAbstractDriver, self._update_resource_handle(vnf_instance, vir_storage_res_info.storage_resource, pop_resources, - vir_storage_res_info.virtual_storage_desc_id) + vir_storage_res_info.virtual_storage_desc_id, + vim_connection_info) break stack_id, pop_resources = _pop_stack_resources( @@ -986,7 +993,7 @@ class OpenStack(abstract_driver.VnfAbstractDriver, self._update_resource_handle(vnf_instance, vnfc_res_info.compute_resource, pop_resources, - vnfc_res_info.vdu_id) + vnfc_res_info.vdu_id, vim_connection_info) vnfc_res_info.metadata.update({"stack_id": stack_id}) _populate_virtual_storage(vnfc_res_info, pop_resources) @@ -1012,6 +1019,8 @@ class OpenStack(abstract_driver.VnfAbstractDriver, for ext_vl_port in ext_managed_vl_info.vnf_link_ports: if vl_port.id == ext_vl_port.id: # Update the resource_id + ext_vl_port.resource_handle.vim_connection_id =\ + vl_port.resource_handle.vim_connection_id ext_vl_port.resource_handle.resource_id =\ vl_port.resource_handle.resource_id ext_vl_port.resource_handle.vim_level_resource_type =\ @@ -1038,11 +1047,12 @@ class OpenStack(abstract_driver.VnfAbstractDriver, inst_vnf_info.vnfc_info = vnfc_info - def _update_vnfc_resources(self, vnf_instance, stack_resources): + def _update_vnfc_resources(self, vnf_instance, stack_resources, + vim_connection_info): inst_vnf_info = vnf_instance.instantiated_vnf_info for vnfc_res_info in inst_vnf_info.vnfc_resource_info: self._update_vnfc_resource_info(vnf_instance, vnfc_res_info, - stack_resources) + stack_resources, vim_connection_info) # update vnf_link_ports of ext_managed_virtual_link_info using already # populated vnf_link_ports from vnf_virtual_link_resource_info. @@ -1232,7 +1242,8 @@ class OpenStack(abstract_driver.VnfAbstractDriver, error=error) self._update_vnfc_resource_info(vnf_instance, vnfc_res_info, - {stack_id: resources}, update_network_resource=False) + {stack_id: resources}, vim_connection_info, + update_network_resource=False) @log.log def get_scale_ids(self, plugin, context, vnf_dict, auth_attr,