Feature 11037 Change default NBI port 86/14386/2 master
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Wed, 22 May 2024 16:51:48 +0000 (18:51 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Wed, 22 May 2024 21:47:47 +0000 (23:47 +0200)
Change-Id: I6061cef2ca869eb8286cd03522e3508e327517dd
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osmclient/cli_commands/utils.py
osmclient/common/package_tool.py
osmclient/sol005/client.py
osmclient/sol005/ns.py
osmclient/sol005/vnf.py
tox.ini

index 9ec03f6..25fc21a 100755 (executable)
@@ -48,6 +48,8 @@ def check_client_version(obj, what, version="sol005"):
         message = f"The following commands or options are only supported with the version v1 of OSM SOL005': {what}"
     elif version == "sol005_v2":
         message = f"The following commands or options are only supported with the version v2 of OSM SOL005': {what}"
         message = f"The following commands or options are only supported with the version v1 of OSM SOL005': {what}"
     elif version == "sol005_v2":
         message = f"The following commands or options are only supported with the version v2 of OSM SOL005': {what}"
+    else:
+        message = f"The following commands or options are only supported with the version {version} of OSM SOL005': {what}"
     fullclassname = obj.__module__ + "." + obj.__class__.__name__
     if fullclassname != "osmclient.{}.client.Client".format(version):
         raise ClientException(message)
     fullclassname = obj.__module__ + "." + obj.__class__.__name__
     if fullclassname != "osmclient.{}.client.Client".format(version):
         raise ClientException(message)
index a2cbd87..b1565ea 100644 (file)
@@ -708,6 +708,8 @@ class PackageTool(object):
                 or package_handling.SOL004_TOSCA == package_type
             ):
                 the_package = SOL004Package(package_folder)
                 or package_handling.SOL004_TOSCA == package_type
             ):
                 the_package = SOL004Package(package_folder)
+            else:
+                raise ClientException(f"Unknown package type: {package_type}")
 
             the_package.create_or_update_metadata_file()
 
 
             the_package.create_or_update_metadata_file()
 
index 5146fe2..fe72850 100644 (file)
@@ -48,7 +48,7 @@ class Client(object):
     def __init__(
         self,
         host=None,
     def __init__(
         self,
         host=None,
-        so_port=9999,
+        so_port=443,
         user="admin",
         password="admin",
         project="admin",
         user="admin",
         password="admin",
         project="admin",
@@ -63,17 +63,19 @@ class Client(object):
         self._auth_endpoint = "/admin/v1/tokens"
         self._headers = {}
         self._token = None
         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 = self._host
         else:
         else:
-            self._host = host
-            self._so_port = so_port
-
-        self._http_client = http.Http(
-            "https://{}:{}/osm".format(self._host, self._so_port), **kwargs
-        )
+            if len(host.split(":")) > 1:
+                # backwards compatible, port provided as part of host
+                self._host = host.split(":")[0]
+                self._so_port = host.split(":")[1]
+            else:
+                self._host = host
+                self._so_port = so_port
+            self._url = "https://{}:{}/osm".format(self._host, self._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._headers["Accept"] = "application/json"
         self._headers["Content-Type"] = "application/yaml"
         self._http_client.set_http_header(self._headers)
index e8442f9..8328dba 100644 (file)
@@ -613,7 +613,7 @@ class Ns(object):
                 http_code, resp = self._http.get2_cmd(
                     "{}/{}".format(self._apiBase, uuid)
                 )
                 http_code, resp = self._http.get2_cmd(
                     "{}/{}".format(self._apiBase, uuid)
                 )
-            if not uuid:
+            else:  # if not uuid
                 http_code, resp = self._http.get2_cmd(
                     "{}/{}/{}/{}".format(self._apiBase, uuid, project_name, ns_id)
                 )
                 http_code, resp = self._http.get2_cmd(
                     "{}/{}/{}/{}".format(self._apiBase, uuid, project_name, ns_id)
                 )
index f7c20d9..12e789f 100644 (file)
@@ -46,7 +46,7 @@ class Vnf(object):
         if ns:
             ns_instance = self._client.ns.get(ns)
             if filter_string:
         if ns:
             ns_instance = self._client.ns.get(ns)
             if filter_string:
-                filter_string += ",nsr-id-ref={}".format(ns_instance["_id"])
+                filter_string += "&nsr-id-ref={}".format(ns_instance["_id"])
             else:
                 filter_string = "?nsr-id-ref={}".format(ns_instance["_id"])
         _, resp = self._http.get2_cmd("{}{}".format(self._apiBase, filter_string))
             else:
                 filter_string = "?nsr-id-ref={}".format(ns_instance["_id"])
         _, resp = self._http.get2_cmd("{}{}".format(self._apiBase, filter_string))
diff --git a/tox.ini b/tox.ini
index f822051..8c89a9d 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -64,7 +64,7 @@ commands =
 deps =  {[testenv]deps}
         -r{toxinidir}/requirements-dev.txt
         -r{toxinidir}/requirements-test.txt
 deps =  {[testenv]deps}
         -r{toxinidir}/requirements-dev.txt
         -r{toxinidir}/requirements-test.txt
-        pylint==3.0.3
+        pylint==3.2.2
 commands =
         pylint -E osmclient/
 
 commands =
         pylint -E osmclient/