summaryrefslogtreecommitdiffstats
path: root/testcases
diff options
context:
space:
mode:
Diffstat (limited to 'testcases')
-rw-r--r--testcases/config_functest.py6
-rw-r--r--testcases/functest_utils.py91
2 files changed, 93 insertions, 4 deletions
diff --git a/testcases/config_functest.py b/testcases/config_functest.py
index 9268aa611..a80da49db 100644
--- a/testcases/config_functest.py
+++ b/testcases/config_functest.py
@@ -90,6 +90,12 @@ def action_start():
logger.debug("Cleaning possible functest environment leftovers.")
action_clean()
+ logger.info("Installing needed libraries on the host")
+ cmd = "sudo yum -y install gcc libffi-devel python-devel openssl-devel gmp-devel libxml2-devel libxslt-devel postgresql-devel git wget"
+ if not functest_utils.execute_command(cmd, logger):
+ logger.error("There has been a problem while installing software packages.")
+ exit(-1)
+
logger.info("Installing ODL environment...")
if not install_odl():
logger.error("There has been a problem while installing Robot.")
diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py
index e146db1cd..6af55f7a7 100644
--- a/testcases/functest_utils.py
+++ b/testcases/functest_utils.py
@@ -31,10 +31,6 @@ def check_credentials():
os.environ['OS_TENANT_NAME']
except KeyError:
return False
- try:
- os.environ['OS_REGION_NAME']
- except KeyError:
- return False
return True
@@ -194,6 +190,93 @@ def check_neutron_net(neutron_client, net_name):
return True
return False
+def get_image_id(glance_client, image_name):
+ images = glance_client.images.list()
+ id = ''
+ for i in images:
+ if i.name == image_name:
+ id = i.id
+ break
+ return id
+
+def create_glance_image(glance_client, image_name, file_path):
+ try:
+ with open(file_path) as fimage:
+ image = glance_client.images.create(name=image_name, is_public=True, disk_format="qcow2",
+ container_format="bare", data=fimage)
+ return image.id
+ except:
+ return False
+
+def get_flavor_id(nova_client, flavor_name):
+ flavors = nova_client.flavors.list(detailed=True)
+ id = ''
+ for f in flavors:
+ if f.name == flavor_name:
+ id = f.id
+ break
+ return id
+
+def get_flavor_id_by_ram_range(nova_client, min_ram, max_ram):
+ flavors = nova_client.flavors.list(detailed=True)
+ id = ''
+ for f in flavors:
+ if min_ram <= f.ram and f.ram <= max_ram:
+ id = f.id
+ break
+ return id
+
+
+def get_tenant_id(keystone_client, tenant_name):
+ tenants = keystone_client.tenants.list()
+ id = ''
+ for t in tenants:
+ if t.name == tenant_name:
+ id = t.id
+ break
+ return id
+
+def get_role_id(keystone_client, role_name):
+ roles = keystone_client.roles.list()
+ id = ''
+ for r in roles:
+ if r.name == role_name:
+ id = r.id
+ break
+ return id
+
+def get_user_id(keystone_client, user_name):
+ users = keystone_client.users.list()
+ id = ''
+ for u in users:
+ if u.name == user_name:
+ id = u.id
+ break
+ return id
+
+def create_tenant(keystone_client, tenant_name, tenant_description):
+ try:
+ tenant = keystone_client.tenants.create(tenant_name, tenant_description, enabled=True)
+ return tenant.id
+ except:
+ print "Error:", sys.exc_info()[0]
+ return False
+
+def delete_tenant(keystone_client, tenant_id):
+ try:
+ tenant = keystone_client.tenants.delete(tenant_id)
+ return True
+ except:
+ print "Error:", sys.exc_info()[0]
+ return False
+
+def add_role_user(keystone_client, user_id, role_id, tenant_id):
+ try:
+ keystone_client.roles.add_user_role(user_id, role_id, tenant_id)
+ return True
+ except:
+ print "Error:", sys.exc_info()[0]
+ return False
def check_internet_connectivity(url='http://www.opnfv.org/'):