- self._host = host
- self._so_port = so_port
-
- if ro_host is None:
- ro_host = host
- ro_http_client = http.Http('http://{}:{}/openmano'.format(ro_host, ro_port))
- ro_http_client.set_http_header(
- ['Accept: application/json',
- 'Content-Type: application/json'])
-
- self._http_client = http.Http(
- 'https://{}:{}/osm'.format(self._host,self._so_port))
- self._headers['Accept'] = 'application/json'
- self._headers['Content-Type'] = 'application/yaml'
- http_header = ['{}: {}'.format(key,val)
- for (key,val) in list(self._headers.items())]
- self._http_client.set_http_header(http_header)
-
- token = self.get_token()
- if not token:
- raise ClientException(
- 'Authentication error: not possible to get auth token')
- self._headers['Authorization'] = 'Bearer {}'.format(token)
- http_header.append('Authorization: Bearer {}'.format(token))
- self._http_client.set_http_header(http_header)
+ host_fields = host.split(":")
+ if len(host_fields) > 1:
+ # backwards compatible, port provided as part of host
+ host = host_fields[0]
+ so_port = host_fields[1]
+ self._url = "https://{}:{}/osm".format(host, so_port)
+ self._http_client = http.Http(self._url, **kwargs)
+ self._headers["Accept"] = "application/json"
+ self._headers["Content-Type"] = "application/yaml"
+ self._http_client.set_http_header(self._headers)