LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File novaclient-fallback-apidisccovery.diff of Package python-novaclient (Project home:garloff:OTC:cli-mitaka)

Index: python-novaclient-6.0.2/novaclient/shell.py
===================================================================
--- python-novaclient-6.0.2.orig/novaclient/shell.py
+++ python-novaclient-6.0.2/novaclient/shell.py
@@ -398,6 +398,7 @@ class OpenStackComputeShell(object):
         parser.set_defaults(insecure=strutils.bool_from_string(
             utils.env('NOVACLIENT_INSECURE', default=False)))
         parser.set_defaults(os_auth_url=utils.env('OS_AUTH_URL', 'NOVA_URL'))
+                  #raise
 
         parser.set_defaults(os_username=utils.env('OS_USERNAME',
                                                   'NOVA_USERNAME'))
@@ -813,7 +814,19 @@ class OpenStackComputeShell(object):
                                 "min": novaclient.API_MIN_VERSION.get_string(),
                                 "max": novaclient.API_MAX_VERSION.get_string()}
                         )
-            api_version = api_versions.discover_version(self.cs, api_version)
+            try:
+               api_version = api_versions.discover_version(self.cs, api_version)
+            except:
+               if api_version == api_versions.get_api_version(DEFAULT_OS_COMPUTE_API_VERSION):
+                  #api_version = novaclient.API_MAX_VERSION
+                  api_version = api_versions.APIVersion("2.26")
+                  print(_('WARNING: Could not discover API version, using %s') % api_version.get_string(), file=sys.stderr)
+               else:
+                  if not utils.env("OS_COMPUTE_ALLOW_OVERRIDE"):
+                      raise
+                  api_version = api_versions.get_api_version(args.os_compute_api_version)
+                  print(_('WARNING: Server does not support our desired microversion %s, try anyway') % api_version.get_string(), file=sys.stderr)
+
 
         # build available subcommands based on version
         self.extensions = client.discover_extensions(api_version)