X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_lcm%2FROclient.py;h=1fd5f95f0aba89c55f1c31e5c78c391560393810;hb=c2033f23c8111a172f70873beda52735e23f41a6;hp=fe12f8b3d7c3fb506fb49f5136933f6f62a8b4bf;hpb=22f4f9c3f2fef11377202b95fe2333b78255f8de;p=osm%2FLCM.git diff --git a/osm_lcm/ROclient.py b/osm_lcm/ROclient.py index fe12f8b..1fd5f95 100644 --- a/osm_lcm/ROclient.py +++ b/osm_lcm/ROclient.py @@ -99,12 +99,12 @@ def remove_envelop(item, indata=None): class ROClient: headers_req = {'Accept': 'application/yaml', 'content-type': 'application/yaml'} client_to_RO = {'tenant': 'tenants', 'vim': 'datacenters', 'vim_account': 'datacenters', 'sdn': 'sdn_controllers', - 'vnfd': 'vnfs', 'nsd': 'scenarios', + 'vnfd': 'vnfs', 'nsd': 'scenarios', 'ns': 'instances'} mandatory_for_create = { 'tenant': ("name", ), - 'vnfd': ("name", "id", "connection-point", "vdu"), - 'nsd': ("name", "id", "constituent-vnfd"), + 'vnfd': ("name", "id"), + 'nsd': ("name", "id"), 'ns': ("name", "scenario", "datacenter"), 'vim': ("name", "vim_url"), 'vim_account': (), @@ -206,7 +206,7 @@ class ROClient: try: UUID(uuid_text) return True - except (ValueError, TypeError): + except Exception: return False @staticmethod @@ -353,7 +353,7 @@ class ROClient: """ ns_info = {} for vnf in ns_descriptor["vnfs"]: - if not vnf.get("ip_address"): + if not vnf.get("ip_address") and vnf.get("vms"): raise ROClientException("ns member_vnf_index '{}' has no IP address".format( vnf["member_vnf_index"]), http_code=409) vnfr_info = { @@ -693,7 +693,14 @@ class ROClient: all_tenants = None with aiohttp.ClientSession(loop=self.loop) as session: - return await self._del_item(session, self.client_to_RO[item], item_id_name, all_tenants=all_tenants) + result = await self._del_item(session, self.client_to_RO[item], item_id_name, all_tenants=all_tenants) + # in case of ns delete, get the action_id embeded in text + if item == "ns" and result.get("result"): + _, _, action_id = result["result"].partition("action_id=") + action_id, _, _ = action_id.partition(" ") + if action_id: + result["action_id"] = action_id + return result except aiohttp.errors.ClientOSError as e: raise ROClientException(e, http_code=504) except asyncio.TimeoutError: @@ -750,7 +757,7 @@ class ROClient: async def create(self, item, descriptor=None, descriptor_format=None, **kwargs): """ Creates an item from its descriptor - :param item: can be 'tenant', 'vnfd', 'nsd', 'ns', 'vim', 'vim_account', 'sdn' + :param item: can be 'tenant', 'vnfd', 'nsd', 'ns', 'vim', 'vim_account', 'sdn', nstd :param descriptor: can be a dict, or a yaml/json text. Autodetect unless descriptor_format is provided :param descriptor_format: Can be 'json' or 'yaml' :param kwargs: Overrides descriptor with values as name, description, vim_url, vim_url_admin, vim_type