WIP Adding vEE, vNodlocal, vNodglobal tenants to ecord

Change-Id: I78d356cf346eac5f42d6c2a1f6f289ee7948cc11
diff --git a/ecord-test-subscriber-playbook.yml b/ecord-test-subscriber-playbook.yml
new file mode 100644
index 0000000..9356ed3
--- /dev/null
+++ b/ecord-test-subscriber-playbook.yml
@@ -0,0 +1,27 @@
+---
+# pod-test-playbook.yml
+# Tests CiaB cord-pod XOS configuration
+
+- name: Include vars
+  hosts: all
+  tasks:
+    - name: Include variables
+      include_vars: "{{ item }}"
+      with_items:
+        - "profile_manifests/{{ cord_profile }}.yml"
+        - profile_manifests/local_vars.yml
+
+- name: Create test subscriber
+  hosts: head
+  roles:
+    - test-ecord-subscriber-config
+
+- include: add-onboard-containers-playbook.yml
+
+- name: Enable the test subscriber
+  hosts: xos_ui
+  connection: docker
+  roles:
+    - test-ecord-subscriber-enable
+
+
diff --git a/profile_manifests/ecord.yml b/profile_manifests/ecord.yml
index 2a9878f..735c4be 100644
--- a/profile_manifests/ecord.yml
+++ b/profile_manifests/ecord.yml
@@ -20,6 +20,7 @@
   - openstack.yaml
   - vtn-service.yaml
   - fabric-service.yaml
+  - vee-service.yaml
   - ecord-services.yaml
 
 xos_other_templates:
@@ -39,18 +40,22 @@
 
 # paths defined in manifest/default.xml
 xos_services:
-  - name: vtn
-    path: onos-apps/apps/vtn
   - name: openstack
     path: orchestration/xos_services/openstack
   - name: onos
     path: orchestration/xos_services/onos-service
+  - name: vtn
+    path: onos-apps/apps/vtn
+  - name: fabric
+    path: orchestration/xos_services/fabric
   - name: vrouter
     path: orchestration/xos_services/vrouter
   - name: veg
     path: orchestration/xos_services/vEG
-  - name: fabric
-    path: orchestration/xos_services/fabric
+  - name: vnodlocal
+    path: orchestration/xos_services/metronet-local
+  - name: vee
+    path: orchestration/xos_services/vEE
   - name: veg_rsa
     source_path: "/dev/null"
   - name: veg_rsa.pub
diff --git a/profile_manifests/mock-ecord-global.yml b/profile_manifests/mock-ecord-global.yml
index 2357329..02c5abe 100644
--- a/profile_manifests/mock-ecord-global.yml
+++ b/profile_manifests/mock-ecord-global.yml
@@ -18,9 +18,13 @@
 build_xos_base_image: True
 
 xos_tosca_config_templates:
-  - management-net.yaml
   - mock-onos.yaml
-  - ecord-services.yaml
+  - vnodglobal-service.yaml
+
+# GUI Config [new GUI]
+gui_project_name: "E-CORD"
+gui_background: "cord-bg.jpg" # TODO find ecord image
+gui_payoff: "Your Enterprise VNF orchestrator"
 
 # GUI branding
 gui_branding_name: "ECORD"
@@ -30,14 +34,8 @@
 
 # paths defined in manifest/default.xml
 xos_services:
-  - name: openstack
-    path: orchestration/xos_services/openstack
   - name: onos
     path: orchestration/xos_services/onos-service
-  - name: vrouter
-    path: orchestration/xos_services/vrouter
-  - name: fabric
-    path: orchestration/xos_services/fabric
   - name: metronetwork
     path: orchestration/xos_services/metro-net
 
diff --git a/profile_manifests/mock-ecord.yml b/profile_manifests/mock-ecord.yml
index 69bd8c5..1a969db 100644
--- a/profile_manifests/mock-ecord.yml
+++ b/profile_manifests/mock-ecord.yml
@@ -20,7 +20,10 @@
 xos_tosca_config_templates:
   - management-net.yaml
   - mock-onos.yaml
+#  - vtn-service.yaml # rimosso
+#  - fabric-service.yaml # rimosso
   - ecord-services.yaml
+  - vee-service.yaml
 
 # GUI Config [new GUI]
 gui_project_name: "E-CORD"
@@ -39,14 +42,18 @@
     path: orchestration/xos_services/openstack
   - name: onos
     path: orchestration/xos_services/onos-service
+  - name: vtn
+    path: onos-apps/apps/vtn
+  - name: fabric
+    path: orchestration/xos_services/fabric
   - name: vrouter
     path: orchestration/xos_services/vrouter
   - name: veg
     path: orchestration/xos_services/vEG
   - name: vnodlocal
     path: orchestration/xos_services/metronet-local
