CORD-3024 M-CORD profile chart and service charts

Change-Id: Ic947da2a6e5c77e6c943200fd11f0b35b9c8655b
diff --git a/xos-services/vhss/templates/_helpers.tpl b/xos-services/vhss/templates/_helpers.tpl
new file mode 100644
index 0000000..4ecf8d7
--- /dev/null
+++ b/xos-services/vhss/templates/_helpers.tpl
@@ -0,0 +1,80 @@
+{{/* vim: set filetype=mustache: */}}
+{{/*
+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.
+*/}}
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "vhss.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "vhss.fullname" -}}
+{{- if .Values.fullnameOverride -}}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
+{{- else -}}
+{{- $name := default .Chart.Name .Values.nameOverride -}}
+{{- if contains $name .Release.Name -}}
+{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
+{{- else -}}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "vhss.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{- define "vhss.serviceConfig" -}}
+name: vhss
+accessor:
+  username: {{ .Values.xosAdminUser | quote }}
+  password: {{ .Values.xosAdminPassword | quote }}
+  endpoint: xos-core:50051
+required_models:
+  - VHSSService
+  - VHSSVendor
+  - VHSSTenant
+dependency_graph: "/opt/xos/synchronizers/vhss/model-deps"
+steps_dir: "/opt/xos/synchronizers/vhss/steps"
+sys_dir: "/opt/xos/synchronizers/vhss/sys"
+model_policies_dir: "/opt/xos/synchronizers/vhss/model_policies"
+models_dir: "/opt/xos/synchronizers/vhss/models"
+logging:
+  version: 1
+  handlers:
+    console:
+      class: logging.StreamHandler
+    file:
+      class: logging.handlers.RotatingFileHandler
+      filename: /var/log/xos.log
+      maxBytes: 10485760
+      backupCount: 5
+  loggers:
+    'multistructlog':
+      handlers:
+          - console
+          - file
+      level: DEBUG
+{{- end -}}
diff --git a/xos-services/vhss/templates/_tosca.tpl b/xos-services/vhss/templates/_tosca.tpl
new file mode 100644
index 0000000..547ab9c
--- /dev/null
+++ b/xos-services/vhss/templates/_tosca.tpl
@@ -0,0 +1,62 @@
+{{/* vim: set filetype=mustache: */}}
+{{/*
+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.
+*/}}
+{{- define "vhss.serviceTosca" -}}
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+imports:
+  - custom_types/vhssservice.yaml
+  - custom_types/vhssvendor.yaml
+  - custom_types/flavor.yaml
+  - custom_types/image.yaml
+
+description: Configures the vHSS service
+
+topology_template:
+  node_templates:
+
+    service#vhss:
+      type: tosca.nodes.VHSSService
+      properties:
+        name: vhss
+        public_key: {{ .publicKey | quote }}
+        private_key_fn: /opt/xos/services/vhss/keys/id_rsa
+
+    sprint_hss:
+      type: tosca.nodes.VHSSVendor
+      properties:
+        name: sprint_hss_{{ .vnfImageVersion }}
+      requirements:
+        - image:
+            node: image_hss
+            relationship: tosca.relationships.BelongsToOne
+        - flavor:
+            node: {{ .vnfImageFlavor }}
+            relationship: tosca.relationships.BelongsToOne
+
+    image_hss:
+      type: tosca.nodes.Image
+      properties:
+        name: image_hss_{{ .vnfImageVersion }}
+        disk_format: QCOW2
+        container_format: BARE
+        path: {{ .vnfImageURL }}
+
+    {{ .vnfImageFlavor }}:
+      type: tosca.nodes.Flavor
+      properties:
+        name: {{ .vnfImageFlavor }}
+{{- end -}}
diff --git a/xos-services/vhss/templates/configmap.yaml b/xos-services/vhss/templates/configmap.yaml
new file mode 100644
index 0000000..44d6396
--- /dev/null
+++ b/xos-services/vhss/templates/configmap.yaml
@@ -0,0 +1,23 @@
+---
+
+# 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: v1
+kind: ConfigMap
+metadata:
+  name: vhss
+data:
+  serviceConfig: |
+{{ include "vhss.serviceConfig" . | indent 4 }}
diff --git a/xos-services/vhss/templates/deployment.yaml b/xos-services/vhss/templates/deployment.yaml
new file mode 100644
index 0000000..fe3f768
--- /dev/null
+++ b/xos-services/vhss/templates/deployment.yaml
@@ -0,0 +1,82 @@
+---
+# 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 "vhss.fullname" . }}
+  labels:
+    app: {{ template "vhss.name" . }}
+    chart: {{ template "vhss.chart" . }}
+    release: {{ .Release.Name }}
+    heritage: {{ .Release.Service }}
+spec:
+  replicas: {{ .Values.replicaCount }}
+  selector:
+    matchLabels:
+      app: {{ template "vhss.name" . }}
+      release: {{ .Release.Name }}
+  template:
+    metadata:
+      labels:
+        app: {{ template "vhss.name" . }}
+        release: {{ .Release.Name }}
+      annotations:
+        checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
+    spec:
+      containers:
+        - name: {{ .Chart.Name }}
+          image: {{ .Values.synchronizerImage | quote }}
+          imagePullPolicy: {{ .Values.imagePullPolicy }}
+          resources:
+{{ toYaml .Values.resources | indent 12 }}
+          volumeMounts:
+            - name: vhss-config
+              mountPath: /opt/xos/synchronizers/vhss/vhss_config.yaml
+              subPath: vhss_config.yaml
+            - name: certchain-volume
+              mountPath: /usr/local/share/ca-certificates/local_certs.crt
+              subPath: config/ca_cert_chain.pem
+            - name: vhss-keys
+              mountPath: /opt/xos/services/vhss/keys
+              readOnly: true
+      volumes:
+        - name: vhss-config
+          configMap:
+            name: vhss
+            items:
+              - key: serviceConfig
+                path: vhss_config.yaml
+        - name: certchain-volume
+          configMap:
+            name: ca-certificates
+            items:
+              - key: chain
+                path: config/ca_cert_chain.pem
+        - name: vhss-keys
+          secret:
+            secretName: vhss-keys
+    {{- 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-services/vhss/templates/secret.yaml b/xos-services/vhss/templates/secret.yaml
new file mode 100644
index 0000000..fc74bb3
--- /dev/null
+++ b/xos-services/vhss/templates/secret.yaml
@@ -0,0 +1,23 @@
+---
+# Copyright 2017-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: v1
+kind: Secret
+metadata:
+  name: vhss-keys
+  namespace: default
+type: Opaque
+data:
+  id_rsa: {{ .Files.Get .Values.privateKeyFile | b64enc }}
\ No newline at end of file