Merge "[VMware] inital commit"
diff --git a/README.rst b/README.rst
index 2a6206f..1153f2f 100644
--- a/README.rst
+++ b/README.rst
@@ -109,6 +109,31 @@
           chunk_size: 8
           client_glance_key: AQDOavlU6BsSJhAAnpFR906mvdgdfRqLHwu0Uw==
 
+VMWare integration:
+
+.. code-block:: yaml
+
+    glance:
+      server
+        storage:
+          engine: vmware
+          default_store: vsphere
+          vmware:
+            enabled: true
+            server_host: 1.2.3.4
+            server_username: vmware_username
+            server_password: vmware_password
+            datastores:
+              data1:
+                name: datastore_name1
+                enabled: true
+                path: datacenter_name
+                weight: 10
+              data2:
+                name: datastore_name2
+                enabled: true
+                path: datacenter_name
+
 RabbitMQ HA setup
 
 .. code-block:: yaml
diff --git a/glance/files/pike/glance-api.conf.Debian b/glance/files/pike/glance-api.conf.Debian
index a29833a..422ee73 100644
--- a/glance/files/pike/glance-api.conf.Debian
+++ b/glance/files/pike/glance-api.conf.Debian
@@ -2023,13 +2023,18 @@
 #
 #  (list value)
 #stores = file,http
+{%- if server.storage.default_store is defined %}
+default_store = {{ server.storage.default_store }}
+{%- endif %}
 {%- if 'file' in storage_engines %}
-default_store = file
 stores = file,http
 {%- else %}
+  {%- if server.storage.default_store is not defined %}
 default_store = {{ storage_engines[0]  }}
+  {%- endif %}
 stores = {{ server.storage.engine }}
 {%- endif %}
+
 #
 # The default scheme to use for storing images.
 #
@@ -3224,184 +3229,10 @@
 
 {% endif %}
 
-#
-# Address of the ESX/ESXi or vCenter Server target system.
-#
-# This configuration option sets the address of the ESX/ESXi or vCenter
-# Server target system. This option is required when using the VMware
-# storage backend. The address can contain an IP address (127.0.0.1) or
-# a DNS name (www.my-domain.com).
-#
-# Possible Values:
-#     * A valid IPv4 or IPv6 address
-#     * A valid DNS name
-#
-# Related options:
-#     * vmware_server_username
-#     * vmware_server_password
-#
-#  (string value)
-#vmware_server_host = 127.0.0.1
-
-#
-# Server username.
-#
-# This configuration option takes the username for authenticating with
-# the VMware ESX/ESXi or vCenter Server. This option is required when
-# using the VMware storage backend.
-#
-# Possible Values:
-#     * Any string that is the username for a user with appropriate
-#       privileges
-#
-# Related options:
-#     * vmware_server_host
-#     * vmware_server_password
-#
-#  (string value)
-#vmware_server_username = root
-
-#
-# Server password.
-#
-# This configuration option takes the password for authenticating with
-# the VMware ESX/ESXi or vCenter Server. This option is required when
-# using the VMware storage backend.
-#
-# Possible Values:
-#     * Any string that is a password corresponding to the username
-#       specified using the "vmware_server_username" option
-#
-# Related options:
-#     * vmware_server_host
-#     * vmware_server_username
-#
-#  (string value)
-#vmware_server_password = vmware
-
-#
-# The number of VMware API retries.
-#
-# This configuration option specifies the number of times the VMware
-# ESX/VC server API must be retried upon connection related issues or
-# server API call overload. It is not possible to specify 'retry
-# forever'.
-#
-# Possible Values:
-#     * Any positive integer value
-#
-# Related options:
-#     * None
-#
-#  (integer value)
-# Minimum value: 1
-#vmware_api_retry_count = 10
-
-#
-# Interval in seconds used for polling remote tasks invoked on VMware
-# ESX/VC server.
-#
-# This configuration option takes in the sleep time in seconds for polling an
-# on-going async task as part of the VMWare ESX/VC server API call.
-#
-# Possible Values:
-#     * Any positive integer value
-#
-# Related options:
-#     * None
-#
-#  (integer value)
-# Minimum value: 1
-#vmware_task_poll_interval = 5
-
-#
-# The directory where the glance images will be stored in the datastore.
-#
-# This configuration option specifies the path to the directory where the
-# glance images will be stored in the VMware datastore. If this option
-# is not set,  the default directory where the glance images are stored
-# is openstack_glance.
-#
-# Possible Values:
-#     * Any string that is a valid path to a directory
-#
-# Related options:
-#     * None
-#
-#  (string value)
-#vmware_store_image_dir = /openstack_glance
-
-#
-# Set verification of the ESX/vCenter server certificate.
-#
-# This configuration option takes a boolean value to determine
-# whether or not to verify the ESX/vCenter server certificate. If this
-# option is set to True, the ESX/vCenter server certificate is not
-# verified. If this option is set to False, then the default CA
-# truststore is used for verification.
-#
-# This option is ignored if the "vmware_ca_file" option is set. In that
-# case, the ESX/vCenter server certificate will then be verified using
-# the file specified using the "vmware_ca_file" option .
-#
-# Possible Values:
-#     * True
-#     * False
-#
-# Related options:
-#     * vmware_ca_file
-#
-#  (boolean value)
-# Deprecated group/name - [glance_store]/vmware_api_insecure
-#vmware_insecure = false
-
-#
-# Absolute path to the CA bundle file.
-#
-# This configuration option enables the operator to use a custom
-# Cerificate Authority File to verify the ESX/vCenter certificate.
-#
-# If this option is set, the "vmware_insecure" option will be ignored
-# and the CA file specified will be used to authenticate the ESX/vCenter
-# server certificate and establish a secure connection to the server.
-#
-# Possible Values:
-#     * Any string that is a valid absolute path to a CA file
-#
-# Related options:
-#     * vmware_insecure
-#
-#  (string value)
-#vmware_ca_file = /etc/ssl/certs/ca-certificates.crt
-
-#
-# The datastores where the image can be stored.
-#
-# This configuration option specifies the datastores where the image can
-# be stored in the VMWare store backend. This option may be specified
-# multiple times for specifying multiple datastores. The datastore name
-# should be specified after its datacenter path, separated by ":". An
-# optional weight may be given after the datastore name, separated again
-# by ":" to specify the priority. Thus, the required format becomes
-# <datacenter_path>:<datastore_name>:<optional_weight>.
-#
-# When adding an image, the datastore with highest weight will be
-# selected, unless there is not enough free space available in cases
-# where the image size is already known. If no weight is given, it is
-# assumed to be zero and the directory will be considered for selection
-# last. If multiple datastores have the same weight, then the one with
-# the most free space available is selected.
-#
-# Possible Values:
-#     * Any string of the format:
-#       <datacenter_path>:<datastore_name>:<optional_weight>
-#
-# Related options:
-#    * None
-#
-#  (multi valued)
-#vmware_datastores =
-
+{%- if server.storage is defined and server.storage.get('vmware', {}).get('enabled')%}
+{%- set _data = server.storage.vmware %}
+{%- include "glance/files/pike/stores/_vmware.conf" %}
+{%- endif %}
 
 [image_format]
 
