Add RCORD service to the profile

Change-Id: I265726e47c0b5b82aec9fa12287abe6daf911a00
diff --git a/xos-profiles/rcord-lite/templates/configmap.yaml b/xos-profiles/rcord-lite/templates/rcord-models-configmap.yaml
similarity index 64%
copy from xos-profiles/rcord-lite/templates/configmap.yaml
copy to xos-profiles/rcord-lite/templates/rcord-models-configmap.yaml
index b9da88e..e32b876 100644
--- a/xos-profiles/rcord-lite/templates/configmap.yaml
+++ b/xos-profiles/rcord-lite/templates/rcord-models-configmap.yaml
@@ -17,13 +17,7 @@
 apiVersion: v1
 kind: ConfigMap
 metadata:
-  name: rcord-lite-tosca
+  name: rcord-lite-config
 data:
-  010-fixtures.yaml: |
-{{ toYaml .Values.toscaRecipes.fixtures | indent 4 }}
-  020-deployment.yaml: |
-{{ toYaml .Values.toscaRecipes.deployment | indent 4 }}
-  030-fabric-service.yaml: |
-{{ toYaml .Values.toscaRecipes.fabricService | indent 4 }}
-  040-cord-services.yaml: |
-{{ toYaml .Values.toscaRecipes.cordServices | indent 4 }}
+  serviceConfig: |
+{{ toYaml .Values.serviceConfig | indent 4 }}
diff --git a/xos-profiles/rcord-lite/templates/rcord-models-deployment.yaml b/xos-profiles/rcord-lite/templates/rcord-models-deployment.yaml
new file mode 100644
index 0000000..71a4ad0
--- /dev/null
+++ b/xos-profiles/rcord-lite/templates/rcord-models-deployment.yaml
@@ -0,0 +1,59 @@
+---
+
+# 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.
+
+apiVersion: apps/v1beta2
+kind: Deployment
+metadata:
+  name: {{ template "rcord-lite.fullname" . }}-rcord-models
+  labels:
+    app: {{ template "rcord-lite.name" . }}
+    chart: {{ template "rcord-lite.chart" . }}
+    release: {{ .Release.Name }}
+    heritage: {{ .Release.Service }}
+spec:
+  replicas: {{ .Values.replicaCount }}
+  selector:
+    matchLabels:
+      app: {{ template "rcord-lite.name" . }}
+      release: {{ .Release.Name }}
+  template:
+    metadata:
+      labels:
+        app: {{ template "rcord-lite.name" . }}
+        release: {{ .Release.Name }}
+      annotations:
+        checksum/config: {{ include (print $.Template.BasePath "/rcord-models-configmap.yaml") . | sha256sum }}
+    spec:
+      containers:
+        - name: {{ .Chart.Name }}-rcord
+          image: "{{ .Values.pull_docker_registry }}{{ .Values.image.rcordSynchronizer.repository }}:{{ .Values.image.rcordSynchronizer.tag }}"
+          imagePullPolicy: {{ .Values.image.rcordSynchronizer.pullPolicy }}
+          volumeMounts:
+            - name: rcord-lite-config
+              mountPath: /opt/xos/synchronizers/rcord/rcord_config.yaml
+              subPath: rcord_config.yaml
+            - name: cert-chain-secret
+              mountPath: /usr/local/share/ca-certificates
+      volumes:
+        - name: rcord-lite-config
+          configMap:
+            name: rcord-lite-config
+            items:
+              - key: serviceConfig
+                path: rcord_config.yaml
+        - name: cert-chain-secret
+          secret:
+            secretName: cert-chain-secret
diff --git a/xos-profiles/rcord-lite/templates/configmap.yaml b/xos-profiles/rcord-lite/templates/tosca-configmap.yaml
similarity index 90%
rename from xos-profiles/rcord-lite/templates/configmap.yaml
rename to xos-profiles/rcord-lite/templates/tosca-configmap.yaml
index b9da88e..f39acb3 100644
--- a/xos-profiles/rcord-lite/templates/configmap.yaml
+++ b/xos-profiles/rcord-lite/templates/tosca-configmap.yaml
@@ -27,3 +27,5 @@
 {{ toYaml .Values.toscaRecipes.fabricService | indent 4 }}
   040-cord-services.yaml: |
 {{ toYaml .Values.toscaRecipes.cordServices | indent 4 }}
+  050-service-graph-constraints.yaml: |
+{{ toYaml .Values.toscaRecipes.serviceGraphConstraints | indent 4 }}
diff --git a/xos-profiles/rcord-lite/templates/deployment.yaml b/xos-profiles/rcord-lite/templates/tosca-deployment.yaml
similarity index 75%
rename from xos-profiles/rcord-lite/templates/deployment.yaml
rename to xos-profiles/rcord-lite/templates/tosca-deployment.yaml
index e06960f..ef13db2 100644
--- a/xos-profiles/rcord-lite/templates/deployment.yaml
+++ b/xos-profiles/rcord-lite/templates/tosca-deployment.yaml
@@ -17,7 +17,7 @@
 apiVersion: apps/v1beta2
 kind: Deployment
 metadata:
