From 77fa9ad1606b5054d733a8140e44b652608806c7 Mon Sep 17 00:00:00 2001
From: Martin Kopec <mkopec@redhat.com>
Date: Tue, 5 Jun 2018 14:16:56 +0000
Subject: [PATCH] Remove the content of default-overrides.conf

Move all needed values to the load_basic_defaults method and
remove the rest.
The default-overrides.conf itself will be removed in a following
patch.

Change-Id: I47a12560bee4746efb54eb9b3c841b2783aa15f6
---
 config_tempest/constants.py                   |   2 -
 config_tempest/main.py                        |  37 ++++--
 .../tests/services/test_object_storage.py     |   8 +-
 etc/default-overrides.conf                    | 114 +-----------------
 ...fault-overrides.conf-9ad55f5ef953ab06.yaml |   5 +
 5 files changed, 38 insertions(+), 128 deletions(-)
 create mode 100644 releasenotes/notes/Remove-default-overrides.conf-9ad55f5ef953ab06.yaml

diff --git a/config_tempest/constants.py b/config_tempest/constants.py
index 376ab9b1..34de41fa 100644
--- a/config_tempest/constants.py
+++ b/config_tempest/constants.py
@@ -23,8 +23,6 @@ TEMPEST_WORKSPACE = os.getcwd()
 
 DEPLOYER_INPUT = os.path.join(os.path.expanduser("~"),
                               "tempest-deployer-input.conf")
-DEFAULTS_FILE = os.path.join(TEMPEST_WORKSPACE, "etc",
-                             "default-overrides.conf")
 DEFAULT_IMAGE = ("http://download.cirros-cloud.net/0.3.5/"
                  "cirros-0.3.5-x86_64-disk.img")
 DEFAULT_IMAGE_FORMAT = 'qcow2'
diff --git a/config_tempest/main.py b/config_tempest/main.py
index a6117831..ea27595e 100755
--- a/config_tempest/main.py
+++ b/config_tempest/main.py
@@ -16,9 +16,7 @@
 This script will generate the etc/tempest.conf file by applying a series of
 specified options in the following order:
 
-1. Values from etc/default-overrides.conf, if present. This file will be
-provided by the distributor of the tempest code, a distro for example, to
-specify defaults that are different than the generic defaults for tempest.
+1. Default values provided by the tool.
 
 2. Values using the file provided by the --deployer-input argument to the
 script.
@@ -76,13 +74,19 @@ def load_basic_defaults(conf):
     """
     LOG.debug("Setting basic default values")
     default_values = {
+        "DEFAULT": [
+            ("debug", "true"),
+            ("use_stderr", "false"),
+            ("log_file", "tempest.log")
+        ],
         "identity": [
             ("username", "demo"),
             ("password", "secrete"),
             ("project_name", "demo"),
             ("alt_username", "alt_demo"),
             ("alt_password", "secrete"),
-            ("alt_project_name", "alt_demo")
+            ("alt_project_name", "alt_demo"),
+            ("disable_ssl_certificate_validation", "true")
         ],
         "scenario": [
             ("img_dir", "etc")
@@ -92,10 +96,25 @@ def load_basic_defaults(conf):
             ("admin_username", "admin"),
             ("admin_project_name", "admin"),
             ("admin_domain_name", "Default")
+        ],
+        "object-storage": [
+            ("reseller_admin_role", "ResellerAdmin")
+        ],
+        "oslo-concurrency": [
+            ("lock_path", "/tmp")
+        ],
+        "compute-feature-enabled": [
+            # Default deployment does not use shared storage
+            ("live_migration", "false"),
+            ("live_migrate_paused_instances", "true"),
+            ("preserve_ports", "true")
+        ],
+        "network-feature-enabled": [
+            ("ipv6_subnet_attributes", "true")
         ]}
 
     for section in default_values.keys():
-        if not conf.has_section(section):
+        if section != "DEFAULT" and not conf.has_section(section):
             conf.add_section(section)
         for key, value in default_values[section]:
             if not conf.has_option(section, key):
@@ -124,7 +143,7 @@ def set_options(conf, deployer_input, non_admin, overrides=[],
                 no_default_deployer=False):
     """Set options in conf provided by different source.
 
-    1. read the default values in default-overrides file
+    1. read the default values
     2. read a file provided by --deployer-input argument
     3. read default DEPLOYER_INPUT if --no-deployer-input is False and no
        deployer_input was passed
