def __init__(
self,
host=None,
- so_port=9999,
+ so_port=443,
user="admin",
password="admin",
project="admin",
self._auth_endpoint = "/admin/v1/tokens"
self._headers = {}
self._token = None
- if len(host.split(":")) > 1:
- # backwards compatible, port provided as part of host
- self._host = host.split(":")[0]
- self._so_port = host.split(":")[1]
+ self._url = None
+ if host.startswith("http://") or host.startswith("https://"):
+ self._url = host
else:
- self._host = host
- self._so_port = so_port
-
- self._http_client = http.Http(
- "https://{}:{}/osm".format(self._host, self._so_port), **kwargs
- )
+ 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)
self.utils = utils.Utils(http_client, **kwargs)
"""
- def get_token(self, pwd_change=None):
+ def get_token(self, pwd_change=False):
self._logger.debug("")
if self._token is None:
postfields_dict = {