aboutsummaryrefslogtreecommitdiffstats
path: root/onap-client
diff options
context:
space:
mode:
authorstark, steven <steven.stark@att.com>2020-08-13 12:39:10 -0700
committerstark, steven <steven.stark@att.com>2020-08-13 12:39:10 -0700
commit6b5ef9b8b18f46358e699686a6e706ed3002bd9a (patch)
tree15e7bb604105bb7e45a06f3bd371cfaef2803e57 /onap-client
parentba21c2865908523292807bcfc86354ee0a6823f8 (diff)
[VVP] Support for duplicate VM types
Handle creation when vm consolidation does not occur Issue-ID: VVP-456 Signed-off-by: stark, steven <steven.stark@att.com> Change-Id: I20f2d4d92a3793d6e93655902850caae9ea4359d
Diffstat (limited to 'onap-client')
-rw-r--r--onap-client/onap_client/client/response.py9
-rw-r--r--onap-client/onap_client/sdc/vnf.py25
-rw-r--r--onap-client/setup.py2
3 files changed, 17 insertions, 19 deletions
diff --git a/onap-client/onap_client/client/response.py b/onap-client/onap_client/client/response.py
index 9693af5..307ed1b 100644
--- a/onap-client/onap_client/client/response.py
+++ b/onap-client/onap_client/client/response.py
@@ -79,13 +79,8 @@ class ResponseHandler:
response_items,
) in self.request_object.return_data.items():
response_value = response_iterator(response_data, *response_items)
- if not response_value:
- logger.warning(
- "Request was successful but value for {} was not present in response".format(
- response_key
- )
- )
- setattr(self, response_key, response_value)
+ if response_value:
+ setattr(self, response_key, response_value)
except simplejson.errors.JSONDecodeError:
response_data = response.text
diff --git a/onap-client/onap_client/sdc/vnf.py b/onap-client/onap_client/sdc/vnf.py
index 94c45ef..33e2558 100644
--- a/onap-client/onap_client/sdc/vnf.py
+++ b/onap-client/onap_client/sdc/vnf.py
@@ -151,11 +151,16 @@ class VNF(Resource):
properties = vm_type.get("properties")
resources = vm_type.get("resources", [])
instance_ids = instance_ids_for_property(model, "vm_type_tag", vm_type_tag)
+ x = 0
for instance_id in instance_ids:
+ name_index = ""
+ if x > 0:
+ name_index = x
vm_type_instances.append(instance_id)
self._add_instance_properties(instance_id, properties)
- self._add_resources(instance_id, resources)
+ self._add_resources(instance_id, resources, resource_name_index=name_index)
self._add_vm_type_network_role(instance_id, network_roles)
+ x += 1
for policy in policies:
policy_name = policy.get("policy_name")
@@ -186,9 +191,11 @@ class VNF(Resource):
# updating vm_type properties
self.add_instance_property(instance_id, k, v)
- def _add_resources(self, instance_id, resources_dict):
+ def _add_resources(self, instance_id, resources_dict, resource_name_index=""):
for resource in resources_dict:
resource_name = resource.get("resource_name")
+ if resource_name_index:
+ resource_name = "{}-{}".format(resource_name, resource_name_index)
if self.resource_exists(resource_name):
continue
@@ -207,6 +214,7 @@ class VNF(Resource):
)
)
new_resource = add_resource(self.catalog_resource_id, resource_id, resource_name, origin_type=resource_origin)
+ self._refresh()
new_resource_id = new_resource["id"]
if resource_relationship:
relationship_type = resource_relationship.get("relationship_type")
@@ -226,7 +234,7 @@ class VNF(Resource):
capability_name = capability.get("name")
capability_uid = capability.get("uniqueId")
- return self.oc.sdc.vnf.add_resource_relationship(
+ self.oc.sdc.vnf.add_resource_relationship(
**self.attributes,
from_node_resource_id=from_node,
to_node_resource_id=to_node,
@@ -302,8 +310,6 @@ class VNF(Resource):
:property_value: value to update input with
"""
- self._refresh()
-
inputs = self.tosca.get("inputs", [])
for item in inputs:
if item["name"] == input_name:
@@ -335,8 +341,6 @@ class VNF(Resource):
:property_value: value to update property with
"""
- self._refresh()
-
instance_inputs = self.tosca.get(origin_section, {}).get(
instance_id, {}
)
@@ -374,8 +378,6 @@ class VNF(Resource):
:property_value: value to update property with
"""
- self._refresh()
-
instance_inputs = self.tosca.get(origin_section, {}).get(
instance_id, {}
)
@@ -413,8 +415,6 @@ class VNF(Resource):
:property_value: value to update property with
"""
- self._refresh()
-
policies = (
self.tosca.get("policies", {}).get(policy_id, {}).get("properties", {})
)
@@ -456,6 +456,8 @@ class VNF(Resource):
**self.attributes, catalog_policy_name=policy
)
+ self._refresh()
+
return new_policy.catalog_resource_id
def associate_policy(self, policy_id, instance_ids):
@@ -619,6 +621,7 @@ def add_resource(parent_resource_id, catalog_resource_id, catalog_resource_name,
"id": resource_instance.catalog_resource_instance_id,
"tosca": resource_instance.response_data,
}
+
return response
diff --git a/onap-client/setup.py b/onap-client/setup.py
index 67e763a..e63b08c 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.2",
+ version="0.9.3",
author="Steven Stark",
author_email="steven.stark@att.com",
description="Python API wrapper for ONAP applications",