Convert cli tests to use global CONF object

This commit takes all the uses of config in the cli tests and coverts
them to use the global CONF object.

Partially implements bp config-cleanup

Change-Id: I7a39839d7a4ebbf8372489507486ad2cac7f3adc
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 21c8506..f7f74b8 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -155,7 +155,7 @@
 [cli]
 
 #
-# Options defined in tempest.cli
+# Options defined in tempest.config
 #
 
 # enable cli tests (boolean value)
diff --git a/tempest/cli/__init__.py b/tempest/cli/__init__.py
index dfa2124..a5e0447 100644
--- a/tempest/cli/__init__.py
+++ b/tempest/cli/__init__.py
@@ -17,31 +17,15 @@
 import shlex
 import subprocess
 
-from oslo.config import cfg
-
 import tempest.cli.output_parser
+from tempest import config
 from tempest.openstack.common import log as logging
 import tempest.test
 
 
 LOG = logging.getLogger(__name__)
 
-cli_opts = [
-    cfg.BoolOpt('enabled',
-                default=True,
-                help="enable cli tests"),
-    cfg.StrOpt('cli_dir',
-               default='/usr/local/bin',
-               help="directory where python client binaries are located"),
-    cfg.IntOpt('timeout',
-               default=15,
-               help="Number of seconds to wait on a CLI timeout"),
-]
-
-CONF = cfg.CONF
-cli_group = cfg.OptGroup(name='cli', title="cli Configuration Options")
-CONF.register_group(cli_group)
-CONF.register_opts(cli_opts, group=cli_group)
+CONF = config.CONF
 
 
 class ClientTestBase(tempest.test.BaseTestCase):
@@ -50,7 +34,6 @@
         if not CONF.cli.enabled:
             msg = "cli testing disabled"
             raise cls.skipException(msg)
-        cls.identity = cls.config.identity
         super(ClientTestBase, cls).setUpClass()
 
     def __init__(self, *args, **kwargs):
@@ -106,10 +89,10 @@
         # TODO(jogo) make admin=False work
         creds = ('--os-username %s --os-tenant-name %s --os-password %s '
                  '--os-auth-url %s ' %
-                 (self.identity.admin_username,
-                  self.identity.admin_tenant_name,
-                  self.identity.admin_password,
-                  self.identity.uri))
+                 (CONF.identity.admin_username,
+                  CONF.identity.admin_tenant_name,
+                  CONF.identity.admin_password,
+                  CONF.identity.uri))
         flags = creds + ' ' + flags
         return self.cmd(cmd, action, flags, params, fail_ok)
 
diff --git a/tempest/cli/simple_read_only/test_cinder.py b/tempest/cli/simple_read_only/test_cinder.py
index 5dcb708..afbd732 100644
--- a/tempest/cli/simple_read_only/test_cinder.py
+++ b/tempest/cli/simple_read_only/test_cinder.py
@@ -20,7 +20,6 @@
 import tempest.cli
 from tempest import config
 
-
 CONF = config.CONF
 LOG = logging.getLogger(__name__)
 
@@ -73,14 +72,14 @@
     def test_cinder_quota_defaults(self):
         """This CLI can accept and string as param."""
         roles = self.parser.listing(self.cinder('quota-defaults',
-                                                params=self.identity.
+                                                params=CONF.identity.
                                                 admin_tenant_name))
         self.assertTableStruct(roles, ['Property', 'Value'])
 
     def test_cinder_quota_show(self):
         """This CLI can accept and string as param."""
         roles = self.parser.listing(self.cinder('quota-show',
-                                                params=self.identity.
+                                                params=CONF.identity.
                                                 admin_tenant_name))
         self.assertTableStruct(roles, ['Property', 'Value'])
 
@@ -146,7 +145,7 @@
         self.cinder('list', flags='--retries 3')
 
     def test_cinder_region_list(self):
-        region = self.config.volume.region
+        region = CONF.volume.region
         if not region:
-            region = self.config.identity.region
+            region = CONF.identity.region
         self.cinder('list', flags='--os-region-name ' + region)
diff --git a/tempest/cli/simple_read_only/test_glance.py b/tempest/cli/simple_read_only/test_glance.py
index b558190..9869483 100644
--- a/tempest/cli/simple_read_only/test_glance.py
+++ b/tempest/cli/simple_read_only/test_glance.py
@@ -16,13 +16,11 @@
 import re
 import subprocess
 
