aboutsummaryrefslogtreecommitdiffstats
path: root/testcases
diff options
context:
space:
mode:
authorunknown <boucherv@live.fr>2015-09-18 18:29:48 +0200
committerunknown <boucherv@live.fr>2015-09-18 18:35:14 +0200
commitd9bb547be665f2cfc284103028fbe912ff6c69bb (patch)
treeaf4dbbb3e844a67ff10cdbb57c585630bd95169d /testcases
parent1700f807501b8fd4e03d06f0b466be17be32f7b4 (diff)
Adding some methods on functest_utils.py
These methodes allow to manage : - keystone user, tenant and role - glance image - nova flavor These methodes will be used on vIMS test-case. JIRA: FUNCTEST-38 Change-Id: Ib5f1fb5ef325ab0527115a36b9c6ce6b45aa84f6 Signed-off-by: boucherv <boucherv@live.fr>
Diffstat (limited to 'testcases')
-rw-r--r--testcases/functest_utils.py87
1 files changed, 87 insertions, 0 deletions
diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py
index 04c283618..6af55f7a7 100644
--- a/testcases/functest_utils.py
+++ b/testcases/functest_utils.py
@@ -190,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/'):