Merge "FIXes in Makefile for monitoring service deployment"
diff --git a/cord-pod/Makefile b/cord-pod/Makefile
index fce354b..78054ad 100644
--- a/cord-pod/Makefile
+++ b/cord-pod/Makefile
@@ -117,8 +117,9 @@
 	bash ../common/wait_for_onboarding_ready.sh 81 xos
 	bash ../common/wait_for_xos_port.sh 80
 
-cord-monitoringservice: ceilometer_custom_images cord onboard-monitoringservice
+cord-monitoringservice: ceilometer_custom_images onboard-monitoringservice
 	$(RUN_TOSCA) monitoringservice.yaml
+	$(RUN_TOSCA) monitoringtenant.yaml
 
 onboard-monitoringservice: download-monitoringservice
 	sudo cp id_rsa key_import/monitoringservice_rsa
@@ -168,15 +169,19 @@
 	./cleanup.sh
 	bash -c "source ./admin-openrc.sh; nova list --all-tenants; neutron net-list"
 
-ceilometer_custom_images: images/ceilometer-trusty-server-multi-nic.img
-	bash -c "source ./admin-openrc.sh; glance image-show ceilometer-trusty-server-multi-nic || glance image-create --name ceilometer-trusty-server-multi-nic --disk-format qcow2 --file ./images/ceilometer-trusty-server-multi-nic.img --container-format bare"
+ceilometer_custom_images: images/ceilometer-service-trusty-server-multi-nic.img images/ceilometer-trusty-server-multi-nic.img
+	#TODO: Add logic for service VM custom image (ceilometer-service-trusty-server-multi-nic)
+	bash -c "source ./admin-openrc.sh; glance image-show ceilometer-trusty-server-multi-nic || glance image-create --name ceilometer-trusty-server-multi-nic --disk-format qcow2 --file ./images/ceilometer-trusty-server-multi-nic.compressed.qcow2 --container-format bare"
 
 vsg_custom_images: images/vsg-1.0.img
 	bash -c "source ./admin-openrc.sh; glance image-show vsg-1.0 || glance image-create --name vsg-1.0 --disk-format qcow2 --file ./images/vsg-1.0.img --container-format bare"
 
 images/ceilometer-trusty-server-multi-nic.img: images
-	wget http://www.vicci.org/cord/ceilometer-trusty-server-multi-nic.compressed.qcow2 -P ./images
-	mv ./images/ceilometer-trusty-server-multi-nic.compressed.qcow2 ./images/ceilometer-trusty-server-multi-nic.img
+	bash -c "source ../setup/admin-openrc.sh; glance image-show ceilometer-trusty-server-multi-nic || wget http://www.vicci.org/cord/ceilometer-trusty-server-multi-nic.compressed.qcow2 -P ./images"
+
+images/ceilometer-service-trusty-server-multi-nic.img: images
+	#TODO: Add logic for service VM custom image (ceilometer-service-trusty-server-multi-nic) once image is uploaded into vicci portal
+	#bash -c "source ../setup/admin-openrc.sh; glance image-show ceilometer-service-trusty-server-multi-nic || wget http://www.vicci.org/cord/ceilometer-service-trusty-server-multi-nic.compressed.qcow2 -P ./images"
 
 images/vsg-1.0.img: images
 	wget http://www.vicci.org/cord/vsg-1.0.img -P ./images
diff --git a/cord-pod/monitoringservice.yaml b/cord-pod/monitoringservice.yaml
index da9c01d..b076057 100644
--- a/cord-pod/monitoringservice.yaml
+++ b/cord-pod/monitoringservice.yaml
@@ -16,6 +16,18 @@
             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
@@ -68,6 +80,18 @@
             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
@@ -172,6 +196,9 @@
     ceilometer-trusty-server-multi-nic:
       type: tosca.nodes.Image
 
+    ceilometer-service-trusty-server-multi-nic:
+      type: tosca.nodes.Image
+
     m1.small:
       type: tosca.nodes.Flavor
 
@@ -195,6 +222,24 @@
               node: m1.small
               relationship: tosca.relationships.DefaultFlavor
 
