CORD-871: Migrate monitoring service to new CORD build infrastructure - phase1

Usage of Monitoring Service build commands in new build system:
----------------------------------------------
Add the below alias to your bashrc file and source it.
CiaB platform-install brings up monitoring-service synchronizer by default.
Once the synchronizer is completely operational, run 'cord-monitoringservice' on your terminal.

alias deploy-monitoringservice="pushd /opt/cord/build/platform-install; ansible-playbook -i inventory/rcord --extra-vars @../genconfig/config.yml onboard-monitoringservice-playbook.yml"
alias instantiate-monitoringservice="pushd /opt/cord/build/platform-install; ansible-playbook -i inventory/rcord --extra-vars @../genconfig/config.yml instantiate-monitoringservice-playbook.yml"
alias generate-install-infra-agents-config=“ansible-playbook -i /etc/maas/ansible/pod-inventory --extra-vars=@/opt/cord/build/genconfig/config.yml monitoringagent-infra-install-config.yml"
alias install-infra-agents=“ansible-playbook -i /opt/cord_profile/monitoringagent_install.hosts monitoringagent-infra-install.yml"
alias generate-enable-infra-monitoring-config=“ansible-playbook -i /etc/maas/ansible/pod-inventory --extra-vars=@/opt/cord/build/genconfig/config.yml monitoringservice-enable-inframonitoring-config.yml"
alias enable-infra-monitoring=“ansible-playbook -i inventory/rcord --extra-vars @../genconfig/config.yml monitoringservice-enable-inframonitoring.yml"
alias test-monitoringservice-initial=“ansible-playbook -i inventory/rcord  --extra-vars @../genconfig/config.yml monitoringservice-test-initial.yaml"
alias test-monitoringservice-inframetrics=“ansible-playbook -i inventory/rcord --extra-vars @../genconfig/config.yml monitoringservice-test-inframetrics.yaml"
alias test-monitoringservice-vsgmetrics=“ansible-playbook -i inventory/rcord --extra-vars @../genconfig/config.yml monitoringservice-test-vsgmetrics.yaml"
alias test-monitoringservice-exampleservicemetrics=“ansible-playbook -i inventory/rcord --extra-vars @../genconfig/config.yml monitoringservice-test-exampleservicemetrics.yaml"

alias cord-monitoringservice="echo \"*******NOTE:Ensure monitoring service synchronizer is completely up and running********\"; instantiate-monitoringservice; test-monitoringservice-initial"
alias install-inframonitoring-agent="generate-install-infra-agents-config; install-infra-agents"
alias enable-inframonitoring="generate-enable-infra-monitoring-config; enable-infra-monitoring; test-monitoringservice-inframetrics"

Change-Id: I9895dd1107de50e9817325f750f0608d9eb72be5
diff --git a/roles/monitoringservice-enable-inframonitoring-config/templates/inframonitoring.yaml.j2 b/roles/monitoringservice-enable-inframonitoring-config/templates/inframonitoring.yaml.j2
new file mode 100644
index 0000000..a2b55af
--- /dev/null
+++ b/roles/monitoringservice-enable-inframonitoring-config/templates/inframonitoring.yaml.j2
@@ -0,0 +1,74 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Auto generated file to enable monitoring of infrastructure services (OpenStack, ONOS...etc).
+
+imports:
+   - custom_types/xos.yaml
+   - custom_types/monitoring_tosca_types.yaml
+
+topology_template:
+  node_templates:
+    service_ceilometer:
+      type: tosca.nodes.CeilometerService
+      properties:
+          no-create: true
+          no-update: true
+          no-delete: true
+
+    onos_monitoring_agent_head_node:
+      description: Monitoring agent info
+      type: tosca.nodes.InfraMonitoringAgentInfo
+      properties:
+          start_url: http://ceilometer-1.cord.lab:5004/monitoring/agent/onos/start
+          start_url_json_data: { get_artifact: [ SELF, onos_monitoring_service_endpoints, LOCAL_FILE] }
+          stop_url: http://ceilometer-1.cord.lab:5004/monitoring/agent/onos/stop
+      artifacts:
+          onos_monitoring_service_endpoints: /opt/cord_profile/onos_monitoring_service_endpoints.json
+
+    os_monitoring_agent_head_node:
+      description: Openstack Monitoring agent info
+      type: tosca.nodes.InfraMonitoringAgentInfo
+      properties:
+          start_url: http://ceilometer-1.cord.lab:5004/monitoring/agent/openstack/start
+          stop_url: http://ceilometer-1.cord.lab:5004/monitoring/agent/openstack/stop
+
+# OpenStack compute nodes
+{% for node in groups["compute"] %}
+    os_monitoring_agent_cp_{{ loop.index }}:
+      description: Openstack Monitoring agent info for {{ node }}
+      type: tosca.nodes.InfraMonitoringAgentInfo
+      properties:
+          start_url: http://{{ node }}:5004/monitoring/agent/openstack/start
+          stop_url: http://{{ node }}:5004/monitoring/agent/openstack/stop
+{% endfor %}
+
+    os_monitoring_collector_plugin:
+      description: Infra Monitoring collector plugin info
+      type: tosca.nodes.MonitoringCollectorPluginInfo
+      properties:
+          plugin_folder_path: /opt/xos/synchronizers/monitoring/ceilometer/ceilometer-plugins/network/ext_services/openstack_infra/
+          plugin_rabbit_exchange: openstack_infra
+ 
+    openstack_monitoring_publisher_tenant:
+      description: OpenStack Monitoring Publisher Tenant
+      type: tosca.nodes.OpenStackMonitoringPublisher
+      requirements:
+          - provider_service:
+              node: service_ceilometer
+              relationship: tosca.relationships.TenantOfService
+          - monitoring_collector_plugin:
+              node: os_monitoring_collector_plugin
+              relationship: tosca.relationships.ProvidesMonitoringCollectorPluginInfo
+          - monitoring_agent_1:
+              node: os_monitoring_agent_head_node
+              relationship: tosca.relationships.ProvidesInfraMonitoringAgentInfo
+          - monitoring_agent_2:
+              node: onos_monitoring_agent_head_node
+              relationship: tosca.relationships.ProvidesInfraMonitoringAgentInfo
+{% set count = 2 %}
+{% for node in groups["compute"] %}
+          - monitoring_agent_{{ count + loop.index }}:
+              node: os_monitoring_agent_cp_{{ loop.index }}
+              relationship: tosca.relationships.ProvidesInfraMonitoringAgentInfo
+{% endfor %}
+
diff --git a/roles/monitoringservice-enable-inframonitoring-config/templates/onos_monitoring_service_endpoints.json.j2 b/roles/monitoringservice-enable-inframonitoring-config/templates/onos_monitoring_service_endpoints.json.j2
new file mode 100644
index 0000000..af9ad84
--- /dev/null
+++ b/roles/monitoringservice-enable-inframonitoring-config/templates/onos_monitoring_service_endpoints.json.j2
@@ -0,0 +1,6 @@
+{
+    "resources" : [
+        "onos://onos-cord.cord.lab:8182?auth=basic&user=onos&password=rocks&scheme=http",
+        "onos://onos-fabric.cord.lab:8181?auth=basic&user=onos&password=rocks&scheme=http"
+     ]
+}