X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fsol005%2Fclient.py;h=cec74365ffedcca935f39269aa82dacf5d979a31;hb=da765d5ec750a9de0e4123d60ff211ca86a2ad61;hp=d1c90aabb4e6ee98aa140775553134a8b4df885d;hpb=170b8fd5bdd218a5d9fe6709bd3e9b90a48447c4;p=osm%2Fosmclient.git diff --git a/osmclient/sol005/client.py b/osmclient/sol005/client.py index d1c90aa..cec7436 100644 --- a/osmclient/sol005/client.py +++ b/osmclient/sol005/client.py @@ -18,16 +18,17 @@ OSM SOL005 client API """ -#from osmclient.v1 import vnf #from osmclient.v1 import vca from osmclient.sol005 import vnfd from osmclient.sol005 import nsd from osmclient.sol005 import ns +from osmclient.sol005 import vnf from osmclient.sol005 import vim from osmclient.sol005 import package from osmclient.sol005 import http from osmclient.sol005 import sdncontroller from osmclient.common.exceptions import ClientException +import json class Client(object): @@ -57,9 +58,9 @@ class Client(object): if ro_host is None: ro_host = host - ro_http_client = http.Http('http://{}:{}/'.format(ro_host, ro_port)) + ro_http_client = http.Http('http://{}:{}/openmano'.format(ro_host, ro_port)) ro_http_client.set_http_header( - ['Accept: application/vnd.yand.data+json', + ['Accept: application/json', 'Content-Type: application/json']) self._http_client = http.Http( @@ -84,8 +85,8 @@ class Client(object): self.ns = ns.Ns(self._http_client, client=self) self.vim = vim.Vim(self._http_client, client=self) self.sdnc = sdncontroller.SdnController(self._http_client, client=self) + self.vnf = vnf.Vnf(self._http_client, client=self) ''' - self.vnf = vnf.Vnf(http_client, client=self, **kwargs) self.vca = vca.Vca(http_client, client=self, **kwargs) self.utils = utils.Utils(http_client, **kwargs) ''' @@ -94,8 +95,11 @@ class Client(object): postfields_dict = {'username': self._user, 'password': self._password, 'project-id': self._project} - token = self._http_client.post_cmd(endpoint=self._auth_endpoint, + http_code, resp = self._http_client.post_cmd(endpoint=self._auth_endpoint, postfields_dict=postfields_dict) + if http_code not in (200, 201, 202, 204): + raise ClientException(resp) + token = json.loads(resp) if resp else None if token is not None: return token['_id'] return None