from __future__ import print_function
+import json
import logging
import fileinput
import os
import subprocess
import pkg_resources
+import six
from six.moves import configparser
import yaml
cmd = ['rally', 'deployment', 'check']
output = subprocess.check_output(cmd)
LOGGER.info("%s\n%s", " ".join(cmd), output)
+ return get_verifier_deployment_id()
def create_verifier():
'--type', 'tempest', '--system-wide']
output = subprocess.check_output(cmd)
LOGGER.info("%s\n%s", " ".join(cmd), output)
+ return get_verifier_id()
def get_verifier_id():
"""
Returns verifier id for current Tempest
"""
- create_rally_deployment()
- create_verifier()
cmd = ("rally verify list-verifiers | awk '/" +
getattr(config.CONF, 'tempest_verifier_name') +
"/ {print $2}'")
proc = subprocess.Popen(cmd, shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
- deployment_uuid = proc.stdout.readline().rstrip()
- if deployment_uuid == "":
- LOGGER.error("Tempest verifier not found.")
- raise Exception('Error with command:%s' % cmd)
- return deployment_uuid
+ verifier_uuid = proc.stdout.readline().rstrip()
+ return verifier_uuid
def get_verifier_deployment_id():
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
deployment_uuid = proc.stdout.readline().rstrip()
- if deployment_uuid == "":
- LOGGER.error("Rally deployment not found.")
- raise Exception('Error with command:%s' % cmd)
return deployment_uuid
"""
Returns installed verifier repo directory for Tempest
"""
- if not verifier_id:
- verifier_id = get_verifier_id()
-
return os.path.join(getattr(config.CONF, 'dir_rally_inst'),
'verification',
'verifier-{}'.format(verifier_id),
"""
Returns Rally deployment directory for current verifier
"""
- if not verifier_id:
- verifier_id = get_verifier_id()
-
- if not deployment_id:
- deployment_id = get_verifier_deployment_id()
-
return os.path.join(getattr(config.CONF, 'dir_rally_inst'),
'verification',
'verifier-{}'.format(verifier_id),
def configure_tempest_update_params(
tempest_conf_file, network_name=None, image_id=None, flavor_id=None,
- compute_cnt=1, image_alt_id=None, flavor_alt_id=None):
+ compute_cnt=1, image_alt_id=None, flavor_alt_id=None,
+ domain_name="Default"):
# pylint: disable=too-many-branches, too-many-arguments
"""
Add/update needed parameters into tempest.conf file
if os.environ.get('OS_REGION_NAME'):
rconfig.set('identity', 'region', os.environ.get('OS_REGION_NAME'))
identity_api_version = os.environ.get("OS_IDENTITY_API_VERSION", '3')
+ rconfig.set('auth', 'admin_domain_scope', True)
+ rconfig.set('auth', 'default_credentials_domain_name', domain_name)
if identity_api_version == '3':
auth_version = 'v3'
rconfig.set('identity-feature-enabled', 'api_v2', False)
else:
auth_version = 'v2'
+ if env.get("NEW_USER_ROLE").lower() != "member":
+ rconfig.set(
+ 'auth', 'tempest_roles',
+ convert_list_to_ini([env.get("NEW_USER_ROLE")]))
+ if not json.loads(env.get("USE_DYNAMIC_CREDENTIALS").lower()):
+ rconfig.set('auth', 'use_dynamic_credentials', False)
+ account_file = os.path.join(
+ getattr(config.CONF, 'dir_functest_data'), 'accounts.yaml')
+ assert os.path.exists(
+ account_file), "{} doesn't exist".format(account_file)
+ rconfig.set('auth', 'test_accounts_file', account_file)
rconfig.set('identity', 'auth_version', auth_version)
rconfig.set(
'validation', 'ssh_timeout',
if not os.path.isfile(tempest_conf_file):
LOGGER.error("Tempest configuration file %s NOT found.",
tempest_conf_file)
- raise Exception("Tempest configuration file %s NOT found."
- % tempest_conf_file)
- else:
- return tempest_conf_file
+ return None
+ return tempest_conf_file
+
+
+def convert_dict_to_ini(value):
+ "Convert dict to oslo.conf input"
+ assert isinstance(value, dict)
+ return ",".join("{}:{}".format(
+ key, val) for (key, val) in six.iteritems(value))
+
+
+def convert_list_to_ini(value):
+ "Convert list to oslo.conf input"
+ assert isinstance(value, list)
+ return ",".join("{}".format(val) for val in value)