Add new service level classes

Since Pike default ceilometer backend is gnocchi and database publishers
are deprecated, this commit create classes for ceilometer non-database
setup. This will allow to smoothly switch to Gnocchi as publisher. Also
if publisher isn't set in pillar, default publisher notifier will be used.

Change-Id: I78cf9e12591c474738c0bc14b1c1777974e876e0
Related-Prod: https://mirantis.jira.com/browse/PROD-20813
diff --git a/ceilometer/files/pike/event_pipeline.yaml b/ceilometer/files/pike/event_pipeline.yaml
index 2979d85..aa0ea46 100644
--- a/ceilometer/files/pike/event_pipeline.yaml
+++ b/ceilometer/files/pike/event_pipeline.yaml
@@ -1,11 +1,12 @@
 {%- from "ceilometer/map.jinja" import server with context %}
 {%- from "ceilometer/map.jinja" import agent with context %}
 {%- if server.get('enabled', False) %}
-{%- set publisher = server.publisher %}
+{%- set publisher = server.get('publisher', {}) %}
 {%- else %}
-{%- set publisher = agent.publisher %}
+{%- set publisher = agent.get('publisher', {}) %}
 {%- endif %}
 {%- set publisher_lst = [] %}
+{%- if publisher %}
 {%- for k, v in publisher.items() %}
 {%- if v.get('enabled', False) and v.get('publish_event', False) %}
 {%- if k == 'default' %}
@@ -15,6 +16,9 @@
 {%- endif %}
 {%- endif %}
 {%- endfor %}
+{%- else %}
+{%- do publisher_lst.append( 'notifier://' ) %}
+{%- endif %}
 ---
 sources:
     - name: event_source
diff --git a/ceilometer/files/pike/pipeline.yaml b/ceilometer/files/pike/pipeline.yaml
index c2accf1..96ca2a9 100644
--- a/ceilometer/files/pike/pipeline.yaml
+++ b/ceilometer/files/pike/pipeline.yaml
@@ -1,11 +1,12 @@
 {%- from "ceilometer/map.jinja" import server with context %}
 {%- from "ceilometer/map.jinja" import agent with context %}
 {%- if server.get('enabled', False) %}
-{%- set publisher = server.publisher %}
+{%- set publisher = server.get('publisher', {}) %}
 {%- else %}
-{%- set publisher = agent.publisher %}
+{%- set publisher = agent.get('publisher', {}) %}
 {%- endif %}
 {%- set publisher_lst = [] %}
+{%- if publisher %}
 {%- for k, v in publisher.items() %}
 {%- if v.get('enabled', False) and v.get('publish_metric', False) %}
 {%- if k == 'default' %}
@@ -17,6 +18,9 @@
 {%- endif %}
 {%- endif %}
 {%- endfor %}
+{%- else %}
+{%- do publisher_lst.append( 'notifier://' ) %}
+{%- endif %}
 ---
 sources:
     - name: meter_source
diff --git a/ceilometer/files/queens/event_pipeline.yaml b/ceilometer/files/queens/event_pipeline.yaml
index 2979d85..aa0ea46 100644
--- a/ceilometer/files/queens/event_pipeline.yaml
+++ b/ceilometer/files/queens/event_pipeline.yaml
@@ -1,11 +1,12 @@
 {%- from "ceilometer/map.jinja" import server with context %}
 {%- from "ceilometer/map.jinja" import agent with context %}
 {%- if server.get('enabled', False) %}
-{%- set publisher = server.publisher %}
+{%- set publisher = server.get('publisher', {}) %}
 {%- else %}
-{%- set publisher = agent.publisher %}
+{%- set publisher = agent.get('publisher', {}) %}
 {%- endif %}
 {%- set publisher_lst = [] %}
+{%- if publisher %}
 {%- for k, v in publisher.items() %}
 {%- if v.get('enabled', False) and v.get('publish_event', False) %}
 {%- if k == 'default' %}
