diff options
author | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2022-01-19 11:54:17 +0000 |
---|---|---|
committer | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2022-01-20 07:23:33 +0000 |
commit | 3a370dbe49a9cfae415d5254c91840374330a7ff (patch) | |
tree | 6b09591ba0f0437df400f19fa2a0da1c2138aecd /onap_data_provider | |
parent | d7966b32c11b772ca4a86b600154d79eeeed7f04 (diff) |
Add PNF instantiation support
Issue-ID: INT-2047
Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Change-Id: I55f124cfee3f8f8260c967cc24e52cd79e680e0b
Diffstat (limited to 'onap_data_provider')
-rw-r--r-- | onap_data_provider/resources/service_instance_resource.py | 53 | ||||
-rw-r--r-- | onap_data_provider/schemas/infra_1_1.schema | 3 | ||||
-rw-r--r-- | onap_data_provider/tag_handlers.py | 3 |
3 files changed, 32 insertions, 27 deletions
diff --git a/onap_data_provider/resources/service_instance_resource.py b/onap_data_provider/resources/service_instance_resource.py index b89f9df..b9af670 100644 --- a/onap_data_provider/resources/service_instance_resource.py +++ b/onap_data_provider/resources/service_instance_resource.py @@ -15,7 +15,7 @@ limitations under the License. """ import logging -from typing import Any, Dict +from typing import Any, Dict, List from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant # type: ignore from onapsdk.aai.business import Customer, OwningEntity # type: ignore @@ -27,6 +27,9 @@ from onapsdk.aai.business import ServiceInstance from onapsdk.so.instantiation import ( # type: ignore ServiceInstantiation, SoService, + SoServicePnf, + SoServiceVfModule, + SoServiceVnf ) from .resource import Resource @@ -61,7 +64,7 @@ class ServiceInstanceResource(Resource): raise AttributeError( "Service not distrbuted - instance can't be created" ) - if (cloud_region_id := self.data["cloud_region_id"]) is not None: + if (cloud_region_id := self.data.get("cloud_region_id")) is not None: cloud_region: CloudRegion = CloudRegion.get_by_id( cloud_owner=self.data["cloud_owner"], cloud_region_id=cloud_region_id, @@ -196,28 +199,32 @@ class ServiceInstanceResource(Resource): SoService: SoService object """ + vnfs: List[SoServiceVnf] = [] + pnfs: List[SoServicePnf] = [] + for xnf in self.data.get("instantiation_parameters", []): + if "vnf_name" in xnf: + vnfs.append(SoServiceVnf( + model_name=xnf["vnf_name"], + instance_name=xnf.get("instance_name", xnf["vnf_name"]), + parameters=xnf.get("parameters", {}), + vf_modules=[SoServiceVfModule( + model_name=vf_module["name"], + instance_name=vf_module.get("instance_name", vf_module["name"]), + parameters=vf_module.get("parameters", {}) + ) for vf_module in xnf.get("vf_modules", [])] + )) + elif "pnf_name" in xnf: + pnfs.append(SoServicePnf( + model_name=xnf["pnf_name"], + instance_name=xnf.get("instance_name", xnf["pnf_name"]), + parameters=xnf.get("parameters", {}) + )) + else: + logging.warning("Invalid content, xNF type not supported") return SoService( - subscription_service_type=self.data.get( - "service_subscription_type", self.data["service_name"] - ), - vnfs=[ - { - "model_name": vnf["vnf_name"], - "vnf_name": vnf.get("instance_name", vnf["vnf_name"]), - "parameters": vnf.get("parameters", {}), - "vf_modules": [ - { - "model_name": vf_module["name"], - "vf_module_name": vf_module.get( - "instance_name", vf_module["name"] - ), - "parameters": vf_module.get("parameters", {}), - } - for vf_module in vnf.get("vf_modules", []) - ], - } - for vnf in self.data.get("instantiation_parameters", []) - ], + subscription_service_type=self.service_subscription.service_type, + vnfs=vnfs, + pnfs=pnfs ) @property diff --git a/onap_data_provider/schemas/infra_1_1.schema b/onap_data_provider/schemas/infra_1_1.schema index 9cb1f09..eac5dcb 100644 --- a/onap_data_provider/schemas/infra_1_1.schema +++ b/onap_data_provider/schemas/infra_1_1.schema @@ -429,14 +429,11 @@ properties: required: - service_instance_name - service_name - - cloud_region - customer_id - owning_entity - project - platform - line_of_business - - cloud_region_id - - cloud_owner - aai_service owning-entities: type: array diff --git a/onap_data_provider/tag_handlers.py b/onap_data_provider/tag_handlers.py index a6b4ba7..1f8a21a 100644 --- a/onap_data_provider/tag_handlers.py +++ b/onap_data_provider/tag_handlers.py @@ -14,10 +14,11 @@ See the License for the specific language governing permissions and limitations under the License. """ -import yaml import uuid from typing import Any +import yaml + def join(loader: yaml.SafeLoader, node: yaml.Node) -> str: """Concatinates the nodes fields for !join tag. |