X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fsol005%2Fvim.py;h=9cd882c5c56f3bb78c88c152b89cdb4da74e54da;hb=51489a0d10ee934d3dc2278018112c8257aceb24;hp=b6f1614c64ea827925e3782e6d47e3174ed720a4;hpb=70d6f1843686f323ced68a253127fedde86a1c25;p=osm%2Fosmclient.git diff --git a/osmclient/sol005/vim.py b/osmclient/sol005/vim.py index b6f1614..9cd882c 100644 --- a/osmclient/sol005/vim.py +++ b/osmclient/sol005/vim.py @@ -22,7 +22,6 @@ from osmclient.common import utils from osmclient.common import wait as WaitForStatus from osmclient.common.exceptions import ClientException from osmclient.common.exceptions import NotFound -from osmclient.common.exceptions import OsmHttpException import yaml import json import logging @@ -99,7 +98,7 @@ class Vim(object): if resp: resp = json.loads(resp) if not resp or 'id' not in resp: - raise OsmHttpException('unexpected response from server - {}'.format( + raise ClientException('unexpected response from server - {}'.format( resp)) if wait: # Wait for status for VIM instance creation @@ -146,8 +145,8 @@ class Vim(object): wait_id = vim_id_for_wait # Wait for status for VI instance update self._wait(wait_id) - else: - pass + # else: + # pass #else: # msg = "" # if resp: @@ -204,13 +203,13 @@ class Vim(object): elif http_code == 204: print('Deleted') else: - msg = "" - if resp: - try: - msg = json.loads(resp) - except ValueError: - msg = resp - raise OsmHttpException("failed to delete vim {} - {}".format(vim_name, msg)) + msg = resp or "" + # if resp: + # try: + # msg = json.loads(resp) + # except ValueError: + # msg = resp + raise ClientException("failed to delete vim {} - {}".format(vim_name, msg)) def list(self, filter=None): """Returns a list of VIM accounts @@ -237,12 +236,13 @@ class Vim(object): vim_id = name if not utils.validate_uuid4(name): vim_id = self.get_id(name) - _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase,vim_id)) -# if not resp or '_id' not in resp: -# raise ClientException('failed to get vim info: '.format( -# resp)) -# else: - if resp: - return json.loads(resp) - raise NotFound("vim {} not found".format(name)) + try: + _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase,vim_id)) + if resp: + resp = json.loads(resp) + if not resp or '_id' not in resp: + raise ClientException('failed to get vim info: {}'.format(resp)) + return resp + except NotFound: + raise NotFound("vim '{}' not found".format(name))