-  name: {{ template "rcord-lite.fullname" . }}
+  name: {{ template "rcord-lite.fullname" . }}-tosca-loader
   labels:
     app: {{ template "rcord-lite.name" . }}
     chart: {{ template "rcord-lite.chart" . }}
@@ -35,16 +35,14 @@
         app: {{ template "rcord-lite.name" . }}
         release: {{ .Release.Name }}
       annotations:
-        checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
+        checksum/config: {{ include (print $.Template.BasePath "/tosca-configmap.yaml") . | sha256sum }}
     spec:
       containers:
-        - name: {{ .Chart.Name }}
-          image: "{{ .Values.pull_docker_registry }}{{ .Values.image.repository }}:{{ .Values.image.tag }}"
-          imagePullPolicy: {{ .Values.image.pullPolicy }}
+        - name: {{ .Chart.Name }}-tosca-loader
+          image: "{{ .Values.pull_docker_registry }}{{ .Values.image.toscaLoader.repository }}:{{ .Values.image.toscaLoader.tag }}"
+          imagePullPolicy: {{ .Values.image.toscaLoader.pullPolicy }}
           command: ["/bin/sh"]
           args: ["-c", "for recipe in /opt/tosca/*; do echo $recipe; http --ignore-stdin POST http://xos-tosca:$XOS_TOSCA_SERVICE_PORT/run xos-username:{{ .Values.xosAdminUser }} xos-password:{{ .Values.xosAdminPassword }} @$recipe || exit 1; echo ''; done; sleep 3600"]
-          resources:
-{{ toYaml .Values.resources | indent 12 }}
           volumeMounts:
             - name: rcord-lite-tosca
               mountPath: /opt/tosca
@@ -52,15 +50,3 @@
         - name: rcord-lite-tosca
           configMap:
             name: rcord-lite-tosca
-    {{- with .Values.nodeSelector }}
-      nodeSelector:
-{{ toYaml . | indent 8 }}
-    {{- end }}
-    {{- with .Values.affinity }}
-      affinity:
-{{ toYaml . | indent 8 }}
-    {{- end }}
-    {{- with .Values.tolerations }}
-      tolerations:
-{{ toYaml . | indent 8 }}
-    {{- end }}
diff --git a/xos-profiles/rcord-lite/values.yaml b/xos-profiles/rcord-lite/values.yaml
index a3b7efb..6303aef 100644
--- a/xos-profiles/rcord-lite/values.yaml
+++ b/xos-profiles/rcord-lite/values.yaml
@@ -23,17 +23,14 @@
 pull_docker_registry:
 
 image:
-  repository: clue/httpie
-  tag: latest
-  pullPolicy: IfNotPresent
-
-resources: {}
-
-nodeSelector: {}
-
-tolerations: []
-
-affinity: {}
+  toscaLoader:
+    repository: clue/httpie
+    tag: latest
+    pullPolicy: IfNotPresent
+  rcordSynchronizer:
+    repository: xosproject/rcord-synchronizer
+    tag: fc9d64d591236ec5d428045c67748e67a58b3fe3
+    pullPolicy: IfNotPresent
 
 xosAdminUser: admin@opencord.org
 xosAdminPassword: letmein
@@ -60,6 +57,19 @@
       username: admin@opencord.org
       password: letmein
 
+# The R-CORD synchronizer loads R-CORD-specific models into the core
+serviceConfig:
+  name: rcord
+  accessor:
+    username: admin@opencord.org
+    password: letmein
+    endpoint: xos-core:50051
+  dependency_graph: "/opt/xos/synchronizers/rcord/model-deps"
+  sys_dir: "/opt/xos/synchronizers/rcord/sys"
+  models_dir: "/opt/xos/synchronizers/rcord/models"
+  model_policies_dir: "/opt/xos/synchronizers/rcord/model_policies"
+
+# TOSCA recipes for the tosca-loader
 toscaRecipes:
   fixtures:
     tosca_definitions_version: tosca_simple_yaml_1_0
@@ -254,3 +264,15 @@
           type: tosca.nodes.AddressManagerService
           properties:
             name: addressmanager
+
+  serviceGraphConstraints:
+    tosca_definitions_version: tosca_simple_yaml_1_0
+    imports:
+       - custom_types/servicegraphconstraint.yaml
+    description: Constraints on the Services position in the graph
+    topology_template:
+      node_templates:
+        constraints:
+          type: tosca.nodes.ServiceGraphConstraint
+          properties:
+            constraints: '[[null, "rcord"], [null, "volt"]]'