[VMware] inital commit

This commit unhardcode vmware related options.

Change-Id: I16fbdd65fc794de597462de7822275ae900253dc
Related-Prod: PROD-21448
diff --git a/README.rst b/README.rst
index 23d6b1b..25b2fcd 100644
--- a/README.rst
+++ b/README.rst
@@ -190,6 +190,20 @@
           virtual_host: '/openstack'
           rabbit_ha_queues: true
 
+Ceilometer compute agent vmware:
+--------------------------------
+
+.. code-block:: yaml
+
+
+    ceilometer:
+      agent:
+        enabled: true
+        vmware:
+          enabled: true
+          host_ip: 1.2.3.4
+          host_username: vmware_username
+          host_password: vmware_password
 
 Ceilometer instance discovery method
 ------------------------------------
diff --git a/ceilometer/files/pike/ceilometer-agent.conf.Debian b/ceilometer/files/pike/ceilometer-agent.conf.Debian
index 1beefe8..2a7def9 100644
--- a/ceilometer/files/pike/ceilometer-agent.conf.Debian
+++ b/ceilometer/files/pike/ceilometer-agent.conf.Debian
@@ -76,3 +76,70 @@
 token_cache_time = -1
 interface = internal
 region_name = {{ agent.get('region', 'RegionOne') }}
+
+{%- if agent.get('vmware', {}).get('enabled', False) %}
+{%- set _data = agent.vmware %}
+[vmware]
+
+#
+# From ceilometer
+#
+
+# IP address of the VMware vSphere host. (host address value)
+#host_ip = 127.0.0.1
+{%- if _data.host_ip is defined %}
+host_ip = {{ _data.host_ip }}
+{%- endif %}
+
+# Port of the VMware vSphere host. (port value)
+# Minimum value: 0
+# Maximum value: 65535
+#host_port = 443
+{%- if _data.host_port is defined %}
+host_port = {{ _data.host_port }}
+{%- endif %}
+
+# Username of VMware vSphere. (string value)
+#host_username =
+host_username = {{ _data.host_username }}
+
+# Password of VMware vSphere. (string value)
+#host_password =
+host_password = {{ _data.host_password }}
+
+# CA bundle file to use in verifying the vCenter server certificate. (string
+# value)
+#ca_file = <None>
+{%- if _data.cacert_file is defined %}
+ca_file = {{ _data.cacert_file }}
+{%- endif %}
+
+# If true, the vCenter server certificate is not verified. If false, then the
+# default CA truststore is used for verification. This option is ignored if
+# "ca_file" is set. (boolean value)
+#insecure = false
+{%- if _data.insecure is defined %}
+insecure = {{ _data.insecure }}
+{%- endif %}
+
+# Number of times a VMware vSphere API may be retried. (integer value)
+#api_retry_count = 10
+{%- if _data.api_retry_count is defined %}
+api_retry_count = {{ _data.api_retry_count }}
+{%- endif %}
+
+# Sleep time in seconds for polling an ongoing async task. (floating point
+# value)
+#task_poll_interval = 0.5
+{%- if _data.task_poll_interval is defined %}
+task_poll_interval = {{ _data.task_poll_interval }}
+{%- endif %}
+
+# Optional vim service WSDL location e.g http://<server>/vimService.wsdl.
+# Optional over-ride to default location for bug work-arounds. (string value)
+#wsdl_location = <None>
+{%- if _data.wsdl_location is defined %}
+wsdl_location = {{ _data.wsdl_location }}
+{%- endif %}
+
+{%- endif %}
diff --git a/ceilometer/files/pike/ceilometer-server.conf.Debian b/ceilometer/files/pike/ceilometer-server.conf.Debian
index eca1c73..559ef0d 100644
--- a/ceilometer/files/pike/ceilometer-server.conf.Debian
+++ b/ceilometer/files/pike/ceilometer-server.conf.Debian
@@ -204,3 +204,71 @@
 token_cache_time = -1
 interface = internal
 region_name = {{ server.get('region', 'RegionOne') }}
