Define identity api version in api_versions dict

Change-Id: Id6edb3660d4a50ef68e9091bdf3c2f78fc5d5f4f
diff --git a/README.rst b/README.rst
index ebe58a7..ab5e74a 100644
--- a/README.rst
+++ b/README.rst
@@ -26,11 +26,12 @@
           host: '127.0.0.1'
           port: 11211
           prefix: 'CACHE_HORIZON'
+        api_versions:
+          identity: 2
         identity:
           engine: 'keystone'
           host: '127.0.0.1'
           port: 5000
-          api_version: 2
         mail:
           host: '127.0.0.1'
 
@@ -64,11 +65,12 @@
           host: '127.0.0.1'
           port: 11211
           prefix: 'CACHE_HORIZON'
+        api_versions:
+          identity: 2
         identity:
           engine: 'keystone'
           host: '127.0.0.1'
           port: 5000
-          api_version: 2
         mail:
           host: '127.0.0.1'
 
@@ -86,11 +88,12 @@
           host: '127.0.0.1'
           port: 11211
           prefix: 'CACHE_HORIZON'
+        api_versions:
+          identity: 2
         identity:
           engine: 'keystone'
           host: '127.0.0.1'
           port: 5000
-          api_version: 2
         mail:
           host: '127.0.0.1'
         regions:
@@ -224,11 +227,12 @@
               host: '127.0.0.1'
               port: 11211
               prefix: 'CACHE_DEFAULT'
+            api_versions:
+              identity: 2
             identity:
               engine: 'keystone'
               host: '127.0.0.1'
               port: 5000
-              api_version: 2
             mail:
               host: '127.0.0.1'
 
@@ -264,11 +268,12 @@
               host: '127.0.0.1'
               port: 11211
               prefix: 'CACHE_SITE1'
+            api_versions:
+              identity: 2
             identity:
               engine: 'keystone'
               host: '127.0.0.1'
               port: 5000
-              api_version: 2
             mail:
               host: '127.0.0.1'
           openstack2:
@@ -302,11 +307,12 @@
               host: '127.0.0.1'
               port: 11211
               prefix: 'CACHE_SITE2'
+            api_versions:
+              identity: 3
             identity:
               engine: 'keystone'
               host: '127.0.0.1'
               port: 5000
-              api_version: 3
             mail:
               host: '127.0.0.1'
 
diff --git a/horizon/files/horizon_settings/_keystone_settings.py b/horizon/files/horizon_settings/_keystone_settings.py
index 8939e33..72882ff 100644
--- a/horizon/files/horizon_settings/_keystone_settings.py
+++ b/horizon/files/horizon_settings/_keystone_settings.py
@@ -13,7 +13,7 @@
 # use of the decimal point, so valid options would be "2.0" or "3".
 {%- if app.api_versions is defined %}
 OPENSTACK_API_VERSIONS = {
-{%- for key, value in app.api_versions.iteritems() %}
+{%- for key, value in app.api_versions.iteritems() if (key, value) != ('identity', 2) %}
     "{{ key }}": {{ value }}{% if not loop.last %},{% endif %}
 {%- endfor %}
 }
@@ -33,7 +33,7 @@
 # ]
 
 OPENSTACK_HOST = "{{ app.identity.host }}"
-{%- if app.get('api_versions', {}).identity is defined %}
+{%- if app.get('api_versions', {}).identity is defined and app.get('api_versions', {}).identity != 2 %}
 OPENSTACK_KEYSTONE_URL = "http{% if app.identity.encryption == 'ssl' %}s{% endif %}://%s:{{ app.identity.port }}/v{{ app.api_versions.identity }}" % OPENSTACK_HOST
 {%- else %}
 OPENSTACK_KEYSTONE_URL = "http{% if app.identity.encryption == 'ssl' %}s{% endif %}://%s:{{ app.identity.port }}/v2.0" % OPENSTACK_HOST
diff --git a/metadata/service/server/cluster.yml b/metadata/service/server/cluster.yml
index d0e4076..2fcab19 100644
--- a/metadata/service/server/cluster.yml
+++ b/metadata/service/server/cluster.yml
@@ -5,7 +5,7 @@
 parameters:
   _param:
     horizon_version: kilo
-    horizon_api_version: 3
+    horizon_identity_version: 3
     horizon_identity_endpoint_type: internalURL
   horizon:
     server:
@@ -22,18 +22,19 @@
       cache:
         engine: memcached
         prefix: 'CACHE_HORIZON'
-        members: 
+        members:
         - host: ${_param:cluster_node01_address}
           port: 11211
         - host: ${_param:cluster_node02_address}
           port: 11211
         - host: ${_param:cluster_node03_address}
           port: 11211
+      api_versions:
+        identity: ${_param:horizon_identity_version}
       identity:
         engine: keystone
         host: ${_param:cluster_vip_address}
         port: 5000
-        api_version: 2
         endpoint_type: ${_param:horizon_identity_endpoint_type}
   haproxy:
     proxy:
diff --git a/metadata/service/server/single.yml b/metadata/service/server/single.yml
index fe119a4..16e78c0 100644
--- a/metadata/service/server/single.yml
+++ b/metadata/service/server/single.yml
@@ -29,10 +29,11 @@
         members:
         - host: ${_param:single_address}
           port: 11211
+      api_versions:
+        identity: ${_param:horizon_identity_version}
       identity:
         engine: keystone
         port: 5000
         host: ${_param:horizon_identity_host}
         encryption: ${_param:horizon_identity_encryption}
-        api_version: ${_param:horizon_identity_version}
         endpoint_type: ${_param:horizon_identity_endpoint_type}