From 7b30ad54c69c7287a4bb275eb95d9731e75b304d Mon Sep 17 00:00:00 2001 From: Itxaka Date: Thu, 19 Nov 2015 14:37:57 +0100 Subject: [PATCH] Allow configuration of nova micro-version in the settings Allows to config the api version to use on the local_settings through OPENSTACK_API_VERSIONS. Updates docs and local_settings.py.example. Defaults to version 2. Closes-Bug: 1497056 Change-Id: If9ec4dcdd79baeec105dbe3ec5345b7d6cf1dc10 Signed-off-by: Itxaka --- doc/source/topics/settings.rst | 6 ++++-- openstack_dashboard/api/nova.py | 7 ++++++- openstack_dashboard/local/local_settings.py.example | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/source/topics/settings.rst b/doc/source/topics/settings.rst index 151569f4e..5d4c83171 100644 --- a/doc/source/topics/settings.rst +++ b/doc/source/topics/settings.rst @@ -516,7 +516,8 @@ Default:: { "data-processing": 1.1, "identity": 2.0, - "volume": 2 + "volume": 2, + "compute": 2 } Overrides for OpenStack API versions. Use this setting to force the @@ -532,7 +533,8 @@ OpenStack dashboard to use a specific API version for a given service API. OPENSTACK_API_VERSIONS = { "data-processing": 1.1, "identity": 3, - "volume": 2 + "volume": 2, + "compute": 2 } ``OPENSTACK_ENABLE_PASSWORD_RETRIEVE`` diff --git a/openstack_dashboard/api/nova.py b/openstack_dashboard/api/nova.py index 3790284bd..056fd7e19 100644 --- a/openstack_dashboard/api/nova.py +++ b/openstack_dashboard/api/nova.py @@ -45,6 +45,10 @@ from openstack_dashboard.api import network_base LOG = logging.getLogger(__name__) +# Supported compute versions +VERSIONS = base.APIVersionManager("compute", preferred_version=2) +VERSIONS.load_supported_version(1.1, {"client": nova_client, "version": 1.1}) +VERSIONS.load_supported_version(2, {"client": nova_client, "version": 2}) # API static values INSTANCE_ACTIVE_STATE = 'ACTIVE' @@ -445,7 +449,8 @@ class FloatingIpManager(network_base.FloatingIpManager): def novaclient(request): insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False) cacert = getattr(settings, 'OPENSTACK_SSL_CACERT', None) - c = nova_client.Client(2, request.user.username, + c = nova_client.Client(VERSIONS.get_active_version()['version'], + request.user.username, request.user.token.id, project_id=request.user.tenant_id, auth_url=base.url_for(request, 'compute'), diff --git a/openstack_dashboard/local/local_settings.py.example b/openstack_dashboard/local/local_settings.py.example index ac0370575..149848aee 100644 --- a/openstack_dashboard/local/local_settings.py.example +++ b/openstack_dashboard/local/local_settings.py.example @@ -50,6 +50,7 @@ WEBROOT = '/' # "data-processing": 1.1, # "identity": 3, # "volume": 2, +# "compute": 2 #} # Set this to True if running on multi-domain model. When this is enabled, it