From 7040a716bdc4ca36e22988fdc931adb080e2a059 Mon Sep 17 00:00:00 2001 From: boucherv Date: Fri, 2 Oct 2015 09:29:33 +0200 Subject: vIMS deployment and cleanup These scripts allow to : - Prepare platform (tenant, user, image, quota etc) - Deploy cloudify-manager-server - Deploy vIMS Clearwater - Undeploy vIMS - Undeploy cloudify-manager-server - Clean the platform vIMS test coming soon JIRA: FUNCTEST-38 Change-Id: I35be6433c6511d741a27b67fe24c3031f1e29fe5 Signed-off-by: boucherv --- testcases/functest_utils.py | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'testcases/functest_utils.py') diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py index 101271384..6d60fbce3 100644 --- a/testcases/functest_utils.py +++ b/testcases/functest_utils.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # # jose.lausuch@ericsson.com +# valentin.boucher@orange.com # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 # which accompanies this distribution, and is available at @@ -217,8 +218,27 @@ def get_network_list(neutron_client): else : return network_list +def get_external_net(neutron_client): + for network in neutron_client.list_networks()['networks']: + if network['router:external']: + return network['name'] + return False + +def update_sg_quota(neutron_client, tenant_id, sg_quota, sg_rule_quota): + json_body = {"quota": { + "security_group": sg_quota, + "security_group_rule": sg_rule_quota + }} + + try: + quota = neutron_client.update_quota(tenant_id=tenant_id, body=json_body) + return True + except: + print "Error:", sys.exc_info()[0] + return False ################# GLANCE ################# + def get_image_id(glance_client, image_name): images = glance_client.images.list() id = '' @@ -228,10 +248,10 @@ def get_image_id(glance_client, image_name): break return id -def create_glance_image(glance_client, image_name, file_path): +def create_glance_image(glance_client, image_name, file_path, is_public=True): try: with open(file_path) as fimage: - image = glance_client.images.create(name=image_name, is_public=True, disk_format="qcow2", + image = glance_client.images.create(name=image_name, is_public=is_public, disk_format="qcow2", container_format="bare", data=fimage) return image.id except: @@ -282,6 +302,22 @@ def delete_tenant(keystone_client, tenant_id): print "Error:", sys.exc_info()[0] return False +def create_user(keystone_client, user_name, user_password, user_email, tenant_id): + try: + user = keystone_client.users.create(user_name, user_password, user_email, tenant_id, enabled=True) + return user.id + except: + print "Error:", sys.exc_info()[0] + return False + +def delete_user(keystone_client, user_id): + try: + tenant = keystone_client.users.delete(user_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) -- cgit 1.2.3-korg