diff options
author | Jose Lausuch <jose.lausuch@ericsson.com> | 2016-12-21 10:32:03 +0000 |
---|---|---|
committer | boucherv <valentin.boucher@orange.com> | 2016-12-21 15:12:12 +0100 |
commit | 3542fb76b0034228e588d395fd8a64df4eff8100 (patch) | |
tree | 1b4c5050c0754b3e95f2759c1be3a0b5d99fac3b /functest/utils | |
parent | 266e29ce1eb02bf8f97ada361d759d41567cce73 (diff) | |
parent | 231b742d9db18ee347d786dd6cb42c0ca67ad5bc (diff) |
Updated vims to support keystone v3
Adding the choice, into openstack_utils,
to get openstack client with environment credentials
or with a specific credentials (new user/tenant..)
JIRA: FUNCTEST-529
Change-Id: I295808311de40f37a07b5a831852876a51f276f3
Signed-off-by: boucherv <valentin.boucher@orange.com>
Diffstat (limited to 'functest/utils')
-rw-r--r-- | functest/utils/functest_constants.py | 56 | ||||
-rw-r--r-- | functest/utils/functest_utils.py | 2 | ||||
-rwxr-xr-x | functest/utils/openstack_utils.py | 40 |
3 files changed, 54 insertions, 44 deletions
diff --git a/functest/utils/functest_constants.py b/functest/utils/functest_constants.py index 2664ace1..a39d33ac 100644 --- a/functest/utils/functest_constants.py +++ b/functest/utils/functest_constants.py @@ -60,25 +60,25 @@ def get_value(functest_config_key, env_variable): return constant -HOME = get_value('general.directories.dir_home', 'HOME') -REPOS_DIR = get_value('general.directories.dir_repos', 'REPOS_DIR') -FUNCTEST_BASE_DIR = get_value('general.directories.dir_functest', +HOME = get_value('general.dir.dir_home', 'HOME') +REPOS_DIR = get_value('general.dir.dir_repos', 'REPOS_DIR') +FUNCTEST_BASE_DIR = get_value('general.dir.functest', 'FUNCTEST_BASE_DIR') -FUNCTEST_REPO_DIR = get_value('general.directories.dir_repo_functest', +FUNCTEST_REPO_DIR = get_value('general.dir.repo_functest', 'FUNCTEST_REPO_DIR') -FUNCTEST_TEST_DIR = get_value('general.directories.dir_functest_test', +FUNCTEST_TEST_DIR = get_value('general.dir.functest_test', 'FUNCTEST_TEST_DIR') -FUNCTEST_CONF_DIR = get_value('general.directories.dir_functest_conf', +FUNCTEST_CONF_DIR = get_value('general.dir.functest_conf', 'FUNCTEST_CONF_DIR') -FUNCTEST_DATA_DIR = get_value('general.directories.dir_functest_data', +FUNCTEST_DATA_DIR = get_value('general.dir.functest_data', 'FUNCTEST_DATA_DIR') -FUNCTEST_RESULTS_DIR = get_value('general.directories.dir_results', +FUNCTEST_RESULTS_DIR = get_value('general.dir.results', 'FUNCTEST_RESULTS_DIR') FUNCTEST_TESTCASES_YAML = get_value('general.functest.testcases_yaml', 'FUNCTEST_TESTCASES_YAML') RALLY_DEPLOYMENT_NAME = get_value('rally.deployment_name', 'RALLY_DEPLOYMENT_NAME') -TEMPEST_REPO_DIR = get_value('general.directories.dir_repo_tempest', +TEMPEST_REPO_DIR = get_value('general.dir.dir_repo_tempest', 'TEMPEST_REPO_DIR') ENV_FILE = os.path.join(FUNCTEST_CONF_DIR, "env_active") @@ -87,22 +87,22 @@ OPENSTACK_CREDS = get_value('general.openstack.creds', 'creds') OPENSTACK_SNAPSHOT_FILE = get_value('general.openstack.snapshot_file', 'OPENSTACK_SNAPSHOT_FILE') -DOMINO_REPO_DIR = get_value('general.directories.dir_repo_domino', +DOMINO_REPO_DIR = get_value('general.dir.dir_repo_domino', 'DOMINO_REPO_DIR') -SDNVPN_REPO_DIR = get_value('general.directories.dir_repo_sdnvpn', +SDNVPN_REPO_DIR = get_value('general.dir.dir_repo_sdnvpn', 'SDNVPN_REPO_DIR') -SFC_REPO_DIR = get_value('general.directories.dir_repo_sfc', +SFC_REPO_DIR = get_value('general.dir.dir_repo_sfc', 'SFC_REPO_DIR') ONOS_SFC_IMAGE_NAME = get_value('onos_sfc.image_name', 'ONOS_SFC_IMAGE_NAME') ONOS_SFC_IMAGE_FILENAME = get_value('onos_sfc.image_file_name', 'ONOS_SFC_IMAGE_FILENAME') -ONOS_SFC_RELATIVE_PATH = get_value('general.directories.dir_onos_sfc', +ONOS_SFC_RELATIVE_PATH = get_value('general.dir.dir_onos_sfc', 'ONOS_SFC_RELATIVE_PATH') ONOS_SFC_IMAGE_BASE_URL = get_value('onos_sfc.image_base_url', 'ONOS_SFC_IMAGE_BASE_URL') -RALLY_RELATIVE_PATH = get_value('general.directories.dir_rally', +RALLY_RELATIVE_PATH = get_value('general.dir.dir_rally', 'RALLY_RELATIVE_PATH') RALLY_PRIVATE_NET_NAME = get_value('rally.network_name', 'RALLY_PRIVATE_NET_NAME') @@ -111,7 +111,7 @@ RALLY_PRIVATE_SUBNET_NAME = get_value('rally.subnet_name', RALLY_PRIVATE_SUBNET_CIDR = get_value('rally.subnet_cidr', 'RALLY_PRIVATE_SUBNET_CIDR') RALLY_ROUTER_NAME = get_value('rally.router_name', 'RALLY_ROUTER_NAME') -RALLY_INSTALLATION_DIR = get_value('general.directories.dir_rally_inst', +RALLY_INSTALLATION_DIR = get_value('general.dir.dir_rally_inst', 'RALLY_INSTALLATION_DIR') GLANCE_IMAGE_NAME = get_value('general.openstack.image_name', 'GLANCE_IMAGE_NAME') @@ -149,24 +149,24 @@ TEMPEST_USE_CUSTOM_IMAGES = get_value('tempest.use_custom_images', 'TEMPEST_USE_CUSTOM_IMAGES') TEMPEST_USE_CUSTOM_FLAVORS = get_value('tempest.use_custom_flavors', 'TEMPEST_USE_CUSTOM_FLAVORS') -TEMPEST_TEST_LIST_DIR = get_value('general.directories.dir_tempest_cases', +TEMPEST_TEST_LIST_DIR = get_value('general.dir.dir_tempest_cases', 'TEMPEST_TEST_LIST_DIR') NAME_VM_1 = get_value('vping.vm_name_1', 'NAME_VM_1') NAME_VM_2 = get_value('vping.vm_name_2', 'NAME_VM_2') PING_TIMEOUT = get_value('vping.ping_timeout', 'PING_TIMEOUT') VPING__IMAGE_NAME = get_value('vping.image_name', 'VPING__IMAGE_NAME') VPING_VM_FLAVOR = get_value('vping.vm_flavor', 'VPING_VM_FLAVOR') -VPING_PRIVATE_NET_NAME = get_value('vping.vping_private_net_name', +VPING_PRIVATE_NET_NAME = get_value('vping.private_net_name', 'VPING_PRIVATE_NET_NAME') -VPING_PRIVATE_SUBNET_NAME = get_value('vping.vping_private_subnet_name', +VPING_PRIVATE_SUBNET_NAME = get_value('vping.private_subnet_name', 'VPING_PRIVATE_SUBNET_NAME') -VPING_PRIVATE_SUBNET_CIDR = get_value('vping.vping_private_subnet_cidr', +VPING_PRIVATE_SUBNET_CIDR = get_value('vping.private_subnet_cidr', 'VPING_PRIVATE_SUBNET_CIDR') -VPING_ROUTER_NAME = get_value('vping.vping_router_name', +VPING_ROUTER_NAME = get_value('vping.router_name', 'VPING_ROUTER_NAME') -VPING_SECGROUP_NAME = get_value('vping.vping_sg_name', +VPING_SECGROUP_NAME = get_value('vping.sg_name', 'VPING_SECGROUP_NAME') -VPING_SECGROUP_DESCR = get_value('vping.vping_sg_descr', +VPING_SECGROUP_DESCR = get_value('vping.sg_desc', 'VPING_SECGROUP_DESCR') ONOSBENCH_USERNAME = get_value('ONOS.general.onosbench_username', 'ONOSBENCH_USERNAME') @@ -192,7 +192,7 @@ ONOS_INSTALLER_MASTER_USERNAME = get_value( ONOS_INSTALLER_MASTER_PASSWORD = get_value( 'ONOS.environment.installer_master_password', 'ONOS_INSTALLER_MASTER_PASSWORD') -PROMISE_REPO_DIR = get_value('general.directories.dir_repo_promise', +PROMISE_REPO_DIR = get_value('general.dir.dir_repo_promise', 'PROMISE_REPO_DIR') PROMISE_TENANT_NAME = get_value('promise.tenant_name', 'PROMISE_TENANT_NAME') @@ -217,9 +217,9 @@ PROMISE_SUBNET_CIDR = get_value('promise.subnet_cidr', 'PROMISE_SUBNET_CIDR') PROMISE_ROUTER_NAME = get_value('promise.router_name', 'PROMISE_ROUTER_NAME') -DOCTOR_REPO_DIR = get_value('general.directories.dir_repo_doctor', +DOCTOR_REPO_DIR = get_value('general.dir.dir_repo_doctor', 'DOCTOR_REPO_DIR') -COPPER_REPO_DIR = get_value('general.directories.dir_repo_copper', +COPPER_REPO_DIR = get_value('general.dir.dir_repo_copper', 'COPPER_REPO_DIR') EXAMPLE_INSTANCE_NAME = get_value('example.example_vm_name', 'EXAMPLE_INSTANCE_NAME') @@ -240,9 +240,9 @@ EXAMPLE_SECGROUP_NAME = get_value('example.example_sg_name', 'EXAMPLE_SECGROUP_NAME') EXAMPLE_SECGROUP_DESCR = get_value('example.example_sg_descr', 'EXAMPLE_SECGROUP_DESCR') -VIMS_DATA_DIR = get_value('general.directories.dir_vIMS_data', +VIMS_DATA_DIR = get_value('general.dir.dir_vIMS_data', 'VIMS_DATA_DIR') -VIMS_TEST_DIR = get_value('general.directories.dir_repo_vims_test', +VIMS_TEST_DIR = get_value('general.dir.dir_repo_vims_test', 'VIMS_TEST_DIR') VIMS_TENANT_NAME = get_value('vIMS.general.tenant_name', 'VIMS_TENANT_NAME') @@ -260,5 +260,5 @@ CW_DEPLOYMENT_NAME = get_value('vIMS.clearwater.deployment-name', CW_INPUTS = get_value('vIMS.clearwater.inputs', 'CW_INPUTS') CW_REQUIERMENTS = get_value('vIMS.clearwater.requierments', 'CW_REQUIERMENTS') -PARSER_REPO_DIR = get_value('general.directories.dir_repo_parser', +PARSER_REPO_DIR = get_value('general.dir.dir_repo_parser', 'PARSER_REPO_DIR') diff --git a/functest/utils/functest_utils.py b/functest/utils/functest_utils.py index b1e4d3cd..e4845c62 100644 --- a/functest/utils/functest_utils.py +++ b/functest/utils/functest_utils.py @@ -326,7 +326,7 @@ def get_deployment_dir(): Returns current Rally deployment directory """ deployment_name = get_functest_config('rally.deployment_name') - rally_dir = get_functest_config('general.directories.dir_rally_inst') + rally_dir = get_functest_config('general.dir.dir_rally_inst') cmd = ("rally deployment list | awk '/" + deployment_name + "/ {print $2}'") p = subprocess.Popen(cmd, shell=True, diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py index ec784121..38a30cb3 100755 --- a/functest/utils/openstack_utils.py +++ b/functest/utils/openstack_utils.py @@ -86,7 +86,7 @@ def get_env_cred_dict(): return env_cred_dict -def get_credentials(): +def get_credentials(other_creds={}): """Returns a creds dictionary filled with parsed from env """ creds = {} @@ -99,6 +99,16 @@ def get_credentials(): else: creds_key = env_cred_dict.get(envvar) creds.update({creds_key: os.getenv(envvar)}) + + if 'tenant' in other_creds.keys(): + if is_keystone_v3(): + tenant = 'project_name' + else: + tenant = 'tenant_name' + other_creds[tenant] = other_creds.pop('tenant') + + creds.update(other_creds) + return creds @@ -138,9 +148,9 @@ def get_credentials_for_rally(): return rally_conf -def get_session_auth(): +def get_session_auth(other_creds={}): loader = loading.get_plugin_loader('password') - creds = get_credentials() + creds = get_credentials(other_creds) auth = loader.load_from_options(**creds) return auth @@ -152,8 +162,8 @@ def get_endpoint(service_type, endpoint_type='publicURL'): endpoint_type=endpoint_type) -def get_session(): - auth = get_session_auth() +def get_session(other_creds={}): + auth = get_session_auth(other_creds) return session.Session(auth=auth) @@ -169,8 +179,8 @@ def get_keystone_client_version(): return DEFAULT_API_VERSION -def get_keystone_client(): - sess = get_session() +def get_keystone_client(other_creds={}): + sess = get_session(other_creds) return keystoneclient.Client(get_keystone_client_version(), session=sess) @@ -183,8 +193,8 @@ def get_nova_client_version(): return DEFAULT_API_VERSION -def get_nova_client(): - sess = get_session() +def get_nova_client(other_creds={}): + sess = get_session(other_creds) return novaclient.Client(get_nova_client_version(), session=sess) @@ -197,8 +207,8 @@ def get_cinder_client_version(): return DEFAULT_API_VERSION -def get_cinder_client(): - sess = get_session() +def get_cinder_client(other_creds={}): + sess = get_session(other_creds) return cinderclient.Client(get_cinder_client_version(), session=sess) @@ -211,8 +221,8 @@ def get_neutron_client_version(): return DEFAULT_API_VERSION -def get_neutron_client(): - sess = get_session() +def get_neutron_client(other_creds={}): + sess = get_session(other_creds) return neutronclient.Client(get_neutron_client_version(), session=sess) @@ -224,8 +234,8 @@ def get_glance_client_version(): return DEFAULT_API_VERSION -def get_glance_client(): - sess = get_session() +def get_glance_client(other_creds={}): + sess = get_session(other_creds) return glanceclient.Client(get_glance_client_version(), session=sess) |