Merge pull request #7 from salt-formulas/pr_fix_liberty_auth_uri

fix liberty_auth_uri
diff --git a/.gitignore b/.gitignore
index 1bfce6e..aa8e42a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
+.kitchen
 tests/build/
 *.swp
 *.pyc
-.ropeproject
\ No newline at end of file
+.ropeproject
diff --git a/Makefile b/Makefile
index fc83783..1043fbe 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,38 @@
 DESTDIR=/
 SALTENVDIR=/usr/share/salt-formulas/env
 RECLASSDIR=/usr/share/salt-formulas/reclass
-FORMULANAME=$(shell grep name: metadata.yml|head -1|cut -d : -f 2|grep -Eo '[a-z0-9\-]*')
+FORMULANAME=$(shell grep name: metadata.yml|head -1|cut -d : -f 2|grep -Eo '[a-z0-9\-\_]*')
+VERSION=$(shell grep version: metadata.yml|head -1|cut -d : -f 2|grep -Eo '[a-z0-9\.\-\_]*')
+VERSION_MAJOR := $(shell echo $(VERSION)|cut -d . -f 1-2)
+VERSION_MINOR := $(shell echo $(VERSION)|cut -d . -f 3)
+
+NEW_MAJOR_VERSION ?= $(shell date +%Y.%m|sed 's,\.0,\.,g')
+NEW_MINOR_VERSION ?= $(shell /bin/bash -c 'echo $$[ $(VERSION_MINOR) + 1 ]')
+
+MAKE_PID := $(shell echo $$PPID)
+JOB_FLAG := $(filter -j%, $(subst -j ,-j,$(shell ps T | grep "^\s*$(MAKE_PID).*$(MAKE)")))
+
+ifneq ($(subst -j,,$(JOB_FLAG)),)
+JOBS := $(subst -j,,$(JOB_FLAG))
+else
+JOBS := 1
+endif
+
+KITCHEN_LOCAL_YAML?=.kitchen.yml
+KITCHEN_OPTS?="--concurrency=$(JOBS)"
+KITCHEN_OPTS_CREATE?=""
+KITCHEN_OPTS_CONVERGE?=""
+KITCHEN_OPTS_VERIFY?=""
+KITCHEN_OPTS_TEST?=""
 
 all:
 	@echo "make install - Install into DESTDIR"
 	@echo "make test    - Run tests"
+	@echo "make kitchen - Run Kitchen CI tests (create, converge, verify)"
 	@echo "make clean   - Cleanup after tests run"
+	@echo "make release-major  - Generate new major release"
+	@echo "make release-minor  - Generate new minor release"
+	@echo "make changelog      - Show changes since last release"
 
 install:
 	# Formula
@@ -14,6 +40,7 @@
 	cp -a $(FORMULANAME) $(DESTDIR)/$(SALTENVDIR)/
 	[ ! -d _modules ] || cp -a _modules $(DESTDIR)/$(SALTENVDIR)/
 	[ ! -d _states ] || cp -a _states $(DESTDIR)/$(SALTENVDIR)/ || true
