Use ipaddress for better network calculation in Create ITM Tunnel 03/48703/4
authorDavid López <david.lopez.munoz@ericsson.com>
Fri, 25 Nov 2016 13:59:40 +0000 (14:59 +0100)
committerJamo Luhrsen <jluhrsen@redhat.com>
Tue, 29 Nov 2016 00:52:13 +0000 (00:52 +0000)
Change-Id: I4fccc3166514b774c48c1414d364fecc0e8ec295
Signed-off-by: David Lopez <david.lopez.munoz@ericsson.com>
csit/libraries/OVSDB.robot
csit/suites/openstack/vpnservice/basic_vpnservice.robot

index 016997e732a91785cd23d5f59586bb97585ae596..40893e4d719d30057e1b107346359a933e199c5c 100644 (file)
@@ -3,6 +3,7 @@ Library           SSHLibrary
 Library           String
 Library           Collections
 Library           RequestsLibrary
+Library           ipaddress
 Resource          Utils.robot
 Resource          ClusterManagement.robot
 Resource          ${CURDIR}/TemplatedRequests.robot
@@ -153,6 +154,14 @@ Get DPID
     Log    ${dpnid}
     [Return]    ${dpnid}
 
+Get Subnet
+    [Arguments]    ${ip}
+    [Documentation]    Return the subnet from the system at the given ip address and interface
+    ${output} =    Run Command On Remote System    ${ip}    /usr/sbin/ip addr show | grep ${ip} | cut -d' ' -f6
+    ${interface} =    ipaddress.ip_interface    ${output}
+    ${network}=    Set Variable    ${interface.network.__str__()}
+    [Return]    ${network}
+
 Get Ethernet Adapter
     [Arguments]    ${ip}
     [Documentation]    Returns the ethernet adapter name from the system at the given ip address using ip addr show.
index e5f8056dbd8f5771e73251bc3fe160d954af0938..1275990025b313cf63b36cf89809acbb63f032f5 100644 (file)
@@ -266,8 +266,7 @@ Create ITM Tunnel
     ${node_2_dpid} =    Get DPID    ${OS_COMPUTE_2_IP}
     ${node_1_adapter} =    Get Ethernet Adapter    ${OS_COMPUTE_1_IP}
     ${node_2_adapter} =    Get Ethernet Adapter    ${OS_COMPUTE_2_IP}
-    ${first_two_octets}    ${third_octet}    ${last_octet}=    Split String From Right    ${OS_COMPUTE_1_IP}    .    2
-    ${subnet} =    Set Variable    ${first_two_octets}.0.0/16
+    ${subnet} =    Get Subnet    ${OS_COMPUTE_1_IP}
     ${gateway} =    Get Default Gateway    ${OS_COMPUTE_1_IP}
     ITM Create Tunnel    tunneltype=vxlan    vlanid=0    prefix=${subnet}    gateway=${gateway}    ipaddress1=${OS_COMPUTE_1_IP}    dpnid1=${node_1_dpid}
     ...    portname1=${node_1_adapter}    ipaddress2=${OS_COMPUTE_2_IP}    dpnid2=${node_2_dpid}    portname2=${node_2_adapter}