Refactoring the mcord-profile

Change-Id: I5e82e920c2720ff09366e7c6491b4ea969d45494
diff --git a/xos-profiles/mcord/templates/_tosca.tpl b/xos-profiles/mcord/templates/_tosca.tpl
index 747027e..8ad427e 100644
--- a/xos-profiles/mcord/templates/_tosca.tpl
+++ b/xos-profiles/mcord/templates/_tosca.tpl
@@ -20,10 +20,6 @@
 imports:
   - custom_types/deployment.yaml
   - custom_types/site.yaml
-  - custom_types/networktemplate.yaml
-  - custom_types/network.yaml
-  - custom_types/networkslice.yaml
-  - custom_types/sitedeployment.yaml
 
 description: set up site and deployment and link them
 
@@ -43,77 +39,74 @@
         name: {{ .Values.cordDeploymentName }}
 {{- end -}}
 
+{{- define "mcord.onosTosca" -}}
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+imports:
+   - custom_types/onosapp.yaml
+   - custom_types/onosservice.yaml
+   - custom_types/serviceinstanceattribute.yaml
+
+description: Configures the VOLTHA ONOS service
+
+topology_template:
+  node_templates:
+
+    service#onos:
+      type: tosca.nodes.ONOSService
+      properties:
+          name: onos
+          kind: data
+          rest_hostname: {{ .onosRestService | quote }}
+          rest_port: 8181
+
+    onos_app#segmentrouting:
+      type: tosca.nodes.ONOSApp
+      properties:
+        name: org.onosproject.segmentrouting
+        app_id: org.onosproject.segmentrouting
+      requirements:
+        - owner:
+            node: service#onos
+            relationship: tosca.relationships.BelongsToOne
+
+    onos_app#netcfghostprovider:
+      type: tosca.nodes.ONOSApp
+      properties:
+        name: org.onosproject.netcfghostprovider
+        app_id: org.onosproject.netcfghostprovider
+      requirements:
+        - owner:
+            node: service#onos
+            relationship: tosca.relationships.BelongsToOne
+
+    onos_app#openflow:
+      type: tosca.nodes.ONOSApp
+      properties:
+        name: org.onosproject.openflow
+        app_id: org.onosproject.openflow
+      requirements:
+        - owner:
+            node: service#onos
+            relationship: tosca.relationships.BelongsToOne
+{{- end -}}
+
 {{- define "mcord.serviceGraphTosca" -}}
 tosca_definitions_version: tosca_simple_yaml_1_0
 
 imports:
-   - custom_types/internetemulatorservice.yaml
-   - custom_types/hssdbservice.yaml
+   - custom_types/fabricservice.yaml
    - custom_types/mcordsubscriberservice.yaml
+   - custom_types/onosservice.yaml
    - custom_types/progranservice.yaml
-   - custom_types/sdncontrollerservice.yaml
-   - custom_types/vepcservice.yaml
-   - custom_types/vhssservice.yaml
-   - custom_types/vmmeservice.yaml
-   - custom_types/vspgwcservice.yaml
-   - custom_types/vspgwuservice.yaml
    - custom_types/servicegraphconstraint.yaml
    - custom_types/servicedependency.yaml
-   - custom_types/serviceinstancelink.yaml
 
 description: Configures the base-openstack service graph
 
 topology_template:
   node_templates:
 
-    service#vmme:
-      type: tosca.nodes.VMMEService
-      properties:
-        name: vmme
-        must-exist: true
-
-    service#vspgwc:
-      type: tosca.nodes.VSPGWCService
-      properties:
-        name: vspgwc
-        must-exist: true
-
-    service#vspgwu:
-      type: tosca.nodes.VSPGWUService
-      properties:
-        name: vspgwu
-        must-exist: true
-
-    service#vhss:
-      type: tosca.nodes.VHSSService
-      properties:
-        name: vhss
-        must-exist: true
-
-    service#hssdb:
-      type: tosca.nodes.HSSDBService
-      properties:
-        name: hssdb
-        must-exist: true
-
-    service#internetemulator:
-      type: tosca.nodes.InternetEmulatorService
-      properties:
-        name: internetemulator
-        must-exist: true
-
-    service#sdncontroller:
-      type: tosca.nodes.SDNControllerService
-      properties:
-        name: sdncontroller
-        must-exist: true
-
-    service#vepc:
-      type: tosca.nodes.VEPCService
-      properties:
-        name: vepc
-        must-exist: true
-
     service#progran:
       type: tosca.nodes.ProgranService
       properties:
@@ -124,450 +117,47 @@
       type: tosca.nodes.MCordSubscriberService
       properties:
         name: mcord