+	[ ! -d _grains ] || cp -a _grains $(DESTDIR)/$(SALTENVDIR)/ || true
 	# Metadata
 	[ -d $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) ] || mkdir -p $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)
 	cp -a metadata/service/* $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)
@@ -21,6 +48,71 @@
 test:
 	[ ! -d tests ] || (cd tests; ./run_tests.sh)
 
+release-major: check-changes
+	@echo "Current version is $(VERSION), new version is $(NEW_MAJOR_VERSION)"
+	@[ $(VERSION_MAJOR) != $(NEW_MAJOR_VERSION) ] || (echo "Major version $(NEW_MAJOR_VERSION) already released, nothing to do. Do you want release-minor?" && exit 1)
+	echo "$(NEW_MAJOR_VERSION)" > VERSION
+	sed -i 's,version: .*,version: "$(NEW_MAJOR_VERSION)",g' metadata.yml
+	[ ! -f debian/changelog ] || dch -v $(NEW_MAJOR_VERSION) -m --force-distribution -D `dpkg-parsechangelog -S Distribution` "New version"
+	make genchangelog-$(NEW_MAJOR_VERSION)
+	(git add -u; git commit -m "Version $(NEW_MAJOR_VERSION)")
+	git tag -s -m $(NEW_MAJOR_VERSION) $(NEW_MAJOR_VERSION)
+
+release-minor: check-changes
+	@echo "Current version is $(VERSION), new version is $(VERSION_MAJOR).$(NEW_MINOR_VERSION)"
+	echo "$(VERSION_MAJOR).$(NEW_MINOR_VERSION)" > VERSION
+	sed -i 's,version: .*,version: "$(VERSION_MAJOR).$(NEW_MINOR_VERSION)",g' metadata.yml
+	[ ! -f debian/changelog ] || dch -v $(VERSION_MAJOR).$(NEW_MINOR_VERSION) -m --force-distribution -D `dpkg-parsechangelog -S Distribution` "New version"
+	make genchangelog-$(VERSION_MAJOR).$(NEW_MINOR_VERSION)
+	(git add -u; git commit -m "Version $(VERSION_MAJOR).$(NEW_MINOR_VERSION)")
+	git tag -s -m $(NEW_MAJOR_VERSION) $(VERSION_MAJOR).$(NEW_MINOR_VERSION)
+
+check-changes:
+	@git log --pretty=oneline --decorate $(VERSION)..HEAD | grep -Eqc '.*' || (echo "No new changes since version $(VERSION)"; exit 1)
+
+changelog:
+	git log --pretty=short --invert-grep --grep="Merge pull request" --decorate $(VERSION)..HEAD
+
+genchangelog: genchangelog-$(VERSION_MAJOR).$(NEW_MINOR_VERSION)
+
+genchangelog-%:
+	$(eval NEW_VERSION := $(patsubst genchangelog-%,%,$@))
+	(echo "=========\nChangelog\n=========\n"; \
+	(echo $(NEW_VERSION);git tag) | sort -r | grep -E '^[0-9\.]+' | while read i; do \
+	    cur=$$i; \
+	    test $$i = $(NEW_VERSION) && i=HEAD; \
+	    prev=`(echo $(NEW_VERSION);git tag)|sort|grep -E '^[0-9\.]+'|grep -B1 "$$cur\$$"|head -1`; \
+	    echo "Version $$cur\n=============================\n"; \
+	    git log --pretty=short --invert-grep --grep="Merge pull request" --decorate $$prev..$$i; \
+	    echo; \
+	done) > CHANGELOG.rst
+
+kitchen-check:
+	@[ -e $(KITCHEN_LOCAL_YAML) ] || (echo "Kitchen tests not available, there's no $(KITCHEN_LOCAL_YAML)." && exit 1)
+
+kitchen: kitchen-check kitchen-create kitchen-converge kitchen-verify kitchen-list
+
+kitchen-create: kitchen-check
+	kitchen create ${KITCHEN_OPTS} ${KITCHEN_OPTS_CREATE}
+	[ "$(shell echo $(KITCHEN_LOCAL_YAML)|grep -Eo docker)" = "docker" ] || sleep 120
+
+kitchen-converge: kitchen-check
+	kitchen converge ${KITCHEN_OPTS} ${KITCHEN_OPTS_CONVERGE} &&\
+	kitchen converge ${KITCHEN_OPTS} ${KITCHEN_OPTS_CONVERGE}
+
+kitchen-verify: kitchen-check
+	[ ! -d tests/integration ] || kitchen verify -t tests/integration ${KITCHEN_OPTS} ${KITCHEN_OPTS_VERIFY}
+	[ -d tests/integration ]   || kitchen verify ${KITCHEN_OPTS} ${KITCHEN_OPTS_VERIFY}
+
+kitchen-test: kitchen-check
+	[ ! -d tests/integration ] || kitchen test -t tests/integration ${KITCHEN_OPTS} ${KITCHEN_OPTS_TEST}
+	[ -d tests/integration ]   || kitchen test ${KITCHEN_OPTS} ${KITCHEN_OPTS_TEST}
+
+kitchen-list: kitchen-check
+	kitchen list
+
 clean:
+	[ ! -x "$(shell which kitchen)" ] || kitchen destroy
+	[ ! -d .kitchen ] || rm -rf .kitchen
 	[ ! -d tests/build ] || rm -rf tests/build
 	[ ! -d build ] || rm -rf build
diff --git a/README.rst b/README.rst
index fed6b9e..7d6c011 100644
--- a/README.rst
+++ b/README.rst
@@ -54,6 +54,7 @@
             pool: SAS7K2
         audit: 
           enabled: false
+        osapi_max_limit: 500
 
     cinder:
       volume:
@@ -134,6 +135,8 @@
 
 Cinder setup with zeroing deleted volumes
 
+.. code-block:: yaml
+
     cinder:
       controller:
         enabled: true
@@ -406,6 +409,35 @@
           filter_factory: 'keystonemiddleware.audit:filter_factory'
           map_file: '/etc/pycadf/cinder_api_audit_map.conf'
 
+
+Cinder setup with custom availability zones:
+
+.. code-block:: yaml
+
+    cinder:
+      controller:
+        default_availability_zone: my-default-zone
+        storage_availability_zone: my-custom-zone-name
+    cinder:
+      volume:
+        default_availability_zone: my-default-zone
+        storage_availability_zone: my-custom-zone-name
+
+public_endpoint and osapi_volume_base_url parameters:
+"public_endpoint" is used for configuring versions endpoint,
+"osapi_volume_base_URL" is used to present Cinder URL to users.
+They are useful when running Cinder under load balancer in SSL.
+
+.. code-block:: yaml
+
+    cinder:
+      controller:
+        public_endpoint_address: https://${_param:cluster_domain}:8776
+
+The default availability zone is used when a volume has been created, without specifying a zone in the create request. (this zone must exist in your configuration obviously)
+The storage availability zone is the actual zone where the node belongs to. Make sure to specify this per node.
+Check the documentation of OpenStack for more information
+
 Documentation and Bugs
 ============================
 
@@ -431,3 +463,36 @@
 Developers should also join the discussion on the IRC list, at:
 
     https://wiki.openstack.org/wiki/Meetings/openstack-salt
+
+Documentation and Bugs
+======================
+
+To learn how to install and update salt-formulas, consult the documentation
+available online at:
+
+    http://salt-formulas.readthedocs.io/
+
+In the unfortunate event that bugs are discovered, they should be reported to
+the appropriate issue tracker. Use Github issue tracker for specific salt
+formula:
+
+    https://github.com/salt-formulas/salt-formula-cinder/issues
+
+For feature requests, bug reports or blueprints affecting entire ecosystem,
+use Launchpad salt-formulas project:
+
+    https://launchpad.net/salt-formulas
+
+You can also join salt-formulas-users team and subscribe to mailing list:
+
+    https://launchpad.net/~salt-formulas-users
+
+Developers wishing to work on the salt-formulas projects should always base
+their work on master branch and submit pull request against specific formula.
+
+    https://github.com/salt-formulas/salt-formula-cinder
+
+Any questions or feedback is always welcome so feel free to join our IRC
+channel:
+
+    #salt-formulas @ irc.freenode.net
diff --git a/cinder/files/backend/_ceph.conf b/cinder/files/backend/_ceph.conf
index 42151b0..6455459 100644
--- a/cinder/files/backend/_ceph.conf
+++ b/cinder/files/backend/_ceph.conf
@@ -1,5 +1,6 @@
 
 [{{ backend_name }}]
+host={{ backend.get('host', grains.host) }}
 volume_backend_name={{ backend_name }}
 volume_driver = cinder.volume.drivers.rbd.RBDDriver
 #
diff --git a/cinder/files/backend/_fujitsu.conf b/cinder/files/backend/_fujitsu.conf
index 24925f0..28b3e2e 100644
--- a/cinder/files/backend/_fujitsu.conf
+++ b/cinder/files/backend/_fujitsu.conf
@@ -1,5 +1,6 @@
 
 [{{ backend_name }}]
+host={{ backend.get('host', grains.host) }}
 volume_backend_name={{ backend_name }}
 volume_driver=cinder.volume.drivers.fujitsu.fujitsu_eternus_dx_fc.FJDXFCDriver
 cinder_eternus_config_file=/etc/cinder/cinder_fujitsu_eternus_dx_{{ backend_name }}.xml
diff --git a/cinder/files/backend/_gpfs.conf b/cinder/files/backend/_gpfs.conf
index 3000c39..09289b2 100644
--- a/cinder/files/backend/_gpfs.conf
+++ b/cinder/files/backend/_gpfs.conf
@@ -1,5 +1,6 @@
 
 [{{ backend_name }}]
+host={{ backend.get('host', grains.host) }}
 volume_backend_name={{ backend_name }}
 volume_driver = cinder.volume.drivers.ibm.gpfs.GPFSDriver
 gpfs_mount_point_base={{ backend.mount_point }}
diff --git a/cinder/files/backend/_hitachi_vsp.conf b/cinder/files/backend/_hitachi_vsp.conf
index ea5059c..cf4f78b 100644
--- a/cinder/files/backend/_hitachi_vsp.conf
+++ b/cinder/files/backend/_hitachi_vsp.conf
@@ -1,6 +1,6 @@
 
 [{{ backend_name }}]
-
+host={{ backend.get('host', grains.host) }}
 volume_backend_name={{ backend_name }}
 volume_driver = cinder.volume.drivers.hitachi.hbsd.hbsd_fc.HBSDFCDriver
 
diff --git a/cinder/files/backend/_hp3par.conf b/cinder/files/backend/_hp3par.conf
index f28a4ba..78ddfb7 100644
--- a/cinder/files/backend/_hp3par.conf
+++ b/cinder/files/backend/_hp3par.conf
@@ -1,5 +1,6 @@
 
 [{{ backend_name }}]
+host={{ backend.get('host', grains.host) }}
 volume_backend_name={{ backend_name }}
 hp3par_api_url={{ backend.url }}
 
diff --git a/cinder/files/backend/_hp_lefthand.conf b/cinder/files/backend/_hp_lefthand.conf
index 12d52b6..e47fd9f 100644
--- a/cinder/files/backend/_hp_lefthand.conf
+++ b/cinder/files/backend/_hp_lefthand.conf
@@ -1,4 +1,5 @@
 [{{ backend_name }}]
+host={{ backend.get('host', grains.host) }}
 volume_backend_name={{ backend_name }}
 hplefthand_api_url={{ backend.api_url }}
 
diff --git a/cinder/files/backend/_lvm.conf b/cinder/files/backend/_lvm.conf
index 04a5bd8..b71fa23 100644
--- a/cinder/files/backend/_lvm.conf
+++ b/cinder/files/backend/_lvm.conf
@@ -1,5 +1,6 @@
 
 [{{ backend_name }}]
+host={{ backend.get('host', grains.host) }}
 volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
 volume_backend_name={{ backend_name }}
 lvm_type = default
diff --git a/cinder/files/backend/_solidfire.conf b/cinder/files/backend/_solidfire.conf
index bc7ecd4..e0b8ab1 100644
--- a/cinder/files/backend/_solidfire.conf
+++ b/cinder/files/backend/_solidfire.conf
@@ -1,5 +1,6 @@
 
 [{{ backend_name }}]
+host={{ backend.get('host', grains.host) }}
 volume_backend_name={{ backend_name }}
 san_ip={{ backend.san_ip }}
 san_login={{ backend.san_login }}
diff --git a/cinder/files/backend/_storwize.conf b/cinder/files/backend/_storwize.conf
index 1f09fca..b7115a1 100644
--- a/cinder/files/backend/_storwize.conf
+++ b/cinder/files/backend/_storwize.conf
@@ -1,5 +1,6 @@
 
 [{{ backend_name }}]
+host={{ backend.get('host', grains.host) }}
 volume_driver = cinder.volume.drivers.ibm.storwize_svc.StorwizeSVCDriver
 volume_backend_name={{ backend_name }}
 san_ip={{ backend.host }}
diff --git a/cinder/files/collectd_openstack_cinder.conf b/cinder/files/collectd_openstack_cinder.conf
index 6b2928c..55cee92 100644
--- a/cinder/files/collectd_openstack_cinder.conf
+++ b/cinder/files/collectd_openstack_cinder.conf
@@ -5,6 +5,9 @@
     Username "{{ plugin.username }}"
     Password "{{ plugin.password }}"
     Tenant "{{ plugin.tenant }}"
-    MaxRetries "2"
-    Timeout "20"
+    Region "{{ plugin.region }}"
+    MaxRetries "{{ plugin.max_retries|default(2) }}"
+    Timeout "{{ plugin.timeout|default(20) }}"
+    PaginationLimit "{{ plugin.pagination_limit|default(500) }}"
+    PollingInterval "{{ plugin.polling_interval|default(60) }}"
 </Module>
diff --git a/cinder/files/collectd_openstack_cinder_services.conf b/cinder/files/collectd_openstack_cinder_services.conf
new file mode 100644
index 0000000..3eb3813
--- /dev/null
+++ b/cinder/files/collectd_openstack_cinder_services.conf
@@ -0,0 +1,11 @@
+Import "openstack_cinder_services"
+
+<Module "openstack_cinder_services">
+    KeystoneUrl "{{ plugin.url }}"
+    Username "{{ plugin.username }}"
+    Password "{{ plugin.password }}"
+    Tenant "{{ plugin.tenant }}"
+    Region "{{ plugin.region }}"
+    MaxRetries "2"
+    Timeout "20"
+</Module>
diff --git a/cinder/files/juno/cinder.conf.controller.Debian b/cinder/files/juno/cinder.conf.controller.Debian
index cf7b94f..3961e82 100644
--- a/cinder/files/juno/cinder.conf.controller.Debian
+++ b/cinder/files/juno/cinder.conf.controller.Debian
@@ -47,6 +47,15 @@
 
 {%- endif %}
 
+{%- if controller.storage_availability_zone is defined %}
+storage_availability_zone={{controller.storage_availability_zone}}
+{%- endif %}
+
+{%- if controller.default_availability_zone is defined %}
+default_availability_zone={{controller.default_availability_zone}}
+{%- endif %}
+
+
 #RPC response timeout recommended by Hitachi
 rpc_response_timeout=3600
 
diff --git a/cinder/files/juno/cinder.conf.volume.Debian b/cinder/files/juno/cinder.conf.volume.Debian
index 2cb1031..64e0050 100644
--- a/cinder/files/juno/cinder.conf.volume.Debian
+++ b/cinder/files/juno/cinder.conf.volume.Debian
@@ -47,6 +47,15 @@
 
 {%- endif %}
 
+{%- if volume.storage_availability_zone is defined %}
+storage_availability_zone={{volume.storage_availability_zone}}
+{%- endif %}
+
+{%- if volume.default_availability_zone is defined %}
+default_availability_zone={{volume.default_availability_zone}}
+{%- endif %}
+
+
 #RPC response timeout recommended by Hitachi
 rpc_response_timeout=3600
 
diff --git a/cinder/files/kilo/cinder.conf.controller.Debian b/cinder/files/kilo/cinder.conf.controller.Debian
index e29a399..d35b484 100644
--- a/cinder/files/kilo/cinder.conf.controller.Debian
+++ b/cinder/files/kilo/cinder.conf.controller.Debian
@@ -50,6 +50,15 @@
 
 {%- endif %}
 
+{%- if controller.storage_availability_zone is defined %}
+storage_availability_zone={{controller.storage_availability_zone}}
+{%- endif %}
+
+{%- if controller.default_availability_zone is defined %}
+default_availability_zone={{controller.default_availability_zone}}
+{%- endif %}
+
+
 #RPC response timeout recommended by Hitachi
 rpc_response_timeout=3600
 
diff --git a/cinder/files/kilo/cinder.conf.volume.Debian b/cinder/files/kilo/cinder.conf.volume.Debian
index 94efa00..8bf4f8b 100644
--- a/cinder/files/kilo/cinder.conf.volume.Debian
+++ b/cinder/files/kilo/cinder.conf.volume.Debian
@@ -49,6 +49,15 @@
 
 {%- endif %}
 
+{%- if volume.storage_availability_zone is defined %}
+storage_availability_zone={{volume.storage_availability_zone}}
+{%- endif %}
+
+{%- if volume.default_availability_zone is defined %}
+default_availability_zone={{volume.default_availability_zone}}
+{%- endif %}
+
+
 #RPC response timeout recommended by Hitachi
 rpc_response_timeout=3600
 
diff --git a/cinder/files/liberty/cinder.conf.controller.Debian b/cinder/files/liberty/cinder.conf.controller.Debian
index ecd9b54..32cfe84 100644
--- a/cinder/files/liberty/cinder.conf.controller.Debian
+++ b/cinder/files/liberty/cinder.conf.controller.Debian
@@ -4,6 +4,13 @@
 rootwrap_config = /etc/cinder/rootwrap.conf
 api_paste_confg = /etc/cinder/api-paste.ini
 
+{%- if controller.public_endpoint_address is defined %}
+
+public_endpoint = {{ controller.public_endpoint_address }}
+osapi_volume_base_URL = {{ controller.public_endpoint_address }}
+
+{%- endif %}
+
 iscsi_helper = tgtadm
 volume_name_template = volume-%s
 #volume_group = cinder
@@ -29,6 +36,7 @@
 #glance_api_insecure=False
 
 osapi_volume_listen={{ controller.osapi.host }}
+osapi_max_limit={{ controller.osapi_max_limit|default('1000') }}
 
 glance_host={{ controller.glance.host }}
 glance_port={{ controller.glance.port }}
@@ -50,6 +58,15 @@
 
 {%- endif %}
 
+{%- if controller.storage_availability_zone is defined %}
+storage_availability_zone={{controller.storage_availability_zone}}
+{%- endif %}
+
+{%- if controller.default_availability_zone is defined %}
+default_availability_zone={{controller.default_availability_zone}}
+{%- endif %}
+
+
 #RPC response timeout recommended by Hitachi
 rpc_response_timeout=3600
 
@@ -141,7 +158,7 @@
 max_pool_size=30
 max_retries=-1
 max_overflow=40
-connection = {{ controller.database.engine }}://{{ controller.database.user }}:{{ controller.database.password }}@{{ controller.database.host }}/{{ controller.database.name }}
+connection = {{ controller.database.engine }}+pymysql://{{ controller.database.user }}:{{ controller.database.password }}@{{ controller.database.host }}/{{ controller.database.name }}
 
 {# new way #}
 
diff --git a/cinder/files/liberty/cinder.conf.volume.Debian b/cinder/files/liberty/cinder.conf.volume.Debian
index fbaacee..0ab8e54 100644
--- a/cinder/files/liberty/cinder.conf.volume.Debian
+++ b/cinder/files/liberty/cinder.conf.volume.Debian
@@ -49,6 +49,15 @@
 
 {%- endif %}
 
+{%- if volume.storage_availability_zone is defined %}
+storage_availability_zone={{volume.storage_availability_zone}}
+{%- endif %}
+
+{%- if volume.default_availability_zone is defined %}
+default_availability_zone={{volume.default_availability_zone}}
+{%- endif %}
+
+
 #RPC response timeout recommended by Hitachi
 rpc_response_timeout=3600
 
@@ -140,7 +149,7 @@
 max_pool_size=30
 max_retries=-1
 max_overflow=40
-connection = {{ volume.database.engine }}://{{ volume.database.user }}:{{ volume.database.password }}@{{ volume.database.host }}/{{ volume.database.name }}
+connection = {{ volume.database.engine }}+pymysql://{{ volume.database.user }}:{{ volume.database.password }}@{{ volume.database.host }}/{{ volume.database.name }}
 
 {# new way #}
 
diff --git a/cinder/files/mitaka/cinder.conf.controller.Debian b/cinder/files/mitaka/cinder.conf.controller.Debian
index 4ff2811..6ce59df 100644
--- a/cinder/files/mitaka/cinder.conf.controller.Debian
+++ b/cinder/files/mitaka/cinder.conf.controller.Debian
@@ -27,6 +27,7 @@
 #glance_api_insecure=False
 
 osapi_volume_listen={{ controller.osapi.host }}
+osapi_max_limit={{ controller.osapi_max_limit|default('1000') }}
 
 glance_host={{ controller.glance.host }}
 glance_port={{ controller.glance.port }}
@@ -42,6 +43,15 @@
 
 {%- endif %}
 
+{%- if controller.storage_availability_zone is defined %}
+storage_availability_zone={{controller.storage_availability_zone}}
+{%- endif %}
+
+{%- if controller.default_availability_zone is defined %}
+default_availability_zone={{controller.default_availability_zone}}
+{%- endif %}
+
+
 #RPC response timeout recommended by Hitachi
 rpc_response_timeout=3600
 
diff --git a/cinder/files/mitaka/cinder.conf.volume.Debian b/cinder/files/mitaka/cinder.conf.volume.Debian
index 73b6ca1..beb8008 100644
--- a/cinder/files/mitaka/cinder.conf.volume.Debian
+++ b/cinder/files/mitaka/cinder.conf.volume.Debian
@@ -42,6 +42,15 @@
 
 {%- endif %}
 
+{%- if volume.storage_availability_zone is defined %}
+storage_availability_zone={{volume.storage_availability_zone}}
+{%- endif %}
+
+{%- if volume.default_availability_zone is defined %}
+default_availability_zone={{volume.default_availability_zone}}
+{%- endif %}
+
+
 #RPC response timeout recommended by Hitachi
 rpc_response_timeout=3600
 
diff --git a/cinder/files/newton/cinder.conf.controller.Debian b/cinder/files/newton/cinder.conf.controller.Debian
index b7e5b74..a0c4c53 100644
--- a/cinder/files/newton/cinder.conf.controller.Debian
+++ b/cinder/files/newton/cinder.conf.controller.Debian
@@ -42,6 +42,15 @@
 
 {%- endif %}
 
+{%- if controller.storage_availability_zone is defined %}
+storage_availability_zone={{controller.storage_availability_zone}}
+{%- endif %}
+
+{%- if controller.default_availability_zone is defined %}
+default_availability_zone={{controller.default_availability_zone}}
+{%- endif %}
+
+
 #RPC response timeout recommended by Hitachi
 rpc_response_timeout=3600
 
@@ -69,7 +78,7 @@
 lock_path=/var/lock/cinder
 
 nova_catalog_admin_info = compute:nova:adminURL
-nova_catalog_info = compute:nova:publicURL
+nova_catalog_info = compute:nova:{{ server.identity.get('endpoint_type', 'publicURL') }}
 
 osapi_volume_extension = cinder.api.contrib.standard_extensions
 
diff --git a/cinder/files/newton/cinder.conf.volume.Debian b/cinder/files/newton/cinder.conf.volume.Debian
index f5183be..a8d4f7b 100644
--- a/cinder/files/newton/cinder.conf.volume.Debian
+++ b/cinder/files/newton/cinder.conf.volume.Debian
@@ -42,6 +42,15 @@
 
 {%- endif %}
 
+{%- if volume.storage_availability_zone is defined %}
+storage_availability_zone={{volume.storage_availability_zone}}
+{%- endif %}
+
+{%- if volume.default_availability_zone is defined %}
+default_availability_zone={{volume.default_availability_zone}}
+{%- endif %}
+
+
 #RPC response timeout recommended by Hitachi
 rpc_response_timeout=3600
 
@@ -67,7 +76,7 @@
 verbose=True
 
 nova_catalog_admin_info = compute:nova:adminURL
-nova_catalog_info = compute:nova:publicURL
+nova_catalog_info = compute:nova:{{ server.identity.get('endpoint_type', 'publicURL') }}
 
 [oslo_messaging_notifications]
 {%- if volume.notification is mapping %}
diff --git a/cinder/meta/collectd.yml b/cinder/meta/collectd.yml
index d0229c5..5f0ee4b 100644
--- a/cinder/meta/collectd.yml
+++ b/cinder/meta/collectd.yml
@@ -15,5 +15,14 @@
     username: {{ controller.identity.user }}
     password: {{ controller.identity.password }}
     tenant: {{ controller.identity.tenant }}
+    region: {{ controller.identity.region }}
+  openstack_cinder_services:
+    plugin: python
+    template: cinder/files/collectd_openstack_cinder_services.conf
+    url: "http://{{ controller.identity.host }}:{{ controller.identity.port }}/v{% if controller.identity.get('api_version', 2)|int == 2 %}2.0{% else %}3{% endif %}"
+    username: {{ controller.identity.user }}
+    password: {{ controller.identity.password }}
+    tenant: {{ controller.identity.tenant }}
+    region: {{ controller.identity.region }}
 {%- endif %}
 {%- endif %}
diff --git a/cinder/meta/grafana.yml b/cinder/meta/grafana.yml
index 4a390f5..532dba2 100644
--- a/cinder/meta/grafana.yml
+++ b/cinder/meta/grafana.yml
@@ -2,3 +2,31 @@
   cinder:
     format: json
     template: cinder/files/grafana_dashboards/cinder_influxdb.json
+  main:
+    row:
+      ost-control-plane:
+        title: OpenStack Control Plane
+        panel:
+          cinder:
+            title: Cinder
+            links:
+            - dashboard: Cinder
+              title: Cinder
+              type: dashboard
+            target:
+              cluster_status:
+                rawQuery: true
+                query: SELECT last(value) FROM cluster_status WHERE cluster_name = 'cinder-control' AND environment_label = '$environment' AND $timeFilter GROUP BY time($interval) fill(null)
+      ost-data-plane:
+        title: OpenStack Data Plane
+        panel:
+          cinder:
+            title: Cinder
+            links:
+            - dashboard: Cinder
+              title: Cinder
+              type: dashboard
+            target:
+              cluster_status:
+                rawQuery: true
+                query: SELECT last(value) FROM cluster_status WHERE cluster_name = 'cinder-data' AND environment_label = '$environment' AND $timeFilter GROUP BY time($interval) fill(null)
diff --git a/cinder/meta/sensu.yml b/cinder/meta/sensu.yml
index 6ab150a..8404d03 100644
--- a/cinder/meta/sensu.yml
+++ b/cinder/meta/sensu.yml
@@ -1,5 +1,5 @@
 {%- from "cinder/map.jinja" import controller with context %}
-{%- set region = controller.identity.region %}
+{%- set region = controller.get('identity', {}).get('region', 'RegionOne') %}
 check:
   local_cinder_api_proc:
     command: "PATH=$PATH:/usr/lib64/nagios/plugins:/usr/lib/nagios/plugins check_procs -C cinder-api -u cinder -c 1:1024"
diff --git a/metadata/service/control/cluster.yml b/metadata/service/control/cluster.yml
index c0c9682..ffd2aac 100644
--- a/metadata/service/control/cluster.yml
+++ b/metadata/service/control/cluster.yml
@@ -3,6 +3,8 @@
 classes:
 - service.cinder.support
 parameters:
+  _param:
+    keystone_cinder_endpoint_type: internalURL
   cinder:
     controller:
       enabled: true
@@ -24,6 +26,7 @@
         tenant: service
         user: cinder
         password: ${_param:keystone_cinder_password}
+        endpoint_type: ${_param:keystone_cinder_endpoint_type}
       glance:
         host: ${_param:cluster_vip_address}
         port: 9292
diff --git a/metadata/service/control/cluster_control.yml b/metadata/service/control/cluster_control.yml
index c0c9682..ffd2aac 100644
--- a/metadata/service/control/cluster_control.yml
+++ b/metadata/service/control/cluster_control.yml
@@ -3,6 +3,8 @@
 classes:
 - service.cinder.support
 parameters:
+  _param:
+    keystone_cinder_endpoint_type: internalURL
   cinder:
     controller:
       enabled: true
@@ -24,6 +26,7 @@
         tenant: service
         user: cinder
         password: ${_param:keystone_cinder_password}
+        endpoint_type: ${_param:keystone_cinder_endpoint_type}
       glance:
         host: ${_param:cluster_vip_address}
         port: 9292
diff --git a/metadata/service/control/container.yml b/metadata/service/control/container.yml
index 951ded8..4c82662 100644
--- a/metadata/service/control/container.yml
+++ b/metadata/service/control/container.yml
@@ -1,4 +1,6 @@
 parameters:
+  _param:
+    keystone_cinder_endpoint_type: internalURL
   kubernetes:
     control:
       configmap:
@@ -29,6 +31,7 @@
                   tenant: service
                   user: cinder
                   password: ${_param:keystone_cinder_password}
+                  endpoint_type: ${_param:keystone_cinder_endpoint_type}
                 glance:
                   host: ${_param:glance_service_host}
                   port: 9292
diff --git a/metadata/service/control/single.yml b/metadata/service/control/single.yml
index 5b5c9aa..1bf8378 100644
--- a/metadata/service/control/single.yml
+++ b/metadata/service/control/single.yml
@@ -3,6 +3,8 @@
 classes:
 - service.cinder.support
 parameters:
+  _param:
+    keystone_cinder_endpoint_type: internalURL
   cinder:
     controller:
       enabled: true
@@ -24,6 +26,7 @@
         tenant: service
         user: cinder
         password: ${_param:keystone_cinder_password}
+        endpoint_type: ${_param:keystone_cinder_endpoint_type}
       glance:
         host: ${_param:single_address}
         port: 9292
diff --git a/metadata/service/volume/single.yml b/metadata/service/volume/single.yml
index a452086..65a5640 100644
--- a/metadata/service/volume/single.yml
+++ b/metadata/service/volume/single.yml
@@ -3,6 +3,8 @@
 classes:
 - service.cinder.support
 parameters:
+  _param:
+    keystone_cinder_endpoint_type: internalURL
   cinder:
     volume:
       enabled: true
@@ -24,6 +26,7 @@
         tenant: service
         user: cinder
         password: ${_param:keystone_cinder_password}
+        endpoint_type: ${_param:keystone_cinder_endpoint_type}
       glance:
         host: ${_param:cluster_vip_address}
         port: 9292
diff --git a/tests/pillar/control_cluster.sls b/tests/pillar/control_cluster.sls
index ddb9e38..9fcafb4 100644
--- a/tests/pillar/control_cluster.sls
+++ b/tests/pillar/control_cluster.sls
@@ -19,6 +19,7 @@
       tenant: service
       user: cinder
       password: password
+      endpoint_type: internalURL
     glance:
       host: 127.0.0.1
       port: 9292
diff --git a/tests/pillar/control_single.sls b/tests/pillar/control_single.sls
index 4c3b3bf..73a7a2e 100644
--- a/tests/pillar/control_single.sls
+++ b/tests/pillar/control_single.sls
@@ -19,6 +19,7 @@
       tenant: service
       user: cinder
       password: password
+      endpoint_type: internalURL
     glance:
       host: 127.0.0.1
       port: 9292
diff --git a/tests/pillar/volume_single.sls b/tests/pillar/volume_single.sls
index 1b66ae2..d8f7071 100644
--- a/tests/pillar/volume_single.sls
+++ b/tests/pillar/volume_single.sls
@@ -18,6 +18,7 @@
       tenant: service
       user: cinder
       password: password
+      endpoint_type: internalURL
     glance:
       host: 127.0.0.1
       port: 9292