Feature 10908: Update charm in running VNF instance
[osm/tests.git] / robot-systest / lib / ns_lib.robot
index 2d6fdb7..a7c6cb9 100644 (file)
@@ -54,6 +54,15 @@ Instantiate Network Service
     [Return]  ${stdout}
 
 
+Update Network Service
+    [Arguments]   ${ns_id}   ${update_type}   ${ns_update_config}   ${ns_update_timeout}
+
+    ${rc}   ${stdout}=   Run and Return RC and Output   osm ns-update ${ns_id} --updatetype ${update_type} --config ${ns_update_config} --timeout ${ns_update_timeout} --wait
+    log   ${stdout}
+    Should Be Equal As Integers   ${rc}   ${success_return_code}
+    [Return]  ${stdout}
+
+
 Get Vnf Management Ip Address
     [Arguments]   ${ns_id}   ${vnf_member_index}
 
@@ -299,3 +308,28 @@ Get Application Names
     @{app_names} =  Split String  ${stdout}
     [Return]  ${app_names}
 
+
+Get VDU Affinity Group Name
+    [Documentation]   Return the affinity group name for a NF
+
+    [Arguments]   ${ns_name}   ${vnf_id}   ${vdur_id}
+
+    ${rc}   ${affinity_group_id}=   Run and Return RC and Output   osm vnf-show ${vnf_id} --literal | yq '.vdur[] | select(.id == "'${vdur_id}'")' | yq '."affinity-or-anti-affinity-group-id"[0]' | tr -d \\" 2>&1
+    log   ${affinity_group_id}
+    Should Be Equal As Integers   ${rc}   ${success_return_code}   msg=${affinity_group_id}   values=False
+    ${rc}   ${affinity_group_name}=   Run and Return RC and Output   osm ns-show ${ns_name} --literal | yq '."affinity-or-anti-affinity-group"[] | select(.id == "'${affinity_group_id}'")' | yq '.name' | tr -d \\" 2>&1
+    log   ${affinity_group_name}
+    Should Be Equal As Integers   ${rc}   ${success_return_code}   msg=${affinity_group_name}   values=False
+    [Return]   ${affinity_group_name}
+
+
+Get Vnf Namespace
+    [Documentation]    Return the KDU's namespace
+
+    [Arguments]   ${vnf_id}
+
+    ${rc}  ${stdout}=  Run and Return RC and Output  osm vnf-show ${vnf_id} --literal | yq '.kdur[]."k8s-namespace"' | tr -d \\"
+    Should Be Equal As Integers  ${rc}  ${success_return_code}  msg=${stdout}  values=False
+    Should Not Be Empty   ${stdout}
+    log  namespace: ${stdout}
+    [Return]  ${stdout}