diff --git a/glance/files/pike/glance-cache.conf.Debian b/glance/files/pike/glance-cache.conf.Debian
index 716cf3e..7d2432b 100644
--- a/glance/files/pike/glance-cache.conf.Debian
+++ b/glance/files/pike/glance-cache.conf.Debian
@@ -2110,187 +2110,15 @@
 #  (string value)
 #swift_store_config_file = <None>
 
-#
-# Address of the ESX/ESXi or vCenter Server target system.
-#
-# This configuration option sets the address of the ESX/ESXi or vCenter
-# Server target system. This option is required when using the VMware
-# storage backend. The address can contain an IP address (127.0.0.1) or
-# a DNS name (www.my-domain.com).
-#
-# Possible Values:
-#     * A valid IPv4 or IPv6 address
-#     * A valid DNS name
-#
-# Related options:
-#     * vmware_server_username
-#     * vmware_server_password
-#
-#  (string value)
-#vmware_server_host = 127.0.0.1
-
-#
-# Server username.
-#
-# This configuration option takes the username for authenticating with
-# the VMware ESX/ESXi or vCenter Server. This option is required when
-# using the VMware storage backend.
-#
-# Possible Values:
-#     * Any string that is the username for a user with appropriate
-#       privileges
-#
-# Related options:
-#     * vmware_server_host
-#     * vmware_server_password
-#
-#  (string value)
-#vmware_server_username = root
-
-#
-# Server password.
-#
-# This configuration option takes the password for authenticating with
-# the VMware ESX/ESXi or vCenter Server. This option is required when
-# using the VMware storage backend.
-#
-# Possible Values:
-#     * Any string that is a password corresponding to the username
-#       specified using the "vmware_server_username" option
-#
-# Related options:
-#     * vmware_server_host
-#     * vmware_server_username
-#
-#  (string value)
-#vmware_server_password = vmware
-
-#
-# The number of VMware API retries.
-#
-# This configuration option specifies the number of times the VMware
-# ESX/VC server API must be retried upon connection related issues or
-# server API call overload. It is not possible to specify 'retry
-# forever'.
-#
-# Possible Values:
-#     * Any positive integer value
-#
-# Related options:
-#     * None
-#
-#  (integer value)
-# Minimum value: 1
-#vmware_api_retry_count = 10
-
-#
-# Interval in seconds used for polling remote tasks invoked on VMware
-# ESX/VC server.
-#
-# This configuration option takes in the sleep time in seconds for polling an
-# on-going async task as part of the VMWare ESX/VC server API call.
-#
-# Possible Values:
-#     * Any positive integer value
-#
-# Related options:
-#     * None
-#
-#  (integer value)
-# Minimum value: 1
-#vmware_task_poll_interval = 5
-
-#
-# The directory where the glance images will be stored in the datastore.
-#
-# This configuration option specifies the path to the directory where the
-# glance images will be stored in the VMware datastore. If this option
-# is not set,  the default directory where the glance images are stored
-# is openstack_glance.
-#
-# Possible Values:
-#     * Any string that is a valid path to a directory
-#
-# Related options:
-#     * None
-#
-#  (string value)
-#vmware_store_image_dir = /openstack_glance
-
-#
-# Set verification of the ESX/vCenter server certificate.
-#
-# This configuration option takes a boolean value to determine
-# whether or not to verify the ESX/vCenter server certificate. If this
-# option is set to True, the ESX/vCenter server certificate is not
-# verified. If this option is set to False, then the default CA
-# truststore is used for verification.
-#
-# This option is ignored if the "vmware_ca_file" option is set. In that
-# case, the ESX/vCenter server certificate will then be verified using
-# the file specified using the "vmware_ca_file" option .
-#
-# Possible Values:
-#     * True
-#     * False
-#
-# Related options:
-#     * vmware_ca_file
-#
-#  (boolean value)
-# Deprecated group/name - [glance_store]/vmware_api_insecure
-#vmware_insecure = false
-
-#
-# Absolute path to the CA bundle file.
-#
-# This configuration option enables the operator to use a custom
-# Cerificate Authority File to verify the ESX/vCenter certificate.
-#
-# If this option is set, the "vmware_insecure" option will be ignored
-# and the CA file specified will be used to authenticate the ESX/vCenter
-# server certificate and establish a secure connection to the server.
-#
-# Possible Values:
-#     * Any string that is a valid absolute path to a CA file
-#
-# Related options:
-#     * vmware_insecure
-#
-#  (string value)
-#vmware_ca_file = /etc/ssl/certs/ca-certificates.crt
-
-#
-# The datastores where the image can be stored.
-#
-# This configuration option specifies the datastores where the image can
-# be stored in the VMWare store backend. This option may be specified
-# multiple times for specifying multiple datastores. The datastore name
-# should be specified after its datacenter path, separated by ":". An
-# optional weight may be given after the datastore name, separated again
-# by ":" to specify the priority. Thus, the required format becomes
-# <datacenter_path>:<datastore_name>:<optional_weight>.
-#
-# When adding an image, the datastore with highest weight will be
-# selected, unless there is not enough free space available in cases
-# where the image size is already known. If no weight is given, it is
-# assumed to be zero and the directory will be considered for selection
-# last. If multiple datastores have the same weight, then the one with
-# the most free space available is selected.
-#
-# Possible Values:
-#     * Any string of the format:
-#       <datacenter_path>:<datastore_name>:<optional_weight>
-#
-# Related options:
-#    * None
-#
-#  (multi valued)
-#vmware_datastores =
 {% if server.identity.region is defined %}
 os_region_name = {{ server.identity.region }}
 {% endif %}
 
