def get_field(self, ns_name, field): nsr = self.get(ns_name) print(yaml.safe_dump(nsr)) if nsr is None: raise NotFound("failed to retrieve ns {}".format(ns_name)) if field in nsr: return nsr[field] raise NotFound("failed to find {} in ns {}".format(field, ns_name))
def _get_ro_datacenter(self, name, tenant_uuid='any'): resp = self._ro_http.get_cmd('openmano/{}/datacenters/{}'.format( tenant_uuid, name)) if not resp: raise NotFound("datacenter {} not found".format(name)) if 'datacenter' in resp and 'uuid' in resp['datacenter']: return resp['datacenter'] else: raise NotFound("datacenter {} not found".format(name))
def get_field(self, ns_name, field): nsr = self.get(ns_name) if nsr is None: raise NotFound("failed to retrieve ns {}".format(ns_name)) if field in nsr: return nsr[field] nsopdata = self.get_opdata(nsr['id']) if field in nsopdata['nsr:nsr']: return nsopdata['nsr:nsr'][field] raise NotFound("failed to find {} in ns {}".format(field, ns_name))
def get_individual(self, name): self._logger.debug("") pdud = self.get(name) # It is redundant, since the previous one already gets the whole pdudInfo # The only difference is that a different primitive is exercised try: _, resp = self._http.get2_cmd('{}/{}'.format( self._apiBase, pdud['_id'])) except NotFound: raise NotFound("pdu '{}' not found".format(name)) #print(yaml.safe_dump(resp)) if resp: return json.loads(resp) raise NotFound("pdu '{}' not found".format(name))
def get_individual(self, name): self._logger.debug("") # Call to get_token not required, because will be implicitly called by get. try: nsd = self.get(name) # It is redundant, since the previous one already gets the whole nsdinfo # The only difference is that a different primitive is exercised _, resp = self._http.get2_cmd('{}/{}'.format( self._apiBase, nsd['_id'])) #print(yaml.safe_dump(resp)) if resp: return json.loads(resp) except NotFound: raise NotFound("nsd '{}' not found".format(name)) raise NotFound("nsd '{}' not found".format(name))
def get_id(self, name): """Returns a VIM id from a VIM name """ for vim in self.list(): if name == vim['name']: return vim['uuid'] raise NotFound("vim {} not found".format(name))
def _terminate(self, ns_name): ns = self.get(ns_name) if ns is None: raise NotFound("cannot find ns {}".format(ns_name)) return self._http.delete_cmd('api/config/{}ns-instance-config/nsr/{}' .format(self._client.so_rbac_project_path, ns['id']))
def get_id(self, name): """Returns a K8s cluster id from a K8s cluster name """ for cluster in self.list(): if name == cluster['name']: return cluster['_id'] raise NotFound("K8s cluster {} not found".format(name))
def get(self, name): """Returns an ns based on name """ for ns in self.list(): if name == ns['name']: return ns raise NotFound("ns {} not found".format(name))
def get(self, vnf_name): vnfs = self.list() for vnf in vnfs: if vnf_name == vnf['name']: return vnf if vnf_name == vnf['id']: return vnf raise NotFound("vnf {} not found".format(vnf_name))
def get_id(self, name): """Returns a WIM id from a WIM name """ self._logger.debug("") for wim in self.list(): if name == wim['name']: return wim['uuid'] raise NotFound("wim {} not found".format(name))
def get_id(self, name): """Returns a repo id from a repo name """ self._client.get_token() for repo in self.list(): if name == repo['name']: return repo['_id'] raise NotFound("Repo {} not found".format(name))
def get_individual(self, name): self._logger.debug("") self._client.get_token() ns_id = name if not utils.validate_uuid4(name): for ns in self.list(): if name == ns['name']: ns_id = ns['_id'] break try: _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase, ns_id)) #resp = self._http.get_cmd('{}/{}/nsd_content'.format(self._apiBase, ns_id)) #print(yaml.safe_dump(resp)) if resp: return json.loads(resp) except NotFound: raise NotFound("ns '{}' not found".format(name)) raise NotFound("ns '{}' not found".format(name))
def get_vim_account_id(vim_account): self._logger.debug("") if vim_account_id.get(vim_account): return vim_account_id[vim_account] vim = self._client.vim.get(vim_account) if vim is None: raise NotFound("cannot find vim account '{}'".format(vim_account)) vim_account_id[vim_account] = vim['_id'] return vim['_id']
def get_individual(self, name): vnfd = self.get(name) # It is redundant, since the previous one already gets the whole vnfpkginfo # The only difference is that a different primitive is exercised resp = self._http.get_cmd('{}/{}'.format(self._apiBase, vnfd['_id'])) #print yaml.safe_dump(resp) if resp: return resp raise NotFound("vnfd {} not found".format(name))
def get_individual(self, name): self._logger.debug("") self._client.get_token() vnf_id = name if not utils.validate_uuid4(name): for vnf in self.list(): if name == vnf['name']: vnf_id = vnf['_id'] break try: _, resp = self._http.get2_cmd('{}/{}'.format( self._apiBase, vnf_id)) #print('RESP: {}'.format(resp)) if resp: return json.loads(resp) except NotFound: raise NotFound("vnf '{}' not found".format(name)) raise NotFound("vnf '{}' not found".format(name))
def get(self, name): if utils.validate_uuid4(name): for vnfd in self.list(): if name == vnfd['_id']: return vnfd else: for vnfd in self.list(): if 'name' in vnfd and name == vnfd['name']: return vnfd raise NotFound("vnfd {} not found".format(name))
def get(self, name): if utils.validate_uuid4(name): for pdud in self.list(): if name == pdud['_id']: return pdud else: for pdud in self.list(): if 'name' in pdud and name == pdud['name']: return pdud raise NotFound("pdud {} not found".format(name))
def delete(self, nsd_name): nsd = self.get(nsd_name) if nsd is None: raise NotFound("cannot find nsd {}".format(nsd_name)) resp = self._http.delete_cmd( 'api/running/{}nsd-catalog/nsd/{}' .format(self._client.so_rbac_project_path, nsd['id'])) if 'success' not in resp: raise ClientException("failed to delete nsd {}".format(nsd_name))
def get(self, name): if utils.validate_uuid4(name): for nst in self.list(): if name == nst['_id']: return nst else: for nst in self.list(): if 'name' in nst and name == nst['name']: return nst raise NotFound("nst {} not found".format(name))
def get(self, name): """Returns an SDN controller based on name or id """ if utils.validate_uuid4(name): for sdnc in self.list(): if name == sdnc['_id']: return sdnc else: for sdnc in self.list(): if name == sdnc['name']: return sdnc raise NotFound("SDN controller {} not found".format(name))
def get(self, name): self._logger.debug("") self._client.get_token() if utils.validate_uuid4(name): for pdud in self.list(): if name == pdud['_id']: return pdud else: for pdud in self.list(): if 'name' in pdud and name == pdud['name']: return pdud raise NotFound("pdud {} not found".format(name))
def get(self, name): self._logger.debug("") self._client.get_token() if utils.validate_uuid4(name): for nst in self.list(): if name == nst['_id']: return nst else: for nst in self.list(): if 'name' in nst and name == nst['name']: return nst raise NotFound("nst {} not found".format(name))
def get_wim_account_id(wim_account): if not isinstance(wim_account, str): return wim_account if wim_account_id.get(wim_account): return wim_account_id[wim_account] wim = self._client.wim.get(wim_account) if wim is None: raise NotFound( "cannot find wim account '{}'".format(wim_account)) wim_account_id[wim_account] = wim['_id'] return wim['_id']
def get(self, name): """Returns a VNF instance based on name or id """ if utils.validate_uuid4(name): for vnf in self.list(): if name == vnf['_id']: return vnf else: for vnf in self.list(): if name == vnf['name']: return vnf raise NotFound("vnf {} not found".format(name))
def get(self, name): """Returns a VIM account based on name or id """ vim_id = name if not utils.validate_uuid4(name): vim_id = self.get_id(name) resp = self._http.get_cmd('{}/{}'.format(self._apiBase, vim_id)) if not resp or '_id' not in resp: raise ClientException('failed to get vim info: '.format(resp)) else: return resp raise NotFound("vim {} not found".format(name))
def get(self, name): """Returns an NSI based on name or id """ if utils.validate_uuid4(name): for nsi in self.list(): if name == nsi['_id']: return nsi else: for nsi in self.list(): if name == nsi['name']: return nsi raise NotFound("nsi {} not found".format(name))
def get(self, name): """Returns a specific OSM project based on name or id """ if utils.validate_uuid4(name): for proj in self.list(): if name == proj['_id']: return proj else: for proj in self.list(): if name == proj['name']: return proj raise NotFound("Project {} not found".format(name))
def get_wim_account_id(wim_account): self._logger.debug("") # wim_account can be False (boolean) to indicate not use wim account if not isinstance(wim_account, str): return wim_account if wim_account_id.get(wim_account): return wim_account_id[wim_account] wim = self._client.wim.get(wim_account) if wim is None: raise NotFound("cannot find wim account '{}'".format(wim_account)) wim_account_id[wim_account] = wim['_id'] return wim['_id']
def get_individual(self, name): vnf_id = name if not utils.validate_uuid4(name): for vnf in self.list(): if name == vnf['name']: vnf_id = vnf['_id'] break resp = self._http.get_cmd('{}/{}'.format(self._apiBase, vnf_id)) #print 'RESP: {}'.format(resp) if resp: return resp raise NotFound("vnf {} not found".format(name))