コード例 #1
0
    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))
コード例 #2
0
ファイル: vim.py プロジェクト: TCSOSM-20/osmclient
    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))
コード例 #3
0
ファイル: ns.py プロジェクト: qarawlus/tng-sdk-benchmark
    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))
コード例 #4
0
ファイル: pdud.py プロジェクト: TCSOSM-20/osmclient
 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))
コード例 #5
0
 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))
コード例 #6
0
ファイル: vim.py プロジェクト: qarawlus/tng-sdk-benchmark
 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))
コード例 #7
0
    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']))
コード例 #8
0
 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))
コード例 #9
0
ファイル: ns.py プロジェクト: qarawlus/tng-sdk-benchmark
 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))
コード例 #10
0
 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))
コード例 #11
0
ファイル: wim.py プロジェクト: TCSOSM-20/osmclient
 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))
コード例 #12
0
ファイル: repo.py プロジェクト: TCSOSM-20/osmclient
 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))
コード例 #13
0
ファイル: ns.py プロジェクト: TCSOSM-20/osmclient
 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))
コード例 #14
0
ファイル: ns.py プロジェクト: 5growth/5gr-so
 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']
コード例 #15
0
 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))
コード例 #16
0
 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))
コード例 #17
0
 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))
コード例 #18
0
 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))
コード例 #19
0
    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))
コード例 #20
0
ファイル: nst.py プロジェクト: qarawlus/tng-sdk-benchmark
 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))
コード例 #21
0
ファイル: sdncontroller.py プロジェクト: jorgebaranda/5gt-so
 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))
コード例 #22
0
ファイル: pdud.py プロジェクト: TCSOSM-20/osmclient
 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))
コード例 #23
0
ファイル: nst.py プロジェクト: TCSOSM-20/osmclient
 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))
コード例 #24
0
        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']
コード例 #25
0
ファイル: vnf.py プロジェクト: qarawlus/tng-sdk-benchmark
 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))
コード例 #26
0
ファイル: vim.py プロジェクト: qarawlus/tng-sdk-benchmark
 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))
コード例 #27
0
ファイル: nsi.py プロジェクト: qarawlus/tng-sdk-benchmark
 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))
コード例 #28
0
 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))
コード例 #29
0
ファイル: ns.py プロジェクト: 5growth/5gr-so
 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']
コード例 #30
0
ファイル: vnf.py プロジェクト: qarawlus/tng-sdk-benchmark
 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))