+{%- if server.storage is defined and server.storage.get('vmware', {}).get('enabled') %}
+{%- set _data = server.storage.vmware %}
+{%- include "glance/files/pike/stores/_vmware.conf" %}
+{%- endif %}
+
 
 [oslo_policy]
 
diff --git a/glance/files/pike/stores/_vmware.conf b/glance/files/pike/stores/_vmware.conf
new file mode 100644
index 0000000..89c931a
--- /dev/null
+++ b/glance/files/pike/stores/_vmware.conf
@@ -0,0 +1,211 @@
+
+#
+# Address of the ESX/ESXi or vCenter Server target system.
+#
+# This configuration option sets the address of the ESX/ESXi or vCenter
+# Server target system. This option is required when using the VMware
+# storage backend. The address can contain an IP address (127.0.0.1) or
+# a DNS name (www.my-domain.com).
+#
+# Possible Values:
+#     * A valid IPv4 or IPv6 address
+#     * A valid DNS name
+#
+# Related options:
+#     * vmware_server_username
+#     * vmware_server_password
+#
+#  (unknown value)
+#vmware_server_host = 127.0.0.1
+{%- if _data.server_host is defined %}
+vmware_server_host = {{ _data.server_host }}
+{%- endif %}
+
+#
+# Server username.
+#
+# This configuration option takes the username for authenticating with
+# the VMware ESX/ESXi or vCenter Server. This option is required when
+# using the VMware storage backend.
+#
+# Possible Values:
+#     * Any string that is the username for a user with appropriate
+#       privileges
+#
+# Related options:
+#     * vmware_server_host
+#     * vmware_server_password
+#
+#  (string value)
+#vmware_server_username = root
+vmware_server_username = {{ _data.server_username }}
+
+#
+# Server password.
+#
+# This configuration option takes the password for authenticating with
+# the VMware ESX/ESXi or vCenter Server. This option is required when
+# using the VMware storage backend.
+#
+# Possible Values:
+#     * Any string that is a password corresponding to the username
+#       specified using the "vmware_server_username" option
+#
+# Related options:
+#     * vmware_server_host
+#     * vmware_server_username
+#
+#  (string value)
+#vmware_server_password = vmware
+vmware_server_password = {{ _data.server_password }}
+
+#
+# The number of VMware API retries.
+#
+# This configuration option specifies the number of times the VMware
+# ESX/VC server API must be retried upon connection related issues or
+# server API call overload. It is not possible to specify 'retry
+# forever'.
+#
+# Possible Values:
+#     * Any positive integer value
+#
+# Related options:
+#     * None
+#
+#  (integer value)
+# Minimum value: 1
+#vmware_api_retry_count = 10
+{%- if _data.api_retry_count is defined %}
+vmware_api_retry_count = {{ _data.api_retry_count }}
+{%- endif %}
+
+#
+# Interval in seconds used for polling remote tasks invoked on VMware
+# ESX/VC server.
+#
+# This configuration option takes in the sleep time in seconds for polling an
+# on-going async task as part of the VMWare ESX/VC server API call.
+#
+# Possible Values:
+#     * Any positive integer value
+#
+# Related options:
+#     * None
+#
+#  (integer value)
+# Minimum value: 1
+#vmware_task_poll_interval = 5
+{%- if _data.task_poll_interval is defined %}
+vmware_task_poll_interval = {{ _data.task_poll_interval }}
+{%- endif %}
+
+#
+# The directory where the glance images will be stored in the datastore.
+#
+# This configuration option specifies the path to the directory where the
+# glance images will be stored in the VMware datastore. If this option
+# is not set,  the default directory where the glance images are stored
+# is openstack_glance.
+#
+# Possible Values:
+#     * Any string that is a valid path to a directory
+#
+# Related options:
+#     * None
+#
+#  (string value)
+#vmware_store_image_dir = /openstack_glance
+{%- if _data.store_image_dir is defined %}
+vmware_store_image_dir = {{ _data.store_image_dir }}
+{%- endif %}
+
+#
+# Set verification of the ESX/vCenter server certificate.
+#
+# This configuration option takes a boolean value to determine
+# whether or not to verify the ESX/vCenter server certificate. If this
+# option is set to True, the ESX/vCenter server certificate is not
+# verified. If this option is set to False, then the default CA
+# truststore is used for verification.
+#
+# This option is ignored if the "vmware_ca_file" option is set. In that
+# case, the ESX/vCenter server certificate will then be verified using
+# the file specified using the "vmware_ca_file" option .
+#
+# Possible Values:
+#     * True
+#     * False
+#
+# Related options:
+#     * vmware_ca_file
+#
+#  (boolean value)
+# Deprecated group/name - [glance_store]/vmware_api_insecure
+#vmware_insecure = false
+{%- if _data.insecure is defined %}
+vmware_insecure = {{ _data.insecure }}
+{%- endif %}
+
+#
+# Absolute path to the CA bundle file.
+#
+# This configuration option enables the operator to use a custom
+# Cerificate Authority File to verify the ESX/vCenter certificate.
+#
+# If this option is set, the "vmware_insecure" option will be ignored
+# and the CA file specified will be used to authenticate the ESX/vCenter
+# server certificate and establish a secure connection to the server.
+#
+# Possible Values:
+#     * Any string that is a valid absolute path to a CA file
+#
+# Related options:
+#     * vmware_insecure
+#
+#  (string value)
+#vmware_ca_file = /etc/ssl/certs/ca-certificates.crt
+{%- if _data.cacert_file is defined %}
+vmware_ca_file = {{ _data.cacert_file }}
+{%- endif %}
+
+#
+# The datastores where the image can be stored.
+#
+# This configuration option specifies the datastores where the image can
+# be stored in the VMWare store backend. This option may be specified
+# multiple times for specifying multiple datastores. The datastore name
+# should be specified after its datacenter path, separated by ":". An
+# optional weight may be given after the datastore name, separated again
+# by ":" to specify the priority. Thus, the required format becomes
+# <datacenter_path>:<datastore_name>:<optional_weight>.
+#
+# When adding an image, the datastore with highest weight will be
+# selected, unless there is not enough free space available in cases
+# where the image size is already known. If no weight is given, it is
+# assumed to be zero and the directory will be considered for selection
+# last. If multiple datastores have the same weight, then the one with
+# the most free space available is selected.
+#
+# Possible Values:
+#     * Any string of the format:
+#       <datacenter_path>:<datastore_name>:<optional_weight>
+#
+# Related options:
+#    * None
+#
+#  (multi valued)
+#vmware_datastores =
+{%- if _data.datastores is defined %}
+{%- for dname,ddata in _data.datastores.iteritems() %}
+{%- set vmware_datastores = [] %}
+{%- if ddata.get('enabled', False) %}
+{%- do vmware_datastores.append(ddata.path) %}
+{%- do vmware_datastores.append(ddata.get('name', dname)) %}
+{%- if ddata.weight is defined %}
+{%- do vmware_datastores.append(ddata.weight|string) %}
+{%- endif %}
+{%- endif %}
+vmware_datastores = {{ ':'.join(vmware_datastores) }}
+{%- endfor %}
+{%- endif %}
diff --git a/glance/files/queens/glance-api.conf.Debian b/glance/files/queens/glance-api.conf.Debian
index 40bf715..d1de46c 100644
--- a/glance/files/queens/glance-api.conf.Debian
+++ b/glance/files/queens/glance-api.conf.Debian
@@ -2200,11 +2200,15 @@
 # cinder - <No description provided>
 # vsphere - <No description provided>
 #default_store = file
