[CORD-2925] Adding vRouter to rcord-lite

Change-Id: Id0a6e36b237064355a9f2cb460c2b200cf91781f
diff --git a/xos-profiles/rcord-lite/requirements.yaml b/xos-profiles/rcord-lite/requirements.yaml
index 31551dc..6219740 100644
--- a/xos-profiles/rcord-lite/requirements.yaml
+++ b/xos-profiles/rcord-lite/requirements.yaml
@@ -27,3 +27,6 @@
 - name: vsg-hw
   version: 0.1.0
   repository: file://../../xos-services/vsg-hw
+- name: vrouter
+  version: 0.1.0
+  repository: file://../../xos-services/vrouter
diff --git a/xos-profiles/rcord-lite/values.yaml b/xos-profiles/rcord-lite/values.yaml
index 49084b6..cf65680 100644
--- a/xos-profiles/rcord-lite/values.yaml
+++ b/xos-profiles/rcord-lite/values.yaml
@@ -240,6 +240,7 @@
       - custom_types/serviceinstancelink.yaml
       - custom_types/slice.yaml
       - custom_types/voltservice.yaml
+      - custom_types/vrouterservice.yaml
       - custom_types/vsghwservice.yaml
     topology_template:
       node_templates:
@@ -272,6 +273,15 @@
           type: tosca.nodes.VSGHWService
           properties:
             name: vsg-hw
+        service#vrouter:
+          type: tosca.nodes.VRouterService
+          properties:
+            name: vrouter
+            kind: rcord
+            rest_hostname: onos-fabric-ui
+            rest_port: 8181
+            rest_user: karaf
+            rest_pass: karaf
         volt_vsg-hw:
           type: tosca.nodes.ServiceDependency
           properties:
@@ -294,6 +304,17 @@
             - provider_service:
                 node: service#ONOS_Fabric
                 relationship: tosca.relationships.BelongsToOne
+        vsg-hw_vrouter:
+          type: tosca.nodes.ServiceDependency
+          properties:
+            connect_method: None
+          requirements:
+            - subscriber_service:
+                node: service#vsg-hw
+                relationship: tosca.relationships.BelongsToOne
+            - provider_service:
+                node: service#vrouter
+                relationship: tosca.relationships.BelongsToOne
 
   serviceGraphConstraints:
     tosca_definitions_version: tosca_simple_yaml_1_0
@@ -305,4 +326,4 @@
         constraints:
           type: tosca.nodes.ServiceGraphConstraint
           properties:
-            constraints: '[[null, "rcord"], [null, "volt"], ["ONOS_Fabric", "vsg-hw"]]'
+            constraints: '[[null, "rcord"], [null, "volt"], ["ONOS_Fabric", "vsg-hw"], [null, "vrouter"]]'
diff --git a/xos-services/vrouter/.helmignore b/xos-services/vrouter/.helmignore
new file mode 100644
index 0000000..f0c1319
--- /dev/null
+++ b/xos-services/vrouter/.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/vrouter/Chart.yaml b/xos-services/vrouter/Chart.yaml
new file mode 100644
index 0000000..29f15d0
--- /dev/null
+++ b/xos-services/vrouter/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 "vRouter" service
+name: vrouter
+version: 0.1.0
diff --git a/xos-services/vrouter/templates/_helpers.tpl b/xos-services/vrouter/templates/_helpers.tpl
new file mode 100644
index 0000000..03d5458
--- /dev/null
+++ b/xos-services/vrouter/templates/_helpers.tpl
@@ -0,0 +1,47 @@
+{{/* 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 "vrouter.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 "vrouter.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 "vrouter.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
diff --git a/xos-services/vrouter/templates/configmap.yaml b/xos-services/vrouter/templates/configmap.yaml
new file mode 100644
index 0000000..dd8e766
--- /dev/null
+++ b/xos-services/vrouter/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: vrouter
+data:
+  serviceConfig: |
+{{ toYaml .Values.serviceConfig | indent 4 }}
diff --git a/xos-services/vrouter/templates/deployment.yaml b/xos-services/vrouter/templates/deployment.yaml
new file mode 100644
index 0000000..82630a3
--- /dev/null
+++ b/xos-services/vrouter/templates/deployment.yaml
@@ -0,0 +1,73 @@
+---
+
+# 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 "vrouter.fullname" . }}
+  labels:
+    app: {{ template "vrouter.name" . }}
+    chart: {{ template "vrouter.chart" . }}
+    release: {{ .Release.Name }}
+    heritage: {{ .Release.Service }}
+spec:
+  replicas: {{ .Values.replicaCount }}
+  selector:
+    matchLabels:
+      app: {{ template "vrouter.name" . }}
+      release: {{ .Release.Name }}
+  template:
+    metadata:
+      labels:
+        app: {{ template "vrouter.name" . }}
+        release: {{ .Release.Name }}
+      annotations:
+        checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
+    spec:
+      containers:
+        - name: {{ .Chart.Name }}
+          image: "{{ .Values.pull_docker_registry }}{{ .Values.image.repository }}:{{ .Values.image.tag }}"
+          imagePullPolicy: {{ .Values.image.pullPolicy }}
+          resources:
+{{ toYaml .Values.resources | indent 12 }}
+          volumeMounts:
+            - name: vrouter-config
+              mountPath: /opt/xos/synchronizers/vrouter/vrouter_config.yaml
+              subPath: vrouter_config.yaml
+            - name: cert-chain-secret
+              mountPath: /usr/local/share/ca-certificates
+      volumes:
+        - name: vrouter-config
+          configMap:
+            name: vrouter
+            items:
+              - key: serviceConfig
+                path: vrouter_config.yaml
+        - name: cert-chain-secret
+          secret:
+            secretName: cert-chain-secret
+    {{- 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/vrouter/values.yaml b/xos-services/vrouter/values.yaml
new file mode 100644
index 0000000..c267596
--- /dev/null
+++ b/xos-services/vrouter/values.yaml
@@ -0,0 +1,71 @@
+---
+
+# 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 addressmanager.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+replicaCount: 1
+
+pull_docker_registry:
+
+nameOverride: ""
+fullnameOverride: ""
+
+image:
+  repository: xosproject/vrouter-synchronizer
+  tag: master
+  pullPolicy: IfNotPresent
+
+resources: {}
+
+nodeSelector: {}
+
+tolerations: []
+
+affinity: {}
+
+serviceConfig:
+  name: vrouter
+  accessor:
+    username: admin@opencord.org
+    password: letmein
+    endpoint: xos-core:50051
+  required_models:
+    - VRouterService
+    - VRouterDevice
+    - VRouterApp
+    - VRouterPort
+  dependency_graph: "/opt/xos/synchronizers/vrouter/model-deps"
+  steps_dir: "/opt/xos/synchronizers/vrouter/steps"
+  sys_dir: "/opt/xos/synchronizers/vrouter/sys"
+  models_dir: "/opt/xos/synchronizers/vrouter/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