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/resources | |
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/resources')
-rw-r--r-- | onap_data_provider/resources/service_instance_resource.py | 53 |
1 files changed, 30 insertions, 23 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 |