+{%- if server.storage.default_store is defined %}
+default_store = {{ server.storage.default_store }}
+{%- endif %}
 {%- if 'file' in storage_engines %}
-default_store = file
 stores = file,http
 {%- else %}
+  {%- if server.storage.default_store is not defined %}
 default_store = {{ storage_engines[0]  }}
+  {%- endif %}
 stores = {{ server.storage.engine }}
 {%- endif %}
 
@@ -3551,195 +3555,10 @@
 #  (string value)
 #swift_upload_buffer_dir = <None>
 
-#
-# Address of the ESX/ESXi or vCenter Server target system.
-#
-# This configuration option sets the address of the ESX/ESXi or
-# vCenter
-# Server target system. This option is required when using the VMware
-# storage backend. The address can contain an IP address (127.0.0.1)
-# or
-# a DNS name (www.my-domain.com).
-#
-# Possible Values:
-#     * A valid IPv4 or IPv6 address
-#     * A valid DNS name
-#
-# Related options:
-#     * vmware_server_username
-#     * vmware_server_password
-#
-#  (unknown value)
-#vmware_server_host = 127.0.0.1
-
-#
-# Server username.
-#
-# This configuration option takes the username for authenticating with
-# the VMware ESX/ESXi or vCenter Server. This option is required when
-# using the VMware storage backend.
-#
-# Possible Values:
-#     * Any string that is the username for a user with appropriate
-#       privileges
-#
-# Related options:
-#     * vmware_server_host
-#     * vmware_server_password
-#
-#  (string value)
-#vmware_server_username = root
-
-#
-# Server password.
-#
-# This configuration option takes the password for authenticating with
-# the VMware ESX/ESXi or vCenter Server. This option is required when
-# using the VMware storage backend.
-#
-# Possible Values:
-#     * Any string that is a password corresponding to the username
-#       specified using the "vmware_server_username" option
-#
-# Related options:
-#     * vmware_server_host
-#     * vmware_server_username
-#
-#  (string value)
-#vmware_server_password = vmware
-
-#
-# The number of VMware API retries.
-#
-# This configuration option specifies the number of times the VMware
-# ESX/VC server API must be retried upon connection related issues or
-# server API call overload. It is not possible to specify 'retry
-# forever'.
-#
-# Possible Values:
-#     * Any positive integer value
-#
-# Related options:
-#     * None
-#
-#  (integer value)
-# Minimum value: 1
-#vmware_api_retry_count = 10
-
-#
-# Interval in seconds used for polling remote tasks invoked on VMware
-# ESX/VC server.
-#
-# This configuration option takes in the sleep time in seconds for
-# polling an
-# on-going async task as part of the VMWare ESX/VC server API call.
-#
-# Possible Values:
-#     * Any positive integer value
-#
-# Related options:
-#     * None
-#
-#  (integer value)
-# Minimum value: 1
-#vmware_task_poll_interval = 5
-
-#
-# The directory where the glance images will be stored in the
-# datastore.
-#
-# This configuration option specifies the path to the directory where
-# the
-# glance images will be stored in the VMware datastore. If this option
-# is not set,  the default directory where the glance images are
-# stored
-# is openstack_glance.
-#
-# Possible Values:
-#     * Any string that is a valid path to a directory
-#
-# Related options:
-#     * None
-#
-#  (string value)
-#vmware_store_image_dir = /openstack_glance
-
-#
-# Set verification of the ESX/vCenter server certificate.
-#
-# This configuration option takes a boolean value to determine
-# whether or not to verify the ESX/vCenter server certificate. If this
-# option is set to True, the ESX/vCenter server certificate is not
-# verified. If this option is set to False, then the default CA
-# truststore is used for verification.
-#
-# This option is ignored if the "vmware_ca_file" option is set. In
-# that
-# case, the ESX/vCenter server certificate will then be verified using
-# the file specified using the "vmware_ca_file" option .
-#
-# Possible Values:
-#     * True
-#     * False
-#
-# Related options:
-#     * vmware_ca_file
-#
-#  (boolean value)
-# Deprecated group/name - [glance_store]/vmware_api_insecure
-#vmware_insecure = false
-
-#
-# Absolute path to the CA bundle file.
-#
-# This configuration option enables the operator to use a custom
-# Cerificate Authority File to verify the ESX/vCenter certificate.
-#
-# If this option is set, the "vmware_insecure" option will be ignored
-# and the CA file specified will be used to authenticate the
-# ESX/vCenter
-# server certificate and establish a secure connection to the server.
-#
-# Possible Values:
-#     * Any string that is a valid absolute path to a CA file
-#
-# Related options:
-#     * vmware_insecure
-#
-#  (string value)
-#vmware_ca_file = /etc/ssl/certs/ca-certificates.crt
-
-#
-# The datastores where the image can be stored.
-#
-# This configuration option specifies the datastores where the image
-# can
-# be stored in the VMWare store backend. This option may be specified
-# multiple times for specifying multiple datastores. The datastore
-# name
-# should be specified after its datacenter path, separated by ":". An
-# optional weight may be given after the datastore name, separated
-# again
-# by ":" to specify the priority. Thus, the required format becomes
-# <datacenter_path>:<datastore_name>:<optional_weight>.
-#
-# When adding an image, the datastore with highest weight will be
-# selected, unless there is not enough free space available in cases
-# where the image size is already known. If no weight is given, it is
-# assumed to be zero and the directory will be considered for
-# selection
-# last. If multiple datastores have the same weight, then the one with
-# the most free space available is selected.
-#
-# Possible Values:
-#     * Any string of the format:
-#       <datacenter_path>:<datastore_name>:<optional_weight>
-#
-# Related options:
-#    * None
-#
-#  (multi valued)
-#vmware_datastores =
+{%- if server.storage is defined and server.storage.get('vmware', {}).get('enabled') %}
+{%- set _data = server.storage.vmware %}
+{%- include "glance/files/queens/stores/_vmware.conf" %}
+{%- endif %}
 
 [oslo_concurrency]
 {%- if server.concurrency is defined %}