+
+
+{%- if server.get('vmware', {}).get('enabled', False) %}
+{%- set _data = server.vmware %}
+[vmware]
+
+#
+# From ceilometer
+#
+
+# IP address of the VMware vSphere host. (host address value)
+#host_ip = 127.0.0.1
+{%- if _data.host_ip is defined %}
+host_ip = {{ _data.host_ip }}
+{%- endif %}
+
+# Port of the VMware vSphere host. (port value)
+# Minimum value: 0
+# Maximum value: 65535
+#host_port = 443
+{%- if _data.host_port is defined %}
+host_port = {{ _data.host_port }}
+{%- endif %}
+
+# Username of VMware vSphere. (string value)
+#host_username =
+host_username = {{ _data.host_username }}
+
+# Password of VMware vSphere. (string value)
+#host_password =
+host_password = {{ _data.host_password }}
+
+# CA bundle file to use in verifying the vCenter server certificate. (string
+# value)
+#ca_file = <None>
+{%- if _data.cacert_file is defined %}
+ca_file = {{ _data.cacert_file }}
+{%- endif %}
+
+# If true, the vCenter server certificate is not verified. If false, then the
+# default CA truststore is used for verification. This option is ignored if
+# "ca_file" is set. (boolean value)
+#insecure = false
+{%- if _data.insecure is defined %}
+insecure = {{ _data.insecure }}
+{%- endif %}
+
+# Number of times a VMware vSphere API may be retried. (integer value)
+#api_retry_count = 10
+{%- if _data.api_retry_count is defined %}
+api_retry_count = {{ _data.api_retry_count }}
+{%- endif %}
+
+# Sleep time in seconds for polling an ongoing async task. (floating point
+# value)
+#task_poll_interval = 0.5
+{%- if _data.task_poll_interval is defined %}
+task_poll_interval = {{ _data.task_poll_interval }}
+{%- endif %}
+
+# Optional vim service WSDL location e.g http://<server>/vimService.wsdl.
+# Optional over-ride to default location for bug work-arounds. (string value)
+#wsdl_location = <None>
+{%- if _data.wsdl_location is defined %}
+wsdl_location = {{ _data.wsdl_location }}
+{%- endif %}
+
+{%- endif %}
diff --git a/ceilometer/files/queens/ceilometer-agent.conf.Debian b/ceilometer/files/queens/ceilometer-agent.conf.Debian
index 6ae28d2..8d26346 100644
--- a/ceilometer/files/queens/ceilometer-agent.conf.Debian
+++ b/ceilometer/files/queens/ceilometer-agent.conf.Debian
@@ -402,7 +402,8 @@
 # Deprecated group/name - [service_types]/cinderv2
 #cinder = volumev3
 
-
+{%- if agent.get('vmware', {}).get('enabled', False) %}
+{%- set _data = agent.vmware %}
 [vmware]
 
 #
@@ -411,38 +412,62 @@
 
 # IP address of the VMware vSphere host. (host address value)
 #host_ip = 127.0.0.1
+{%- if _data.host_ip is defined %}
+host_ip = {{ _data.host_ip }}
+{%- endif %}
 
 # Port of the VMware vSphere host. (port value)
 # Minimum value: 0
 # Maximum value: 65535
 #host_port = 443
+{%- if _data.host_port is defined %}
+host_port = {{ _data.host_port }}
+{%- endif %}
 
 # Username of VMware vSphere. (string value)
 #host_username =
+host_username = {{ _data.host_username }}
 
 # Password of VMware vSphere. (string value)
 #host_password =
+host_password = {{ _data.host_password }}
 
 # CA bundle file to use in verifying the vCenter server certificate. (string
 # value)
 #ca_file = <None>
+{%- if _data.cacert_file is defined %}
+ca_file = {{ _data.cacert_file }}
+{%- endif %}
 
 # If true, the vCenter server certificate is not verified. If false, then the
 # default CA truststore is used for verification. This option is ignored if
 # "ca_file" is set. (boolean value)
 #insecure = false
+{%- if _data.insecure is defined %}
+insecure = {{ _data.insecure }}
+{%- endif %}
 
 # Number of times a VMware vSphere API may be retried. (integer value)
 #api_retry_count = 10
+{%- if _data.api_retry_count is defined %}
+api_retry_count = {{ _data.api_retry_count }}
+{%- endif %}
 
 # Sleep time in seconds for polling an ongoing async task. (floating point
 # value)
 #task_poll_interval = 0.5
+{%- if _data.task_poll_interval is defined %}
+task_poll_interval = {{ _data.task_poll_interval }}
+{%- endif %}
 
 # Optional vim service WSDL location e.g http://<server>/vimService.wsdl.
 # Optional over-ride to default location for bug work-arounds. (string value)
 #wsdl_location = <None>