+    # Virtual machines
+    ceilometer_service_instance:
+      type: tosca.nodes.Compute
+      capabilities:
+        # Host container properties
+        host:
+         properties:
+           num_cpus: 1
+           disk_size: 20 GB
+           mem_size: 2 GB
+      requirements:
+          - slice:
+                node: mysite_ceilometer
+                relationship: tosca.relationships.MemberOfSlice
+          - image:
+                node: ceilometer-service-trusty-server-multi-nic
+                relationship: tosca.relationships.UsesImage
+
 #    mysite_sflow:
 #      description: Slice for sFlow service
 #      type: tosca.nodes.Slice
@@ -206,13 +251,17 @@
 #              node: mysite
 #              relationship: tosca.relationships.MemberOfSite
 
-    my_ceilometer_tenant:
-      description: Ceilometer Service default Tenant
-      type: tosca.nodes.CeilometerTenant
-      requirements:
-          - provider_service:
-              node: service_ceilometer
-              relationship: tosca.relationships.MemberOfService
+# MOVING this section to monitoringtenant.yaml
+#    my_ceilometer_tenant:
+#      description: Ceilometer Service default Tenant
+#      type: tosca.nodes.CeilometerTenant
+#      requirements:
+#          - provider_service:
+#              node: service_ceilometer
+#              relationship: tosca.relationships.MemberOfService
+#          - dependency:
+#              node: ceilometer_service_instance
+#              relationship: tosca.relationships.DependsOn
        
     # Virtual machines
 #    sflow_service_instance:
@@ -237,27 +286,28 @@
 #                node: mysite_sflow
 #                relationship: tosca.relationships.MemberOfSlice
 
-    Ceilometer:
-      type: tosca.nodes.DashboardView
-      properties:
-          url: template:xosCeilometerDashboard
-    Tenant:
-      type: tosca.nodes.DashboardView
-      properties:
-          no-create: true
-          no-update: true
-          no-delete: true
-
-    padmin@vicci.org:
-      type: tosca.nodes.User
-      properties:
-          firstname: XOS
-          lastname: admin
-          is_admin: true
-      requirements:
-          - tenant_dashboard:
-              node: Tenant
-              relationship: tosca.relationships.UsesDashboard
-          - ceilometer_dashboard:
-              node: Ceilometer
-              relationship: tosca.relationships.UsesDashboard
+# MOVING the below sections to monitoringtenant.yaml
+#    Ceilometer:
+#      type: tosca.nodes.DashboardView
+#      properties:
+#          url: template:xosCeilometerDashboard
+#    Tenant:
+#      type: tosca.nodes.DashboardView
+#      properties:
+#          no-create: true
+#          no-update: true
+#          no-delete: true
+#
+#    padmin@vicci.org:
+#      type: tosca.nodes.User
+#      properties:
+#          firstname: XOS
+#          lastname: admin
+#          is_admin: true
+#      requirements:
+#          - tenant_dashboard:
+#              node: Tenant
+#              relationship: tosca.relationships.UsesDashboard
+#          - ceilometer_dashboard:
+#              node: Ceilometer
+#              relationship: tosca.relationships.UsesDashboard
diff --git a/cord-pod/monitoringtenant.yaml b/cord-pod/monitoringtenant.yaml
new file mode 100644
index 0000000..37cda64
--- /dev/null
+++ b/cord-pod/monitoringtenant.yaml
@@ -0,0 +1,182 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Setup CORD-related services -- vOLT, vCPE, vBNG.
+
+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
+
+topology_template:
+  node_templates:
+    service_ceilometer:
+      type: tosca.nodes.CeilometerService
+      properties:
+          no-create: true
+          no-update: true
+          no-delete: true
+
+    my_ceilometer_tenant:
+      description: Ceilometer Service default Tenant
+      type: tosca.nodes.CeilometerTenant
+      requirements:
+          - provider_service:
+              node: service_ceilometer
+              relationship: tosca.relationships.MemberOfService
+       
+    Ceilometer:
+      type: tosca.nodes.DashboardView
+      properties:
+          url: template:xosCeilometerDashboard
+    Tenant:
+      type: tosca.nodes.DashboardView
+      properties:
+          no-create: true
+          no-update: true
+          no-delete: true
+
+    padmin@vicci.org:
+      type: tosca.nodes.User
+      properties:
+          firstname: XOS
+          lastname: admin
+          is_admin: true
+      requirements:
+          - tenant_dashboard:
+              node: Tenant
+              relationship: tosca.relationships.UsesDashboard
+          - ceilometer_dashboard:
+              node: Ceilometer
+              relationship: tosca.relationships.UsesDashboard