diff --git a/glance/files/queens/glance-cache.conf.Debian b/glance/files/queens/glance-cache.conf.Debian
index 6c95146..ab18a63 100644
--- a/glance/files/queens/glance-cache.conf.Debian
+++ b/glance/files/queens/glance-cache.conf.Debian
@@ -2425,200 +2425,15 @@
 #  (string value)
 #swift_upload_buffer_dir = <None>
 
-#
-# Address of the ESX/ESXi or vCenter Server target system.
-#
-# This configuration option sets the address of the ESX/ESXi or
-# vCenter
-# Server target system. This option is required when using the VMware
-# storage backend. The address can contain an IP address (127.0.0.1)
-# or
-# a DNS name (www.my-domain.com).
-#
-# Possible Values:
-#     * A valid IPv4 or IPv6 address
-#     * A valid DNS name
-#
-# Related options:
-#     * vmware_server_username
-#     * vmware_server_password
-#
-#  (unknown value)
-#vmware_server_host = 127.0.0.1
-
-#
-# Server username.
-#
-# This configuration option takes the username for authenticating with
-# the VMware ESX/ESXi or vCenter Server. This option is required when
-# using the VMware storage backend.
-#
-# Possible Values:
-#     * Any string that is the username for a user with appropriate
-#       privileges
-#
-# Related options:
-#     * vmware_server_host
-#     * vmware_server_password
-#
-#  (string value)
-#vmware_server_username = root
-
-#
-# Server password.
-#
-# This configuration option takes the password for authenticating with
-# the VMware ESX/ESXi or vCenter Server. This option is required when
-# using the VMware storage backend.
-#
-# Possible Values:
-#     * Any string that is a password corresponding to the username
-#       specified using the "vmware_server_username" option
-#
-# Related options:
-#     * vmware_server_host
-#     * vmware_server_username
-#
-#  (string value)
-#vmware_server_password = vmware
-
-#
-# The number of VMware API retries.
-#
-# This configuration option specifies the number of times the VMware
-# ESX/VC server API must be retried upon connection related issues or
-# server API call overload. It is not possible to specify 'retry
-# forever'.
-#
-# Possible Values:
-#     * Any positive integer value
-#
-# Related options:
-#     * None
-#
-#  (integer value)
-# Minimum value: 1
-#vmware_api_retry_count = 10
-
-#
-# Interval in seconds used for polling remote tasks invoked on VMware
-# ESX/VC server.
-#
-# This configuration option takes in the sleep time in seconds for
-# polling an
-# on-going async task as part of the VMWare ESX/VC server API call.
-#
-# Possible Values:
-#     * Any positive integer value
-#
-# Related options:
-#     * None
-#
-#  (integer value)
-# Minimum value: 1
-#vmware_task_poll_interval = 5
-
-#
-# The directory where the glance images will be stored in the
-# datastore.
-#
-# This configuration option specifies the path to the directory where
-# the
-# glance images will be stored in the VMware datastore. If this option
-# is not set,  the default directory where the glance images are
-# stored
-# is openstack_glance.
-#
-# Possible Values:
-#     * Any string that is a valid path to a directory
-#
-# Related options:
-#     * None
-#
-#  (string value)
-#vmware_store_image_dir = /openstack_glance
-
-#
-# Set verification of the ESX/vCenter server certificate.
-#
-# This configuration option takes a boolean value to determine
-# whether or not to verify the ESX/vCenter server certificate. If this
-# option is set to True, the ESX/vCenter server certificate is not
-# verified. If this option is set to False, then the default CA
-# truststore is used for verification.
-#
-# This option is ignored if the "vmware_ca_file" option is set. In
-# that
-# case, the ESX/vCenter server certificate will then be verified using
-# the file specified using the "vmware_ca_file" option .
-#
-# Possible Values:
-#     * True
-#     * False
-#
-# Related options:
-#     * vmware_ca_file
-#
-#  (boolean value)
-# Deprecated group/name - [glance_store]/vmware_api_insecure
-#vmware_insecure = false
-
-#
-# Absolute path to the CA bundle file.
-#
-# This configuration option enables the operator to use a custom
-# Cerificate Authority File to verify the ESX/vCenter certificate.
-#
-# If this option is set, the "vmware_insecure" option will be ignored
-# and the CA file specified will be used to authenticate the
-# ESX/vCenter
-# server certificate and establish a secure connection to the server.
-#
-# Possible Values:
-#     * Any string that is a valid absolute path to a CA file
-#
-# Related options:
-#     * vmware_insecure
-#
-#  (string value)
-#vmware_ca_file = /etc/ssl/certs/ca-certificates.crt
-
-#
-# The datastores where the image can be stored.
-#
-# This configuration option specifies the datastores where the image
-# can
-# be stored in the VMWare store backend. This option may be specified
-# multiple times for specifying multiple datastores. The datastore
-# name
-# should be specified after its datacenter path, separated by ":". An
-# optional weight may be given after the datastore name, separated
-# again
-# by ":" to specify the priority. Thus, the required format becomes
-# <datacenter_path>:<datastore_name>:<optional_weight>.
-#
-# When adding an image, the datastore with highest weight will be
-# selected, unless there is not enough free space available in cases
-# where the image size is already known. If no weight is given, it is
-# assumed to be zero and the directory will be considered for
-# selection
-# last. If multiple datastores have the same weight, then the one with
-# the most free space available is selected.
-#
-# Possible Values:
-#     * Any string of the format:
-#       <datacenter_path>:<datastore_name>:<optional_weight>
-#
-# Related options:
-#    * None
-#
-#  (multi valued)
-#vmware_datastores =
-
 {% if server.identity.region is defined %}
 os_region_name = {{ server.identity.region }}
 {% endif %}
 