@@ -15,6 +16,9 @@
 {%- endif %}
 {%- endif %}
 {%- endfor %}
+{%- else %}
+{%- do publisher_lst.append( 'notifier://' ) %}
+{%- endif %}
 ---
 sources:
     - name: event_source
diff --git a/ceilometer/files/queens/pipeline.yaml b/ceilometer/files/queens/pipeline.yaml
index c2accf1..96ca2a9 100644
--- a/ceilometer/files/queens/pipeline.yaml
+++ b/ceilometer/files/queens/pipeline.yaml
@@ -1,11 +1,12 @@
 {%- from "ceilometer/map.jinja" import server with context %}
 {%- from "ceilometer/map.jinja" import agent with context %}
 {%- if server.get('enabled', False) %}
-{%- set publisher = server.publisher %}
+{%- set publisher = server.get('publisher', {}) %}
 {%- else %}
-{%- set publisher = agent.publisher %}
+{%- set publisher = agent.get('publisher', {}) %}
 {%- endif %}
 {%- set publisher_lst = [] %}
+{%- if publisher %}
 {%- for k, v in publisher.items() %}
 {%- if v.get('enabled', False) and v.get('publish_metric', False) %}
 {%- if k == 'default' %}
@@ -17,6 +18,9 @@
 {%- endif %}
 {%- endif %}
 {%- endfor %}
+{%- else %}
+{%- do publisher_lst.append( 'notifier://' ) %}
+{%- endif %}
 ---
 sources:
     - name: meter_source
diff --git a/metadata/service/agent/cluster.yml b/metadata/service/agent/cluster/common.yml
similarity index 90%
rename from metadata/service/agent/cluster.yml
rename to metadata/service/agent/cluster/common.yml
index 588dc26..778dfbe 100644
--- a/metadata/service/agent/cluster.yml
+++ b/metadata/service/agent/cluster/common.yml
@@ -13,11 +13,6 @@
       enabled: true
       version: ${_param:ceilometer_version}
       secret: ${_param:ceilometer_secret_key}
-      publisher:
-        default:
-          enabled: true
-          publish_event: true
-          publish_metric: true
       identity:
         engine: keystone
         host: ${_param:cluster_vip_address}
diff --git a/metadata/service/agent/cluster/init.yml b/metadata/service/agent/cluster/init.yml
new file mode 100644
index 0000000..258640a
--- /dev/null
+++ b/metadata/service/agent/cluster/init.yml
@@ -0,0 +1,12 @@
+applications:
+- ceilometer
+classes:
+- service.ceilometer.agent.cluster.common
+parameters:
+  ceilometer:
+    agent:
+      publisher:
+        default:
+          enabled: true
+          publish_event: true
+          publish_metric: true
\ No newline at end of file
diff --git a/metadata/service/agent/single.yml b/metadata/service/agent/single/common.yml
similarity index 90%
rename from metadata/service/agent/single.yml
rename to metadata/service/agent/single/common.yml
index b0a0058..34739ad 100644
--- a/metadata/service/agent/single.yml
+++ b/metadata/service/agent/single/common.yml
@@ -13,11 +13,6 @@
       enabled: true
       version: ${_param:ceilometer_version}
       secret: ${_param:ceilometer_secret_key}
-      publisher:
-        default:
-          enabled: true
-          publish_event: true
-          publish_metric: true
       identity:
         engine: keystone
         host: ${_param:cluster_vip_address}
