From 17abb7b915e58122ab741606483361569ba5fcf2 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Mon, 2 Dec 2013 12:23:27 -0500 Subject: [PATCH] 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 --- keystoneclient/shell.py | 4 ++++ keystoneclient/tests/test_shell.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/keystoneclient/shell.py b/keystoneclient/shell.py index c3a709f14..ea09eb34e 100644 --- a/keystoneclient/shell.py +++ b/keystoneclient/shell.py @@ -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): diff --git a/keystoneclient/tests/test_shell.py b/keystoneclient/tests/test_shell.py index 17a4a09ce..10e7ae942 100644 --- a/keystoneclient/tests/test_shell.py +++ b/keystoneclient/tests/test_shell.py @@ -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()