[CORD-1650]
Update TOSCA/variables to work with bridge/bond refactor

Change-Id: Ifdbdeee1b6281bed94eac26d4e7f89371768b5e4
diff --git a/ecord-global.yml b/ecord-global.yml
index 81155fd..6017c45 100644
--- a/ecord-global.yml
+++ b/ecord-global.yml
@@ -61,6 +61,3 @@
 # service graph gui constraints
 xos_gui_service_graph_constraints: '["vnaas"]'
 
-# VTN network configuration
-management_network_ip: 172.27.0.1/24
-data_plane_ip: 10.168.0.253/24
diff --git a/ecord.yml b/ecord.yml
index a8f61a1..b35b123 100644
--- a/ecord.yml
+++ b/ecord.yml
@@ -76,10 +76,6 @@
 # service graph gui constraints
 xos_gui_service_graph_constraints: '["vee", "veg", "vrouter"]'
 
-# VTN network configuration
-management_network_ip: 172.27.0.1/24
-data_plane_ip: 10.168.0.253/24
-
 # Juju config
 charm_versions:
   ceilometer: "cs:trusty/ceilometer-17"
diff --git a/templates/carrierethernet-global-app.yaml.j2 b/templates/carrierethernet-global-app.yaml.j2
index d1406fb..0b9e96c 100644
--- a/templates/carrierethernet-global-app.yaml.j2
+++ b/templates/carrierethernet-global-app.yaml.j2
@@ -6,7 +6,7 @@
    - custom_types/onosservice.yaml
    - custom_types/serviceinstanceattribute.yaml
 
-description: carrierethernet-app onboarding, generated by platform-install
+description: carrierethernet-app onboarding, generated by ecord profile
 topology_template:
   node_templates:
 
diff --git a/templates/carrierethernet-local-app.yaml.j2 b/templates/carrierethernet-local-app.yaml.j2
index 70f24aa..b792f36 100644
--- a/templates/carrierethernet-local-app.yaml.j2
+++ b/templates/carrierethernet-local-app.yaml.j2
@@ -5,7 +5,7 @@
    - custom_types/onosservice.yaml
    - custom_types/serviceinstanceattribute.yaml
 
-description: carrierethernet-app onboarding, generated by platform-install
+description: carrierethernet-app onboarding, generated by ecord profile
 topology_template:
   node_templates:
 