+{%- if server.storage is defined and server.storage.get('vmware', {}).get('enabled') %}
+{%- set _data = server.storage.vmware %}
+{%- include "glance/files/queens/stores/_vmware.conf" %}
+{%- endif %}
+
 [oslo_policy]
 {%- if server.oslo_policy is defined %}
 {%- set _data = server.oslo_policy %}
diff --git a/glance/files/queens/stores/_vmware.conf b/glance/files/queens/stores/_vmware.conf
new file mode 100644
index 0000000..89c931a
--- /dev/null
+++ b/glance/files/queens/stores/_vmware.conf
@@ -0,0 +1,211 @@
+
+#
+# Address of the ESX/ESXi or vCenter Server target system.
+#
+# This configuration option sets the address of the ESX/ESXi or vCenter
+# Server target system. This option is required when using the VMware
+# storage backend. The address can contain an IP address (127.0.0.1) or
+# a DNS name (www.my-domain.com).
+#
+# Possible Values:
+#     * A valid IPv4 or IPv6 address
+#     * A valid DNS name
+#
+# Related options:
+#     * vmware_server_username
+#     * vmware_server_password
+#
+#  (unknown value)
+#vmware_server_host = 127.0.0.1
+{%- if _data.server_host is defined %}
+vmware_server_host = {{ _data.server_host }}
+{%- endif %}
+
+#
+# Server username.
+#
+# This configuration option takes the username for authenticating with
+# the VMware ESX/ESXi or vCenter Server. This option is required when
+# using the VMware storage backend.
+#
+# Possible Values:
+#     * Any string that is the username for a user with appropriate
+#       privileges
+#
+# Related options:
+#     * vmware_server_host
+#     * vmware_server_password
+#
+#  (string value)
+#vmware_server_username = root
+vmware_server_username = {{ _data.server_username }}
+
+#
+# Server password.
+#
+# This configuration option takes the password for authenticating with
+# the VMware ESX/ESXi or vCenter Server. This option is required when
+# using the VMware storage backend.
+#
+# Possible Values:
+#     * Any string that is a password corresponding to the username
+#       specified using the "vmware_server_username" option
+#
+# Related options:
+#     * vmware_server_host
+#     * vmware_server_username
+#
+#  (string value)
+#vmware_server_password = vmware
+vmware_server_password = {{ _data.server_password }}
+
+#
+# The number of VMware API retries.
+#
+# This configuration option specifies the number of times the VMware
+# ESX/VC server API must be retried upon connection related issues or
+# server API call overload. It is not possible to specify 'retry
+# forever'.
+#
+# Possible Values:
+#     * Any positive integer value
+#
+# Related options:
+#     * None
+#
+#  (integer value)
+# Minimum value: 1
+#vmware_api_retry_count = 10
+{%- if _data.api_retry_count is defined %}
+vmware_api_retry_count = {{ _data.api_retry_count }}
+{%- endif %}
+
+#
+# Interval in seconds used for polling remote tasks invoked on VMware
+# ESX/VC server.
+#
+# This configuration option takes in the sleep time in seconds for polling an
+# on-going async task as part of the VMWare ESX/VC server API call.
+#
+# Possible Values:
+#     * Any positive integer value
+#
+# Related options:
+#     * None
+#
+#  (integer value)
+# Minimum value: 1
+#vmware_task_poll_interval = 5
+{%- if _data.task_poll_interval is defined %}
+vmware_task_poll_interval = {{ _data.task_poll_interval }}
+{%- endif %}
+
+#
+# The directory where the glance images will be stored in the datastore.
+#
+# This configuration option specifies the path to the directory where the
+# glance images will be stored in the VMware datastore. If this option
+# is not set,  the default directory where the glance images are stored
+# is openstack_glance.
+#
+# Possible Values:
+#     * Any string that is a valid path to a directory
+#
+# Related options:
+#     * None
+#
+#  (string value)
+#vmware_store_image_dir = /openstack_glance
+{%- if _data.store_image_dir is defined %}
+vmware_store_image_dir = {{ _data.store_image_dir }}
+{%- endif %}
+
+#
+# Set verification of the ESX/vCenter server certificate.
+#
+# This configuration option takes a boolean value to determine
+# whether or not to verify the ESX/vCenter server certificate. If this
+# option is set to True, the ESX/vCenter server certificate is not
+# verified. If this option is set to False, then the default CA
+# truststore is used for verification.
+#
+# This option is ignored if the "vmware_ca_file" option is set. In that
+# case, the ESX/vCenter server certificate will then be verified using
+# the file specified using the "vmware_ca_file" option .
+#
+# Possible Values:
+#     * True
+#     * False
+#
+# Related options:
+#     * vmware_ca_file
+#
+#  (boolean value)
+# Deprecated group/name - [glance_store]/vmware_api_insecure
+#vmware_insecure = false
+{%- if _data.insecure is defined %}
+vmware_insecure = {{ _data.insecure }}
+{%- endif %}
+
+#
+# Absolute path to the CA bundle file.
+#
+# This configuration option enables the operator to use a custom
+# Cerificate Authority File to verify the ESX/vCenter certificate.
+#
+# If this option is set, the "vmware_insecure" option will be ignored
+# and the CA file specified will be used to authenticate the ESX/vCenter
+# server certificate and establish a secure connection to the server.
+#
+# Possible Values:
+#     * Any string that is a valid absolute path to a CA file
+#
+# Related options:
+#     * vmware_insecure
+#
+#  (string value)
+#vmware_ca_file = /etc/ssl/certs/ca-certificates.crt
+{%- if _data.cacert_file is defined %}
+vmware_ca_file = {{ _data.cacert_file }}
+{%- endif %}
+
+#
+# The datastores where the image can be stored.
+#
+# This configuration option specifies the datastores where the image can
+# be stored in the VMWare store backend. This option may be specified
+# multiple times for specifying multiple datastores. The datastore name
+# should be specified after its datacenter path, separated by ":". An
+# optional weight may be given after the datastore name, separated again
+# by ":" to specify the priority. Thus, the required format becomes
+# <datacenter_path>:<datastore_name>:<optional_weight>.
+#
+# When adding an image, the datastore with highest weight will be
+# selected, unless there is not enough free space available in cases
+# where the image size is already known. If no weight is given, it is
+# assumed to be zero and the directory will be considered for selection
+# last. If multiple datastores have the same weight, then the one with
+# the most free space available is selected.
+#
+# Possible Values:
+#     * Any string of the format:
+#       <datacenter_path>:<datastore_name>:<optional_weight>
+#
+# Related options:
+#    * None
+#
+#  (multi valued)
+#vmware_datastores =
+{%- if _data.datastores is defined %}
+{%- for dname,ddata in _data.datastores.iteritems() %}
+{%- set vmware_datastores = [] %}
+{%- if ddata.get('enabled', False) %}
+{%- do vmware_datastores.append(ddata.path) %}
+{%- do vmware_datastores.append(ddata.get('name', dname)) %}
+{%- if ddata.weight is defined %}
+{%- do vmware_datastores.append(ddata.weight|string) %}
+{%- endif %}
+{%- endif %}
+vmware_datastores = {{ ':'.join(vmware_datastores) }}
+{%- endfor %}
+{%- endif %}
diff --git a/metadata/service/control/cluster.yml b/metadata/service/control/cluster.yml
index 076f639..d50efba 100644
--- a/metadata/service/control/cluster.yml
+++ b/metadata/service/control/cluster.yml
@@ -1,6 +1,7 @@
 applications:
 - glance
 classes:
