aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/onapsdk/configuration/global_settings.py63
-rw-r--r--src/onapsdk/so/catalog_cb_adapter.py52
-rw-r--r--src/onapsdk/so/so_db_adapter.py4
-rw-r--r--tests/test_settings.py3
-rw-r--r--tests/test_so_catalog_adapter.py136
5 files changed, 226 insertions, 32 deletions
diff --git a/src/onapsdk/configuration/global_settings.py b/src/onapsdk/configuration/global_settings.py
index 25cdf80..fa0ec58 100644
--- a/src/onapsdk/configuration/global_settings.py
+++ b/src/onapsdk/configuration/global_settings.py
@@ -21,37 +21,38 @@
######################
## API
-AAI_URL = "https://aai.api.sparky.simpledemo.onap.org:30233"
-AAI_API_VERSION = "v27"
-AAI_AUTH = "Basic QUFJOkFBSQ=="
-AAI_BULK_CHUNK = 30
-CDS_URL = "http://portal.api.simpledemo.onap.org:30449"
-CDS_AUTH = ("ccsdkapps", "ccsdkapps")
-CPS_URL = "http://portal.api.simpledemo.onap.org:8080"
-CPS_AUTH = ("cpsuser", "cpsr0cks!")
-CPS_VERSION = "v2"
-MSB_URL = "https://msb.api.simpledemo.onap.org:30283"
-K8SPLUGIN_URL = "http://k8splugin.api.simpledemo.onap.org:30455"
-SDC_BE_URL = "https://sdc.api.be.simpledemo.onap.org:30204"
-SDC_FE_URL = "https://sdc.api.fe.simpledemo.onap.org:30207"
-SDC_AUTH = "Basic YWFpOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2YW9HR21KdlV5MlU="
-SDNC_URL = "https://sdnc.api.simpledemo.onap.org:30267"
-SDNC_AUTH = "Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ=="
-SO_URL = "http://so.api.simpledemo.onap.org:30277"
-SO_API_VERSION = "v7"
-SO_AUTH = "Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA=="
-SO_CAT_DB_AUTH = "Basic YnBlbDpwYXNzd29yZDEk"
-VID_URL = "https://vid.api.simpledemo.onap.org:30200"
-VID_API_VERSION = "/vid"
-CLAMP_URL = "https://clamp.api.simpledemo.onap.org:30258"
-CLAMP_AUTH = "Basic ZGVtb0BwZW9wbGUub3NhYWYub3JnOmRlbW8xMjM0NTYh"
-VES_URL = "http://ves.api.simpledemo.onap.org:30417"
-DMAAP_URL = "http://dmaap.api.simpledemo.onap.org:3904"
-NBI_URL = "https://nbi.api.simpledemo.onap.org:30274"
-NBI_API_VERSION = "/nbi/api/v4"
-DCAEMOD_URL = ""
-HOLMES_URL = "https://aai.api.sparky.simpledemo.onap.org:30293"
-POLICY_URL = ""
+AAI_URL = "https://aai.api.sparky.simpledemo.onap.org:30233"
+AAI_API_VERSION = "v27"
+AAI_AUTH = "Basic QUFJOkFBSQ=="
+AAI_BULK_CHUNK = 30
+CDS_URL = "http://portal.api.simpledemo.onap.org:30449"
+CDS_AUTH = ("ccsdkapps", "ccsdkapps")
+CPS_URL = "http://portal.api.simpledemo.onap.org:8080"
+CPS_AUTH = ("cpsuser", "cpsr0cks!")
+CPS_VERSION = "v2"
+MSB_URL = "https://msb.api.simpledemo.onap.org:30283"
+K8SPLUGIN_URL = "http://k8splugin.api.simpledemo.onap.org:30455"
+SDC_BE_URL = "https://sdc.api.be.simpledemo.onap.org:30204"
+SDC_FE_URL = "https://sdc.api.fe.simpledemo.onap.org:30207"
+SDC_AUTH = "Basic YWFpOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2YW9HR21KdlV5MlU=" # pylint: disable=line-too-long
+SDNC_URL = "https://sdnc.api.simpledemo.onap.org:30267"
+SDNC_AUTH = "Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" # pylint: disable=line-too-long
+SO_CATALOG_DB_ADAPTER_URL = "http://so-catalog-db-adapter:8082"
+SO_URL = "http://so.api.simpledemo.onap.org:30277"
+SO_API_VERSION = "v7"
+SO_AUTH = "Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA=="
+SO_CAT_DB_AUTH = "Basic YnBlbDpwYXNzd29yZDEk"
+VID_URL = "https://vid.api.simpledemo.onap.org:30200"
+VID_API_VERSION = "/vid"
+CLAMP_URL = "https://clamp.api.simpledemo.onap.org:30258"
+CLAMP_AUTH = "Basic ZGVtb0BwZW9wbGUub3NhYWYub3JnOmRlbW8xMjM0NTYh"
+VES_URL = "http://ves.api.simpledemo.onap.org:30417"
+DMAAP_URL = "http://dmaap.api.simpledemo.onap.org:3904"
+NBI_URL = "https://nbi.api.simpledemo.onap.org:30274"
+NBI_API_VERSION = "/nbi/api/v4"
+DCAEMOD_URL = ""
+HOLMES_URL = "https://aai.api.sparky.simpledemo.onap.org:30293"
+POLICY_URL = ""
## GUI
AAI_GUI_URL = "https://aai.api.sparky.simpledemo.onap.org:30220"
diff --git a/src/onapsdk/so/catalog_cb_adapter.py b/src/onapsdk/so/catalog_cb_adapter.py
new file mode 100644
index 0000000..f8c54e0
--- /dev/null
+++ b/src/onapsdk/so/catalog_cb_adapter.py
@@ -0,0 +1,52 @@
+# Copyright 2023 Deutsche Telekom AG
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""SO ecomp module."""
+from abc import ABC
+from typing import Any, Dict
+
+from onapsdk.configuration import settings
+from onapsdk.onap_service import OnapService
+from onapsdk.so.so_element import SoElement
+from onapsdk.utils.headers_creator import headers_so_catelog_db_creator
+
+
+class CatalogDbAdapter(SoElement, ABC):
+ """SO catalog db adapter service class."""
+
+ base_url = settings.SO_CATALOG_DB_ADAPTER_URL
+ headers = headers_so_catelog_db_creator(OnapService.headers)
+
+ @classmethod
+ def get_service_info(cls, service_model_uuid: str) -> Dict[Any, Any]:
+ """Get Service VNF and VF details.
+
+ Returns:
+ The response in a dict format
+
+ """
+ url = (f"{cls.base_url}/ecomp/mso/catalog/v2/serviceResources?"
+ f"serviceModelUuid={service_model_uuid}")
+ return cls.send_message_json("GET", "Get Service Details", url, headers=cls.headers)
+
+ @classmethod
+ def get_service_vnf_info(cls, service_model_uuid: str) -> Dict[Any, Any]:
+ """Get Service VNF and VF details.
+
+ Returns:
+ The response in a dict format
+
+ """
+ url = (f"{cls.base_url}/ecomp/mso/catalog/v2/serviceVnfs?"
+ f"serviceModelUuid={service_model_uuid}")
+ return cls.send_message_json("GET", "Get Service Details", url, headers=cls.headers)
diff --git a/src/onapsdk/so/so_db_adapter.py b/src/onapsdk/so/so_db_adapter.py
index b3694d1..31a93fa 100644
--- a/src/onapsdk/so/so_db_adapter.py
+++ b/src/onapsdk/so/so_db_adapter.py
@@ -15,6 +15,7 @@
from abc import ABC
from dataclasses import dataclass
from typing import Dict, Any
+import warnings
from onapsdk.so.so_element import SoElement
from onapsdk.onap_service import OnapService
@@ -81,6 +82,7 @@ class SoDbAdapter(SoElement, ABC):
headers=headers_so_creator(OnapService.headers)
)
return response
+
@classmethod
def get_service_vnf_info(cls, identifier: str) -> Dict[Any, Any]:
"""Get Service VNF and VF details.
@@ -89,6 +91,8 @@ class SoDbAdapter(SoElement, ABC):
The response in a dict format
"""
+ warnings.warn("That method is deprecated and it's going to be removed. Please use "
+ "onapsdk.so.ecomp.Ecomp.get_service_vnf_info instead.")
url = f"{cls.base_url}/ecomp/mso/catalog/v2/serviceVnfs?serviceModelUuid={identifier}"
headers = headers_so_catelog_db_creator(OnapService.headers)
return cls.send_message_json("GET", "Get Service Details", url, headers=headers)
diff --git a/tests/test_settings.py b/tests/test_settings.py
index 0ecaf88..438b3c5 100644
--- a/tests/test_settings.py
+++ b/tests/test_settings.py
@@ -24,10 +24,11 @@ from onapsdk.exceptions import ModuleError
def test_global_settings():
"""Test global settings."""
- assert len(settings._settings) == 45
+ assert len(settings._settings) == 46
assert settings.AAI_URL == "https://aai.api.sparky.simpledemo.onap.org:30233"
assert settings.CDS_URL == "http://portal.api.simpledemo.onap.org:30449"
assert settings.SDNC_URL == "https://sdnc.api.simpledemo.onap.org:30267"
+ assert settings.SO_CATALOG_DB_ADAPTER_URL == "http://so-catalog-db-adapter:8082"
assert settings.SO_URL == "http://so.api.simpledemo.onap.org:30277"
assert settings.MSB_URL == "https://msb.api.simpledemo.onap.org:30283"
assert settings.K8SPLUGIN_URL == "http://k8splugin.api.simpledemo.onap.org:30455"
diff --git a/tests/test_so_catalog_adapter.py b/tests/test_so_catalog_adapter.py
new file mode 100644
index 0000000..f020b74
--- /dev/null
+++ b/tests/test_so_catalog_adapter.py
@@ -0,0 +1,136 @@
+# Copyright 2023 Deutsche Telekom AG
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+from unittest import mock
+
+from onapsdk.so.catalog_cb_adapter import CatalogDbAdapter
+
+
+SERVICE_RESPONSE = {
+ "serviceResources" : {
+ "modelInfo" : {
+ "modelName" : "test_service",
+ "modelUuid" : "4631a8c6-b432-4a15-a2ef-74d616377371",
+ "modelInvariantUuid" : "bb6a88a7-2030-4f66-93c3-b9d713d2f511",
+ "modelVersion" : "1.0"
+ },
+ "serviceCategory" : "Network Service",
+ "serviceType" : "",
+ "serviceRole" : "",
+ "environmentContext" : "General_Revenue-Bearing",
+ "resourceOrder" : "test_service",
+ "workloadContext" : "Production",
+ "serviceVnfs": [
+
+ { "modelInfo" : {
+ "modelName" : "test_service",
+ "modelUuid" : "d94c326a-bb0f-4896-bc17-69e544f46f82",
+ "modelInvariantUuid" : "15916c82-46b9-4c39-b9e1-6bd6a2d24e4a",
+ "modelVersion" : "1.0",
+ "modelCustomizationUuid" : "46680890-2886-45ea-84dd-a3720a4c3e84",
+ "modelInstanceName" : "test_service 0"
+ },
+ "toscaNodeType" : "org.openecomp.resource.vf.BasicOnboardNxtypj",
+ "nfFunction" : None,
+ "nfType" : None,
+ "nfRole" : None,
+ "nfNamingCode" : None,
+ "multiStageDesign" : "false",
+ "vnfcInstGroupOrder" : None,
+ "resourceInput" : "{\"skip_post_instantiation_configuration\":\"true\"}",
+ "vfModules": [
+ {
+ "modelInfo" : {
+ "modelName" : "TestService..base_ubuntu18..module-0",
+ "modelUuid" : "ebee8e31-c892-4260-b82a-082c515dc138",
+ "modelInvariantUuid" : "9e650a3e-70f2-4e51-959d-c5dbe12bb614",
+ "modelVersion" : "1",
+ "modelCustomizationUuid" : "63b7dd74-b4bd-4e20-bce7-828e46c16e8d",
+ }, "isBase" : True,
+ "vfModuleLabel" : "base_ubuntu18",
+ "initialCount" : 1,
+ "hasVolumeGroup" : False,
+ }
+ ],
+ "groups": [],
+ },
+ ],
+ "serviceNetworks": [],
+ "serviceInfo":
+
+ { "id" : 10,
+ "serviceInput" : "[{\"default\":\"\",\"name\":\"default_software_version\",\"type\":\"string\",\"required\":false}]",
+ "serviceProperties" : "[]",
+ "serviceArtifact": [],
+ },
+ "serviceProxy": [],
+ "serviceAllottedResources": [],
+ }
+}
+
+
+SERVICE_VNF_RESPONSE = {
+ 'serviceVnfs': [
+ {
+ 'modelInfo': {
+ 'modelName': 'test_vnf_01',
+ 'modelUuid': 'd2779cc5-fb01-449f-a355-7e5d911dca93',
+ 'modelInvariantUuid': '027cb696-f68f-47db-9b0e-585ea3eaa512',
+ 'modelVersion': '1.0',
+ 'modelCustomizationUuid': 'b8740912-e0fc-426f-af97-7657caf57847',
+ 'modelInstanceName': 'test_vnf_01 0'
+ },
+ 'toscaNodeType': 'org.openecomp.resource.vf.Mvnr5gCucpVfT003',
+ 'nfFunction': None,
+ 'nfType': None,
+ 'nfRole': None,
+ 'nfNamingCode': None,
+ 'multiStageDesign': 'false',
+ 'vnfcInstGroupOrder': None,
+ 'resourceInput': None,
+ 'vfModules': [{'modelInfo':
+ {
+ 'modelName': 'test_vf_01',
+ 'modelUuid': '153464b8-4f47-4140-8b92-9614c4578d91',
+ 'modelInvariantUuid': '753deff5-99a2-4154-8c1d-3e956cb96f32',
+ 'modelVersion': '1',
+ 'modelCustomizationUuid': '7ca564f3-b908-499c-b086-ae77ad270d8c'
+ },
+ 'isBase': False,
+ 'vfModuleLabel': 'vf_mod_label',
+ 'initialCount': 0,
+ 'hasVolumeGroup': False
+ }
+ ],
+ 'groups': []
+ }
+ ]
+}
+
+
+@mock.patch.object(CatalogDbAdapter, "send_message_json")
+def test_get_service_info(mock_send_message_json):
+ mock_send_message_json.return_value = SERVICE_RESPONSE
+
+ response = CatalogDbAdapter.get_service_info(service_model_uuid="4631a8c6-b432-4a15-a2ef-74d616377371")
+ assert "serviceResources" in response
+ assert response['serviceResources']["modelInfo"]["modelName"] == "test_service"
+
+
+@mock.patch.object(CatalogDbAdapter, "send_message_json")
+def test_get_service_vnf_info(mock_send_message_json):
+ mock_send_message_json.return_value = SERVICE_VNF_RESPONSE
+
+ response = CatalogDbAdapter.get_service_vnf_info(service_model_uuid="test_id_0")
+ assert "serviceVnfs" in response
+ assert response['serviceVnfs'][0]["modelInfo"]["modelName"] == "test_vnf_01"