Merge "Add keystone API versioning support"
diff --git a/README.rst b/README.rst
index a54683b..1914361 100644
--- a/README.rst
+++ b/README.rst
@@ -682,6 +682,16 @@
barbican:
enabled: true
+
+Specify Keystone API version (v3 is default):
+
+.. code-block:: yaml
+
+ cinder:
+ controller:
+ identity:
+ api_version: v2.0
+
Enhanced logging with logging.conf
----------------------------------
diff --git a/_modules/cinderng.py b/_modules/cinderng.py
index 71d7c5c..08aaad9 100644
--- a/_modules/cinderng.py
+++ b/_modules/cinderng.py
@@ -32,10 +32,11 @@
'username': profile['user'],
'password': profile['password'],
'project_id': profile['project_id'],
- 'auth_url': "{}://{}:{}/v2.0".format(
+ 'auth_url': "{}://{}:{}/{}".format(
profile['protocol'],
profile['host'],
- profile['port']
+ profile['port'],
+ profile.get('api_version', 'v3')
),
'endpoint_type': profile['endpoint_type'],
'certificate': profile['certificate'],
diff --git a/cinder/client.sls b/cinder/client.sls
index 865df36..c104985 100644
--- a/cinder/client.sls
+++ b/cinder/client.sls
@@ -11,6 +11,18 @@
{%- set identity = salt['pillar.get']('keystone:client:server:'+client.identity) %}
{%- endif %}
+{#- Keystone V3 is supported only from Ocata release (https://docs.openstack.org/releasenotes/python-cinderclient/ocata.html) #}
+{#- Therefore if api_version is not defined and OpenStack version is mitaka or newton use v2.0. #}
+{%- if 'api_version' in identity %}
+{%- set keystone_api_version = identity.get('api_version') %}
+{%- else %}
+{%- if 'version' in client and client.version in ['mitaka', 'newton'] %}
+{%- set keystone_api_version = 'v2.0' %}
+{%- else %}
+{%- set keystone_api_version = 'v3' %}
+{%- endif %}
+{%- endif %}
+
{%- set credentials = {'host': identity.host,
'user': identity.user,
'password': identity.password,
@@ -19,7 +31,8 @@
'protocol': identity.get('protocol', 'http'),
'region_name': identity.get('region_name', 'RegionOne'),
'endpoint_type': identity.get('endpoint_type', 'internalURL'),
- 'certificate': identity.get('certificate', client.cacert_file)} %}
+ 'certificate': identity.get('certificate', client.cacert_file),
+ 'api_version': keystone_api_version} %}
{%- for backend_name, backend in client.get('backend', {}).items() %}
diff --git a/cinder/controller.sls b/cinder/controller.sls
index 950b6ca..fc660de 100644
--- a/cinder/controller.sls
+++ b/cinder/controller.sls
@@ -279,6 +279,19 @@
{%- if not grains.get('noservices', False) %}
{%- set identity = controller.identity %}
+
+{#- Keystone V3 is supported only from Ocata release (https://docs.openstack.org/releasenotes/python-cinderclient/ocata.html) #}
+{#- Therefore if api_version is not defined and OpenStack version is mitaka or newton use v2.0. #}
+{%- if 'api_version' in identity %}
+{%- set keystone_api_version = identity.get('api_version') %}
+{%- else %}
+{%- if 'version' in controller and controller.version in ['mitaka', 'newton'] %}
+{%- set keystone_api_version = 'v2.0' %}
+{%- else %}
+{%- set keystone_api_version = 'v3' %}
+{%- endif %}
+{%- endif %}
+
{%- set credentials = {'host': identity.host,
'user': identity.user,
'password': identity.password,
@@ -287,7 +300,8 @@
'protocol': identity.get('protocol', 'http'),
'region_name': identity.get('region_name', 'RegionOne'),
'endpoint_type': identity.get('endpoint_type', 'internalURL'),
- 'certificate': identity.get('certificate', controller.cacert_file)} %}
+ 'certificate': identity.get('certificate', controller.cacert_file),
+ 'api_version': keystone_api_version} %}
{%- for backend_name, backend in controller.get('backend', {}).items() %}