+{%- if _data.wsdl_location is defined %}
+wsdl_location = {{ _data.wsdl_location }}
+{%- endif %}
 
+{%- endif %}
 
 [xenapi]
 
@@ -479,4 +504,3 @@
 [oslo_messaging_{{ messaging_engine }}]
 {%- include "oslo_templates/files/queens/oslo/messaging/_" + messaging_engine + ".conf" %}
 {%- endif %}
-
diff --git a/ceilometer/files/queens/ceilometer-server.conf.Debian b/ceilometer/files/queens/ceilometer-server.conf.Debian
index 2190366..67448e4 100644
--- a/ceilometer/files/queens/ceilometer-server.conf.Debian
+++ b/ceilometer/files/queens/ceilometer-server.conf.Debian
@@ -407,7 +407,8 @@
 # Deprecated group/name - [service_types]/cinderv2
 #cinder = volumev3
 
-
+{%- if server.get('vmware', {}).get('enabled', False) %}
+{%- set _data = server.vmware %}
 [vmware]
 
 #
@@ -416,37 +417,62 @@
 
 # IP address of the VMware vSphere host. (host address value)
 #host_ip = 127.0.0.1
+{%- if _data.host_ip is defined %}
+host_ip = {{ _data.host_ip }}
+{%- endif %}
 
 # Port of the VMware vSphere host. (port value)
 # Minimum value: 0
 # Maximum value: 65535
 #host_port = 443
+{%- if _data.host_port is defined %}
+host_port = {{ _data.host_port }}
+{%- endif %}
 
 # Username of VMware vSphere. (string value)
 #host_username =
+host_username = {{ _data.host_username }}
 
 # Password of VMware vSphere. (string value)
 #host_password =
+host_password = {{ _data.host_password }}
 
 # CA bundle file to use in verifying the vCenter server certificate. (string
 # value)
 #ca_file = <None>
+{%- if _data.cacert_file is defined %}
+ca_file = {{ _data.cacert_file }}
+{%- endif %}
 
 # If true, the vCenter server certificate is not verified. If false, then the
 # default CA truststore is used for verification. This option is ignored if
 # "ca_file" is set. (boolean value)
 #insecure = false
+{%- if _data.insecure is defined %}
+insecure = {{ _data.insecure }}
+{%- endif %}
 
 # Number of times a VMware vSphere API may be retried. (integer value)
 #api_retry_count = 10
+{%- if _data.api_retry_count is defined %}
+api_retry_count = {{ _data.api_retry_count }}
+{%- endif %}
 
 # Sleep time in seconds for polling an ongoing async task. (floating point
 # value)
 #task_poll_interval = 0.5
+{%- if _data.task_poll_interval is defined %}
+task_poll_interval = {{ _data.task_poll_interval }}
+{%- endif %}
 
 # Optional vim service WSDL location e.g http://<server>/vimService.wsdl.
 # Optional over-ride to default location for bug work-arounds. (string value)
 #wsdl_location = <None>
+{%- if _data.wsdl_location is defined %}
+wsdl_location = {{ _data.wsdl_location }}
+{%- endif %}
+
+{%- endif %}
 
 
 [xenapi]
@@ -484,4 +510,3 @@
 [oslo_messaging_{{ messaging_engine }}]
 {%- include "oslo_templates/files/queens/oslo/messaging/_" + messaging_engine + ".conf" %}
 {%- endif %}
-
diff --git a/tests/pillar/agent_single_vmware.sls b/tests/pillar/agent_single_vmware.sls
new file mode 100644
index 0000000..077c7c1
--- /dev/null
+++ b/tests/pillar/agent_single_vmware.sls
@@ -0,0 +1,42 @@
+ceilometer:
+  agent:
+    debug: true
+    #region: RegionOne
+    enabled: true
+    version: pike
+    secret: password
+    publisher:
+      default:
+        enabled: true
+    identity:
+      engine: keystone
+      host: 127.0.0.1
+      port: 35357
+      tenant: service
+      user: ceilometer
+      password: password
+      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'
+      # Workaround for https://bugs.launchpad.net/ceilometer/+bug/1337715
+      rpc_thread_pool_size: 5
+    vmware:
+      enabled: true
+      host_ip: 1.2.3.4
+      host_port: 443
+      host_username: vmware_user
+      host_password: vmware_password