aboutsummaryrefslogtreecommitdiffstats
path: root/onap-client/onap_client/sdc/vnf.py
diff options
context:
space:
mode:
authorstark, steven <steven.stark@att.com>2020-04-10 13:58:40 -0700
committerstark, steven <steven.stark@att.com>2020-04-14 08:11:03 -0700
commitd6b3ac08745b099fbd0ea5ff9feec22a0247bf49 (patch)
tree24681e2239d99ca9ce7f73195b15feb46a74c850 /onap-client/onap_client/sdc/vnf.py
parent71a1fd0d98c99692a25f9087ad5edfbd7cf00800 (diff)
[VVP] adding support for updating checked out resources
- also fixing imports of client to skip tests* Issue-ID: VVP-403 Signed-off-by: stark, steven <steven.stark@att.com> Change-Id: I0f0bddb04d4de10b9003e4fc6380619539f41ca4
Diffstat (limited to 'onap-client/onap_client/sdc/vnf.py')
-rw-r--r--onap-client/onap_client/sdc/vnf.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/onap-client/onap_client/sdc/vnf.py b/onap-client/onap_client/sdc/vnf.py
index d07882c..1d2989a 100644
--- a/onap-client/onap_client/sdc/vnf.py
+++ b/onap-client/onap_client/sdc/vnf.py
@@ -506,7 +506,14 @@ class VNF(Resource):
def update_vnf(catalog_resource_id, vnf_input):
- vnf = vnf_client.checkout_catalog_resource(catalog_resource_id=catalog_resource_id).response_data
+ existing_vnf = vnf_client.get_catalog_resource(
+ catalog_resource_id=catalog_resource_id
+ ).response_data
+
+ if existing_vnf.get("lifecycleState") != "NOT_CERTIFIED_CHECKOUT":
+ vnf = vnf_client.checkout_catalog_resource(catalog_resource_id=catalog_resource_id).response_data
+ else:
+ vnf = vnf_client.get_catalog_resource_metadata(catalog_resource_id=catalog_resource_id).response_data.get("metadata", {})
new_vnf_metadata = vnf_client.get_catalog_resource_metadata(catalog_resource_id=vnf.get("uniqueId")).response_data.get("metadata", {})
@@ -622,7 +629,11 @@ def get_vnf(vnf_name):
def get_vnf_id(vnf_name):
response = vnf_client.get_resources()
results = response.response_data.get("resources", [])
+ catalog_resource = {}
+ update_time = -1
for vnf in results:
- if vnf.get("name") == vnf_name:
- return vnf["uniqueId"]
- return None
+ if vnf.get("name") == vnf_name and vnf.get("lastUpdateDate") > update_time:
+ update_time = vnf.get("lastUpdateDate")
+ catalog_resource = vnf
+
+ return catalog_resource.get("uniqueId")