+        must-exist: true
 
-    vmme_vspgwc:
+    service#onos:
+      type: tosca.nodes.ONOSService
+      properties:
+        name: onos
+        must-exist: true
+
+    service#fabric:
+      type: tosca.nodes.FabricService
+      properties:
+        name: fabric
+        must-exist: true
+
+    mcord_progran:
       type: tosca.nodes.ServiceDependency
       properties:
         connect_method: none
       requirements:
         - subscriber_service:
-            node: service#vmme
-            relationship: tosca.relationships.BelongsToOne
-        - provider_service:
-            node: service#vspgwc
-            relationship: tosca.relationships.BelongsToOne
-
-    vmme_vspgwu:
-      type: tosca.nodes.ServiceDependency
-      properties:
-        connect_method: none
-      requirements:
-        - subscriber_service:
-            node: service#vmme
-            relationship: tosca.relationships.BelongsToOne
-        - provider_service:
-            node: service#vspgwu
-            relationship: tosca.relationships.BelongsToOne
-
-    vspgwc_vspgwu:
-      type: tosca.nodes.ServiceDependency
-      properties:
-        connect_method: none
-      requirements:
-        - subscriber_service:
-            node: service#vspgwc
-            relationship: tosca.relationships.BelongsToOne
-        - provider_service:
-            node: service#vspgwu
-            relationship: tosca.relationships.BelongsToOne
-
-    vmme_vhss:
-      type: tosca.nodes.ServiceDependency
-      properties:
-        connect_method: none
-      requirements:
-        - subscriber_service:
-            node: service#vmme
-            relationship: tosca.relationships.BelongsToOne
-        - provider_service:
-            node: service#vhss
-            relationship: tosca.relationships.BelongsToOne
-
-    vhss_hssdb:
-      type: tosca.nodes.ServiceDependency
-      properties:
-        connect_method: none
-      requirements:
-        - subscriber_service:
-            node: service#vhss
-            relationship: tosca.relationships.BelongsToOne
-        - provider_service:
-            node: service#hssdb
-            relationship: tosca.relationships.BelongsToOne
-
-    mcord_vmme:
-      type: tosca.nodes.ServiceDependency
-      properties:
-        connect_method: none
-      requirements:
-        - subscriber_service:
-            node: service#vmme
+            node: service#progran
             relationship: tosca.relationships.BelongsToOne
         - provider_service:
             node: service#mcord
             relationship: tosca.relationships.BelongsToOne
 
+    service_dependency#onos-fabric_fabric:
+      type: tosca.nodes.ServiceDependency
+      properties:
+        connect_method: none
+      requirements:
+        - subscriber_service:
+            node: service#fabric
+            relationship: tosca.relationships.BelongsToOne
+        - provider_service:
+            node: service#onos
+            relationship: tosca.relationships.BelongsToOne
+
     constraints:
       type: tosca.nodes.ServiceGraphConstraint
       properties:
-        constraints: '[ ["vepc", null, "mcord", null, null], [null, null, "progran", null, null], ["hssdb", "vhss", "vmme", null, null], [null, "vspgwc", "sdncontroller","vspgwu", null], [null, null, null, "internetemulator", null] ]'
+        constraints: '[ ["mcord", null, "onos"], ["progran", null, "fabric"] ]'
 {{- end -}}
 
