diff options
-rw-r--r-- | functest/core/tenantnetwork.py | 16 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/shaker/shaker.py | 38 |
2 files changed, 40 insertions, 14 deletions
diff --git a/functest/core/tenantnetwork.py b/functest/core/tenantnetwork.py index 7d9a330f1..5d77fe438 100644 --- a/functest/core/tenantnetwork.py +++ b/functest/core/tenantnetwork.py @@ -44,34 +44,36 @@ class NewProject(object): self.guid = guid self.project = None self.user = None + self.password = None + self.domain = None def create(self): """Create projects/users""" assert self.orig_cloud assert self.case_name - password = str(uuid.uuid4()) - domain = self.orig_cloud.get_domain( + self.password = str(uuid.uuid4()) + self.domain = self.orig_cloud.get_domain( name_or_id=self.orig_cloud.auth.get( "project_domain_name", "Default")) self.project = self.orig_cloud.create_project( name='{}-project_{}'.format(self.case_name, self.guid), description="Created by OPNFV Functest: {}".format( self.case_name), - domain_id=domain.id) + domain_id=self.domain.id) self.__logger.debug("project: %s", self.project) self.user = self.orig_cloud.create_user( name='{}-user_{}'.format(self.case_name, self.guid), - password=password, - domain_id=domain.id) + password=self.password, + domain_id=self.domain.id) self.__logger.debug("user: %s", self.user) self.orig_cloud.grant_role( "_member_", user=self.user.id, project=self.project.id, - domain=domain.id) + domain=self.domain.id) osconfig = os_client_config.config.OpenStackConfig() osconfig.cloud_config[ 'clouds']['envvars']['project_name'] = self.project.name osconfig.cloud_config['clouds']['envvars']['username'] = self.user.name - osconfig.cloud_config['clouds']['envvars']['password'] = password + osconfig.cloud_config['clouds']['envvars']['password'] = self.password self.cloud = shade.OpenStackCloud( cloud_config=osconfig.get_one_cloud()) diff --git a/functest/opnfv_tests/openstack/shaker/shaker.py b/functest/opnfv_tests/openstack/shaker/shaker.py index ba93ba5b5..70eb8a75b 100644 --- a/functest/opnfv_tests/openstack/shaker/shaker.py +++ b/functest/opnfv_tests/openstack/shaker/shaker.py @@ -50,16 +50,40 @@ class Shaker(singlevm.SingleVm2): - 1 on operation error """ assert self.ssh + keystone_id = self.orig_cloud.search_services('keystone')[0].id + self.__logger.debug("keystone id: %s", keystone_id) + endpoint = self.orig_cloud.search_endpoints( + filters={'interface': os.environ.get('OS_INTERFACE', 'public'), + 'service_id': keystone_id})[0].url + self.__logger.debug("keystone endpoint: %s", endpoint) + self.orig_cloud.grant_role( + "admin", user=self.project.user.id, + project=self.project.project.id, + domain=self.project.domain.id) + self.orig_cloud.grant_role( + "heat_stack_owner", user=self.project.user.id, + project=self.project.project.id, + domain=self.project.domain.id) scpc = scp.SCPClient(self.ssh.get_transport()) - scpc.put('/home/opnfv/functest/conf/env_file', '~/env_file') + scpc.put('/home/opnfv/functest/conf/env_file', remote_path='~/') (_, stdout, stderr) = self.ssh.exec_command( - 'source ~/env_file && export OS_INTERFACE=public &&' - 'shaker --server-endpoint {}:9000 --scenario ' - 'openstack/full_l2,openstack/full_l3_east_west,' - 'openstack/full_l3_north_south,openstack/perf_l2,' - 'openstack/perf_l3_east_west,openstack/perf_l3_north_south ' + 'source ~/env_file && ' + 'export OS_INTERFACE=public && ' + 'export OS_AUTH_URL={} && ' + 'export OS_USERNAME={} && ' + 'export OS_PROJECT_NAME={} && ' + 'export OS_PASSWORD={} && ' + 'env && ' + 'shaker --image-name {} --flavor-name {} ' + '--server-endpoint {}:9000 --scenario ' + 'openstack/full_l2,' + 'openstack/full_l3_east_west,' + 'openstack/full_l3_north_south,' + 'openstack/perf_l3_north_south ' '--report report.html --output report.json'.format( - self.sshvm.public_v4)) + endpoint, self.project.user.name, self.project.project.name, + self.project.password, self.image.name, self.flavor.name, + self.fip.floating_ip_address)) self.__logger.info("output:\n%s", stdout.read()) self.__logger.info("error:\n%s", stderr.read()) if not os.path.exists(self.res_dir): |