-from oslo.config import cfg
-
 import tempest.cli
+from tempest import config
 from tempest.openstack.common import log as logging
 
-CONF = cfg.CONF
-
+CONF = config.CONF
 
 LOG = logging.getLogger(__name__)
 
@@ -55,7 +53,7 @@
             'Size', 'Status'])
 
     def test_glance_member_list(self):
-        tenant_name = '--tenant-id %s' % self.identity.admin_tenant_name
+        tenant_name = '--tenant-id %s' % CONF.identity.admin_tenant_name
         out = self.glance('member-list',
                           params=tenant_name)
         endpoints = self.parser.listing(out)
diff --git a/tempest/cli/simple_read_only/test_heat.py b/tempest/cli/simple_read_only/test_heat.py
index b45182b..cf4580c 100644
--- a/tempest/cli/simple_read_only/test_heat.py
+++ b/tempest/cli/simple_read_only/test_heat.py
@@ -14,12 +14,11 @@
 import os
 import yaml
 
-from oslo.config import cfg
-
 import tempest.cli
+from tempest import config
 from tempest.openstack.common import log as logging
 
-CONF = cfg.CONF
+CONF = config.CONF
 
 LOG = logging.getLogger(__name__)
 
diff --git a/tempest/cli/simple_read_only/test_keystone.py b/tempest/cli/simple_read_only/test_keystone.py
index 271a18c..1efbede 100644
--- a/tempest/cli/simple_read_only/test_keystone.py
+++ b/tempest/cli/simple_read_only/test_keystone.py
@@ -16,12 +16,11 @@
 import re
 import subprocess
 
-from oslo.config import cfg
-
 import tempest.cli
+from tempest import config
 from tempest.openstack.common import log as logging
 
-CONF = cfg.CONF
+CONF = config.CONF
 
 
 LOG = logging.getLogger(__name__)
diff --git a/tempest/cli/simple_read_only/test_nova.py b/tempest/cli/simple_read_only/test_nova.py
index f8ba971..b0264d0 100644
--- a/tempest/cli/simple_read_only/test_nova.py
+++ b/tempest/cli/simple_read_only/test_nova.py
@@ -15,15 +15,14 @@
 
 import subprocess
 
-from oslo.config import cfg
 import testtools
 
 import tempest.cli
+from tempest import config
 from tempest.openstack.common import log as logging
 import tempest.test
 
-CONF = cfg.CONF
-
+CONF = config.CONF
 
 LOG = logging.getLogger(__name__)
 
diff --git a/tempest/config.py b/tempest/config.py
index 5a9199d..704556f 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -689,6 +689,20 @@
                help="Catalog type of the baremetal provisioning service."),
 ]
 
+cli_group = cfg.OptGroup(name='cli', title="cli Configuration Options")
+
+CLIGroup = [
+    cfg.BoolOpt('enabled',
+                default=True,
+                help="enable cli tests"),
+    cfg.StrOpt('cli_dir',
+               default='/usr/local/bin',
+               help="directory where python client binaries are located"),
+    cfg.IntOpt('timeout',
+               default=15,
+               help="Number of seconds to wait on a CLI timeout"),
+]
+
 
 # this should never be called outside of this class
 class TempestConfigPrivate(object):
@@ -759,6 +773,7 @@
         register_opt_group(cfg.CONF, debug_group, DebugGroup)
         register_opt_group(cfg.CONF, baremetal_group, BaremetalGroup)
         register_opt_group(cfg.CONF, input_scenario_group, InputScenarioGroup)
+        register_opt_group(cfg.CONF, cli_group, CLIGroup)
         self.compute = cfg.CONF.compute
         self.compute_feature_enabled = cfg.CONF['compute-feature-enabled']
         self.identity = cfg.CONF.identity
@@ -784,6 +799,7 @@
         self.debug = cfg.CONF.debug
         self.baremetal = cfg.CONF.baremetal
         self.input_scenario = cfg.CONF['input-scenario']
+        self.cli = cfg.CONF.cli
         if not self.compute_admin.username:
             self.compute_admin.username = self.identity.admin_username
             self.compute_admin.password = self.identity.admin_password