From 94a29637a68af60f86d66b973ca7b73d850b84d8 Mon Sep 17 00:00:00 2001
From: uihassan <uihassan@etsi.org>
Date: Wed, 25 Nov 2020 12:01:59 +0500
Subject: [PATCH] descriptors templating for 7.3.1.1.1 added

---
 .../VnfLcmMntOperationKeywords.robot          | 38 ++++++++++++++-----
 .../jsons/createVnfRequest.json               | 11 +++++-
 2 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/SOL003/VNFLifecycleManagement-API/VnfLcmMntOperationKeywords.robot b/SOL003/VNFLifecycleManagement-API/VnfLcmMntOperationKeywords.robot
index 3daaa313..68ffc12f 100644
--- a/SOL003/VNFLifecycleManagement-API/VnfLcmMntOperationKeywords.robot
+++ b/SOL003/VNFLifecycleManagement-API/VnfLcmMntOperationKeywords.robot
@@ -124,7 +124,16 @@ Send VNF Instance Resource Create Request
     Set Headers  {"Accept":"${ACCEPT}"}  
     Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
     Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
-    ${body}=    Get File    jsons/createVnfRequest.json
+    Get key for VNF Descriptor
+    ${descriptor_id}=    Get Variable Value    ${topology_template.node_templates.${vnfKey}.properties.descriptor_id}
+    ${provider}=    Get Variable Value    ${topology_template.node_templates.${vnfKey}.properties.provider}
+    ${product_name}=    Get Variable Value    ${topology_template.node_templates.${vnfKey}.properties.product_name}
+    ${software_version}=    Get Variable Value    ${topology_template.node_templates.${vnfKey}.properties.software_version}
+    ${descriptor_version}=    Get Variable Value    ${topology_template.node_templates.${vnfKey}.properties.descriptor_version}
+    ${configurable_properties}=    Get Variable Value    ${topology_template.node_templates.${vnfKey}.properties.configurable_properties}
+    ${flavour_id}=    Get Variable Value    ${topology_template.node_templates.${vnfKey}.properties.flavour_id}
+    ${template}=    Get File    jsons/createVnfRequest.json
+    ${body}=        Format String   ${template}     vnfdId=${descriptor_id}    vnfProvider=${provider}    vnfProductName=${product_name}    vnfSoftwareVersion=${software_version}    vnfdVersion= ${descriptor_version}    vnfConfigurableProperties=${configurable_properties}    flavourId=${flavour_id}
     ${response}=    Post    ${apiRoot}/${apiName}/${apiMajorVersion}/vnf_instances    ${body}
 
 Send VNF Instance Resource Delete Request
@@ -361,8 +370,16 @@ POST Create a new vnfInstance
     Set Headers  {"Accept":"${ACCEPT}"}  
     Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
     Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
+    Get key for VNF Descriptor
+    ${descriptor_id}=    Get Variable Value    ${topology_template.node_templates.${vnfKey}.properties.descriptor_id}
+    ${provider}=    Get Variable Value    ${topology_template.node_templates.${vnfKey}.properties.provider}
+    ${product_name}=    Get Variable Value    ${topology_template.node_templates.${vnfKey}.properties.product_name}
+    ${software_version}=    Get Variable Value    ${topology_template.node_templates.${vnfKey}.properties.software_version}
+    ${descriptor_version}=    Get Variable Value    ${topology_template.node_templates.${vnfKey}.properties.descriptor_version}
+    ${configurable_properties}=    Get Variable Value    ${topology_template.node_templates.${vnfKey}.properties.configurable_properties}
+    ${flavour_id}=    Get Variable Value    ${topology_template.node_templates.${vnfKey}.properties.flavour_id}
     ${template}=    Get File    jsons/createVnfRequest.json
-    ${body}=        Format String   ${template}     vnfdId=${vnfdId} 
+    ${body}=        Format String   ${template}     vnfdId=${descriptor_id}    vnfProvider=${provider}    vnfProductName=${product_name}    vnfSoftwareVersion=${software_version}    vnfdVersion= ${descriptor_version}    vnfConfigurableProperties=${configurable_properties}    flavourId=${flavour_id}
     Post    ${apiRoot}/${apiName}/${apiMajorVersion}/vnf_instances    ${body}
     ${outputResponse}=    Output    response
 	Set Global Variable    ${response}    ${outputResponse} 	
@@ -1186,11 +1203,7 @@ Check HTTP Response Body vnfInstance content against VNF Descriptor
     Run Keyword If  '${descriptorType}'=='SOL001'  Parse SOL001    ELSE    Parse SOL006
     
 Parse SOL001
-    FOR    ${key}    IN    @{topology_template.node_templates.keys()} 
-        Log    ${key}
-        ${check1}=    Run Keyword And Return Status    Should End With    ${key}    VNF
-        Run Keyword If     ${check1}     Set Global Variable    ${vnfKey}    ${key}   
-    END
+    Get key for VNF Descriptor
     
     ${descriptor_id}=    Get Variable Value    ${topology_template.node_templates.${vnfKey}.properties.descriptor_id}
     ${provider}=    Get Variable Value    ${topology_template.node_templates.${vnfKey}.properties.provider}
@@ -1206,7 +1219,14 @@ Parse SOL001
     Should Be Equal As Strings    ${response['body']['vnfSoftwareVesion']}    ${software_version}
     Should Be Equal As Strings    ${response['body']['vnfdVersion']}    ${descriptor_version}
     Should Be Equal As Strings    ${response['body']['vnfConfigurableProperties']}    ${configurable_properties}
-    Should Be Equal As Strings    ${response['body']['flavourId']}    ${flavour_id}
+    Should Be Equal As Strings    ${response['body']['instantiatedVnfInfo']['flavourId']}    ${flavour_id}
     
 Parse SOL006
-    Log    SOL006 code
\ No newline at end of file
+    Log    SOL006 code
+    
+Get key for VNF Descriptor
+    FOR    ${key}    IN    @{topology_template.node_templates.keys()} 
+        Log    ${key}
+        ${check1}=    Run Keyword And Return Status    Should End With    ${key}    VNF
+        Run Keyword If     ${check1}     Set Global Variable    ${vnfKey}    ${key}   
+    END
\ No newline at end of file
diff --git a/SOL003/VNFLifecycleManagement-API/jsons/createVnfRequest.json b/SOL003/VNFLifecycleManagement-API/jsons/createVnfRequest.json
index 64ab8e55..35c7f6f4 100644
--- a/SOL003/VNFLifecycleManagement-API/jsons/createVnfRequest.json
+++ b/SOL003/VNFLifecycleManagement-API/jsons/createVnfRequest.json
@@ -1,6 +1,15 @@
 {{
-  "vnfdId": "{vnfdId}",
   "vnfInstanceName": "string",
   "vnfInstanceDescription": "string",
+  "vnfdId": "{vnfdId}",
+  "vnfProvider":"{vnfProvider}",
+  "vnfProductName":"{vnfProductName}",
+  "vnfSoftwareVersion":"{vnfSoftwareVersion}",
+  "vnfdVersion":"{vnfdVersion}",
+  "vnfConfigurableProperties":"{vnfConfigurableProperties}",
+  "instantiatedVnfInfo":{{
+  	"flavourId":"{flavourId}",
+  	"vnfState":"STARTED"
+  }}
   "metadata":{{}}
 }}
\ No newline at end of file
-- 
GitLab