+- service.glance.control.storage.file
 - service.glance.support
 parameters:
   _param:
@@ -53,8 +54,6 @@
         user: openstack
         password: ${_param:rabbitmq_openstack_password}
         virtual_host: '/openstack'
-      storage:
-        engine: file
       cache:
         engine: memcached
         members:
diff --git a/metadata/service/control/container.yml b/metadata/service/control/container.yml
index 7e19b51..a482b9f 100644
--- a/metadata/service/control/container.yml
+++ b/metadata/service/control/container.yml
@@ -1,3 +1,5 @@
+classes:
+- service.glance.control.storage.file
 parameters:
   _param:
     keystone_glance_endpoint_type: internalURL
@@ -42,7 +44,5 @@
                   user: openstack
                   password: ${_param:rabbitmq_openstack_password}
                   virtual_host: '/openstack'
-                storage:
-                  engine: file
                 cache:
-                  engine: memcached
\ No newline at end of file
+                  engine: memcached
diff --git a/metadata/service/control/single.yml b/metadata/service/control/single.yml
index 30bfed8..0e16de5 100644
--- a/metadata/service/control/single.yml
+++ b/metadata/service/control/single.yml
@@ -1,6 +1,7 @@
 applications:
 - glance
 classes:
+- service.glance.control.storage.file
 - service.glance.support
 parameters:
   _param:
