aboutsummaryrefslogtreecommitdiffstats
path: root/onap-client/onap_client/so
diff options
context:
space:
mode:
authorstark, steven <steven.stark@att.com>2020-07-21 15:14:27 -0700
committerstark, steven <steven.stark@att.com>2020-07-21 15:15:34 -0700
commit9df81b14e7203d6c3911f5f36881cb5170afdccc (patch)
tree2a9b5e913e83d0f21b374f068c53df266d3dec56 /onap-client/onap_client/so
parentb3e7a9fbcbf52ac095ca424f3f17610bf1e8df88 (diff)
[VVP] onap-client refactoring
removing create hook from _init_ for resources removing _init_ for non-abstract resources refactor validation logic enhancing error catch for resource failure adding _on_failure hook Issue-ID: VVP-441 Signed-off-by: stark, steven <steven.stark@att.com> Change-Id: Ia627fc7fd35fe6e112d6f89399701c70b5888077
Diffstat (limited to 'onap-client/onap_client/so')
-rw-r--r--onap-client/onap_client/so/module_instance.py56
-rw-r--r--onap-client/onap_client/so/service_instance.py48
-rw-r--r--onap-client/onap_client/so/tests/test_module_instance.py21
-rw-r--r--onap-client/onap_client/so/tests/test_service_instance.py25
-rw-r--r--onap-client/onap_client/so/tests/test_vnf_instance.py21
-rw-r--r--onap-client/onap_client/so/vnf_instance.py41
6 files changed, 62 insertions, 150 deletions
diff --git a/onap-client/onap_client/so/module_instance.py b/onap-client/onap_client/so/module_instance.py
index 75105ed..51c9bc2 100644
--- a/onap-client/onap_client/so/module_instance.py
+++ b/onap-client/onap_client/so/module_instance.py
@@ -59,37 +59,14 @@ class ModuleInstance(Resource):
"api_type": {"type": str, "required": False, "default": "GR_API"},
}
- def __init__(
- self,
- module_instance_name,
- vnf_instance_name,
- service_instance_name,
- requestor_id,
- heat_template_name,
- preload_path,
- tenant_name,
- cloud_owner,
- cloud_region,
- api_type,
- ):
- instance_input = {}
-
- tenant_id = so.service_instance.get_tenant_id(cloud_region, cloud_owner, tenant_name)
-
- instance_input["module_instance_name"] = module_instance_name
- instance_input["vnf_instance_name"] = vnf_instance_name
- instance_input["service_instance_name"] = service_instance_name
- instance_input["requestor_id"] = requestor_id
- instance_input["heat_template_name"] = heat_template_name
- instance_input["preload_path"] = preload_path
+ def _create(self, instance_input):
+ tenant_id = so.service_instance.get_tenant_id(
+ instance_input.get("cloud_region"),
+ instance_input.get("cloud_owner"),
+ instance_input.get("tenant_name")
+ )
instance_input["tenant_id"] = tenant_id
- instance_input["cloud_owner"] = cloud_owner
- instance_input["cloud_region"] = cloud_region
- instance_input["api_type"] = api_type
-
- super().__init__(instance_input)
- def _create(self, instance_input):
service_instance = so.vnf_instance.get_service_instance(
instance_input.get("service_instance_name")
)
@@ -169,24 +146,19 @@ class ModuleInstance(Resource):
return create_module_instance(instance_input)
- def _post_create(self):
- pass
-
- def _submit(self):
- pass
-
def create_module_instance(instance_input):
oc = Client()
- sdnc.preload.Preload(
- instance_input.get("preload_path"),
- instance_input.get("vnf_instance_name"),
- instance_input.get("service_instance_name"),
- instance_input.get("module_instance_name"),
- instance_input.get("heat_template_name"),
- instance_input.get("api_type")
+ preload = sdnc.preload.Preload(
+ preload_path=instance_input.get("preload_path"),
+ vnf_instance_name=instance_input.get("vnf_instance_name"),
+ service_instance_name=instance_input.get("service_instance_name"),
+ module_instance_name=instance_input.get("module_instance_name"),
+ heat_template_name=instance_input.get("heat_template_name"),
+ api_type=instance_input.get("api_type")
)
+ preload.create()
headers = {"X-TransactionId": str(uuid.uuid4())}
module_instance = oc.so.service_instantiation.create_module_instance(
diff --git a/onap-client/onap_client/so/service_instance.py b/onap-client/onap_client/so/service_instance.py
index 6398ac8..10271fa 100644
--- a/onap-client/onap_client/so/service_instance.py
+++ b/onap-client/onap_client/so/service_instance.py
@@ -74,43 +74,15 @@ class ServiceInstance(Resource):
"owning_entity_name": {"type": str, "required": True},
}
- def __init__(
- self,
- service_instance_name,
- requestor_id,
- model_name,
- model_version,
- tenant_name,
- cloud_owner,
- cloud_region,
- api_type,
- service_type,
- customer_name,
- project_name,
- owning_entity_name,
- ):
- self.oc = Client()
-
- instance_input = {}
-
- tenant_id = get_tenant_id(cloud_region, cloud_owner, tenant_name)
-
- instance_input["service_instance_name"] = service_instance_name
- instance_input["requestor_id"] = requestor_id
- instance_input["model_name"] = model_name
- instance_input["model_version"] = model_version
+ def _create(self, instance_input):
+ tenant_id = get_tenant_id(
+ instance_input.get("cloud_region"),
+ instance_input.get("cloud_owner"),
+ instance_input.get("tenant_name")
+ )
instance_input["tenant_id"] = tenant_id
- instance_input["cloud_owner"] = cloud_owner
- instance_input["cloud_region"] = cloud_region
- instance_input["api_type"] = api_type
- instance_input["service_type"] = service_type
- instance_input["customer_id"] = customer_name
- instance_input["project_name"] = project_name
- instance_input["owning_entity_name"] = owning_entity_name
-
- super().__init__(instance_input)
+ instance_input["customer_id"] = instance_input.get("customer_name")
- def _create(self, instance_input):
service_model = self.oc.sdc.service.get_sdc_service(
catalog_service_id=sdc.service.get_service_id(
instance_input.get("model_name")
@@ -128,12 +100,6 @@ class ServiceInstance(Resource):
return create_service_instance(instance_input)
- def _post_create(self):
- pass
-
- def _submit(self):
- pass
-
@utility
def get_service_instance(instance_name):
diff --git a/onap-client/onap_client/so/tests/test_module_instance.py b/onap-client/onap_client/so/tests/test_module_instance.py
index 297fdea..e102702 100644
--- a/onap-client/onap_client/so/tests/test_module_instance.py
+++ b/onap-client/onap_client/so/tests/test_module_instance.py
@@ -212,16 +212,17 @@ def test_module_instance():
)
mi = ModuleInstance(
- MODULE_INSTANCE_NAME,
- VNF_INSTANCE_NAME,
- SERVICE_INSTANCE_NAME,
- "cs0008",
- HEAT_TEMPLATE_NAME,
- "{}/base_preload.json".format(THIS_DIR),
- TENANT_NAME,
- CLOUD_OWNER,
- CLOUD_REGION,
- "GR_API"
+ module_instance_name=MODULE_INSTANCE_NAME,
+ vnf_instance_name=VNF_INSTANCE_NAME,
+ service_instance_name=SERVICE_INSTANCE_NAME,
+ requestor_id="cs0008",
+ heat_template_name=HEAT_TEMPLATE_NAME,
+ preload_path="{}/base_preload.json".format(THIS_DIR),
+ tenant_name=TENANT_NAME,
+ cloud_owner=CLOUD_OWNER,
+ cloud_region=CLOUD_REGION,
+ api_type="GR_API"
)
+ mi.create()
assert mi.module_instance_name == MODULE_INSTANCE_NAME
diff --git a/onap-client/onap_client/so/tests/test_service_instance.py b/onap-client/onap_client/so/tests/test_service_instance.py
index e0afccc..b215fbf 100644
--- a/onap-client/onap_client/so/tests/test_service_instance.py
+++ b/onap-client/onap_client/so/tests/test_service_instance.py
@@ -119,18 +119,19 @@ def test_service_instance():
)
si = ServiceInstance(
- SERVICE_INSTANCE_NAME,
- "cs0008",
- SERVICE_MODEL_NAME,
- "1.0",
- TENANT_NAME,
- CLOUD_OWNER,
- CLOUD_REGION,
- "GR_API",
- "ONAPSERVICE",
- "ONAPCUSTOMER",
- "ONAPPROJECT",
- OWNING_ENTITY_NAME
+ service_instance_name=SERVICE_INSTANCE_NAME,
+ requestor_id="cs0008",
+ model_name=SERVICE_MODEL_NAME,
+ model_version="1.0",
+ tenant_name=TENANT_NAME,
+ cloud_owner=CLOUD_OWNER,
+ cloud_region=CLOUD_REGION,
+ api_type="GR_API",
+ service_type="ONAPSERVICE",
+ customer_name="ONAPCUSTOMER",
+ project_name="ONAPPROJECT",
+ owning_entity_name=OWNING_ENTITY_NAME
)
+ si.create()
assert si.service_instance_name == SERVICE_INSTANCE_NAME
diff --git a/onap-client/onap_client/so/tests/test_vnf_instance.py b/onap-client/onap_client/so/tests/test_vnf_instance.py
index 3805da8..cecdb39 100644
--- a/onap-client/onap_client/so/tests/test_vnf_instance.py
+++ b/onap-client/onap_client/so/tests/test_vnf_instance.py
@@ -159,16 +159,17 @@ def test_vnf_instance():
)
vnfi = VNFInstance(
- VNF_INSTANCE_NAME,
- SERVICE_INSTANCE_NAME,
- "cs0008",
- VNF_MODEL_NAME,
- TENANT_NAME,
- CLOUD_OWNER,
- CLOUD_REGION,
- "GR_API",
- "platform",
- "lob"
+ vnf_instance_name=VNF_INSTANCE_NAME,
+ service_instance_name=SERVICE_INSTANCE_NAME,
+ requestor_id="cs0008",
+ model_name=VNF_MODEL_NAME,
+ tenant_name=TENANT_NAME,
+ cloud_owner=CLOUD_OWNER,
+ cloud_region=CLOUD_REGION,
+ api_type="GR_API",
+ platform="platform",
+ line_of_business="lob"
)
+ vnfi.create()
assert vnfi.vnf_instance_name == VNF_INSTANCE_NAME
diff --git a/onap-client/onap_client/so/vnf_instance.py b/onap-client/onap_client/so/vnf_instance.py
index 4d289a0..abb26c3 100644
--- a/onap-client/onap_client/so/vnf_instance.py
+++ b/onap-client/onap_client/so/vnf_instance.py
@@ -77,37 +77,14 @@ class VNFInstance(Resource):
"line_of_business": {"type": str, "required": True},
}
- def __init__(
- self,
- vnf_instance_name,
- service_instance_name,
- requestor_id,
- model_name,
- tenant_name,
- cloud_owner,
- cloud_region,
- api_type,
- platform,
- line_of_business,
- ):
- instance_input = {}
-
- tenant_id = so.service_instance.get_tenant_id(cloud_region, cloud_owner, tenant_name)
-
- instance_input["vnf_instance_name"] = vnf_instance_name
- instance_input["service_instance_name"] = service_instance_name
- instance_input["requestor_id"] = requestor_id
- instance_input["model_name"] = model_name
+ def _create(self, instance_input):
+ tenant_id = so.service_instance.get_tenant_id(
+ instance_input.get("cloud_region"),
+ instance_input.get("cloud_owner"),
+ instance_input.get("tenant_name")
+ )
instance_input["tenant_id"] = tenant_id
- instance_input["cloud_owner"] = cloud_owner
- instance_input["cloud_region"] = cloud_region
- instance_input["api_type"] = api_type
- instance_input["platform"] = platform
- instance_input["line_of_business"] = line_of_business
- super().__init__(instance_input)
-
- def _create(self, instance_input):
service_instance = get_service_instance(
instance_input.get("service_instance_name")
)
@@ -156,12 +133,6 @@ class VNFInstance(Resource):
return create_vnf_instance(instance_input)
- def _post_create(self):
- pass
-
- def _submit(self):
- pass
-
def get_vnf_model_component(service_model_name, vnf_model_name):
service_model = sdc_client.service.get_sdc_service(