X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fv1%2Fvnfd.py;fp=osmclient%2Fv1%2Fvnfd.py;h=e43475d3e1ce07d21186f895b76cdc0db72f84dc;hb=95686bbc69ded243c346f94dceb0bee567572fb7;hp=dd3b11740567d5e7222da692878a8a47fa91c464;hpb=52424a2ae26db69c5a97d01e84454ffdd4d31228;p=osm%2Fosmclient.git diff --git a/osmclient/v1/vnfd.py b/osmclient/v1/vnfd.py index dd3b117..e43475d 100644 --- a/osmclient/v1/vnfd.py +++ b/osmclient/v1/vnfd.py @@ -23,34 +23,37 @@ from osmclient.common.exceptions import ClientException class Vnfd(object): - def __init__(self, http=None, client=None): self._http = http self._client = client def list(self): - resp = self._http.get_cmd('api/running/{}vnfd-catalog/vnfd' - .format(self._client.so_rbac_project_path)) + resp = self._http.get_cmd( + "api/running/{}vnfd-catalog/vnfd".format(self._client.so_rbac_project_path) + ) - if self._client._so_version == 'v3': - if resp and 'project-vnfd:vnfd' in resp: - return resp['project-vnfd:vnfd'] + if self._client._so_version == "v3": + if resp and "project-vnfd:vnfd" in resp: + return resp["project-vnfd:vnfd"] else: # Backwards Compatibility - if resp and 'vnfd:vnfd' in resp: - return resp['vnfd:vnfd'] - + if resp and "vnfd:vnfd" in resp: + return resp["vnfd:vnfd"] + return list() def get(self, name): for vnfd in self.list(): - if name == vnfd['name']: + if name == vnfd["name"]: return vnfd raise NotFound("vnfd {} not found".format(name)) def delete(self, vnfd_name): vnfd = self.get(vnfd_name) - resp = self._http.delete_cmd('api/running/{}vnfd-catalog/vnfd/{}' - .format(self._client.so_rbac_project_path, vnfd['id'])) - if 'success' not in resp: + resp = self._http.delete_cmd( + "api/running/{}vnfd-catalog/vnfd/{}".format( + self._client.so_rbac_project_path, vnfd["id"] + ) + ) + if "success" not in resp: raise ClientException("failed to delete vnfd {}".format(vnfd_name))