monitoing publisher tenant changes

Includes make file changes to install monitoring agent on
ceilometer running nodes.

Change-Id: I751cb7e2bdc3e709a0b365415a6b8813cc9fa795
diff --git a/cord-pod/Makefile b/cord-pod/Makefile
index f03e831..14b1a5e 100644
--- a/cord-pod/Makefile
+++ b/cord-pod/Makefile
@@ -114,6 +114,20 @@
 	bash $(COMMON_DIR)/rebuild.sh $(XOS_BOOTSTRAP_PORT) monitoring
 	bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos
 
+install-inframonitoring-agents:
+	bash $(SERVICE_DIR)/monitoring/xos/synchronizer/ceilometer/monitoring_agent/install_monitoring_ceilometer.sh
+
+enable-inframonitoring: inframonitoring_yaml
+	$(RUN_TOSCA) inframonitoring.yaml
+
+enable-vsgmonitoring:
+	$(RUN_TOSCA) vsgmonitoring.yaml
+
+enable-exampleservicemonitoring:
+	$(RUN_TOSCA) exampleservicemonitoring.yaml
+
+inframonitoring_yaml:
+	export SETUPDIR=$(CONFIG_DIR); bash ./make-inframonitoring-yaml.sh
+
 virtualbng_json:
 	export SETUPDIR=$(CONFIG_DIR); bash ./make-virtualbng-json.sh
-
diff --git a/cord-pod/exampleservicemonitoring.yaml b/cord-pod/exampleservicemonitoring.yaml
new file mode 100644
index 0000000..9d8a20d
--- /dev/null
+++ b/cord-pod/exampleservicemonitoring.yaml
@@ -0,0 +1,36 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Setup CORD-related services -- vOLT, vCPE, vBNG.
+
+imports:
+   - custom_types/xos.yaml
+   - custom_types/monitoring_tosca_types.yaml
+   - custom_types/exampleservice.yaml
+
+topology_template:
+  node_templates:
+    service_ceilometer:
+      type: tosca.nodes.CeilometerService
+      properties:
+          no-create: true
+          no-update: true
+          no-delete: true
+
+    service#exampleservice:
+      type: tosca.nodes.ExampleService
+      properties:
+          no-create: true
+          no-update: true
+          no-delete: true
+
+    exampleservice_monitoring_publisher_tenant:
+      description: Monitoring Publisher Tenant for Example service
+      type: tosca.nodes.UserServiceMonitoringPublisher
+      requirements:
+          - provider_service:
+              node: service_ceilometer
+              relationship: tosca.relationships.TenantOfService
+          - target_service:
+              node: service#exampleservice
+              relationship: tosca.relationships.PublishesMonitoringData
+
diff --git a/cord-pod/make-inframonitoring-yaml.sh b/cord-pod/make-inframonitoring-yaml.sh
new file mode 100644
index 0000000..2140931
--- /dev/null
+++ b/cord-pod/make-inframonitoring-yaml.sh
@@ -0,0 +1,101 @@
+FN=$SETUPDIR/inframonitoring.yaml
+
+rm -f $FN
+
+cat >> $FN <<EOF
+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: /root/setup/onos_monitoring_service_endpoints.json
+
+    onos_monitoring_publisher_tenant:
+      description: ONOS Monitoring Publisher Tenant
+      type: tosca.nodes.ONOSMonitoringPublisher
+      requirements:
+          - provider_service:
+              node: service_ceilometer
+              relationship: tosca.relationships.TenantOfService
+          - monitoring_agent_1:
+              node: onos_monitoring_agent_head_node
+              relationship: tosca.relationships.ProvidesInfraMonitoringAgentInfo
+
+    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
+
+EOF
+
+NODES=$( bash -c "source $SETUPDIR/admin-openrc.sh ; nova host-list" |grep compute|awk '{print $2}' )
+I=0
+for NODE in $NODES; do
+    echo $I - $NODE
+    I=$(( I+1 ))
+    cat >> $FN <<EOF
+    os_monitoring_agent_cp_${I}:
+      description: Openstack Monitoring agent info for ${NODE}
+      type: tosca.nodes.InfraMonitoringAgentInfo
+      properties:
+          start_url: http://$NODE.cord.lab:5004/monitoring/agent/openstack/start
+          stop_url: http://$NODE.cord.lab:5004/monitoring/agent/openstack/stop
+
+EOF
+done
+
+cat >> $FN <<EOF
+    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
+EOF
+I=0
+for NODE in $NODES; do
+          I=$(( I+1 ))
+          J=$(( I+1 ))
+          cat >> $FN <<EOF
+          - monitoring_agent_${J}:
+              node: os_monitoring_agent_cp_${I}
+              relationship: tosca.relationships.ProvidesInfraMonitoringAgentInfo
+EOF
+done
+
diff --git a/cord-pod/monitoringservice.yaml b/cord-pod/monitoringservice.yaml
index b076057..c8c778a 100644
--- a/cord-pod/monitoringservice.yaml
+++ b/cord-pod/monitoringservice.yaml
@@ -4,139 +4,7 @@
 
 imports:
    - custom_types/xos.yaml