@@ -142,11 +161,7 @@ def set_options(conf, deployer_input, non_admin, overrides=[],
     :param cloud_creds: Cloud credentials from client's config
     :type cloud_creds: dict
     """
-    if os.path.isfile(C.DEFAULTS_FILE):
-        LOG.info("Reading defaults from file '%s'", C.DEFAULTS_FILE)
-        conf.read(C.DEFAULTS_FILE)
-    else:
-        load_basic_defaults(conf)
+    load_basic_defaults(conf)
 
     if deployer_input and os.path.isfile(deployer_input):
         LOG.info("Reading deployer input from file {}".format(
diff --git a/config_tempest/tests/services/test_object_storage.py b/config_tempest/tests/services/test_object_storage.py
index a411945f..0e4c8c50 100644
--- a/config_tempest/tests/services/test_object_storage.py
+++ b/config_tempest/tests/services/test_object_storage.py
@@ -15,7 +15,7 @@
 
 import mock
 
-from config_tempest import constants as C
+from config_tempest import main
 from config_tempest.services.object_storage import ObjectStorageService
 from config_tempest import tempest_conf
 from config_tempest.tests.base import BaseServiceTest
@@ -45,9 +45,9 @@ class TestObjectStorageService(BaseServiceTest):
         self.assertItemsEqual(self.Service.get_extensions(), [])
 
     def test_list_create_roles(self):
-        conf = tempest_conf.TempestConf()
-        # TODO(mkopec) remove reading of default file when it's removed
-        conf.read(C.DEFAULTS_FILE)
+        conf = self.Service.conf
+        # load default values
+        main.load_basic_defaults(self.Service.conf)
         client = mock.Mock()
         return_mock = mock.Mock(return_value=self.FAKE_ROLES)
         client.list_roles = return_mock
diff --git a/etc/default-overrides.conf b/etc/default-overrides.conf
index 942975d8..7b23b211 100644
--- a/etc/default-overrides.conf
+++ b/etc/default-overrides.conf
@@ -1,111 +1,3 @@
-[DEFAULT]
-
-# Print debugging output (set logging level to DEBUG instead
-# of default WARNING level). (boolean value)
-debug=true
-
-
-# Log output to standard error (boolean value)
-use_stderr=false
-
-# (Optional) Name of log file to output to. If no default is
-# set, logging will go to stdout. (string value)
-# Deprecated group/name - [DEFAULT]/logfile
-log_file=tempest.log
-
-[auth]
-# Roles to assign to all users created by tempest (list value)
-tempest_roles = _member_
-
-# Administrative Username to use for Keystone API requests.
-# (string value)
-admin_username=admin
-
-# Administrative Tenant name to use for Keystone API requests.
-# (string value)
-admin_project_name=admin
-
-admin_domain_name=Default
-
-[identity]
-
-# Full URI of the OpenStack Identity API (Keystone), v3
-# (string value)
-#uri_v3=<None> $$$ DERIVE from uri
-
-# Username to use for Nova API requests. (string value)
-username=demo
-
-# Tenant name to use for Nova API requests. (string value)
-project_name=demo
-
-# API key to use when authenticating. (string value)
-password=secrete
-
-# Username of alternate user to use for Nova API requests.
-# (string value)
-alt_username=alt_demo
-
-# Alternate user's Tenant name to use for Nova API requests.
-# (string value)
-alt_project_name=alt_demo
-
-# API key to use when authenticating as alternate user.
-# (string value)
-alt_password=secrete
-
-admin_domain_name=Default
-
-
-disable_ssl_certificate_validation=true
-
-[object-storage]
-# default-overrides.conf file will be removed soon, this value will be
-# moved to load_basic_defaults method in config_tempest/main.py
-reseller_admin_role = ResellerAdmin
-
-[data-processing]
-
-
-[orchestration]
-
-# Name of heat-cfntools enabled image to use when launching
-# test instances. (string value)
-#image_ref=<None> $$$ Not sure
-
-# Name of existing keypair to launch servers with. (string
-# value)
-#keypair_name=<None> $$$ Not sure
-
-[scenario]
-
-#
-# Options defined in tempest.config
-#
-
-# Directory containing image files (string value)
-img_dir=etc
-
-[oslo_concurrency]
-
-# Directory to use for lock files. (string value)
-lock_path=/tmp
-
-[volume-feature-enabled]
-# Added in kilo
-bootable=true
-
-# It needs to be true since mitaka
-# this option expected to be removed after liberty EOL
-volume_services=true
-
-[compute-feature-enabled]
-# Default deployment does not use shared storage
-live_migration=false
-# Added in kilo
-live_migrate_paused_instances=true
-preserve_ports=true
-
-[network-feature-enabled]
-# Added in juno
-ipv6_subnet_attributes=true
+# The content of the file was moved to the source
+# code of python-tempestconf.
+# The file will removed soon.
diff --git a/releasenotes/notes/Remove-default-overrides.conf-9ad55f5ef953ab06.yaml b/releasenotes/notes/Remove-default-overrides.conf-9ad55f5ef953ab06.yaml
new file mode 100644
index 00000000..f28d38e2
--- /dev/null
+++ b/releasenotes/notes/Remove-default-overrides.conf-9ad55f5ef953ab06.yaml
@@ -0,0 +1,5 @@
+---
+upgrade:
+  - |
+    etc/default-overrides.conf is removed and is no longer used or read.
+    Important default values were moved to load_basic_defaults method.