-{{- define "mcord.sliceTosca" -}}
-tosca_definitions_version: tosca_simple_yaml_1_0
-
-imports:
-   - custom_types/internetemulatorservice.yaml
-   - custom_types/hssdbservice.yaml
-   - custom_types/mcordsubscriberservice.yaml
-   - custom_types/progranservice.yaml
-   - custom_types/sdncontrollerservice.yaml
-   - custom_types/vepcservice.yaml
-   - custom_types/vhssservice.yaml
-   - custom_types/vmmeservice.yaml
-   - custom_types/vspgwcservice.yaml
-   - custom_types/vspgwuservice.yaml
-   - custom_types/servicegraphconstraint.yaml
-   - custom_types/servicedependency.yaml
-   - custom_types/serviceinstancelink.yaml
-   - custom_types/site.yaml
-   - custom_types/slice.yaml
-   - custom_types/flavor.yaml
-   - custom_types/image.yaml
-
-description: Configures the M-CORD slices
-
-topology_template:
-  node_templates:
-
-    {{ .Values.cordSiteName }}:
-      type: tosca.nodes.Site
-      properties:
-        name: {{ .Values.cordSiteName }}
-        must-exist: true
-
-    service#vmme:
-      type: tosca.nodes.VMMEService
-      properties:
-        name: vmme
-        must-exist: true
-
-    service#vspgwc:
-      type: tosca.nodes.VSPGWCService
-      properties:
-        name: vspgwc
-        must-exist: true
-
-    service#vspgwu:
-      type: tosca.nodes.VSPGWUService
-      properties:
-        name: vspgwu
-        must-exist: true
-
-    service#vhss:
-      type: tosca.nodes.VHSSService
-      properties:
-        name: vhss
-        must-exist: true
-
-    service#hssdb:
-      type: tosca.nodes.HSSDBService
-      properties:
-        name: hssdb
-        must-exist: true
-
-    service#internetemulator:
-      type: tosca.nodes.InternetEmulatorService
-      properties:
-        name: internetemulator
-        must-exist: true
-
-    service#sdncontroller:
-      type: tosca.nodes.SDNControllerService
-      properties:
-        name: sdncontroller
-        must-exist: true
-
-    m1.small:
-      type: tosca.nodes.Flavor
-      properties:
-        name: m1.small
-        must-exist: true
-
-    m1.large:
-      type: tosca.nodes.Flavor
-      properties:
-        name: m1.large
-        must-exist: true
-
-    m1.xlarge:
-      type: tosca.nodes.Flavor
-      properties:
-        name: m1.xlarge
-        must-exist: true
-
-    image_mme:
-      type: tosca.nodes.Image
-      properties:
-        name: image_mme_{{ .Values.vmme.vnfImageVersion }}
-        must-exist: true
-
-    image_spgwc:
-      type: tosca.nodes.Image
-      properties:
-        name: image_spgwc_{{ .Values.vspgwc.vnfImageVersion }}
-        must-exist: true
-
-    image_spgwu:
-      type: tosca.nodes.Image
-      properties:
-        name: image_spgwu_{{ .Values.vspgwu.vnfImageVersion }}
-        must-exist: true
-
-    image_hss:
-      type: tosca.nodes.Image
-      properties:
-        name: image_hss_{{ .Values.vhss.vnfImageVersion }}
-        must-exist: true
-
-    image_hssdb:
-      type: tosca.nodes.Image
-      properties:
-        name: image_hssdb_{{ .Values.hssdb.vnfImageVersion }}
-        must-exist: true
-
-    image_internetemulator:
-      type: tosca.nodes.Image
-      properties:
-        name: image_internetemulator_{{ .Values.internetemulator.vnfImageVersion }}
-        must-exist: true
-
-    image_sdncontroller:
-      type: tosca.nodes.Image
-      properties:
-        name: image_sdncontroller_{{ .Values.sdncontroller.vnfImageVersion }}
-        must-exist: true
-
-    {{ .Values.cordSiteName }}_vmme:
-      description: vMME Service Slice
-      type: tosca.nodes.Slice
-      properties:
-          name: {{ .Values.cordSiteName }}_vmme
-          default_isolation: vm
-          network: noauto
-      requirements:
-          - site:
-              node: {{ .Values.cordSiteName }}
-              relationship: tosca.relationships.BelongsToOne
-          - service:
-              node: service#vmme
-              relationship: tosca.relationships.BelongsToOne
-          - default_image:
-              node: image_mme
-              relationship: tosca.relationships.BelongsToOne
-          - default_flavor:
-              node: m1.large
-              relationship: tosca.relationships.BelongsToOne
-
-    {{ .Values.cordSiteName }}_vspgwc:
-      description: vSPGW-C slice
-      type: tosca.nodes.Slice
-      properties:
-          name: {{ .Values.cordSiteName }}_vspgwc
-          default_isolation: vm
-          network: noauto
-      requirements:
-          - site:
-              node: {{ .Values.cordSiteName }}
-              relationship: tosca.relationships.BelongsToOne
-          - service:
-              node: service#vspgwc
-              relationship: tosca.relationships.BelongsToOne
-          - default_image:
-              node: image_spgwc
-              relationship: tosca.relationships.BelongsToOne
-          - default_flavor:
-              node: m1.large
-              relationship: tosca.relationships.BelongsToOne
-
-    {{ .Values.cordSiteName }}_vspgwu:
-      description: vSPGW-U slice
-      type: tosca.nodes.Slice
-      properties:
-          name: {{ .Values.cordSiteName }}_vspgwu
-          default_isolation: vm
-          network: noauto
-      requirements:
-          - site:
-              node: {{ .Values.cordSiteName }}
-              relationship: tosca.relationships.BelongsToOne
-          - service:
-              node: service#vspgwu
-              relationship: tosca.relationships.BelongsToOne
-          - default_image:
-              node: image_spgwu
-              relationship: tosca.relationships.BelongsToOne
-          - default_flavor:
-              node: m1.xlarge
-              relationship: tosca.relationships.BelongsToOne
-
-    {{ .Values.cordSiteName }}_vhss:
-      description: vHSS Service Slice
-      type: tosca.nodes.Slice
-      properties:
-          name: {{ .Values.cordSiteName }}_vhss
-          default_isolation: vm
-          network: noauto
-      requirements:
-          - site:
-              node: {{ .Values.cordSiteName }}
-              relationship: tosca.relationships.BelongsToOne
-          - service:
-              node: service#vhss
-              relationship: tosca.relationships.BelongsToOne
-          - default_image:
-              node: image_hss
-              relationship: tosca.relationships.BelongsToOne
-          - default_flavor:
-              node: m1.large
-              relationship: tosca.relationships.BelongsToOne
-
-    {{ .Values.cordSiteName }}_hssdb:
-      description: HSS-DB Service Slice
-      type: tosca.nodes.Slice
-      properties:
-          name: {{ .Values.cordSiteName }}_hssdb
-          default_isolation: vm
-          network: noauto
-      requirements:
-          - site:
-              node: {{ .Values.cordSiteName }}
-              relationship: tosca.relationships.BelongsToOne
-          - service:
-              node: service#hssdb
-              relationship: tosca.relationships.BelongsToOne
-          - default_image:
-              node: image_hssdb
-              relationship: tosca.relationships.BelongsToOne
-          - default_flavor:
-              node: m1.large
-              relationship: tosca.relationships.BelongsToOne
-
-    {{ .Values.cordSiteName }}_internetemulator:
-      description: Internetemulator Service Slice
-      type: tosca.nodes.Slice
-      properties:
-          name: {{ .Values.cordSiteName }}_internetemulator
-          default_isolation: vm
-          network: noauto
-      requirements:
-          - site:
-              node: {{ .Values.cordSiteName }}
-              relationship: tosca.relationships.BelongsToOne
-          - service:
-              node: service#internetemulator
-              relationship: tosca.relationships.BelongsToOne
-          - default_image:
-              node: image_internetemulator
-              relationship: tosca.relationships.BelongsToOne
-          - default_flavor:
-              node: m1.small
-              relationship: tosca.relationships.BelongsToOne
-
-    {{ .Values.cordSiteName }}_sdncontroller:
-      description: SDN controller slice
-      type: tosca.nodes.Slice
-      properties:
-          name: {{ .Values.cordSiteName }}_sdncontroller
-          default_isolation: vm
-          network: noauto
-      requirements:
-          - site:
-              node: {{ .Values.cordSiteName }}
-              relationship: tosca.relationships.BelongsToOne
-          - service:
-              node: service#sdncontroller
-              relationship: tosca.relationships.BelongsToOne
-          - default_image:
-              node: image_sdncontroller
-              relationship: tosca.relationships.BelongsToOne
-          - default_flavor:
-              node: m1.small
-              relationship: tosca.relationships.BelongsToOne
-{{- end -}}
-
-{{- define "mcord.networkTosca" -}}
-tosca_definitions_version: tosca_simple_yaml_1_0
-
-imports:
-   - custom_types/networktemplate.yaml
-   - custom_types/slice.yaml
-   - custom_types/networkslice.yaml
-   - custom_types/network.yaml
-
-description: Configures the M-CORD network templates, vEPC will create the networks
-
-topology_template:
-  node_templates:
-
-    private_template:
-      type: tosca.nodes.NetworkTemplate
-      properties:
-        name: private_template
-        visibility: private
-        translation: none
-        vtn_kind: PRIVATE
-
-    flat_template:
-      type: tosca.nodes.NetworkTemplate
-      properties:
-        name: flat_template
-        visibility: private
-        translation: none
-        vtn_kind: FLAT
-
-# Network Slices for InternetEmulator, not created by EPC
-
-    management:
-      type: tosca.nodes.Network
-      properties:
-        name: management
-        must-exist: true
-
-    {{ .Values.cordSiteName }}_internetemulator:
-      type: tosca.nodes.Slice
-      properties:
-        name: {{ .Values.cordSiteName }}_internetemulator
-        must-exist: true
-
-    {{ .Values.cordSiteName }}_vspgwu:
-      type: tosca.nodes.Slice
-      properties:
-        name: {{ .Values.cordSiteName }}_vspgwu
-        must-exist: true
-
-    sgi_network:
-      type: tosca.nodes.Network
-      properties:
-          name: sgi_network
-          subnet: 115.0.0.0/24
-          permit_all_slices: true
-      requirements:
-          - template:
-              node: private_template
-              relationship: tosca.relationships.BelongsToOne
-          - owner:
-              node: {{ .Values.cordSiteName }}_vspgwu
-              relationship: tosca.relationships.BelongsToOne
-
-    internetemulator_slice_management_network:
-      type: tosca.nodes.NetworkSlice
-      requirements:
-        - network:
-            node: management
-            relationship: tosca.relationships.BelongsToOne
-        - slice:
-            node: {{ .Values.cordSiteName }}_internetemulator
-            relationship: tosca.relationships.BelongsToOne
-
-    internetemulator_slice_sgi_network:
-      type: tosca.nodes.NetworkSlice
-      requirements:
-        - network:
-            node: sgi_network
-            relationship: tosca.relationships.BelongsToOne
-        - slice:
-            node: {{ .Values.cordSiteName }}_internetemulator
-            relationship: tosca.relationships.BelongsToOne
-
-{{- end -}}
diff --git a/xos-profiles/mcord/templates/tosca-configmap.yaml b/xos-profiles/mcord/templates/tosca-configmap.yaml
index f47c2b3..0928483 100644
--- a/xos-profiles/mcord/templates/tosca-configmap.yaml
+++ b/xos-profiles/mcord/templates/tosca-configmap.yaml
@@ -19,31 +19,15 @@
 metadata:
   name: mcord-tosca
 data:
