Create 2 images and flavors for tempest tests
[functest.git] / functest / opnfv_tests / openstack / tempest / conf_utils.py
index 6fc44d8..d6b1eb4 100644 (file)
@@ -33,19 +33,12 @@ RALLY_AARCH64_PATCH_PATH = pkg_resources.resource_filename(
 GLANCE_IMAGE_PATH = os.path.join(
     getattr(config.CONF, 'dir_functest_images'),
     getattr(config.CONF, 'openstack_image_file_name'))
-TEMPEST_RESULTS_DIR = os.path.join(
-    getattr(config.CONF, 'dir_results'), 'tempest')
 TEMPEST_CUSTOM = pkg_resources.resource_filename(
     'functest', 'opnfv_tests/openstack/tempest/custom_tests/test_list.txt')
 TEMPEST_BLACKLIST = pkg_resources.resource_filename(
     'functest', 'opnfv_tests/openstack/tempest/custom_tests/blacklist.txt')
-TEMPEST_RAW_LIST = os.path.join(TEMPEST_RESULTS_DIR, 'test_raw_list.txt')
-TEMPEST_LIST = os.path.join(TEMPEST_RESULTS_DIR, 'test_list.txt')
 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 = env.get('INSTALLER_TYPE')
 
@@ -93,8 +86,7 @@ def create_verifier():
         getattr(config.CONF, 'tempest_verifier_name'))
     ft_utils.execute_command(cmd, error_msg=(
         "Verifier %s does not exist."
-        % getattr(config.CONF, 'tempest_verifier_name')),
-                             verbose=False)
+        % getattr(config.CONF, 'tempest_verifier_name')), verbose=False)
     cmd = ("rally verify create-verifier --source {0} "
            "--name {1} --type tempest --system-wide"
            .format(getattr(config.CONF, 'dir_repo_tempest'),
@@ -168,45 +160,14 @@ def get_verifier_deployment_dir(verifier_id, deployment_id):
                         'for-deployment-{}'.format(deployment_id))
 
 
-def backup_tempest_config(conf_file):
+def backup_tempest_config(conf_file, res_dir):
     """
     Copy config file to tempest results directory
     """
-    if not os.path.exists(TEMPEST_RESULTS_DIR):
-        os.makedirs(TEMPEST_RESULTS_DIR)
+    if not os.path.exists(res_dir):
+        os.makedirs(res_dir)
     shutil.copyfile(conf_file,
-                    os.path.join(TEMPEST_RESULTS_DIR, 'tempest.conf'))
-
-
-def configure_tempest(deployment_dir, network_name=None, image_id=None,
-                      flavor_id=None, compute_cnt=None):
-    """
-    Calls rally verify and updates the generated tempest.conf with
-    given parameters
-    """
-    conf_file = configure_verifier(deployment_dir)
-    configure_tempest_update_params(conf_file, network_name, image_id,
-                                    flavor_id, compute_cnt)
-
-
-def generate_test_accounts_file(tenant_id):
-    """
-    Add needed tenant and user params into test_accounts.yaml
-    """
-
-    LOGGER.debug("Add needed params into test_accounts.yaml...")
-    accounts_list = [
-        {
-            'tenant_name': getattr(
-                config.CONF, 'tempest_identity_tenant_name'),
-            'tenant_id': str(tenant_id),
-            'username': getattr(config.CONF, 'tempest_identity_user_name'),
-            'password': getattr(config.CONF, 'tempest_identity_user_password')
-        }
-    ]
-
-    with open(TEST_ACCOUNTS_FILE, "w") as tfile:
-        yaml.dump(accounts_list, tfile, default_flow_style=False)
+                    os.path.join(res_dir, 'tempest.conf'))
 
 
 def update_tempest_conf_file(conf_file, rconfig):
@@ -226,9 +187,10 @@ def update_tempest_conf_file(conf_file, rconfig):
         rconfig.write(config_file)
 
 
-def configure_tempest_update_params(tempest_conf_file, network_name=None,
-                                    image_id=None, flavor_id=None,
-                                    compute_cnt=1):
+def configure_tempest_update_params(tempest_conf_file, res_dir,
+                                    network_name=None, image_id=None,
+                                    flavor_id=None, compute_cnt=1):
+    # pylint: disable=too-many-branches, too-many-arguments
     """
     Add/update needed parameters into tempest.conf file
     """
@@ -236,9 +198,7 @@ def configure_tempest_update_params(tempest_conf_file, network_name=None,
     rconfig = ConfigParser.RawConfigParser()
     rconfig.read(tempest_conf_file)
     rconfig.set('compute', 'fixed_network_name', network_name)
-    rconfig.set('compute', 'volume_device_name',
-                getattr(config.CONF, 'tempest_volume_device_name'))
-
+    rconfig.set('compute', 'volume_device_name', env.get('VOLUME_DEVICE_NAME'))
     if image_id is not None:
         rconfig.set('compute', 'image_ref', image_id)
     if IMAGE_ID_ALT is not None:
@@ -254,8 +214,7 @@ def configure_tempest_update_params(tempest_conf_file, network_name=None,
         rconfig.set('compute-feature-enabled', 'live_migration', True)
 
     rconfig.set('identity', 'region', os.environ.get('OS_REGION_NAME'))
-    identity_api_version = os.environ.get(
-        "OS_IDENTITY_API_VERSION", os.environ.get("IDENTITY_API_VERSION"))
+    identity_api_version = os.environ.get("OS_IDENTITY_API_VERSION", '3')
     if identity_api_version == '3':
         auth_version = 'v3'
         rconfig.set('identity-feature-enabled', 'api_v2', False)
@@ -272,6 +231,8 @@ def configure_tempest_update_params(tempest_conf_file, network_name=None,
         rconfig.set('identity', 'v3_endpoint_type',
                     os.environ.get('OS_ENDPOINT_TYPE'))
 
+    rconfig.set('network-feature-enabled', 'api_extensions', 'all')
+
     if os.environ.get('OS_ENDPOINT_TYPE') is not None:
         sections = rconfig.sections()
         services_list = [
@@ -287,7 +248,7 @@ def configure_tempest_update_params(tempest_conf_file, network_name=None,
                  'into tempest.conf file')
     update_tempest_conf_file(tempest_conf_file, rconfig)
 
-    backup_tempest_config(tempest_conf_file)
+    backup_tempest_config(tempest_conf_file, res_dir)
 
 
 def configure_verifier(deployment_dir):