diff --git a/metadata/service/agent/single/init.yml b/metadata/service/agent/single/init.yml
new file mode 100644
index 0000000..e444d7d
--- /dev/null
+++ b/metadata/service/agent/single/init.yml
@@ -0,0 +1,12 @@
+applications:
+- ceilometer
+classes:
+- service.ceilometer.agent.single.common
+parameters:
+  ceilometer:
+    agent:
+      publisher:
+        default:
+          enabled: true
+          publish_event: true
+          publish_metric: true
\ No newline at end of file
diff --git a/metadata/service/server/cluster.yml b/metadata/service/server/cluster.yml
deleted file mode 100644
index 933b488..0000000
--- a/metadata/service/server/cluster.yml
+++ /dev/null
@@ -1,61 +0,0 @@
-applications:
-- ceilometer
-classes:
-- service.ceilometer.support
-parameters:
-  _param:
-    keystone_ceilometer_endpoint_type: internalURL
-    openstack_log_appender: false
-    openstack_fluentd_handler_enabled: false
-    openstack_ossyslog_handler_enabled: false
-  ceilometer:
-    server:
-      enabled: true
-      version: ${_param:ceilometer_version}
-      cluster: true
-      secret: ${_param:ceilometer_secret_key}
-      ttl: 86400
-      publisher:
-        default:
-          enabled: true
-          publish_event: true
-          publish_metric: true
-      bind:
-        host: ${_param:cluster_local_address}
-        port: 8777
-      identity:
-        engine: keystone
-        host: ${_param:cluster_vip_address}
-        port: 35357
-        tenant: service
-        user: ceilometer
-        password: ${_param:keystone_ceilometer_password}
-        endpoint_type: ${_param:keystone_ceilometer_endpoint_type}
-      logging:
-        log_appender: ${_param:openstack_log_appender}
-        log_handlers:
-          watchedfile:
-            enabled: true
-          fluentd:
-            enabled: ${_param:openstack_fluentd_handler_enabled}
-          ossyslog:
-            enabled: ${_param:openstack_ossyslog_handler_enabled}
-      message_queue:
-        engine: rabbitmq
-        host: ${_param:cluster_vip_address}
-        port: 5672
-        user: openstack
-        password: ${_param:rabbitmq_openstack_password}
-        virtual_host: '/openstack'
-      database:
-        engine: mongodb
-        members:
-        - host: ${_param:cluster_node01_address}
-          port: 27017
-        - host: ${_param:cluster_node02_address}
-          port: 27017
-        - host: ${_param:cluster_node03_address}
-          port: 27017
-        name: ceilometer
-        user: ceilometer
-        password: ${_param:mongodb_ceilometer_password}
diff --git a/metadata/service/agent/single.yml b/metadata/service/server/cluster/common.yml
similarity index 89%
copy from metadata/service/agent/single.yml
copy to metadata/service/server/cluster/common.yml
index b0a0058..d8ffb2e 100644
--- a/metadata/service/agent/single.yml
+++ b/metadata/service/server/cluster/common.yml
@@ -9,15 +9,15 @@
     openstack_fluentd_handler_enabled: false
     openstack_ossyslog_handler_enabled: false
   ceilometer:
-    agent:
+    server:
       enabled: true
       version: ${_param:ceilometer_version}
+      cluster: true
       secret: ${_param:ceilometer_secret_key}
-      publisher:
-        default:
-          enabled: true
-          publish_event: true
-          publish_metric: true
+      ttl: 86400
+      bind:
+        host: ${_param:cluster_local_address}
+        port: 8777
       identity:
         engine: keystone
         host: ${_param:cluster_vip_address}