-  010-fixtures.yaml: |
+  010-onos-service.yaml: |
+{{ include "mcord.onosTosca" .Values | indent 4 }}
+  020-fabric-service.yaml: |
+{{ include "fabric.serviceTosca" .Values.fabric | indent 4 }}
+  030-fixtures.yaml: |
 {{ include "mcord.fixtureTosca" . | indent 4 }}
-  020-vspgwu-service.yaml: |
-{{ include "vspgwu.serviceTosca" .Values.vspgwu | indent 4 }}
-  030-vspgwc-service.yaml: |
-{{ include "vspgwc.serviceTosca" .Values.vspgwc | indent 4 }}
-  040-vmme-service.yaml: |
-{{ include "vmme.serviceTosca" .Values.vmme | indent 4 }}
-  050-vhss-service.yaml: |
-{{ include "vhss.serviceTosca" .Values.vhss | indent 4 }}
-  060-hssdb-service.yaml: |
-{{ include "hssdb.serviceTosca" .Values.hssdb | indent 4 }}
-  070-internetemulator-service.yaml: |
-{{ include "internetemulator.serviceTosca" .Values.internetemulator | indent 4 }}
-  080-progran-service.yaml: |
+  040-progran-service.yaml: |
 {{ include "progran.serviceTosca" .Values.progran | indent 4 }}
