From: endika Date: Mon, 14 Sep 2020 09:20:00 +0000 (+0200) Subject: Fix typo in ROclient.py printable ids X-Git-Tag: release-v9.0-start~30 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F06%2F9706%2F1;p=osm%2FLCM.git Fix typo in ROclient.py printable ids Change-Id: I094275fd0f62d7499a01bf601351dc4f255c0d5f Signed-off-by: endika --- diff --git a/osm_lcm/ROclient.py b/osm_lcm/ROclient.py index db2be1c..cf11490 100644 --- a/osm_lcm/ROclient.py +++ b/osm_lcm/ROclient.py @@ -147,7 +147,7 @@ class ROClient: return self.uri else: raise KeyError("Invalid key '{}'".format(index)) - + def __setitem__(self, index, value): if index == 'tenant': self.tenant_id_name = value @@ -298,14 +298,14 @@ class ROClient: def _get_ref(desc): # return an identification for the network or vm. Try vim_id if exist, if not descriptor id for net if desc.get("vim_net_id"): - return "'vim-id={}'".format(desc["vim_net_id"]) + return "'vim-net-id={}'".format(desc["vim_net_id"]) elif desc.get("ns_net_osm_id"): return "'nsd-vld-id={}'".format(desc["ns_net_osm_id"]) elif desc.get("vnf_net_osm_id"): return "'vnfd-vld-id={}'".format(desc["vnf_net_osm_id"]) # for VM elif desc.get("vim_vm_id"): - return "'vim-id={}'".format(desc["vim_vm_id"]) + return "'vim-vm-id={}'".format(desc["vim_vm_id"]) elif desc.get("vdu_osm_id"): return "'vnfd-vdu-id={}'".format(desc["vdu_osm_id"]) else: @@ -516,7 +516,7 @@ class ROClient: if not self.tenant: self.tenant = await self._get_item_uuid(session, "tenants", self.tenant_id_name, None) return self.tenant - + async def _get_datacenter(self, session): if not self.tenant: await self._get_tenant(session) @@ -637,7 +637,7 @@ class ROClient: tenant_text = "/" + self.tenant payload_req = yaml.safe_dump(descriptor) - + # print payload_req url = "{}{}/{}/{}".format(self.uri, tenant_text, item, item_id) self.logger.debug("RO PUT %s %s", url, payload_req) @@ -984,14 +984,14 @@ class ROClient: url = "{}/{tenant}/{item}/{datacenter}".format(self.uri, tenant=tenant, item=self.client_to_RO[item], datacenter=item_id) self.logger.debug("RO DELETE %s", url) - + # timeout = aiohttp.ClientTimeout(total=self.timeout_large) async with session.delete(url, headers=self.headers_req) as response: response_text = await response.read() self.logger.debug("DELETE {} [{}] {}".format(url, response.status, response_text[:100])) if response.status >= 300: raise ROClientException(self._parse_error_yaml(response_text), http_code=response.status) - + response_desc = self._parse_yaml(response_text, response=True) desc = remove_envelop(item, response_desc) return desc @@ -1113,31 +1113,31 @@ class ROClient: self.logger.debug("GET %s", url) mano_response = requests.get(url, headers=self.headers_req) self.logger.debug("RO response: %s", mano_response.text) - content = self._parse_yaml(mano_response.text, response=True) + content = self._parse_yaml(mano_response.text, response=True) if mano_response.status_code == 200: return content else: - raise ROClientException(str(content), http_code=mano_response.status) + raise ROClientException(str(content), http_code=mano_response.status) elif action == "get" or action == "show": url = "{}{}/vim/{}/{}/{}".format(self.uri, tenant_text, datacenter, item, uuid) self.logger.debug("GET %s", url) mano_response = requests.get(url, headers=self.headers_req) self.logger.debug("RO response: %s", mano_response.text) - content = self._parse_yaml(mano_response.text, response=True) + content = self._parse_yaml(mano_response.text, response=True) if mano_response.status_code == 200: return content else: - raise ROClientException(str(content), http_code=mano_response.status) + raise ROClientException(str(content), http_code=mano_response.status) elif action == "delete": url = "{}{}/vim/{}/{}/{}".format(self.uri, tenant_text, datacenter, item, uuid) self.logger.debug("DELETE %s", url) mano_response = requests.delete(url, headers=self.headers_req) self.logger.debug("RO response: %s", mano_response.text) - content = self._parse_yaml(mano_response.text, response=True) + content = self._parse_yaml(mano_response.text, response=True) if mano_response.status_code == 200: return content else: - raise ROClientException(str(content), http_code=mano_response.status) + raise ROClientException(str(content), http_code=mano_response.status) elif action == "create": if "descriptor" in kwargs: if isinstance(kwargs["descriptor"], str): @@ -1148,7 +1148,7 @@ class ROClient: descriptor = {item[:-1]: {"name": kwargs["name"]}} else: raise ROClientException("Missing descriptor") - + if item[:-1] not in descriptor or len(descriptor) != 1: raise ROClientException("Descriptor must contain only one 'tenant' field") if "name" in kwargs: