[CORD-1942] Define M-CORD Subscriber

Change-Id: Icc5288530c6e45ead09b99a211f53da566098050
diff --git a/docs/bootstrap_models_in_xos.md b/docs/bootstrap_models_in_xos.md
new file mode 100644
index 0000000..593a674
--- /dev/null
+++ b/docs/bootstrap_models_in_xos.md
@@ -0,0 +1,44 @@
+# How to add a TOSCA recipe to platform-install
+
+All the data model bootstrapping in XOS is done via TOSCA in platform install. 
+There two ansible roles involved in that:
+- `cord-profile` responsible to generate the recipes
+- `xos-config-new-tosca` responsible for onboarding the recipes
+
+Here is a list of changes you'll need to make in order to add a new recipe to your profiles:
+
+## Create a new template in `cord-profile`
+
+You can create as many templates as needed under `/platform-install/roles/cord-profile/templates`. 
+These are ansible templates, and they use the `jinja2` syntax. 
+
+For example a basic template can be `site.yml.j2`:
+
+```
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: created by platform-install, need to add M-CORD services later
+
+imports:
+   - custom_types/xos.yaml
+
+topology_template:
+  node_templates:
+    {{ site_name }}:
+      type: tosca.nodes.Site
+```
+
+You can use here all the variables defined in the [build glossary](../build_glossary.md).
+
+## Add the template to your profile manifest
+
+In `platform-install/profile_manifests` locate the profile that your using and open it.
+
+Locate a section called `xos_new_tosca_config_templates` (if it's missing create it), 
+and add there the list of templates you want to be generated and onboarded, eg:
+```
+xos_new_tosca_config_templates:
+  - site.yml
+```
+
+> NOTE: the template name is whatever you specify in this list plus `.j2`
\ No newline at end of file
diff --git a/inventory/mcord b/inventory/mcord
index 906ba93..abaff40 100644
--- a/inventory/mcord
+++ b/inventory/mcord
@@ -3,6 +3,14 @@
 [all:vars]
 cord_profile=mcord
 
+[config]
+localhost ansible_connection=local
+
 [head]
 localhost ansible_connection=local
 
+[build]
+localhost ansible_connection=local
+
+[compute]
+
diff --git a/onboard-profile-playbook.yml b/onboard-profile-playbook.yml
index 844340b..fd0ab58 100644
--- a/onboard-profile-playbook.yml
+++ b/onboard-profile-playbook.yml
@@ -32,3 +32,17 @@
   roles:
     - xos-config
 
+- name: Include vars
+  hosts: config
+  tasks:
+    - name: Include variables
+      include_vars: "{{ item }}"
+      with_items:
+        - "profile_manifests/{{ cord_profile }}.yml"
+        - profile_manifests/local_vars.yml
+
+- name: Apply profile config (new engine)
+  hosts: head
+  roles:
+    - xos-config-new-tosca
+
diff --git a/profile_manifests/mcord.yml b/profile_manifests/mcord.yml
index 61172c4..b93cb69 100644
--- a/profile_manifests/mcord.yml
+++ b/profile_manifests/mcord.yml
@@ -33,6 +33,10 @@
   - fabric-service.yaml
   - management-net.yaml
   - xos-gui-extensions.yml
+  - mcord-services.yml
+
+xos_new_tosca_config_templates:
+  - mcord-subscriber.yml
 
 xos_other_templates:
   - fabric-network-cfg.json
@@ -55,18 +59,11 @@
     keypair: onos_rsa
   - name: fabric
     path: orchestration/xos_services/fabric
-#  uncomment this when vmme migration is to be done.
-#  - name: vmme
-#    path: orchestration/xos_services/vmme
-#    keypair: mcord_rsa
-#    synchronizer: true
   - name: exampleservice
     path: orchestration/xos_services/exampleservice
     keypair: exampleservice_rsa
-#  - name: monitoring
-#    path: orchestration/xos_services/monitoring
-#    keypair: monitoringservice_rsa
-#    synchronizer: false
+
+profile_library: "mcord"
 
 # VTN network configuration
 management_network_cidr: 172.27.0.0/24
diff --git a/roles/cord-profile/defaults/main.yml b/roles/cord-profile/defaults/main.yml
index f94e86a..2e720d8 100644
--- a/roles/cord-profile/defaults/main.yml
+++ b/roles/cord-profile/defaults/main.yml
@@ -65,6 +65,8 @@
 
 xos_tosca_config_templates: []
 
+xos_new_tosca_config_templates: []
+
 xos_other_templates: []
 
 # XOS Config (xos_config.yaml)
diff --git a/roles/cord-profile/tasks/main.yml b/roles/cord-profile/tasks/main.yml
index a3c38ab..92bdbd2 100644
--- a/roles/cord-profile/tasks/main.yml
+++ b/roles/cord-profile/tasks/main.yml
@@ -120,6 +120,12 @@
     dest: "{{ config_cord_profile_dir }}/{{ item }}"
   with_items: "{{ xos_tosca_config_templates }}"
 
+- name: Create profile specific templated TOSCA config files (new Engine)
+  template:
+    src: "{{ item }}.j2"
+    dest: "{{ config_cord_profile_dir }}/{{ item }}"
+  with_items: "{{ xos_new_tosca_config_templates }}"
+
 - name: Create profile specific templated non-TOSCA files
   template:
     src: "{{ item }}.j2"
diff --git a/roles/cord-profile/templates/mcord-services.yaml.j2 b/roles/cord-profile/templates/mcord-services.yml.j2
similarity index 100%
rename from roles/cord-profile/templates/mcord-services.yaml.j2
rename to roles/cord-profile/templates/mcord-services.yml.j2
diff --git a/roles/cord-profile/templates/mcord-subscriber.yml.j2 b/roles/cord-profile/templates/mcord-subscriber.yml.j2
new file mode 100644
index 0000000..06dd8e1
--- /dev/null
+++ b/roles/cord-profile/templates/mcord-subscriber.yml.j2
@@ -0,0 +1,30 @@
+# 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.
+
+
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Persist M-CORD Subscriber
+
+imports:
+   - custom_types/mcordsubscriberservice.yaml
+
+topology_template:
+  node_templates:
+
+    # M-CORD Subscriber
+    mcord:
+      type: tosca.nodes.MCordSubscriberService
+      properties:
+        name: mcord
\ No newline at end of file
diff --git a/roles/xos-config-new-tosca/defaults/main.yml b/roles/xos-config-new-tosca/defaults/main.yml
new file mode 100644
index 0000000..5b6a39a
--- /dev/null
+++ b/roles/xos-config-new-tosca/defaults/main.yml
@@ -0,0 +1,29 @@
+---
+
+# 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.
+
+
+# xos-config/defaults/main.yml
+
+credentials_dir: "{{ playbook_dir }}/credentials"
+
+xos_admin_user: "xosadmin@opencord.org"
+xos_admin_pass: "{{ lookup('password', credentials_dir ~ '/xosadmin@opencord.org chars=ascii_letters,digits') }}"
+
+xos_tosca_config_templates: []
+
+xos_new_tosca_config_templates: []
+
+use_openstack: True
diff --git a/roles/xos-config-new-tosca/tasks/main.yml b/roles/xos-config-new-tosca/tasks/main.yml
new file mode 100644
index 0000000..b2534dc
--- /dev/null
+++ b/roles/xos-config-new-tosca/tasks/main.yml
@@ -0,0 +1,32 @@
+
+# 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.
+
+
+---
+# xos-config-new-tosca/tasks/main.yml
+
+- name: Configure XOS with profile specific TOSCA (new Engine)
+  uri:
+    url: "http://{{headnode}}/xos-tosca/run"
+    method: POST
+    headers:
+      xos-username: "{{ xos_admin_user }}"
+      xos-password: "{{ xos_admin_pass }}"
+    body: "{{ lookup('file','/opt/cord_profile/' + item ) }}"
+    status_code: 200
+  with_items: "{{ xos_new_tosca_config_templates }}"
+  tags:
+    - skip_ansible_lint # TOSCA loading should be idempotent
+