From 602b9e4c8a9dca18a6c7f37cfffc28cc07ab57a9 Mon Sep 17 00:00:00 2001
From: Morgan Fainberg <morgan.fainberg@gmail.com>
Date: Wed, 22 Oct 2014 16:01:32 -0700
Subject: [PATCH 1/2] Update novaclient shell to use shared arguments from
 Session

The novaclient implemented it's own version of the CLI arguments that
are now provided by keystoneclient's session object. This changeset
converts nova over to utilizing the shared argument registration.

Change-Id: Ifc9ddc08614e28358229db84cb9b54552ca36d51
Co-Authored-By: David Hu <david.hu@hp.com>
(cherry picked from commit c8a7e6a02db72241acb61d4f994b96ae351b61d5)
---
 novaclient/shell.py | 45 ++++++++++++++++++++-------------------------
 1 file changed, 20 insertions(+), 25 deletions(-)

diff --git a/novaclient/shell.py b/novaclient/shell.py
index 6623b7f..d8da433 100644
--- a/novaclient/shell.py
+++ b/novaclient/shell.py
@@ -29,6 +29,7 @@ import os
 import pkgutil
 import sys
 
+from keystoneclient import session as ksession
 from oslo.utils import encodeutils
 from oslo.utils import strutils
 import pkg_resources
@@ -232,6 +233,13 @@ class NovaClientArgumentParser(argparse.ArgumentParser):
 
 class OpenStackComputeShell(object):
 
+    def _append_global_identity_args(self, parser):
+        # Register the CLI arguments that have moved to the session object.
+        ksession.Session.register_cli_options(parser)
+
+        parser.set_defaults(insecure=utils.env('NOVACLIENT_INSECURE',
+                            default=False))
+
     def get_base_parser(self):
         parser = NovaClientArgumentParser(
             prog='nova',
@@ -269,12 +277,6 @@ class OpenStackComputeShell(object):
             action='store_true',
             help=_("Print call timing info"))
 
-        parser.add_argument('--timeout',
-            default=600,
-            metavar='<seconds>',
-            type=positive_non_zero_float,
-            help=_("Set HTTP call timeout (in seconds)"))
-
         parser.add_argument('--os-auth-token',
                 default=utils.env('OS_AUTH_TOKEN'),
                 help='Defaults to env[OS_AUTH_TOKEN]')
@@ -351,12 +353,18 @@ class OpenStackComputeShell(object):
         parser.add_argument('--volume_service_name',
             help=argparse.SUPPRESS)
 
-        parser.add_argument('--endpoint-type',
+        parser.add_argument('--os-endpoint-type',
             metavar='<endpoint-type>',
+            dest='endpoint_type',
             default=utils.env('NOVA_ENDPOINT_TYPE',
-                        default=DEFAULT_NOVA_ENDPOINT_TYPE),
-            help=_('Defaults to env[NOVA_ENDPOINT_TYPE] or ')
-                    + DEFAULT_NOVA_ENDPOINT_TYPE + '.')
+                default=utils.env('OS_ENDPOINT_TYPE',
+                    default=DEFAULT_NOVA_ENDPOINT_TYPE)),
+            help=_('Defaults to env[NOVA_ENDPOINT_TYPE], '
+                   'env[OS_ENDPOINT_TYPE] or ')
+                 + DEFAULT_NOVA_ENDPOINT_TYPE + '.')
+
+        parser.add_argument('--endpoint-type',
+            help=argparse.SUPPRESS)
         # NOTE(dtroyer): We can't add --endpoint_type here due to argparse
         #                thinking usage-list --end is ambiguous; but it
         #                works fine with only --endpoint-type present
@@ -373,21 +381,6 @@ class OpenStackComputeShell(object):
         parser.add_argument('--os_compute_api_version',
             help=argparse.SUPPRESS)
 
-        parser.add_argument('--os-cacert',
-            metavar='<ca-certificate>',
-            default=utils.env('OS_CACERT', default=None),
-            help='Specify a CA bundle file to use in '
-                 'verifying a TLS (https) server certificate. '
-                 'Defaults to env[OS_CACERT]')
-
-        parser.add_argument('--insecure',
-            default=utils.env('NOVACLIENT_INSECURE', default=False),
-            action='store_true',
-            help=_("Explicitly allow novaclient to perform \"insecure\" "
-                 "SSL (https) requests. The server's certificate will "
-                 "not be verified against any certificate authorities. "
-                 "This option should be used with caution."))
-
         parser.add_argument('--bypass-url',
             metavar='<bypass-url>',
             dest='bypass_url',
@@ -400,6 +393,8 @@ class OpenStackComputeShell(object):
         # The auth-system-plugins might require some extra options
         novaclient.auth_plugin.load_auth_system_opts(parser)
 
+        self._append_global_identity_args(parser)
+
         return parser
 
     def get_subcommand_parser(self, version):
-- 
2.3.7

