Skip to content

Commit a0fe37e

Browse files
committed
Add warning message if unknown version supplied
Print a warning message if an unknown api version is supplied. An attempt will be made to run the command anyway. Change-Id: Idec8e88fe9621f10ec4b7eecd90708fb3730f56f
1 parent d5f2c50 commit a0fe37e

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

openstackclient/compute/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
DEFAULT_COMPUTE_API_VERSION = '2'
3131
API_VERSION_OPTION = 'os_compute_api_version'
3232
API_NAME = 'compute'
33+
API_VERSIONS = {
34+
"2": "novaclient.client",
35+
}
3336

3437

3538
def make_client(instance):

openstackclient/shell.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ def initialize_app(self, argv):
247247
if version_opt:
248248
api = mod.API_NAME
249249
self.api_version[api] = version_opt
250+
if version_opt not in mod.API_VERSIONS:
251+
self.log.warning(
252+
"The %s version <%s> is not in supported versions <%s>"
253+
% (api, version_opt,
254+
', '.join(mod.API_VERSIONS.keys())))
250255
# Command groups deal only with major versions
251256
version = '.v' + version_opt.replace('.', '_').split('_')[0]
252257
cmd_group = 'openstack.' + api.replace('-', '_') + version

0 commit comments

Comments
 (0)