[CORD-1650]
Use new variables from bridge/bond refactor in TOSCA

Change-Id: I0515e57dcae24b4c9e4362935f88607c673f00af
diff --git a/templates/addressmanager-service.yaml.j2 b/templates/addressmanager-service.yaml.j2
index aae46f2..cb27ef7 100644
--- a/templates/addressmanager-service.yaml.j2
+++ b/templates/addressmanager-service.yaml.j2
@@ -1,4 +1,3 @@
-
 {#
 Copyright 2017-present Open Networking Foundation
 
@@ -32,9 +31,9 @@
       type: tosca.nodes.AddressPool
       properties:
         name: addresses_vsg
-        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:  {{ ( vtn_net_public_hwaddr_prefix ~ ( vtn_net_public_cidr | ipaddr('1') | ipaddr('address') | ip4_hex )) | hwaddr('unix') }}
       requirements:
         - service:
             node: service#addressmanager
@@ -44,9 +43,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:  {{ ( vtn_net_public_hwaddr_prefix ~ ( vtn_net_public_cidr | ipaddr('1') | ipaddr('address') | ip4_hex )) | hwaddr('unix') }}
       requirements:
         - service:
             node: service#addressmanager
diff --git a/templates/cord-services.yaml.j2 b/templates/cord-services.yaml.j2
index 0fb5171..8a6a168 100644
--- a/templates/cord-services.yaml.j2
+++ b/templates/cord-services.yaml.j2
@@ -1,4 +1,4 @@
-
+---
 {#
 Copyright 2017-present Open Networking Foundation
 
@@ -15,10 +15,9 @@
 limitations under the License.
 #}
 
-
 tosca_definitions_version: tosca_simple_yaml_1_0
 
-description: Just enough Tosca to get the vSG slice running on the CORD POD, created by platform-install
+description: Just enough Tosca to get the vSG slice running on the CORD POD, created by rcord profile
 
 imports:
   - custom_types/addressmanagerservice.yaml
@@ -62,10 +61,11 @@
         name: management
         must-exist: true
 
-{% 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 %}
 
@@ -127,13 +127,14 @@
             node: service#vsg
             relationship: tosca.relationships.BelongsToOne
 
+
     addresses_vsg:
       type: tosca.nodes.AddressPool
       properties:
         name: addresses_vsg
-        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:  {{ ( vtn_net_public_hwaddr_prefix ~ ( vtn_net_public_cidr | ipaddr('1') | ipaddr('address') | ip4_hex )) | hwaddr('unix') }}
       requirements:
         - service:
             node: service#addressmanager
@@ -143,9 +144,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:  {{ ( vtn_net_public_hwaddr_prefix ~ ( vtn_net_public_cidr | ipaddr('1') | ipaddr('address') | ip4_hex )) | hwaddr('unix') }}
       requirements:
         - service:
             node: service#addressmanager
@@ -233,10 +234,10 @@
               node: service#vrouter
               relationship: tosca.relationships.BelongsToOne
 
-    template#vsg:
+    vsg_template:
       type: tosca.nodes.NetworkTemplate
       properties:
-        name: vsg
+        name: vsg_template
         visibility: private
         translation: none
         vtn_kind: VSG
@@ -249,7 +250,7 @@
         # ip_version: 4
       requirements:
         - template:
-            node: template#vsg
+            node: vsg_template
             relationship: tosca.relationships.BelongsToOne
         - owner:
             node: {{ site_name }}_vsg
@@ -272,7 +273,7 @@
       properties:
         network: noauto
         name: {{ site_name }}_vsg
-      requirements: 
+      requirements:
         - service:
             node: service#vsg
             relationship: tosca.relationships.BelongsToOne
@@ -293,18 +294,18 @@
               node: {{ site_name }}_vsg
               relationship: tosca.relationships.BelongsToOne
 
-{% if use_management_hosts %}
-    networkslice#management_hosts_to_{{ site_name }}_vsg:
+{% if use_vtn_net_management_host %}
+    networkslice#management_host_to_{{ site_name }}_vsg:
         type: tosca.nodes.NetworkSlice
         requirements:
           - network:
-              node: management_hosts
+              node: management_host
               relationship: tosca.relationships.BelongsToOne
           - slice:
-            node: {{ site_name }}_vsg
-            relationship: tosca.relationships.BelongsToOne
+              node: {{ site_name }}_vsg
+              relationship: tosca.relationships.BelongsToOne
 {% endif %}
-    
+
     # TODO: migrate interfaces when we'll start using them
     # in#lanside:
     #   type: tosca.nodes.InterfaceType
@@ -364,4 +365,5 @@
     #         relationship: tosca.relationships.MemberOfService
     #     - interface:
     #         node: in#wanside
-    #         relationship: tosca.relationships.IsType
\ No newline at end of file
+    #         relationship: tosca.relationships.IsType
+
diff --git a/templates/fabric-service.yaml.j2 b/templates/fabric-service.yaml.j2
index e28d5ea..77ed898 100644
--- a/templates/fabric-service.yaml.j2
+++ b/templates/fabric-service.yaml.j2
@@ -25,7 +25,7 @@
    - custom_types/onosapp.yaml
    - custom_types/serviceinstancelink.yaml
 
-description: fabric services, generated by platform-install
+description: fabric services, generated by rcord profile
 
 topology_template:
   node_templates:
diff --git a/templates/management-net.yaml.j2 b/templates/management-net.yaml.j2
index 9c7b03c..cbef35c 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 rcord 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:
@@ -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..cc30e71 100644
--- a/templates/public-net.yaml.j2
+++ b/templates/public-net.yaml.j2
@@ -1,4 +1,3 @@
-
 {#
 Copyright 2017-present Open Networking Foundation
 
@@ -15,7 +14,6 @@
 limitations under the License.
 #}
 
-
 tosca_definitions_version: tosca_simple_yaml_1_0
 
 imports:
@@ -29,21 +27,30 @@
   - custom_types/site.yaml
   - custom_types/slice.yaml
 
-description: public network config, generated by platform-install
+description: public network config, generated by rcord 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 +58,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 +91,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/vsg-net.yaml.j2 b/templates/vsg-net.yaml.j2
index 9bcf397..ef5787e 100644
--- a/templates/vsg-net.yaml.j2
+++ b/templates/vsg-net.yaml.j2
@@ -6,7 +6,7 @@
   - custom_types/slice.yaml
   - custom_types/site.yaml
 
-description: vsg network config, generated by platform-install
+description: vsg network config, generated by rcord profile
 
 topology_template:
   node_templates:
@@ -31,7 +31,7 @@
       type: tosca.nodes.Network
       properties:
           name: vsg_network
-          subnet: 101.0.0.0/24
+          subnet: {{ addresspool_vsg_cidr }}
       requirements:
           - template:
               node: vsg_template
@@ -51,4 +51,3 @@
               node: {{ site_name }}
               relationship: tosca.relationships.BelongsToOne
 
-
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