return self.uri
else:
raise KeyError("Invalid key '{}'".format(index))
-
+
def __setitem__(self, index, value):
if index == 'tenant':
self.tenant_id_name = value
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:
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)
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)
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
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):
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: