X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fsol005%2Fvim.py;h=421f8a5a122c08c3367a50b31120863e42537e6e;hb=refs%2Fchanges%2F17%2F8117%2F4;hp=3012ae20b433fbc8d442e6a5fb324954cf9065f1;hpb=5de571ed5ac38d3225ebdaa257b2b6b453a03bb5;p=osm%2Fosmclient.git diff --git a/osmclient/sol005/vim.py b/osmclient/sol005/vim.py index 3012ae2..421f8a5 100644 --- a/osmclient/sol005/vim.py +++ b/osmclient/sol005/vim.py @@ -35,8 +35,10 @@ class Vim(object): self._apiResource = '/vim_accounts' self._apiBase = '{}{}{}'.format(self._apiName, self._apiVersion, self._apiResource) + # VIM '--wait' option def _wait(self, id, deleteFlag=False): + self._client.get_token() # Endpoint to get operation status apiUrlStatus = '{}{}{}'.format(self._apiName, self._apiVersion, '/vim_accounts') # Wait for status for VIM instance creation/deletion @@ -59,6 +61,7 @@ class Vim(object): return '' def create(self, name, vim_access, sdn_controller=None, sdn_port_mapping=None, wait=False): + self._client.get_token() if 'vim-type' not in vim_access: #'openstack' not in vim_access['vim-type']): raise Exception("vim type not provided") @@ -82,8 +85,8 @@ class Vim(object): http_code, resp = self._http.post_cmd(endpoint=self._apiBase, postfields_dict=vim_account) - #print 'HTTP CODE: {}'.format(http_code) - #print 'RESP: {}'.format(resp) + #print('HTTP CODE: {}'.format(http_code)) + #print('RESP: {}'.format(resp)) if http_code in (200, 201, 202, 204): if resp: resp = json.loads(resp) @@ -104,6 +107,7 @@ class Vim(object): raise ClientException("failed to create vim {} - {}".format(name, msg)) def update(self, vim_name, vim_account, sdn_controller, sdn_port_mapping, wait=False): + self._client.get_token() vim = self.get(vim_name) vim_id_for_wait = self._get_id_for_wait(vim_name) vim_config = {} @@ -124,8 +128,8 @@ class Vim(object): #vim_account['config'] = json.dumps(vim_config) http_code, resp = self._http.put_cmd(endpoint='{}/{}'.format(self._apiBase,vim['_id']), postfields_dict=vim_account) - # print 'HTTP CODE: {}'.format(http_code) - # print 'RESP: {}'.format(resp) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) if http_code in (200, 201, 202, 204): if wait: # In this case, 'resp' always returns None, so 'resp['id']' cannot be used. @@ -162,6 +166,7 @@ class Vim(object): raise NotFound("vim {} not found".format(name)) def delete(self, vim_name, force=False, wait=False): + self._client.get_token() vim_id = vim_name if not utils.validate_uuid4(vim_name): vim_id = self.get_id(vim_name) @@ -170,8 +175,8 @@ class Vim(object): querystring = '?FORCE=True' http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase, vim_id, querystring)) - #print 'HTTP CODE: {}'.format(http_code) - #print 'RESP: {}'.format(resp) + #print('HTTP CODE: {}'.format(http_code)) + #print('RESP: {}'.format(resp)) if http_code == 202: if wait: # When deleting an account, 'resp' may be None. @@ -198,6 +203,7 @@ class Vim(object): def list(self, filter=None): """Returns a list of VIM accounts """ + self._client.get_token() filter_string = '' if filter: filter_string = '?{}'.format(filter) @@ -213,6 +219,7 @@ class Vim(object): def get(self, name): """Returns a VIM account based on name or id """ + self._client.get_token() vim_id = name if not utils.validate_uuid4(name): vim_id = self.get_id(name)