X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fsol005%2Fvnfd.py;h=dd12096e51c57986a2f4d40861f35b21df595077;hb=98213d0b29e9a26d113eaced1e0975a1d2ce833c;hp=bc77a8d9132f6de0e0878c1f5db340a0645481c4;hpb=017c4fb032ab1f63e1ce474e12787204f33fce96;p=osm%2Fosmclient.git diff --git a/osmclient/sol005/vnfd.py b/osmclient/sol005/vnfd.py index bc77a8d..dd12096 100644 --- a/osmclient/sol005/vnfd.py +++ b/osmclient/sol005/vnfd.py @@ -22,6 +22,7 @@ from osmclient.common.exceptions import NotFound from osmclient.common.exceptions import ClientException from osmclient.common import utils import yaml +import json import magic #from os import stat #from os.path import basename @@ -72,11 +73,11 @@ class Vnfd(object): vnfd = self.get(name) headers = self._client._headers headers['Accept'] = 'application/binary' - resp2 = self._http.get2_cmd('{}/{}/{}'.format(self._apiBase, vnfd['_id'], thing)) + http_code, resp = self._http.get2_cmd('{}/{}/{}'.format(self._apiBase, vnfd['_id'], thing)) #print yaml.safe_dump(resp2) - if resp2: + if resp: #store in a file - return resp2 + return resp raise NotFound("vnfd {} not found".format(name)) def get_descriptor(self, name, filename): @@ -90,9 +91,13 @@ class Vnfd(object): def delete(self, name): vnfd = self.get(name) - resp = self._http.delete_cmd('{}/{}'.format(self._apiBase,vnfd['_id'])) - #print 'RESP: '.format(resp) - if resp is None: + http_code, resp = self._http.delete_cmd('{}/{}'.format(self._apiBase,vnfd['_id'])) + if resp: + resp = json.loads(resp) + #print 'RESP: {}'.format(resp) + if http_code == 202: + print 'Deletion in progress' + elif http_code == 204: print 'Deleted' else: raise ClientException("failed to delete vnfd {}: {}".format(name, resp)) @@ -122,7 +127,7 @@ class Vnfd(object): for (key,val) in headers.items()] self._http.set_http_header(http_header) if update_endpoint: - resp = self._http.put_cmd(endpoint=update_endpoint, filename=filename) + http_code, resp = self._http.put_cmd(endpoint=update_endpoint, filename=filename) else: ow_string = '' if overwrite: @@ -131,7 +136,9 @@ class Vnfd(object): self._apiBase = '{}{}{}'.format(self._apiName, self._apiVersion, self._apiResource) endpoint = '{}{}'.format(self._apiBase,ow_string) - resp = self._http.post_cmd(endpoint=endpoint, filename=filename) + http_code, resp = self._http.post_cmd(endpoint=endpoint, filename=filename) + if resp: + resp = json.loads(resp) #print resp if not resp or 'id' not in resp: raise ClientException("failed to upload package")