X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fsol005%2Fvim.py;h=ec1ccaddeb466d6a004848154938004dffc42264;hb=8e0f07980b9c4ed48e77ec9de22d766c0e186acb;hp=d540c638afadfcb541888f764ef1ce0cc4f566d6;hpb=d192a5aa92da630872a113b8e1459055f859cdf2;p=osm%2Fosmclient.git diff --git a/osmclient/sol005/vim.py b/osmclient/sol005/vim.py index d540c63..ec1ccad 100644 --- a/osmclient/sol005/vim.py +++ b/osmclient/sol005/vim.py @@ -22,6 +22,7 @@ from osmclient.common import utils from osmclient.common.exceptions import ClientException from osmclient.common.exceptions import NotFound import yaml +import json class Vim(object): @@ -49,8 +50,10 @@ class Vim(object): vim_account['config'] = vim_config - resp = self._http.post_cmd(endpoint=self._apiBase, + http_code, resp = self._http.post_cmd(endpoint=self._apiBase, postfields_dict=vim_account) + if resp: + resp = json.loads(resp) if not resp or 'id' not in resp: raise ClientException('failed to create vim {}: {}'.format( name, resp)) @@ -59,9 +62,11 @@ class Vim(object): def update(self, vim_name, vim_account): vim = self.get(vim_name) - #resp = self._http.put_cmd(endpoint='{}/{}'.format(self._apiBase,vim['_id']), - resp = self._http.patch_cmd(endpoint='{}/{}'.format(self._apiBase,vim['_id']), + #http_code, resp = self._http.put_cmd(endpoint='{}/{}'.format(self._apiBase,vim['_id']), + http_code, resp = self._http.patch_cmd(endpoint='{}/{}'.format(self._apiBase,vim['_id']), postfields_dict=vim_account) + if resp: + resp = json.loads(resp) #print 'RESP: {}'.format(resp) if not resp or 'id' not in resp: raise ClientException('failed to update vim: '.format(resp)) @@ -85,11 +90,17 @@ class Vim(object): return vim['uuid'] raise NotFound("vim {} not found".format(name)) - def delete(self, vim_name): + def delete(self, vim_name, force=False): vim_id = vim_name if not utils.validate_uuid4(vim_name): vim_id = self.get_id(vim_name) - http_code, resp = self._http.delete_cmd('{}/{}'.format(self._apiBase,vim_id)) + querystring = '' + if force: + querystring = '?FORCE=True' + http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase, + vim_id, querystring)) + if resp: + resp = json.loads(resp) #print 'RESP: {}'.format(resp) if http_code == 202: print 'Deletion in progress'