-
-node_types:
-    tosca.nodes.SFlowService:
-        derived_from: tosca.nodes.Root
-        description: >
-            XOS SFlow Collection Service
-        capabilities:
-            scalable:
-                type: tosca.capabilities.Scalable
-            service:
-                type: tosca.capabilities.xos.Service
-        properties:
-            no-delete:
-                type: boolean
-                default: false
-                description: Do not allow Tosca to delete this object
-            no-create:
-                type: boolean
-                default: false
-                description: Do not allow Tosca to create this object
-            no-update:
-                type: boolean
-                default: false
-                description: Do not allow Tosca to update this object
-            kind:
-                type: string
-                default: generic
-                description: Type of service.
-            view_url:
-                type: string
-                required: false
-                description: URL to follow when icon is clicked in the Service Directory.
-            icon_url:
-                type: string
-                required: false
-                description: ICON to display in the Service Directory.
-            enabled:
-                type: boolean
-                default: true
-            published:
-                type: boolean
-                default: true
-                description: If True then display this Service in the Service Directory.
-            public_key:
-                type: string
-                required: false
-                description: Public key to install into Instances to allows Services to SSH into them.
-            private_key_fn:
-                type: string
-                required: false
-                description: Location of private key file
-            versionNumber:
-                type: string
-                required: false
-                description: Version number of Service.
-            sflow_port:
-              type: integer
-              required: false
-              default: 6343
-              description: sFlow listening port
-            sflow_api_port:
-              type: integer
-              required: false
-              default: 33333
-              description: sFlow publish subscribe api listening port
-
-    tosca.nodes.CeilometerService:
-        derived_from: tosca.nodes.Root
-        description: >
-            XOS Ceilometer Service
-        capabilities:
-            scalable:
-                type: tosca.capabilities.Scalable
-            service:
-                type: tosca.capabilities.xos.Service
-        properties:
-            no-delete:
-                type: boolean
-                default: false
-                description: Do not allow Tosca to delete this object
-            no-create:
-                type: boolean
-                default: false
-                description: Do not allow Tosca to create this object
-            no-update:
-                type: boolean
-                default: false
-                description: Do not allow Tosca to update this object
-            kind:
-                type: string
-                default: generic
-                description: Type of service.
-            view_url:
-                type: string
-                required: false
-                description: URL to follow when icon is clicked in the Service Directory.
-            icon_url:
-                type: string
-                required: false
-                description: ICON to display in the Service Directory.
-            enabled:
-                type: boolean
-                default: true
-            published:
-                type: boolean
-                default: true
-                description: If True then display this Service in the Service Directory.
-            public_key:
-                type: string
-                required: false
-                description: Public key to install into Instances to allows Services to SSH into them.
-            private_key_fn:
-                type: string
-                required: false
-                description: Location of private key file
-            versionNumber:
-                type: string
-                required: false
-                description: Version number of Service.
-            ceilometer_pub_sub_url:
-                type: string
-                required: false
-                description: REST URL of ceilometer PUB/SUB component
-
-    tosca.nodes.CeilometerTenant:
-        derived_from: tosca.nodes.Root
-        description: >
-            CORD: A Tenant of the Ceilometer Service.
-        properties:
-            kind:
-                type: string
-                default: generic
-                description: Kind of tenant
+   - custom_types/monitoring_tosca_types.yaml
 
 topology_template:
   node_templates:
diff --git a/cord-pod/monitoringtenant.yaml b/cord-pod/monitoringtenant.yaml
index 37cda64..c6d5f14 100644
--- a/cord-pod/monitoringtenant.yaml
+++ b/cord-pod/monitoringtenant.yaml
@@ -4,140 +4,7 @@
 
 imports:
    - custom_types/xos.yaml