@@ -51,5 +52,3 @@
         user: openstack
         password: ${_param:rabbitmq_openstack_password}
         virtual_host: '/openstack'
-      storage:
-        engine: file
diff --git a/metadata/service/control/storage/file.yml b/metadata/service/control/storage/file.yml
new file mode 100644
index 0000000..9f54585
--- /dev/null
+++ b/metadata/service/control/storage/file.yml
@@ -0,0 +1,6 @@
+parameters:
+  glance:
+    server:
+      storage:
+        engine: file
+        default_store: file
diff --git a/metadata/service/control/storage/vmware.yml b/metadata/service/control/storage/vmware.yml
new file mode 100644
index 0000000..b6f286e
--- /dev/null
+++ b/metadata/service/control/storage/vmware.yml
@@ -0,0 +1,17 @@
+parameters:
+  glance:
+    server:
+      storage:
+        engine: vmware
+        default_store: vsphere
+        vmware:
+          enabled: true
+          server_host: ${_param:openstack_vcenter_host}
+          server_username: ${_param:openstack_vcenter_username}
+          server_password: ${_param:openstack_vcenter_password}
+          insecure: true
+          datastores:
+            storage01:
+              enabled: true
+              name: ${_param:openstack_vcenter_storage_name}
+              path: ${_param:openstack_vcenter_datacenter_name}
diff --git a/tests/pillar/single_vmware.sls b/tests/pillar/single_vmware.sls
new file mode 100644
index 0000000..2d916f1
--- /dev/null
+++ b/tests/pillar/single_vmware.sls
@@ -0,0 +1,66 @@
+glance:
+  server:
+    enabled: true
+    version: pike
+    workers: 1
+    database:
+      engine: mysql
+      host: localhost
+      port: 3306
+      name: glance
+      user: glance
+      password: password
+    registry:
+      host: 127.0.0.1
+      port: 9191
+    bind:
+      address: 127.0.0.1
+      port: 9292
+    identity:
+      engine: keystone
+      host: 127.0.0.1
+      port: 35357
+      user: glance
+      password: password
+      region: RegionOne
+      tenant: service
+      endpoint_type: internalURL
+    logging:
+      log_appender: false
+      log_handlers:
+        watchedfile:
+          enabled: true
+        fluentd:
+          enabled: false
+        ossyslog:
+          enabled: false
+    message_queue:
+      engine: rabbitmq
+      host: 127.0.0.1
+      port: 5672
+      user: openstack
+      password: password
+      virtual_host: '/openstack'
+    storage:
+      engine: vmware
+      vmware:
+        server_host: 1.2.3.4
+        server_username: vmware_username
+        server_password: vmware_password
+        datastores:
+          data1:
+            enabled: true
+            path: /data1
+            weight: 10
+          data2:
+            enabled: true
+            path: /data2
+    policy:
+      publicize_image: "role:admin"
+      add_member:
+    quota:
+      image_member: -1
+      image_property: 256
+      image_tag: 256
+      image_location: 15
+      user_storage: 0