[CORD-3100] Upgrading TOSCA to new ONOS Service format

Change-Id: I0863881a305a78fe918d3558f4475a90c7d3b966
diff --git a/.gitignore b/.gitignore
index 18a8a9f..f3aef51 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,5 +9,6 @@
 voltha/charts
 xos-core/charts
 xos-profiles/rcord-lite/charts
+xos-profiles/mcord/charts
 xos-profiles/base-openstack/charts
 xos-profiles/container-vnf/charts
diff --git a/configs/onos-cord.yaml b/configs/onos-cord.yaml
new file mode 100644
index 0000000..0bca082
--- /dev/null
+++ b/configs/onos-cord.yaml
@@ -0,0 +1,27 @@
+---
+
+# Copyright 2018-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Expose ONOS services using NodePorts, for onos-cord configuration
+#
+# helm install onos -f configs/onos-cord.yaml -n onos-cord
+
+services:
+  sshServiceType: NodePort
+  uiServiceType: NodePort
+  ssh:
+    nodePort: 32101
+  ui:
+    nodePort: 32181
diff --git a/examples/image-tag-candidate.yaml b/examples/image-tag-candidate.yaml
index 321359e..1572a8d 100644
--- a/examples/image-tag-candidate.yaml
+++ b/examples/image-tag-candidate.yaml
@@ -49,4 +49,6 @@
   hippieOSS_synchronizerImage: 'xosproject/hippie-oss-synchronizer:candidate'
 openstack:
   openstack_synchronizerImage: 'xosproject/openstack-synchronizer:candidate'
+vtn-service:
+  vtn_synchronizerImage: 'xosproject/vtn-synchronizer:candidate'
 
diff --git a/examples/imagePullPolicy-IfNotPresent.yaml b/examples/imagePullPolicy-IfNotPresent.yaml
index 62a3c41..bfab79b 100644
--- a/examples/imagePullPolicy-IfNotPresent.yaml
+++ b/examples/imagePullPolicy-IfNotPresent.yaml
@@ -40,4 +40,6 @@
 simpleexampleservice:
   imagePullPolicy: 'IfNotPresent'
 openstack:
+  imagePullPolicy: 'IfNotPresent'
+vtn-service:
   imagePullPolicy: 'IfNotPresent'
\ No newline at end of file
diff --git a/examples/openstack-dev-master-node.yaml b/examples/openstack-dev-master-node.yaml
new file mode 100644
index 0000000..ee8c91f
--- /dev/null
+++ b/examples/openstack-dev-master-node.yaml
@@ -0,0 +1,25 @@
+---
+# Copyright 2018-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# kubectl create -f examples/openstack-dev-master-node.yaml
+
+kind: Service
+apiVersion: v1
+metadata:
+  name: master
+  namespace: default
+spec:
+  type: ExternalName
+  externalName: 172.17.0.1
\ No newline at end of file
diff --git a/xos-profiles/base-openstack/templates/_tosca.tpl b/xos-profiles/base-openstack/templates/_tosca.tpl
index 80faa1b..e580a8a 100644
--- a/xos-profiles/base-openstack/templates/_tosca.tpl
+++ b/xos-profiles/base-openstack/templates/_tosca.tpl
@@ -48,7 +48,9 @@
 
 imports:
    - custom_types/onosapp.yaml
+   - custom_types/onosservice.yaml
    - custom_types/servicegraphconstraint.yaml
+   - custom_types/serviceinstance.yaml
    - custom_types/serviceinstancelink.yaml
    - custom_types/vtnservice.yaml
 
@@ -64,21 +66,57 @@
         must-exist: true
         resync: false
 
-    VTN_ONOS_app:
+    service#ONOS_CORD:
+      type: tosca.nodes.ONOSService
+      properties:
+        name: ONOS_CORD
+        must-exist: true
+
+    # NOTE this is defined in the onos-service TOSCA
+    onos_app#vtn:
       type: tosca.nodes.ONOSApp
       properties:
-          name: VTN_ONOS_app
+          name: vtn
           must-exist: true
 
-    VTN_ONOS_app_VTN_Service:
+    # NOTE this is defined in the vtn-service TOSCA
+    vtn_service_instance:
+      type: tosca.nodes.ServiceInstance
+      properties:
+          name: VTN config
+          must-exist: true
+
+    onos_app#vtn_VTN_Service:
         type: tosca.nodes.ServiceInstanceLink
         requirements:
           - provider_service_instance:
-              node: VTN_ONOS_app
+              node: onos_app#vtn
               relationship: tosca.relationships.BelongsToOne
           - subscriber_service:
               node: service#vtn
               relationship: tosca.relationships.BelongsToOne
+
+    link#vtn_to_vtn-config:
+      type: tosca.nodes.ServiceInstanceLink
+      requirements:
+        - subscriber_service_instance:
+            node: vtn_service_instance
+            relationship: tosca.relationships.BelongsToOne
+        - provider_service_instance:
+            node: onos_app#vtn
+            relationship: tosca.relationships.BelongsToOne
+
+    service_dependency#onos-cord_vtn:
+      type: tosca.nodes.ServiceDependency
+      properties:
+        connect_method: None
+      requirements:
+        - subscriber_service:
+            node: service#ONOS_CORD
+            relationship: tosca.relationships.BelongsToOne
+        - provider_service:
+            node: service#vtn
+            relationship: tosca.relationships.BelongsToOne
 {{- end -}}
 
 {{- define "base-openstack.testTosca" -}}
diff --git a/xos-profiles/base-openstack/templates/tosca-configmap.yaml b/xos-profiles/base-openstack/templates/tosca-configmap.yaml
index 5353086..308fc83 100644
--- a/xos-profiles/base-openstack/templates/tosca-configmap.yaml
+++ b/xos-profiles/base-openstack/templates/tosca-configmap.yaml
@@ -25,14 +25,14 @@
 {{ include "openstack.controllerTosca" .Values | indent 4 }}
   030-openstack-flavors.yaml: |
 {{ include "openstack.flavorTosca" .Values.openstack | indent 4 }}
-  040-vtn-service.yaml: |
+  040-onos-service-vtn-app.yaml: |
+{{ include "onos-service.vtnAppTosca" (index .Values "onos-service") | indent 4 }}
+  041-vtn-service.yaml: |
 {{ include "vtn-service.serviceTosca" (index .Values "vtn-service") | indent 4 }}
   050-openstack-compute.yaml: |
 {{ include "base-openstack.computeNodeTosca" . | indent 4 }}
   060-openstack-networks.yaml: |
 {{ include "openstack.networkTosca" .Values | indent 4 }}
-  070-onos-service-vtn-app.yaml: |
-{{ include "onos-service.vtnAppTosca" (index .Values "onos-service") | indent 4 }}
   300-service-graph.yaml: |
 {{ include "base-openstack.serviceGraphTosca" . | indent 4 }}
 
diff --git a/xos-services/onos-service/templates/_tosca.tpl b/xos-services/onos-service/templates/_tosca.tpl
index ccdfee3..ecaf964 100644
--- a/xos-services/onos-service/templates/_tosca.tpl
+++ b/xos-services/onos-service/templates/_tosca.tpl
@@ -27,19 +27,28 @@
       properties:
           name: ONOS_Fabric
           kind: platform
-          no_container: true
           rest_hostname: onos-fabric-ui
           rest_port: 8181
 
-    Fabric_ONOS_app:
+    onos_app#segmentrouting:
       type: tosca.nodes.ONOSApp
-      requirements:
-          - owner:
-              node: service#ONOS_Fabric
-              relationship: tosca.relationships.BelongsToOne
       properties:
