From ba21c2865908523292807bcfc86354ee0a6823f8 Mon Sep 17 00:00:00 2001 From: "stark, steven" Date: Thu, 6 Aug 2020 09:18:46 -0700 Subject: [VVP] Bug fixes Revert type change on return from spec-engine. This was changed incorrectly on previous review. Fixing policy add to VNF, so that properties values are still added on update. Issue-ID: VVP-455 Signed-off-by: stark, steven Change-Id: I36ff9479f69893665bd7155b16c3fdcf1302e29e --- onap-client/onap_client/engine.py | 2 +- onap-client/onap_client/sdc/vnf.py | 20 +++++++++++--------- onap-client/onap_client/tests/test_engine.py | 2 +- onap-client/setup.py | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/onap-client/onap_client/engine.py b/onap-client/onap_client/engine.py index daac47d..37d5b0b 100644 --- a/onap-client/onap_client/engine.py +++ b/onap-client/onap_client/engine.py @@ -211,7 +211,7 @@ class SpecEngine: finished_spec["output"] = t._output() full_engine_spec.append(finished_spec) - return full_engine_spec + return {"spec": full_engine_spec} def resolve_spec(spec_dict): diff --git a/onap-client/onap_client/sdc/vnf.py b/onap-client/onap_client/sdc/vnf.py index 21540e9..94c45ef 100644 --- a/onap-client/onap_client/sdc/vnf.py +++ b/onap-client/onap_client/sdc/vnf.py @@ -159,12 +159,12 @@ class VNF(Resource): for policy in policies: policy_name = policy.get("policy_name") - if self.policy_exists(policy_name): - continue - policy_model = self.add_policy_resource(policy_name) - self.associate_policy(policy_model.catalog_resource_id, vm_type_instances) + policy_id = self.policy_exists(policy_name) + if not policy_id: + policy_id = self.add_policy_resource(policy_name) + self.associate_policy(policy_id, vm_type_instances) for k, v in policy.get("properties", {}).items(): - self.add_policy_property(policy_model.catalog_resource_id, k, v) + self.add_policy_property(policy_id, k, v) for k, v in inputs.items(): self.add_input_value(k, v) @@ -291,9 +291,9 @@ class VNF(Resource): for p_name, policy in policies.items(): tosca_policy_name = policy.get("name").lower() if tosca_policy_name.find("{}..{}".format(self.vnf_name.lower().replace("-", ""), policy_name.lower())) != -1: - return True + return policy.get("uniqueId") - return False + return None def add_input_value(self, input_name, input_default_value): """Updates an input value on a VNF @@ -425,7 +425,7 @@ class VNF(Resource): property_type = prop.get("type") description = prop.get("description") return self.oc.sdc.vnf.add_catalog_policy_property( - **self.attributes, + catalog_resource_id=self.catalog_resource_id, unique_id=unique_id, catalog_policy_id=policy_id, property_name=property_name, @@ -452,10 +452,12 @@ class VNF(Resource): "Policy {} was not found in configuration file".format(policy_name) ) - return self.oc.sdc.vnf.add_catalog_resource_policy( + new_policy = self.oc.sdc.vnf.add_catalog_resource_policy( **self.attributes, catalog_policy_name=policy ) + return new_policy.catalog_resource_id + def associate_policy(self, policy_id, instance_ids): """associates an SDC policy resource to an VNF instance resource diff --git a/onap-client/onap_client/tests/test_engine.py b/onap-client/onap_client/tests/test_engine.py index b305725..808e5b7 100644 --- a/onap-client/onap_client/tests/test_engine.py +++ b/onap-client/onap_client/tests/test_engine.py @@ -46,4 +46,4 @@ def test_engine(): t = load_spec(spec_file) - assert isinstance(t, list) + assert isinstance(t, dict) diff --git a/onap-client/setup.py b/onap-client/setup.py index 5f0048b..67e763a 100644 --- a/onap-client/setup.py +++ b/onap-client/setup.py @@ -47,7 +47,7 @@ for file in os.listdir("etc/payloads"): setuptools.setup( name="onap-client", - version="0.9.0", + version="0.9.2", author="Steven Stark", author_email="steven.stark@att.com", description="Python API wrapper for ONAP applications", -- cgit 1.2.3-korg