Warn user about unsupported API version

Prints a warning when the user tries to use an unsupported API.
Also provides a test case to check it still does fall back to 2.0.

Change-Id: Idabd150f52d27a9d065cf570f6367459126f98be
Closes-bug: #1256987
This commit is contained in:
Tristan Cacqueray
2013-12-02 12:23:27 -05:00
parent 7abf8d2066
commit 17abb7b915
2 changed files with 9 additions and 0 deletions

View File

@@ -431,6 +431,10 @@ class OpenStackIdentityShell(object):
"2.0": shell_v2_0.CLIENT_CLASS,
}[version]
except KeyError:
if version:
msg = ('WARNING: unsupported identity-api-version %s, '
'falling back to 2.0' % version)
print(msg)
return shell_v2_0.CLIENT_CLASS
def do_bash_completion(self, args):

View File

@@ -200,6 +200,11 @@ class ShellTest(utils.TestCase):
'wilma', 'betty', '2.0', True, '500', True)
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
# Test os-identity-api-version fall back to 2.0
shell('--os-identity-api-version 3.0 user-list')
assert do_tenant_mock.called
self.assertTrue(b.os_identity_api_version, '2.0')
def test_shell_user_create_args(self):
"""Test user-create args."""
do_uc_mock = mock.MagicMock()