summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortomsou <soth@intracom-telecom.com>2017-02-03 13:18:06 +0000
committerNikolas Hermanns <nikolas.hermanns@ericsson.com>2017-03-15 15:08:51 +0000
commit7efb216ca8357533dd040cccc49cb5effec42615 (patch)
tree488c0b48f0679d8989909e95a36acc69a74abb04
parent56080b02dc020a622cc3cd2065d8d7cec919c5fc (diff)
Implement a get VM IP function in utils to be used within test cases
Change-Id: Iaedbfb2fc626eb7d88badee2530593b43c0d1152 Signed-off-by: tomsou <soth@intracom-telecom.com>
-rw-r--r--sdnvpn/lib/utils.py7
-rw-r--r--sdnvpn/test/functest/testcase_1.py8
-rw-r--r--sdnvpn/test/functest/testcase_4.py8
-rw-r--r--sdnvpn/test/functest/testcase_7.py2
-rw-r--r--sdnvpn/test/functest/testcase_8.py2
5 files changed, 16 insertions, 11 deletions
diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py
index 8c4aebf..0a77796 100644
--- a/sdnvpn/lib/utils.py
+++ b/sdnvpn/lib/utils.py
@@ -54,7 +54,7 @@ def create_subnet(neutron_client, name, cidr, net_id):
def create_network(neutron_client, net, subnet1, cidr1,
router, subnet2=None, cidr2=None):
- """Network assoc will not work for networks/subnets created by this function.
+ """Network assoc won't work for networks/subnets created by this function.
It is an ODL limitation due to it handling routers as vpns.
See https://bugs.opendaylight.org/show_bug.cgi?id=6962"""
@@ -234,6 +234,11 @@ def get_installer_ip():
return str(os.environ['INSTALLER_IP'])
+def get_instance_ip(instance):
+ instance_ip = instance.networks.itervalues().next()[0]
+ return instance_ip
+
+
def wait_for_instance(instance):
logger.info("Waiting for instance %s to get a DHCP lease..." % instance.id)
# The sleep this function replaced waited for 80s
diff --git a/sdnvpn/test/functest/testcase_1.py b/sdnvpn/test/functest/testcase_1.py
index a5c1494..5aa6411 100644
--- a/sdnvpn/test/functest/testcase_1.py
+++ b/sdnvpn/test/functest/testcase_1.py
@@ -82,7 +82,7 @@ def main():
sg_id,
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_1)
- vm_2_ip = vm_2.networks.itervalues().next()[0]
+ vm_2_ip = test_utils.get_instance_ip(vm_2)
vm_3 = test_utils.create_instance(
nova_client,
@@ -92,7 +92,7 @@ def main():
sg_id,
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_2)
- vm_3_ip = vm_3.networks.itervalues().next()[0]
+ vm_3_ip = test_utils.get_instance_ip(vm_3)
vm_5 = test_utils.create_instance(
nova_client,
@@ -102,7 +102,7 @@ def main():
sg_id,
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_2)
- vm_5_ip = vm_5.networks.itervalues().next()[0]
+ vm_5_ip = test_utils.get_instance_ip(vm_5)
# We boot vm5 first because we need vm5_ip for vm4 userdata
u4 = test_utils.generate_ping_userdata([vm_5_ip])
@@ -115,7 +115,7 @@ def main():
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_1,
userdata=u4)
- vm_4_ip = vm_4.networks.itervalues().next()[0]
+ vm_4_ip = test_utils.get_instance_ip(vm_4)
# We boot VM1 at the end because we need to get the IPs first to generate
# the userdata
diff --git a/sdnvpn/test/functest/testcase_4.py b/sdnvpn/test/functest/testcase_4.py
index bb3ea3e..a474630 100644
--- a/sdnvpn/test/functest/testcase_4.py
+++ b/sdnvpn/test/functest/testcase_4.py
@@ -82,7 +82,7 @@ def main():
sg_id,
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_1)
- vm_2_ip = vm_2.networks.itervalues().next()[0]
+ vm_2_ip = test_utils.get_instance_ip(vm_2)
vm_3 = test_utils.create_instance(
nova_client,
@@ -92,7 +92,7 @@ def main():
sg_id,
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_2)
- vm_3_ip = vm_3.networks.itervalues().next()[0]
+ vm_3_ip = test_utils.get_instance_ip(vm_3)
vm_5 = test_utils.create_instance(
nova_client,
@@ -102,7 +102,7 @@ def main():
sg_id,
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_2)
- vm_5_ip = vm_5.networks.itervalues().next()[0]
+ vm_5_ip = test_utils.get_instance_ip(vm_5)
# We boot vm5 first because we need vm5_ip for vm4 userdata
u4 = test_utils.generate_ping_userdata([vm_5_ip])
@@ -115,7 +115,7 @@ def main():
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_1,
userdata=u4)
- vm_4_ip = vm_4.networks.itervalues().next()[0]
+ vm_4_ip = test_utils.get_instance_ip(vm_4)
# We boot VM1 at the end because we need to get the IPs first to generate
# the userdata
diff --git a/sdnvpn/test/functest/testcase_7.py b/sdnvpn/test/functest/testcase_7.py
index 18b6dda..3bc9afb 100644
--- a/sdnvpn/test/functest/testcase_7.py
+++ b/sdnvpn/test/functest/testcase_7.py
@@ -82,7 +82,7 @@ def main():
network_2_id,
sg_id,
secgroup_name=TESTCASE_CONFIG.secgroup_name)
- vm_2_ip = vm_2.networks.itervalues().next()[0]
+ vm_2_ip = test_utils.get_instance_ip(vm_2)
u1 = test_utils.generate_ping_userdata([vm_2_ip])
vm_1 = test_utils.create_instance(
diff --git a/sdnvpn/test/functest/testcase_8.py b/sdnvpn/test/functest/testcase_8.py
index 1e29bb2..1fdfa00 100644
--- a/sdnvpn/test/functest/testcase_8.py
+++ b/sdnvpn/test/functest/testcase_8.py
@@ -81,7 +81,7 @@ def main():
network_2_id,
sg_id,
secgroup_name=TESTCASE_CONFIG.secgroup_name)
- vm_2_ip = vm_2.networks.itervalues().next()[0]
+ vm_2_ip = test_utils.get_instance_ip(vm_2)
u1 = test_utils.generate_ping_userdata([vm_2_ip])
vm_1 = test_utils.create_instance(