-  090-sdncontroller-service.yaml: |
-{{ include "sdncontroller.serviceTosca" .Values.sdncontroller | indent 4 }}
   100-mcord-subscriber-service.yaml: |
 {{ include "mcord-subscriber.serviceTosca" (index .Values "mcord-subscriber") | indent 4 }}
-  110-epc-service.yaml: |
-{{ include "epc-service.serviceTosca" (index .Values "epc-service") | indent 4 }}
   300-service-graph.yaml: |
 {{ include "mcord.serviceGraphTosca" . | indent 4 }}
-  310-mcord-slices.yaml: |
-{{ include "mcord.sliceTosca" . | indent 4 }}
-  320-mcord-networks.yaml: |
-{{ include "mcord.networkTosca" . | indent 4 }}
diff --git a/xos-profiles/mcord/templates/tosca-job.yaml b/xos-profiles/mcord/templates/tosca-job.yaml
index ed6ae54..5f72ce2 100644
--- a/xos-profiles/mcord/templates/tosca-job.yaml
+++ b/xos-profiles/mcord/templates/tosca-job.yaml
@@ -35,8 +35,8 @@
       restartPolicy: OnFailure
       containers:
         - name: {{ .Chart.Name }}-tosca-loader
-          image: {{ .Values.global.registry }}{{ .Values.image.repository }}:{{ tpl .Values.image.tag . }}
-          imagePullPolicy: {{ .Values.image.pullPolicy }}
+          image: {{ .Values.global.registry }}{{ .Values.images.tosca_loader.repository }}:{{ tpl .Values.images.tosca_loader.tag . }}
+          imagePullPolicy: {{ .Values.images.tosca_loader.pullPolicy }}
           env:
             - name: XOS_USER
               value: {{ .Values.xosAdminUser }}