Migrate verify-tempest-config to new cliff cli framework

Leave existing endpoint for now as to not disrupt existing
workflows and deprecate next cycle.

Added deprecation message for old entry point.

Change-Id: If8afab441f51e5cf0f3bf1e2b95d76b2c1d0c474
Implements: blueprint tempest-cli-improvements
diff --git a/setup.cfg b/setup.cfg
index b94a4f4..183c1fb 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -37,6 +37,7 @@
     cleanup = tempest.cmd.cleanup:TempestCleanup
     run-stress = tempest.cmd.run_stress:TempestRunStress
     list-plugins = tempest.cmd.list_plugins:TempestListPlugins
+    verify-config = tempest.cmd.verify_tempest_config:TempestVerifyConfig
 oslo.config.opts =
     tempest.config = tempest.config:list_opts
 
diff --git a/tempest/cmd/verify_tempest_config.py b/tempest/cmd/verify_tempest_config.py
old mode 100755
new mode 100644
index 9c8e2a0..5d867df
--- a/tempest/cmd/verify_tempest_config.py
+++ b/tempest/cmd/verify_tempest_config.py
@@ -15,10 +15,13 @@
 #    under the License.
 
 import argparse
+import httplib2
 import os
 import sys
+import traceback
 
-import httplib2
+from cliff import command
+from oslo_log import log as logging
 from oslo_serialization import jsonutils as json
 from six import moves
 from six.moves.urllib import parse as urlparse
@@ -31,6 +34,8 @@
 CONF = config.CONF
 CONF_PARSER = None
 
+LOG = logging.getLogger(__name__)
+
 
 def _get_config_file():
     default_config_dir = os.path.join(os.path.abspath(
@@ -310,8 +315,7 @@
     return avail_services
 
 
-def parse_args():
-    parser = argparse.ArgumentParser()
+def _parser_add_args(parser):
     parser.add_argument('-u', '--update', action='store_true',
                         help='Update the config file with results from api '
                              'queries. This assumes whatever is set in the '
@@ -329,13 +333,21 @@
     parser.add_argument('-r', '--replace-ext', action='store_true',
                         help="If specified the all option will be replaced "
                              "with a full list of extensions")
-    args = parser.parse_args()
-    return args
 
 
-def main():
+def parse_args():
+    parser = argparse.ArgumentParser()
+    _parser_add_args(parser)
+    opts = parser.parse_args()
+    return opts
+
+
+def main(opts=None):
     print('Running config verification...')
-    opts = parse_args()
+    if opts is None:
+        print("Use of: 'verify-tempest-config' is deprecated, "
+              "please use: 'tempest verify-config'")
+        opts = parse_args()
     update = opts.update
     replace = opts.replace_ext
     global CONF_PARSER
@@ -373,5 +385,22 @@
         icreds.clear_creds()
 
 
+class TempestVerifyConfig(command.Command):
+    """Verify your current tempest configuration"""
+
+    def get_parser(self, prog_name):
+        parser = super(TempestVerifyConfig, self).get_parser(prog_name)
+        _parser_add_args(parser)
+        return parser
+
+    def take_action(self, parsed_args):
+        try:
+            return main(parsed_args)
+        except Exception:
+            LOG.exception("Failure verifying configuration.")
+            traceback.print_exc()
+            raise
+        return 0
+
 if __name__ == "__main__":
     main()