CORD-3024 M-CORD profile chart and service charts

Change-Id: Ic947da2a6e5c77e6c943200fd11f0b35b9c8655b
diff --git a/xos-services/sdncontroller/.helmignore b/xos-services/sdncontroller/.helmignore
new file mode 100644
index 0000000..f0c1319
--- /dev/null
+++ b/xos-services/sdncontroller/.helmignore
@@ -0,0 +1,21 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
diff --git a/xos-services/sdncontroller/Chart.yaml b/xos-services/sdncontroller/Chart.yaml
new file mode 100644
index 0000000..9391a04
--- /dev/null
+++ b/xos-services/sdncontroller/Chart.yaml
@@ -0,0 +1,21 @@
+---
+
+# 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
+appVersion: "1.0"
+description: A Helm chart for XOS's "sdncontroller" service
+name: sdncontroller
+version: 0.1.0
diff --git a/xos-services/sdncontroller/files/id_rsa b/xos-services/sdncontroller/files/id_rsa
new file mode 100644
index 0000000..c840002
--- /dev/null
+++ b/xos-services/sdncontroller/files/id_rsa
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEpgIBAAKCAQEAy+S+bw7ENW5knorMTH/xmRKr/OaBx7ukRRNe1WKEwLgQbB0J
+xEznHG0E/OakgcuTQDACArTndeYl2H5rpdHhXkh6EK9R9yAF09In+gDcVzpvP2d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IMoPYstnpfF5SIhQnL8NG4906P0Dd9t+PmQz6XXu4987FjOqAc
+zYvVr5vhCFhvSvWcKJN7uGbDAoGBAKvJequlLZDXCEB9UHzkwymn3IMg9ihYQAQH
+GV6Lw7H34gEoULQXRLw0xxlCPsduOPXkUbKxnYJ/drVDebmprh2KT4wAv3SG7eyZ
+SGh/Wv7yFSDAJvSYWwfjDzufMtm5Mc3oupzgY1toD7GLNFH1xasbHswVGRK+5NFl
+QlC1ipcNAoGBAIxqGyCai6btwDlbpkdI+ck2j7k9ndZ8sosc0G2se9d58sfsHdWe
+1wpqe62t7mQZr+IgEyq7RuuEtRR6Xqb8RQqAuEdSms1zcWc30SJJhPiwxIeLL0dx
+ly/HBBqnozD4BN3ENiqnIhOgeZE7XHaS43luYkYpBOuBaWYs5IIZWcct
+-----END RSA PRIVATE KEY-----
diff --git a/xos-services/sdncontroller/templates/_helpers.tpl b/xos-services/sdncontroller/templates/_helpers.tpl
new file mode 100644
index 0000000..b5ae337
--- /dev/null
+++ b/xos-services/sdncontroller/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 "sdncontroller.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 "sdncontroller.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 "sdncontroller.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{- define "sdncontroller.serviceConfig" -}}
+name: sdncontroller
+accessor:
+  username: {{ .Values.xosAdminUser | quote }}
+  password: {{ .Values.xosAdminPassword | quote }}
+  endpoint: xos-core:50051
+required_models:
+  - SDNControllerService
+  - SDNControllerVendor
+  - SDNControllerServiceInstance
+dependency_graph: "/opt/xos/synchronizers/sdncontroller/model-deps"
+steps_dir: "/opt/xos/synchronizers/sdncontroller/steps"
+sys_dir: "/opt/xos/synchronizers/sdncontroller/sys"
+model_policies_dir: "/opt/xos/synchronizers/sdncontroller/model_policies"
+models_dir: "/opt/xos/synchronizers/sdncontroller/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/sdncontroller/templates/_tosca.tpl b/xos-services/sdncontroller/templates/_tosca.tpl
new file mode 100644
index 0000000..c08aa56
--- /dev/null
+++ b/xos-services/sdncontroller/templates/_tosca.tpl
@@ -0,0 +1,63 @@
+{{/* 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 "sdncontroller.serviceTosca" -}}
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+imports:
+  - custom_types/sdncontrollerservice.yaml
+  - custom_types/sdncontrollervendor.yaml
+  - custom_types/image.yaml
+  - custom_types/flavor.yaml
+
+description: Configures the sdncontroller service
+
+topology_template:
+  node_templates:
+
+    service#sdncontroller:
+      type: tosca.nodes.SDNControllerService
+      properties:
+        name: sdncontroller
+        public_key: {{ .publicKey | quote }}
+        private_key_fn: /opt/xos/services/sdncontroller/keys/id_rsa
+
+    intel_sdncontroller:
+      type: tosca.nodes.SDNControllerVendor
+      properties:
+        name: intel_sdncontroller_{{ .vnfImageVersion }}
+      requirements:
+        - image:
+            node: image_sdncontroller
+            relationship: tosca.relationships.BelongsToOne
+        - flavor:
+            node: {{ .vnfImageFlavor }}
+            relationship: tosca.relationships.BelongsToOne
+
+    # This is a placeholder image right now...
+    image_sdncontroller:
+      type: tosca.nodes.Image
+      properties:
+        name: image_sdncontroller_{{ .vnfImageVersion }}
+        disk_format: QCOW2
+        container_format: BARE
+        path: {{ .vnfImageURL }}
+
+    {{ .vnfImageFlavor }}:
+      type: tosca.nodes.Flavor
+      properties:
+        name: {{ .vnfImageFlavor }}
+{{- end -}}
diff --git a/xos-services/sdncontroller/templates/configmap.yaml b/xos-services/sdncontroller/templates/configmap.yaml
new file mode 100644
index 0000000..8fa526f
--- /dev/null
+++ b/xos-services/sdncontroller/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: sdncontroller
+data:
+  serviceConfig: |
+{{ include "sdncontroller.serviceConfig" . | indent 4 }}
diff --git a/xos-services/sdncontroller/templates/deployment.yaml b/xos-services/sdncontroller/templates/deployment.yaml
new file mode 100644
index 0000000..167b54e
--- /dev/null
+++ b/xos-services/sdncontroller/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 "sdncontroller.fullname" . }}
+  labels:
+    app: {{ template "sdncontroller.name" . }}
+    chart: {{ template "sdncontroller.chart" . }}
+    release: {{ .Release.Name }}
+    heritage: {{ .Release.Service }}
+spec:
+  replicas: {{ .Values.replicaCount }}
+  selector:
+    matchLabels:
+      app: {{ template "sdncontroller.name" . }}
+      release: {{ .Release.Name }}
+  template:
+    metadata:
+      labels:
+        app: {{ template "sdncontroller.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: sdncontroller-config
+              mountPath: /opt/xos/synchronizers/sdncontroller/sdncontroller_config.yaml
+              subPath: sdncontroller_config.yaml
+            - name: certchain-volume
+              mountPath: /usr/local/share/ca-certificates/local_certs.crt
+              subPath: config/ca_cert_chain.pem
+            - name: sdncontroller-keys
+              mountPath: /opt/xos/services/sdncontroller/keys
+              readOnly: true
+      volumes:
+        - name: sdncontroller-config
+          configMap:
+            name: sdncontroller
+            items:
+              - key: serviceConfig
+                path: sdncontroller_config.yaml
+        - name: certchain-volume
+          configMap:
+            name: ca-certificates
+            items:
+              - key: chain
+                path: config/ca_cert_chain.pem
+        - name: sdncontroller-keys
+          secret:
+            secretName: sdncontroller-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/sdncontroller/templates/secret.yaml b/xos-services/sdncontroller/templates/secret.yaml
new file mode 100644
index 0000000..16af8b4
--- /dev/null
+++ b/xos-services/sdncontroller/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: sdncontroller-keys
+  namespace: default
+type: Opaque
+data:
+  id_rsa: {{ .Files.Get .Values.privateKeyFile | b64enc }}
\ No newline at end of file
diff --git a/xos-services/sdncontroller/values.yaml b/xos-services/sdncontroller/values.yaml
new file mode 100644
index 0000000..da24f44
--- /dev/null
+++ b/xos-services/sdncontroller/values.yaml
@@ -0,0 +1,45 @@
+---
+# 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.
+
+# Default values for sdncontroller.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+replicaCount: 1
+
+nameOverride: ""
+fullnameOverride: ""
+
+imagePullPolicy: 'IfNotPresent'
+
+synchronizerImage: "xosproject/sdncontroller-synchronizer:master"
+
+xosAdminUser: "admin@opencord.org"
+xosAdminPassword: "letmein"
+
+vnfImageURL: https://github.com/opencord/platform-install/releases/download/vms/trusty-server-cloudimg-amd64-disk1.img.20170201
+vnfImageVersion: "v0.1"
+vnfImageFlavor: "m1.small"
+
+publicKey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDL5L5vDsQ1bmSeisxMf/GZEqv85oHHu6RFE17VYoTAuBBsHQnETOccbQT85qSBy5NAMAICtOd15iXYfmul0eFeSHoQr1H3IAXT0if6ANxXOm8/Z2rlRNthOEgsjDQU9foNxQ4wksygy5epKmbEhMqbFZjuj4zYfStPzE/gkFSE9QjhKMWaJmyLFfq9f8DnC+TTE41K5iGbtramr7qHSWsKKy75XV6MZZLLFExrQqlYDlLA2V0aYezCql3fB96KJmf6GJRT3j3Y7oWaj7gEzMCycA2QgP8ZNFL/2Q1qgvQRc6I46/HUiOh3IT8LVDdo2ZUn9qrNameQ1zR7a+wBvYIV Insecure M-CORD keypair"
+privateKeyFile: "files/id_rsa"
+
+resources: {}
+
+nodeSelector: {}
+
+tolerations: []
+
+affinity: {}