diff --git a/templates/ecord-services.yaml.j2 b/templates/ecord-services.yaml.j2
index cbdc2bf..fad4bde 100644
--- a/templates/ecord-services.yaml.j2
+++ b/templates/ecord-services.yaml.j2
@@ -1,3 +1,4 @@
+---
 {#
 Copyright 2017-present Open Networking Foundation
 
@@ -16,7 +17,7 @@
 
 tosca_definitions_version: tosca_simple_yaml_1_0
 
-description: Just enough Tosca to get the vEG slice running on the CORD POD, created by platform-install
+description: Just enough Tosca to get the vEG slice running on the CORD POD, created by ecord profile
 
 imports:
   - custom_types/addressmanagerservice.yaml
@@ -55,13 +56,14 @@
     management:
       type: tosca.nodes.Network
       properties:
-        name: management
         must-exist: true
+        name: management
 
-{% if use_management_hosts %}
-    management_hosts:
+{% if use_vtn_net_management_host %}
+    management_host:
       type: tosca.nodes.Network
       properties:
+        name: management_host
         must-exist: true
 {% endif %}
 
@@ -80,13 +82,15 @@
         must-exist: true
 
 # CORD Services
+
+# Using same addresses as the r-cord VSG
     addresses_veg:
       type: tosca.nodes.AddressPool
       properties:
         name: addresses_veg
-        addresses: 10.7.1.0/24
-        gateway_ip: 10.7.1.1
-        gateway_mac: a4:23:05:06:01:01
+        addresses: {{ addresspool_vsg_cidr }}
+        gateway_ip: {{ addresspool_vsg_cidr | ipaddr('1') | ipaddr('address') }}
+        gateway_mac: {{ fabric_gateway_hwaddr }}
       requirements:
         - service:
             node: service#addressmanager
@@ -96,9 +100,9 @@
       type: tosca.nodes.AddressPool
       properties:
         name: addresses_public
-        addresses: 10.8.1.0/24
-        gateway_ip: 10.8.1.1
-        gateway_mac: a4:23:05:06:01:01
+        addresses: {{ addresspool_public_cidr }}
+        gateway_ip: {{ addresspool_public_cidr | ipaddr('1') | ipaddr('address') }}
+        gateway_mac: {{ fabric_gateway_hwaddr }}
       requirements:
         - service:
             node: service#addressmanager
@@ -194,10 +198,10 @@
               node: service#vrouter
               relationship: tosca.relationships.BelongsToOne
 
-    template#veg:
+    veg_template:
       type: tosca.nodes.NetworkTemplate
       properties:
-        name: veg
+        name: veg_template
         visibility: private
         translation: none
         vtn_kind: VSG
@@ -210,7 +214,7 @@
         # ip_version: 4
       requirements:
         - template:
-            node: template#veg
+            node: veg_template
             relationship: tosca.relationships.BelongsToOne
         - owner:
             node: {{ site_name }}_veg
@@ -254,12 +258,12 @@
               node: {{ site_name }}_veg
               relationship: tosca.relationships.BelongsToOne
 
-{% if use_management_hosts %}
-    networkslice#management_hosts_to_{{ site_name }}_veg:
+{% if use_vtn_net_management_host %}
+    networkslice#management_host_to_{{ site_name }}_veg:
         type: tosca.nodes.NetworkSlice
         requirements:
           - network:
-              node: management_hosts
+              node: management_host
               relationship: tosca.relationships.BelongsToOne
           - slice:
             node: {{ site_name }}_veg
diff --git a/templates/management-net.yaml.j2 b/templates/management-net.yaml.j2
index 9c7b03c..7447322 100644
--- a/templates/management-net.yaml.j2
+++ b/templates/management-net.yaml.j2
@@ -24,7 +24,7 @@
    - custom_types/slice.yaml
    - custom_types/site.yaml
 
-description: management network config, generated by platform-install
+description: management network config, generated by ecord profile
 
 topology_template:
   node_templates:
@@ -35,7 +35,7 @@
       properties:
         name: {{ site_name }}
 
-# management network
+# management (vtn: MANAGEMENT_LOCAL) network
     management_template:
       type: tosca.nodes.NetworkTemplate
       properties:
@@ -49,7 +49,7 @@
       properties:
         name: management
         # ip_version: 4
-        subnet: {{ management_network_cidr }}
+        subnet: {{ vtn_net_management_local_cidr }}
         permit_all_slices: true
       requirements:
         - template:
@@ -59,33 +59,37 @@
             node: slice#{{ site_name }}_management
             relationship: tosca.relationships.BelongsToOne
 
-{% if use_management_hosts %}
-    management_hosts_template:
+{% if use_vtn_net_management_host %}
+# management_host (vtn: MANAGEMENT_HOST) network
+    management_host_template:
       type: tosca.nodes.NetworkTemplate
       properties:
-        name: management_hosts_template
+        name: management_host_template
         visibility: private
         translation: none
         vtn_kind: MANAGEMENT_HOST
 
-    management_hosts:
+    management_host:
       type: tosca.nodes.Network
       properties:
+        name: management_host
         # ip_version: 4
-        subnet: {{ management_hosts_net_cidr }}
-        start_ip: {{ management_hosts_net_range_xos_low }}
-        end_ip: {{ management_hosts_net_range_xos_high }}
+        subnet: {{ vtn_net_management_host_cidr }}
+        start_ip: {{ vtn_net_management_host_range_xos_low }}
+        end_ip: {{ vtn_net_management_host_range_xos_high }}
+        permit_all_slices: true
       requirements:
         - template:
-            node: management_hosts_template
+            node: management_host_template
             relationship: tosca.relationships.BelongsToOne
         - owner:
             node: slice#{{ site_name }}_management
             relationship: tosca.relationships.BelongsToOne
 {% endif %}
 
+# Slice to own management networks
     slice#{{ site_name }}_management:
-      description: This slice exists solely to own the management network
+      description: This slice exists solely to own the management network(s)
       type: tosca.nodes.Slice
       properties:
         network: noauto
diff --git a/templates/public-net.yaml.j2 b/templates/public-net.yaml.j2
index 610c58b..0c2aeaa 100644
--- a/templates/public-net.yaml.j2
+++ b/templates/public-net.yaml.j2
@@ -1,4 +1,4 @@
-
+---
 {#
 Copyright 2017-present Open Networking Foundation
 
@@ -15,7 +15,6 @@
 limitations under the License.
 #}
 
-
 tosca_definitions_version: tosca_simple_yaml_1_0
 
 imports:
@@ -29,21 +28,30 @@
   - custom_types/site.yaml
   - custom_types/slice.yaml
 
-description: public network config, generated by platform-install
+description: public network config, generated by ecord profile
 
 topology_template:
   node_templates:
 
-# site, fully created in deployment.yaml
+# site, fully created in deployment.yaml.j2
     {{ site_name }}:
       type: tosca.nodes.Site
       properties:
         name: {{ site_name }}
         must-exist: true
 
+    {{ site_name }}_public:
+      description: This slice exists solely to own the public network
+      type: tosca.nodes.Slice
+      properties:
+        network: noauto
+        name: {{ site_name }}_public
+      requirements:
+        - site:
+            node: {{ site_name }}
+            relationship: tosca.relationships.BelongsToOne
 
-
-# Address Manager service, fully created in cord-service.yaml
+# Address Manager service, fully created in cord-services.yaml.j2
     service#addressmanager:
       type: tosca.nodes.AddressManagerService
       properties:
@@ -51,31 +59,30 @@
         must-exist: true
 
 # public network
-
     public_template:
       type: tosca.nodes.NetworkTemplate
       properties:
-          name: public_template
-          visibility: public
-          translation: none
-          vtn_kind: PUBLIC
+        name: public_template
+        visibility: public
+        translation: none
+        vtn_kind: PUBLIC
 
     public:
       type: tosca.nodes.Network
       properties:
-          name: public
-          permit_all_slices: true
-          subnet: 10.8.1.0/24 # NOTE same as AddressPool#addresses_public
-          # ip_version: 4
+        name: public
+        permit_all_slices: true
+        subnet: {{ addresspool_public_cidr }}
+        # ip_version: 4
       requirements:
-          - template:
-              node: public_template
-              relationship: tosca.relationships.BelongsToOne
-          - owner:
-              node: {{ site_name }}_public
-              relationship: tosca.relationships.BelongsToOne
+        - template:
+            node: public_template
+            relationship: tosca.relationships.BelongsToOne
+        - owner:
+            node: {{ site_name }}_public
+            relationship: tosca.relationships.BelongsToOne
 
-    # Created in cord-services.yaml.j2
+# Created in cord-services.yaml.j2
     addresses_public:
       type: tosca.nodes.AddressPool
       properties:
@@ -85,33 +92,22 @@
     AddressManagerServiceInstancePublicNetwork:
       type: tosca.nodes.AddressManagerServiceInstance
       requirements:
-          - owner:
-              node: service#addressmanager
-              relationship: tosca.relationships.BelongsToOne
-          - address_pool:
-              node: addresses_public
-              relationship: tosca.relationships.BelongsToOne
+        - owner:
+            node: service#addressmanager
+            relationship: tosca.relationships.BelongsToOne
+        - address_pool:
+            node: addresses_public
+            relationship: tosca.relationships.BelongsToOne
       properties:
-          name: AM_public_net
+        name: AM_public_net
 
     public_to_address_manager:
-        type: tosca.nodes.ServiceInstanceLink
-        requirements:
-          - provider_service_instance:
-              node: AddressManagerServiceInstancePublicNetwork
-              relationship: tosca.relationships.BelongsToOne
-          - subscriber_network:
-              node: public
-              relationship: tosca.relationships.BelongsToOne
-
-    {{ site_name }}_public:
-      description: This slice exists solely to own the public network
-      type: tosca.nodes.Slice
-      properties:
-          network: noauto
-          name: {{ site_name }}_public
+      type: tosca.nodes.ServiceInstanceLink
       requirements:
-          - site:
-              node: {{ site_name }}
-              relationship: tosca.relationships.BelongsToOne
+        - provider_service_instance:
+            node: AddressManagerServiceInstancePublicNetwork
+            relationship: tosca.relationships.BelongsToOne
+        - subscriber_network:
+            node: public
+            relationship: tosca.relationships.BelongsToOne
 
diff --git a/templates/vee-service.yaml.j2 b/templates/vee-service.yaml.j2
index 9fea06d..4a5dfd1 100644
--- a/templates/vee-service.yaml.j2
+++ b/templates/vee-service.yaml.j2
@@ -1,4 +1,4 @@
-
+---
 {#
 Copyright 2017-present Open Networking Foundation
 
@@ -15,7 +15,6 @@
 limitations under the License.
 #}
 
-
 tosca_definitions_version: tosca_simple_yaml_1_0
 
 imports:
@@ -24,7 +23,7 @@
    - custom_types/networktemplate.yaml
    - custom_types/servicedependency.yaml
 
-description: vee services, generated by platform-install
+description: vee services, generated by ecord profile
 
 topology_template:
   node_templates:
@@ -53,10 +52,10 @@
             node: service#vee
             relationship: tosca.relationships.BelongsToOne
 
-    template#vee:
+    vee_template:
       type: tosca.nodes.NetworkTemplate
       properties:
-        name: vee
+        name: vee_template
         visibility: private
         translation: none
         vtn_kind: vee
diff --git a/templates/vnaasglobal-service-reference.yaml.j2 b/templates/vnaasglobal-service-reference.yaml.j2
index 1fbf3d9..4c0ed98 100644
--- a/templates/vnaasglobal-service-reference.yaml.j2
+++ b/templates/vnaasglobal-service-reference.yaml.j2
@@ -1,3 +1,4 @@
+---
 {#
 Copyright 2017-present Open Networking Foundation
 
@@ -19,7 +20,7 @@
 imports:
    - custom_types/vnaas.yaml
 
-description: vnaasglobal services, generated by platform-install
+description: vnaasglobal services, generated by ecord profile
 
 topology_template:
   node_templates:
diff --git a/templates/vtn-service.yaml.j2 b/templates/vtn-service.yaml.j2
index 6a2dbd6..4f5a419 100644
--- a/templates/vtn-service.yaml.j2
+++ b/templates/vtn-service.yaml.j2
@@ -44,7 +44,7 @@
           kind: platform
           view_url: /admin/vtn/vtnservice/$id$/
           privateGatewayMac: 00:00:00:00:00:01
-          localManagementIp: {{ management_network_ip }}
+          localManagementIp: {{ vtn_net_management_local_cidr | ipaddr('1') }}
           ovsdbPort: 6641
           sshUser: root
           sshKeyFile: /root/node_key