-  - name: fabric
-    path: orchestration/xos_services/fabric
+  - name: vee
+    path: orchestration/xos_services/vEE
 
 xos_service_sshkeys:
   - name: onos_rsa
diff --git a/roles/cord-profile/templates/ecord-services.yaml.j2 b/roles/cord-profile/templates/ecord-services.yaml.j2
index e8b69a0..dc6a71f 100644
--- a/roles/cord-profile/templates/ecord-services.yaml.j2
+++ b/roles/cord-profile/templates/ecord-services.yaml.j2
@@ -5,6 +5,7 @@
 imports:
    - custom_types/xos.yaml
    - custom_types/veg.yaml
+   - custom_types/vnodlocal.yaml
 
 topology_template:
   node_templates:
@@ -116,6 +117,11 @@
         translation: none
         vtn_kind: VEG
 
+    service#vnodlocal:
+      type: tosca.nodes.VNodLocalService
+      properties:
+      requirements:
+
     # Networks required by the CORD setup
     {{ site_name }}_veg-access:
       type: tosca.nodes.network.Network
diff --git a/roles/cord-profile/templates/vee-service.yaml.j2 b/roles/cord-profile/templates/vee-service.yaml.j2
new file mode 100644
index 0000000..56a7de4
--- /dev/null
+++ b/roles/cord-profile/templates/vee-service.yaml.j2
@@ -0,0 +1,69 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+imports:
+   - custom_types/xos.yaml
+   - custom_types/vee.yaml
+   - custom_types/veg.yaml
+   - custom_types/vnodlocal.yaml
+
+description: vee services, generated by platform-install
+
+topology_template:
+  node_templates:
+
+    service#ONOS_Fabric:
+      type: tosca.nodes.ONOSService
+      properties:
+        no-delete: true
+        no-create: true
+        no-update: true
+
+    service#veg:
+      type: tosca.nodes.VEGService
+      requirements:
+      properties:
+        no-delete: true
+        no-create: true
+        no-update: true
+      artifacts:
+        pubkey: /opt/xos/services/veg/keys/veg_rsa.pub
+
+    service#vnodlocal:
+      type: tosca.nodes.VNodLocalService
+      properties:
+        no-delete: true
+        no-create: true
+        no-update: true
+      requirements:
+
+    service#vee:
+      type: tosca.nodes.VEEService
+      requirements:
+          - veg_tenant:
+              node: service#veg
+              relationship: tosca.relationships.TenantOfService
+          - vnodlocal_tenant:
+              node: service#vnodlocal
+              relationship: tosca.relationships.TenantOfService
+      properties:
+        view_url: /admin/vEE/veeservice/$id$/
+
+    template#vee:
+      type: tosca.nodes.NetworkTemplate
+      properties:
+        visibility: private
+        translation: none
+        vtn_kind: vee
+
+    CarrierEthernet_ONOS_app:
+      type: tosca.nodes.ONOSApp
+      requirements:
+        - onos_tenant:
+            node: service#ONOS_Fabric
+            relationship: tosca.relationships.TenantOfService
+        - vee_service:
+            node: service#vee
+            relationship: tosca.relationships.UsedByService
+      properties:
+        dependencies: org.onosproject.drivers, org.onosproject.openflow-base, org.onosproject.ecord.carrierethernet
+
diff --git a/roles/cord-profile/templates/vnodglobal-service.yaml.j2 b/roles/cord-profile/templates/vnodglobal-service.yaml.j2
new file mode 100644
index 0000000..51835b0
--- /dev/null
+++ b/roles/cord-profile/templates/vnodglobal-service.yaml.j2
@@ -0,0 +1,28 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+imports:
+   - custom_types/xos.yaml
+   - custom_types/metronet.yaml
+
+description: vnodglobal services, generated by platform-install
+
+topology_template:
+    node_templates:
+
+      bandwidthprofile#ecordbandwidthprofile:
+        type: tosca.nodes.EcordBandwidthProfile
+        requirements:
+        properties:
+          bwpcfgcbs: 100
+          bwpcfgebs: 50
+          bwpcfgcir: 600
+          bwpcfgeir: 50
+          name: ecordbandwidthprofile
+
+      service#vnodglobal:
+        type: tosca.nodes.VNodGlobalService
+        requirements:
+          - bandwith_profile:
+              node: bandwidthprofile#ecordbandwidthprofile
+              relationship: tosca.relationships.UsesBandwidthProfile
+        properties:
\ No newline at end of file
diff --git a/roles/test-ecord-subscriber-config/defaults/main.yml b/roles/test-ecord-subscriber-config/defaults/main.yml
new file mode 100644
index 0000000..3fbf456
--- /dev/null
+++ b/roles/test-ecord-subscriber-config/defaults/main.yml
@@ -0,0 +1,5 @@
+---
+# test-subscriber-config/defaults/main.yml
+
+cord_profile_dir: "{{ ansible_user_dir + '/cord_profile' }}"
+
diff --git a/roles/test-ecord-subscriber-config/tasks/main.yml b/roles/test-ecord-subscriber-config/tasks/main.yml
new file mode 100644
index 0000000..16a343d
--- /dev/null
+++ b/roles/test-ecord-subscriber-config/tasks/main.yml
@@ -0,0 +1,10 @@
+---
+# test-subscriber/tasks/main.yml
+
+- name: Create test-ecord-subscriber.yaml TOSCA config
+  template:
+    src: test-ecord-subscriber.yaml.j2
+    dest: "{{ cord_profile_dir }}/test-ecord-subscriber.yaml"
+    owner: "{{ ansible_user_id }}"
+    mode: 0644
+
diff --git a/roles/test-ecord-subscriber-config/templates/test-ecord-subscriber.yaml.j2 b/roles/test-ecord-subscriber-config/templates/test-ecord-subscriber.yaml.j2
new file mode 100644
index 0000000..17afe94
--- /dev/null
+++ b/roles/test-ecord-subscriber-config/templates/test-ecord-subscriber.yaml.j2
@@ -0,0 +1,114 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Creates a CORD test subscriber, created by platform-install
+
+imports:
+   - custom_types/xos.yaml
+   - custom_types/vee.yaml
+   - custom_types/veg.yaml
+   - custom_types/vnodlocal.yaml
+
+topology_template:
+  node_templates:
+
+# site, fully created in deployment.yaml
+    {{ site_name }}:
+      type: tosca.nodes.Site
+      properties:
+        no-delete: true
+        no-create: true
+        no-update: true
+# vsg slice, volt service, fully created in cord-services.yaml
+    {{ site_name }}_veg:
+      type: tosca.nodes.Slice
+      properties:
+        no-delete: true
+        no-create: true
+        no-update: true
+
+    service#vee:
+      type: tosca.nodes.VEEService
+      properties:
+        no-delete: true
+        no-create: true
+        no-update: true
+
+    service#vrouter:
+      type: tosca.nodes.VRouterService
+      properties:
+        no-delete: true
+        no-create: true
+        no-update: true
+
+    service#veg:
+      type: tosca.nodes.VEGService
+      requirements:
+      properties:
+        no-delete: true
+        no-create: true
+        no-update: true
+
+    service#vnodlocal:
+      type: tosca.nodes.VNodLocalService
+      properties:
+        no-delete: true
+        no-create: true
+        no-update: true
+      requirements:
+
+# Test subscriber
+
+    # Let's add a user who can be administrator of the household
+    johndoe@myhouse.com:
+      type: tosca.nodes.User
+      properties:
+        password: letmein
+        firstname: john
+        lastname: doe
+      requirements:
+        - site:
+            node: {{ site_name }}
+            relationship: tosca.relationships.MemberOfSite
+        - dependency:
+            node: {{ site_name }}_veg
+            relationship: tosca.relationships.DependsOn
+
+    # A subscriber
+    My Enterprise:
+      type: tosca.nodes.Subscriber
+      properties:
+      requirements:
+
+    My vEG:
+      type: tosca.nodes.Tenant
+      properties:
+        service_specific_id: 123
+      requirements:
+        - provider_service:
+            node: service#vrouter
+            relationship: tosca.relationships.MemberOfService
+        - subscriber_tenant:
+            node: service#vrouter
+            relationship: tosca.relationships.BelongsToTenant
+
+    My vEE:
+      type: tosca.nodes.Tenant
+      properties:
+        service_specific_id: 123
+      requirements:
+        - provider_service:
+            node: service#veg
+            relationship: tosca.relationships.MemberOfService
+            node: service#vnodlocal
+            relationship: tosca.relationships.MemberOfService
+        - subscriber_tenant:
+            node: service#vee
+            relationship: tosca.relationships.BelongsToTenant
+            node: service#vnodlocal
+            relationship: tosca.relationships.BelongsToTenant
+        - subscriber:
+            node: My Enterprise
+            relationship: tosca.relationships.BelongsToSubscriber
+        - dependency:
+            node: {{ site_name }}_veg
+            relationship: tosca.relationships.DependsOn
diff --git a/roles/test-ecord-subscriber-enable/tasks/main.yml b/roles/test-ecord-subscriber-enable/tasks/main.yml
new file mode 100644
index 0000000..0337c0b
--- /dev/null
+++ b/roles/test-ecord-subscriber-enable/tasks/main.yml
@@ -0,0 +1,8 @@
+---
+# test-ecord-subscriber-enable/tasks/main.yml
+
+- name: Run TOSCA to add test-ecord-subscriber
+  command: "python /opt/xos/tosca/run.py {{ xos_admin_user }} /opt/cord_profile/test-ecord-subscriber.yaml"
+  tags:
+    - skip_ansible_lint # TOSCA loading should be idempotent
+