From 765f551a267f07e43eb3acb92835ac7e5d6ca31b Mon Sep 17 00:00:00 2001 From: Josh Kearney Date: Thu, 12 Apr 2012 14:16:31 -0500 Subject: [PATCH] Rename NOVA_VERSION to OS_COMPUTE_API_VERSION. Fixes bug 940432. Change-Id: I18187eb68d936632b4ae78676a0a9f062afba8f2 --- README.rst | 5 +++-- docs/shell.rst | 4 ++-- novaclient/shell.py | 30 ++++++++++++++++-------------- tests/v1_1/test_shell.py | 2 +- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/README.rst b/README.rst index 195480489..5cb639675 100644 --- a/README.rst +++ b/README.rst @@ -52,7 +52,7 @@ and the version of the API with ``--version``. Or set them as an environment variables as well:: export OS_AUTH_URL=http://example.com:8774/v1.1/ - export NOVA_VERSION=1.1 + export OS_COMPUTE_API_VERSION=1.1 If you are using Keystone, you need to set the NOVA_URL to the keystone endpoint:: @@ -213,7 +213,8 @@ You'll find complete documentation on the shell by running Defaults to env[NOVA_SERVICE_NAME] --endpoint_type ENDPOINT_TYPE Defaults to env[NOVA_ENDPOINT_TYPE] or publicURL. - --version VERSION Accepts 1.1, defaults to env[NOVA_VERSION]. + --os_compute_api_version VERSION + Accepts 1.1, defaults to env[OS_COMPUTE_API_VERSION]. --username USERNAME Deprecated --region_name REGION_NAME Deprecated diff --git a/docs/shell.rst b/docs/shell.rst index 54e9667b2..15ad783a7 100644 --- a/docs/shell.rst +++ b/docs/shell.rst @@ -31,7 +31,7 @@ environment variables by setting two environment variables: The OpenStack API server URL. -.. envvar:: NOVA_VERSION +.. envvar:: OS_COMPUTE_API_VERSION The OpenStack API version. @@ -41,7 +41,7 @@ For example, in Bash you'd use:: export OS_PASSWORD=yadayadayada export OS_TENANT_NAME=myproject export OS_AUTH_URL=http://... - export NOVA_VERSION=1.1 + export OS_COMPUTE_API_VERSION=1.1 From there, all shell commands take the form:: diff --git a/novaclient/shell.py b/novaclient/shell.py index 79f40e412..1c846603f 100644 --- a/novaclient/shell.py +++ b/novaclient/shell.py @@ -34,7 +34,7 @@ import novaclient.extension from novaclient import utils from novaclient.v1_1 import shell as shell_v1_1 -DEFAULT_NOVA_VERSION = "1.1" +DEFAULT_OS_COMPUTE_API_VERSION = "1.1" DEFAULT_NOVA_ENDPOINT_TYPE = 'publicURL' DEFAULT_NOVA_SERVICE_TYPE = 'compute' @@ -119,9 +119,10 @@ class OpenStackComputeShell(object): help='Defaults to env[NOVA_ENDPOINT_TYPE] or ' + DEFAULT_NOVA_ENDPOINT_TYPE + '.') - parser.add_argument('--version', - default=utils.env('NOVA_VERSION', default=DEFAULT_NOVA_VERSION), - help='Accepts 1.1, defaults to env[NOVA_VERSION].') + parser.add_argument('--os_compute_api_version', + default=utils.env('OS_COMPUTE_API_VERSION', + default=DEFAULT_OS_COMPUTE_API_VERSION), + help='Accepts 1.1, defaults to env[OS_COMPUTE_API_VERSION].') parser.add_argument('--insecure', default=utils.env('NOVACLIENT_INSECURE', default=False), @@ -267,10 +268,12 @@ class OpenStackComputeShell(object): self.setup_debugging(options.debug) # build available subcommands based on version - self.extensions = self._discover_extensions(options.version) + self.extensions = self._discover_extensions( + options.os_compute_api_version) self._run_extension_hooks('__pre_parse_args__') - subcommand_parser = self.get_subcommand_parser(options.version) + subcommand_parser = self.get_subcommand_parser( + options.os_compute_api_version) self.parser = subcommand_parser if options.help and len(args) == 0: @@ -343,7 +346,8 @@ class OpenStackComputeShell(object): if not os_region_name and region_name: os_region_name = region_name - if options.version and options.version != '1.0': + if (options.os_compute_api_version and + options.os_compute_api_version != '1.0'): if not os_tenant_name: raise exc.CommandError("You must provide a tenant name " "via either --os_tenant_name or env[OS_TENANT_NAME]") @@ -352,13 +356,11 @@ class OpenStackComputeShell(object): raise exc.CommandError("You must provide an auth url " "via either --os_auth_url or env[OS_AUTH_URL]") - self.cs = client.Client(options.version, os_username, os_password, - os_tenant_name, os_auth_url, insecure, - region_name=os_region_name, - endpoint_type=endpoint_type, - extensions=self.extensions, - service_type=service_type, - service_name=service_name) + self.cs = client.Client(options.os_compute_api_version, os_username, + os_password, os_tenant_name, os_auth_url, insecure, + region_name=os_region_name, endpoint_type=endpoint_type, + extensions=self.extensions, service_type=service_type, + service_name=service_name) try: if not utils.isunauthenticated(args.func): diff --git a/tests/v1_1/test_shell.py b/tests/v1_1/test_shell.py index 68c46dbdd..4b9f9e6f2 100644 --- a/tests/v1_1/test_shell.py +++ b/tests/v1_1/test_shell.py @@ -37,7 +37,7 @@ class ShellTest(utils.TestCase): 'NOVA_USERNAME': 'username', 'NOVA_PASSWORD': 'password', 'NOVA_PROJECT_ID': 'project_id', - 'NOVA_VERSION': '1.1', + 'OS_COMPUTE_API_VERSION': '1.1', 'NOVA_URL': 'http://no.where', }