X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fsol005%2Fwim.py;h=943ceb4049a96ffcecc9f6a52bd66ae457e7b524;hb=0eefdebca0e3eefaf207bc22bebf5128a7b7717a;hp=bf10e5fd42e9be9f1f38932d2e6208965ef9d6d0;hpb=5de571ed5ac38d3225ebdaa257b2b6b453a03bb5;p=osm%2Fosmclient.git diff --git a/osmclient/sol005/wim.py b/osmclient/sol005/wim.py index bf10e5f..943ceb4 100644 --- a/osmclient/sol005/wim.py +++ b/osmclient/sol005/wim.py @@ -35,8 +35,10 @@ class Wim(object): self._apiResource = '/wim_accounts' self._apiBase = '{}{}{}'.format(self._apiName, self._apiVersion, self._apiResource) + # WIM '--wait' option def _wait(self, id, deleteFlag=False): + self._client.get_token() # Endpoint to get operation status apiUrlStatus = '{}{}{}'.format(self._apiName, self._apiVersion, '/wim_accounts') # Wait for status for WIM instance creation/deletion @@ -59,6 +61,7 @@ class Wim(object): return '' def create(self, name, wim_input, wim_port_mapping=None, wait=False): + self._client.get_token() if 'wim_type' not in wim_input: raise Exception("wim type not provided") @@ -77,8 +80,8 @@ class Wim(object): http_code, resp = self._http.post_cmd(endpoint=self._apiBase, postfields_dict=wim_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) @@ -99,6 +102,7 @@ class Wim(object): raise ClientException("failed to create wim {} - {}".format(name, msg)) def update(self, wim_name, wim_account, wim_port_mapping=None, wait=False): + self._client.get_token() wim = self.get(wim_name) wim_id_for_wait = self._get_id_for_wait(wim_name) wim_config = {} @@ -114,10 +118,10 @@ class Wim(object): wim_config['wim_port_mapping'] = yaml.safe_load(f.read()) wim_account['config'] = wim_config #wim_account['config'] = json.dumps(wim_config) - http_code, resp = self._http.put_cmd(endpoint='{}/{}'.format(self._apiBase,wim['_id']), + http_code, resp = self._http.patch_cmd(endpoint='{}/{}'.format(self._apiBase,wim['_id']), postfields_dict=wim_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. @@ -137,7 +141,7 @@ class Wim(object): raise ClientException("failed to update wim {} - {}".format(wim_name, msg)) def update_wim_account_dict(self, wim_account, wim_input): - print (wim_input) + print(wim_input) wim_account['wim_type'] = wim_input['wim_type'] wim_account['description'] = wim_input['description'] wim_account['wim_url'] = wim_input['url'] @@ -154,6 +158,7 @@ class Wim(object): raise NotFound("wim {} not found".format(name)) def delete(self, wim_name, force=False, wait=False): + self._client.get_token() wim_id = wim_name wim_id_for_wait = self._get_id_for_wait(wim_name) if not utils.validate_uuid4(wim_name): @@ -163,9 +168,9 @@ class Wim(object): querystring = '?FORCE=True' http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase, wim_id, querystring)) - # print 'HTTP CODE: {}'.format(http_code) - # print 'RESP: {}'.format(resp) - # print 'WIM_ID: {}'.format(wim_id) + # print('HTTP CODE: {}'.format(http_code)) + # print('RESP: {}'.format(resp)) + # print('WIM_ID: {}'.format(wim_id)) if http_code == 202: if wait: # 'resp' may be None. @@ -192,6 +197,7 @@ class Wim(object): def list(self, filter=None): """Returns a list of VIM accounts """ + self._client.get_token() filter_string = '' if filter: filter_string = '?{}'.format(filter) @@ -207,6 +213,7 @@ class Wim(object): def get(self, name): """Returns a VIM account based on name or id """ + self._client.get_token() wim_id = name if not utils.validate_uuid4(name): wim_id = self.get_id(name)