diff options
author | Linda Wang <wangwulin@huawei.com> | 2017-08-22 11:38:58 +0000 |
---|---|---|
committer | Linda Wang <wangwulin@huawei.com> | 2017-08-22 12:19:27 +0000 |
commit | 961d31d83a1b2e872f5e270bcea93519544b5cd2 (patch) | |
tree | b428d7747f6f92ff0acb1abd9ddd33cf2c95bd25 /functest/opnfv_tests/openstack/tempest | |
parent | 42562fa3393aa54d1780a428b439cedcd3590a7b (diff) |
Config test_accounts_file for refstack_defcore
Tenant and user are required by refstack_defcore, which could
be configured in the test_accounts_file. [1]
[1]: https://github.com/openstack/refstack-client/blob/master/refstack_client/refstack_client.py#L170-L193
Change-Id: I9c920b6f15f491d671ebf222976305bedf4dd747
Signed-off-by: Linda Wang <wangwulin@huawei.com>
Diffstat (limited to 'functest/opnfv_tests/openstack/tempest')
-rw-r--r-- | functest/opnfv_tests/openstack/tempest/conf_utils.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py index fd3785b9..8574b0de 100644 --- a/functest/opnfv_tests/openstack/tempest/conf_utils.py +++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py @@ -41,6 +41,9 @@ REFSTACK_RESULTS_DIR = os.path.join(CONST.__getattribute__('dir_results'), 'refstack') TEMPEST_CONF_YAML = pkg_resources.resource_filename( 'functest', 'opnfv_tests/openstack/tempest/custom_tests/tempest_conf.yaml') +TEST_ACCOUNTS_FILE = pkg_resources.resource_filename( + 'functest', + 'opnfv_tests/openstack/tempest/custom_tests/test_accounts.yaml') CI_INSTALLER_TYPE = CONST.__getattribute__('INSTALLER_TYPE') CI_INSTALLER_IP = CONST.__getattribute__('INSTALLER_IP') @@ -117,6 +120,30 @@ def create_tempest_resources(use_custom_images=False, return img_flavor_dict +def create_tenant_user(): + keystone_client = os_utils.get_keystone_client() + + logger.debug("Creating tenant and user for Tempest suite") + tenant_id = os_utils.create_tenant( + keystone_client, + CONST.__getattribute__('tempest_identity_tenant_name'), + CONST.__getattribute__('tempest_identity_tenant_description')) + if not tenant_id: + logger.error("Failed to create %s tenant" + % CONST.__getattribute__('tempest_identity_tenant_name')) + + user_id = os_utils.create_user( + keystone_client, + CONST.__getattribute__('tempest_identity_user_name'), + CONST.__getattribute__('tempest_identity_user_password'), + None, tenant_id) + if not user_id: + logger.error("Failed to create %s user" % + CONST.__getattribute__('tempest_identity_user_name')) + + return tenant_id + + def get_verifier_id(): """ Returns verifer id for current Tempest @@ -228,6 +255,8 @@ def configure_tempest_defcore(deployment_dir, img_flavor_dict): config.set('DEFAULT', 'log_file', '{}/tempest.log'.format(deployment_dir)) config.set('oslo_concurrency', 'lock_path', '{}/lock_files'.format(deployment_dir)) + generate_test_accounts_file() + config.set('auth', 'test_accounts_file', TEST_ACCOUNTS_FILE) config.set('scenario', 'img_dir', '{}'.format(deployment_dir)) config.set('scenario', 'img_file', 'tempest-image') config.set('compute', 'image_ref', img_flavor_dict.get("image_id")) @@ -246,6 +275,28 @@ def configure_tempest_defcore(deployment_dir, img_flavor_dict): shutil.copyfile(conf_file, confpath) +def generate_test_accounts_file(): + """ + Add needed tenant and user params into test_accounts.yaml + """ + + logger.debug("Add needed params into test_accounts.yaml...") + tenant_id = create_tenant_user() + accounts_list = [ + { + 'tenant_name': + CONST.__getattribute__('tempest_identity_tenant_name'), + 'tenant_id': str(tenant_id), + 'username': CONST.__getattribute__('tempest_identity_user_name'), + 'password': + CONST.__getattribute__('tempest_identity_user_password') + } + ] + + with open(TEST_ACCOUNTS_FILE, "w") as f: + yaml.dump(accounts_list, f, default_flow_style=False) + + def configure_tempest_update_params(tempest_conf_file, IMAGE_ID=None, FLAVOR_ID=None): """ |