diff --git a/metadata/service/server/cluster/init.yml b/metadata/service/server/cluster/init.yml
new file mode 100644
index 0000000..a530b0f
--- /dev/null
+++ b/metadata/service/server/cluster/init.yml
@@ -0,0 +1,24 @@
+applications:
+- ceilometer
+classes:
+- service.ceilometer.server.cluster.common
+parameters:
+  ceilometer:
+    server:
+      publisher:
+        default:
+          enabled: true
+          publish_event: true
+          publish_metric: true
+      database:
+        engine: mongodb
+        members:
+        - host: ${_param:cluster_node01_address}
+          port: 27017
+        - host: ${_param:cluster_node02_address}
+          port: 27017
+        - host: ${_param:cluster_node03_address}
+          port: 27017
+        name: ceilometer
+        user: ceilometer
+        password: ${_param:mongodb_ceilometer_password}
diff --git a/metadata/service/server/single.yml b/metadata/service/server/single.yml
deleted file mode 100644
index e0366eb..0000000
--- a/metadata/service/server/single.yml
+++ /dev/null
@@ -1,56 +0,0 @@
-applications:
-- ceilometer
-classes:
-- service.ceilometer.support
-parameters:
-  _param:
-    keystone_ceilometer_endpoint_type: internalURL
-    openstack_log_appender: false
-    openstack_fluentd_handler_enabled: false
-    openstack_ossyslog_handler_enabled: false
-  ceilometer:
-    server:
-      enabled: true
-      version: ${_param:ceilometer_version}
-      secret: ${_param:ceilometer_secret_key}
-      ttl: 86400
-      publisher:
-        default:
-          enabled: true
-          publish_event: true
-          publish_metric: true
-      bind:
-        host: ${_param:single_address}
-        port: 8777
-      identity:
-        engine: keystone
-        host: ${_param:single_address}
-        port: 35357
-        tenant: service
-        user: ceilometer
-        password: ${_param:keystone_ceilometer_password}
-        endpoint_type: ${_param:keystone_ceilometer_endpoint_type}
-      logging:
-        log_appender: ${_param:openstack_log_appender}
-        log_handlers:
-          watchedfile:
-            enabled: true
-          fluentd:
-            enabled: ${_param:openstack_fluentd_handler_enabled}
-          ossyslog:
-            enabled: ${_param:openstack_ossyslog_handler_enabled}
-      message_queue:
-        engine: rabbitmq
-        host: ${_param:single_address}
-        port: 5672
-        user: openstack
-        password: ${_param:rabbitmq_openstack_password}
-        virtual_host: '/openstack'
-        ha_queues: true
-      database:
-        engine: mongodb
-        host: ${_param:ceilometer_database_host}
-        port: 27017
-        name: ceilometer
-        user: ceilometer
-        password: ${_param:mongodb_ceilometer_password}
diff --git a/metadata/service/agent/cluster.yml b/metadata/service/server/single/common.yml
similarity index 83%
copy from metadata/service/agent/cluster.yml
copy to metadata/service/server/single/common.yml
index 588dc26..bb60d05 100644
--- a/metadata/service/agent/cluster.yml
+++ b/metadata/service/server/single/common.yml
@@ -9,18 +9,17 @@
     openstack_fluentd_handler_enabled: false
     openstack_ossyslog_handler_enabled: false
   ceilometer:
-    agent:
+    server:
       enabled: true
       version: ${_param:ceilometer_version}
       secret: ${_param:ceilometer_secret_key}
-      publisher:
-        default:
-          enabled: true
-          publish_event: true
-          publish_metric: true
+      ttl: 86400
+      bind:
+        host: ${_param:single_address}
+        port: 8777
       identity:
         engine: keystone
-        host: ${_param:cluster_vip_address}
+        host: ${_param:single_address}
         port: 35357
         tenant: service
         user: ceilometer
@@ -37,7 +36,7 @@
             enabled: ${_param:openstack_ossyslog_handler_enabled}
       message_queue:
         engine: rabbitmq
-        host: ${_param:cluster_vip_address}
+        host: ${_param:single_address}
         port: 5672
         user: openstack
         password: ${_param:rabbitmq_openstack_password}
diff --git a/metadata/service/server/single/init.yml b/metadata/service/server/single/init.yml
new file mode 100644
index 0000000..95f193e
--- /dev/null
+++ b/metadata/service/server/single/init.yml
@@ -0,0 +1,19 @@
+applications:
+- ceilometer
+classes:
+- service.ceilometer.server.single.common
+parameters:
+  ceilometer:
+    server:
+      publisher:
+        default:
+          enabled: true
+          publish_event: true
+          publish_metric: true
+      database:
+        engine: mongodb
+        host: ${_param:ceilometer_database_host}
+        port: 27017
+        name: ceilometer
+        user: ceilometer
+        password: ${_param:mongodb_ceilometer_password}