-          name: Fabric_ONOS_app
-          dependencies: org.onosproject.drivers, org.onosproject.openflow, org.onosproject.netcfghostprovider, org.onosproject.segmentrouting, org.onosproject.vrouter
+        name: segmentrouting
+        app_id: org.onosproject.segmentrouting
+      requirements:
+        - owner:
+            node: service#ONOS_Fabric
+            relationship: tosca.relationships.BelongsToOne
+
+    onos_app#vrouter:
+      type: tosca.nodes.ONOSApp
+      properties:
+        name: vrouter
+        app_id: org.onosproject.vrouter
+      requirements:
+        - owner:
+            node: service#ONOS_Fabric
+            relationship: tosca.relationships.BelongsToOne
 {{- end -}}
 
 {{- define "onos-service.vtnAppTosca" -}}
@@ -60,28 +69,28 @@
       properties:
           name: ONOS_CORD
           kind: platform
-          no_container: true
           rest_hostname: onos-cord-ui
           rest_port: 8181
 
-    VTN_ONOS_app:
+    onos_app#cord-config:
       type: tosca.nodes.ONOSApp
-      requirements:
-          - owner:
-              node: service#ONOS_CORD
-              relationship: tosca.relationships.BelongsToOne
       properties:
-          name: VTN_ONOS_app
-          install_dependencies: {{ .cordConfigAppURL }}, {{ .vtnAppURL }}
-          dependencies: org.onosproject.drivers, org.onosproject.drivers.ovsdb, org.onosproject.openflow-base, org.onosproject.ovsdb-base, org.onosproject.dhcp
+        name: cord-config
+        url: {{ .cordConfigAppURL }}
+        version: 1.4.0
+      requirements:
+        - owner:
+            node: service#ONOS_CORD
+            relationship: tosca.relationships.BelongsToOne
 
-    VTN_ONOS_app_autogenerate:
-        type: tosca.nodes.ServiceInstanceAttribute
-        requirements:
-          - service_instance:
-              node: VTN_ONOS_app
-              relationship: tosca.relationships.BelongsToOne
-        properties:
-            name: autogenerate
-            value: vtn-network-cfg
+    onos_app#vtn:
+      type: tosca.nodes.ONOSApp
+      properties:
+        name: vtn
+        url: {{ .vtnAppURL }}
+        version: 1.6.0
+      requirements:
+        - owner:
+            node: service#ONOS_CORD
+            relationship: tosca.relationships.BelongsToOne
 {{- end -}}
diff --git a/xos-services/vtn-service/templates/_tosca.tpl b/xos-services/vtn-service/templates/_tosca.tpl
index 49f0ba8..32f765d 100644
--- a/xos-services/vtn-service/templates/_tosca.tpl
+++ b/xos-services/vtn-service/templates/_tosca.tpl
@@ -18,7 +18,10 @@
 tosca_definitions_version: tosca_simple_yaml_1_0
 
 imports:
-   - custom_types/vtnservice.yaml
+  - custom_types/servicedependency.yaml
+  - custom_types/serviceinstance.yaml
+  - custom_types/serviceinstanceattribute.yaml
+  - custom_types/vtnservice.yaml
 
 description: Configures the VTN ONOS service
 
@@ -43,4 +46,23 @@
           vtnAPIVersion: 2
           controllerPort: onos-cord-openflow:6653
           resync: false
+
+    vtn_service_instance:
+      type: tosca.nodes.ServiceInstance
+      properties:
+          name: VTN config
+      requirements:
+        - owner:
+            node: service#vtn
+            relationship: tosca.relationships.BelongsToOne
+
+    vtn_config:
+        type: tosca.nodes.ServiceInstanceAttribute
+        properties:
+            name: autogenerate
+            value: vtn-network-cfg
+        requirements:
+          - service_instance:
+              node: vtn_service_instance
+              relationship: tosca.relationships.BelongsToOne
 {{- end -}}