Fix for add floating ip command change in rocky 85/84085/8
authorJayaPr <jaya.priyadarshini@ericsson.com>
Fri, 30 Aug 2019 15:20:06 +0000 (20:50 +0530)
committerJayaPr <jaya.priyadarshini@ericsson.com>
Thu, 19 Sep 2019 14:51:14 +0000 (20:21 +0530)
With change of openstack version the command for add float ip
has changed

Signed-off-by: JayaPr <jaya.priyadarshini@ericsson.com>
Change-Id: I1309b140760e71eb5c93046a33d7493b7a90da71

csit/libraries/OpenStackOperations.robot

index 2b0a7699cef61a76f016f6e191bb287f5be5df37..57d148af6066e89db3d550cfa25ef240ccc007f3 100644 (file)
@@ -164,13 +164,19 @@ Create And Associate Floating IPs
     \    ${ip_length} =    BuiltIn.Get Length    ${ip}
     \    BuiltIn.Run Keyword If    ${ip_length}>0    Collections.Append To List    ${ip_list}    @{ip}[0]
     \    ...    ELSE    Collections.Append To List    ${ip_list}    None
-    \    ${output} =    OpenStack CLI    openstack server add floating ip ${vm} @{ip}[0]
+    \    ${vm_ip} =    OpenStack CLI    openstack server show ${vm} | grep "addresses" | awk '{print $4}' | cut -d"=" -f 2
+    \    ${port_id} =    OpenStack CLI    openstack port list | grep "ip_address='${vm_ip}'" | awk '{print $2}' | cut -d"=" -f 2
+    \    ${output} =    BuiltIn.Run Keyword If    '${OPENSTACK_BRANCH}' == 'stable/rocky'    OpenStack CLI    openstack floating ip set --port ${port_id} @{ip}[0]
+    \    ...    ELSE    OpenStack CLI    openstack server add floating ip ${vm} @{ip}[0]
     [Return]    ${ip_list}
 
 Remove Floating Ip From Vm
     [Arguments]    ${vm_name}    ${fip}
     [Documentation]    Remove the Floating IP From VM Instance
-    ${output} =    OpenStack CLI    openstack server remove floating ip ${vm_name} ${fip}
+    ${vm_ip} =    OpenStack CLI    openstack server show ${vm_name} | grep "addresses" | awk '{print $4}' | cut -d"=" -f 2
+    ${port_id} =    OpenStack CLI    openstack port list | grep "ip_address='${vm_ip}'" | awk '{print $2}' | cut -d"=" -f 2
+    ${output} =    BuiltIn.Run Keyword If    '${OPENSTACK_BRANCH}' == 'stable/rocky'    OpenStack CLI    openstack floating ip unset --port ${port_id} ${fip}
+    ...    ELSE    OpenStack CLI    openstack server remove floating ip ${vm_name} ${fip}
 
 Delete Floating IP
     [Arguments]    ${fip}