-
-node_types:
-#FIXME: See if we can avoid redefining the below types again in this file by moving to common file
-    tosca.nodes.SFlowService:
-        derived_from: tosca.nodes.Root
-        description: >
-            XOS SFlow Collection Service
-        capabilities:
-            scalable:
-                type: tosca.capabilities.Scalable
-            service:
-                type: tosca.capabilities.xos.Service
-        properties:
-            no-delete:
-                type: boolean
-                default: false
-                description: Do not allow Tosca to delete this object
-            no-create:
-                type: boolean
-                default: false
-                description: Do not allow Tosca to create this object
-            no-update:
-                type: boolean
-                default: false
-                description: Do not allow Tosca to update this object
-            kind:
-                type: string
-                default: generic
-                description: Type of service.
-            view_url:
-                type: string
-                required: false
-                description: URL to follow when icon is clicked in the Service Directory.
-            icon_url:
-                type: string
-                required: false
-                description: ICON to display in the Service Directory.
-            enabled:
-                type: boolean
-                default: true
-            published:
-                type: boolean
-                default: true
-                description: If True then display this Service in the Service Directory.
-            public_key:
-                type: string
-                required: false
-                description: Public key to install into Instances to allows Services to SSH into them.
-            private_key_fn:
-                type: string
-                required: false
-                description: Location of private key file
-            versionNumber:
-                type: string
-                required: false
-                description: Version number of Service.
-            sflow_port:
-              type: integer
-              required: false
-              default: 6343
-              description: sFlow listening port
-            sflow_api_port:
-              type: integer
-              required: false
-              default: 33333
-              description: sFlow publish subscribe api listening port
-
-    tosca.nodes.CeilometerService:
-        derived_from: tosca.nodes.Root
-        description: >
-            XOS Ceilometer Service
-        capabilities:
-            scalable:
-                type: tosca.capabilities.Scalable
-            service:
-                type: tosca.capabilities.xos.Service
-        properties:
-            no-delete:
-                type: boolean
-                default: false
-                description: Do not allow Tosca to delete this object
-            no-create:
-                type: boolean
-                default: false
-                description: Do not allow Tosca to create this object
-            no-update:
-                type: boolean
-                default: false
-                description: Do not allow Tosca to update this object
-            kind:
-                type: string
-                default: generic
-                description: Type of service.
-            view_url:
-                type: string
-                required: false
-                description: URL to follow when icon is clicked in the Service Directory.
-            icon_url:
-                type: string
-                required: false
-                description: ICON to display in the Service Directory.
-            enabled:
-                type: boolean
-                default: true
-            published:
-                type: boolean
-                default: true
-                description: If True then display this Service in the Service Directory.
-            public_key:
-                type: string
-                required: false
-                description: Public key to install into Instances to allows Services to SSH into them.
-            private_key_fn:
-                type: string
-                required: false
-                description: Location of private key file
-            versionNumber:
-                type: string
-                required: false
-                description: Version number of Service.
-            ceilometer_pub_sub_url:
-                type: string
-                required: false
-                description: REST URL of ceilometer PUB/SUB component
-
-    tosca.nodes.CeilometerTenant:
-        derived_from: tosca.nodes.Root
-        description: >
-            CORD: A Tenant of the Ceilometer Service.
-        properties:
-            kind:
-                type: string
-                default: generic
-                description: Kind of tenant
+   - custom_types/monitoring_tosca_types.yaml
 
 topology_template:
   node_templates:
diff --git a/cord-pod/onos_monitoring_service_endpoints.json b/cord-pod/onos_monitoring_service_endpoints.json
new file mode 100644
index 0000000..59cf783
--- /dev/null
+++ b/cord-pod/onos_monitoring_service_endpoints.json
@@ -0,0 +1,6 @@
+{
+    "resources" : [
+        "onos://onos-cord.cord.lab:8181?auth=basic&user=onos&password=rocks&scheme=http",
+        "onos://onos-fabric.cord.lab:8181?auth=basic&user=onos&password=rocks&scheme=http"
+     ]
+}
diff --git a/cord-pod/vsgmonitoring.yaml b/cord-pod/vsgmonitoring.yaml
new file mode 100644
index 0000000..bed81d9
--- /dev/null
+++ b/cord-pod/vsgmonitoring.yaml
@@ -0,0 +1,34 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Setup CORD-related services -- vOLT, vCPE, vBNG.
+
+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
+
+    service#vsg:
+      type: tosca.nodes.VSGService
+      properties:
+          no-create: true
+          no-update: true
+          no-delete: true
+
+    vsg_monitoring_publisher_tenant:
+      description: vSG Monitoring Publisher Tenant
+      type: tosca.nodes.UserServiceMonitoringPublisher
+      requirements:
+          - provider_service:
+              node: service_ceilometer
+              relationship: tosca.relationships.TenantOfService
+          - target_service:
+              node: service#vsg
+              relationship: tosca.relationships.PublishesMonitoringData