aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2016-07-06 09:20:48 +0200
committerJose Lausuch <jose.lausuch@ericsson.com>2016-07-06 08:45:27 +0000
commit1eddb7ec20a2afe7873b85b16e4c3c137c5a200d (patch)
tree8672fc300a69cbbf0ea46a09890dc7b557668f1f /utils
parente635dbe042f7e6f806550aa5f31f2c409166a87f (diff)
Add support functions for SDNVPN test cases
JIRA: FUNCTEST-99 Get availability zones from nova client and give the possibility to create an instance on a specific hypervisor (availability zone) Change-Id: Ieb2d26764c50ea4f4403818bb73a238236e03ee4 Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'utils')
-rw-r--r--utils/openstack_utils.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/utils/openstack_utils.py b/utils/openstack_utils.py
index 1379d782d..b93d38185 100644
--- a/utils/openstack_utils.py
+++ b/utils/openstack_utils.py
@@ -178,6 +178,18 @@ def get_floating_ips(nova_client):
return None
+def get_hypervisors(nova_client):
+ try:
+ nodes = []
+ hypervisors = nova_client.hypervisors.list()
+ for hypervisor in hypervisors:
+ nodes.append(hypervisor.hypervisor_hostname)
+ return nodes
+ except Exception, e:
+ print "Error [get_hypervisors(nova_client)]:", e
+ return None
+
+
def create_flavor(nova_client, flavor_name, ram, disk, vcpus):
try:
flavor = nova_client.flavors.create(flavor_name, ram, vcpus, disk)
@@ -193,7 +205,8 @@ def create_instance(flavor_name,
network_id,
instance_name="functest-vm",
confdrive=True,
- userdata=None):
+ userdata=None,
+ av_zone=''):
nova_client = get_nova_client()
try:
flavor = nova_client.flavors.find(name=flavor_name)
@@ -207,7 +220,8 @@ def create_instance(flavor_name,
name=instance_name,
flavor=flavor,
image=image_id,
- nics=[{"net-id": network_id}]
+ nics=[{"net-id": network_id}],
+ availability_zone=av_zone
)
else:
instance = nova_client.servers.create(
@@ -216,7 +230,8 @@ def create_instance(flavor_name,
image=image_id,
nics=[{"net-id": network_id}],
config_drive=confdrive,
- userdata=userdata
+ userdata=userdata,
+ availability_zone=av_zone
)
return instance
@@ -226,7 +241,8 @@ def create_instance_and_wait_for_active(flavor_name,
network_id,
instance_name="",
config_drive=False,
- userdata=""):
+ userdata="",
+ av_zone=''):
SLEEP = 3
VM_BOOT_TIMEOUT = 180
nova_client = get_nova_client()
@@ -235,7 +251,8 @@ def create_instance_and_wait_for_active(flavor_name,
network_id,
instance_name,
config_drive,
- userdata)
+ userdata,
+ av_zone)
count = VM_BOOT_TIMEOUT / SLEEP
for n in range(count, -1, -1):