Integrate vMX in tungstenfabric environment

Related-PROD: PRODX-20668
Change-Id: I202bf3a25cf7fd4b70b43ce6d0b3e1397872c9ed
diff --git a/de/heat-templates/top.yaml b/de/heat-templates/top.yaml
index d3331b3..b6a3e19 100644
--- a/de/heat-templates/top.yaml
+++ b/de/heat-templates/top.yaml
@@ -24,13 +24,9 @@
       - "destination": "10.100.100.1/32"
         "nexthop": "172.16.1.1"
     default: []
-  control_network_vsrx_peering_ip:
+  control_network_ext_router_ip:
     type: string
-    description: IP address of vsrx for tungsten fabric peering
-    default: ''
-  data_network_vsrx_ip:
-    type: string
-    description: IP address of vsrx in tungsten fabric data network
+    description: IP address of vsrx/vmx in control network
     default: ''
   docker_default_address_pool:
     type: string
@@ -168,6 +164,30 @@
   tungstenfabric_enabled:
     type: boolean
     default: false
+  vmx_linux_img:
+    type: string
+    description: Name of image to use for servers
+    default: "vPFC-20170216"
+  vmx_linux_flav:
+    type: string
+    description: Name of image to use for servers
+    default: "vfp.lite"
+  vmx_junos_img:
+    type: string
+    description: Name of image to use for servers
+    default: "vmx-x86-64-17.1R1.8"
+  vmx_junos_flav:
+    type: string
+    description: Name of image to use for servers
+    default: "vcp.lite"
+  vmx_gateway_ip:
+    type: string
+    description: Default GW for vmx
+    default: '10.10.0.1'
+  vmx_lo_ip:
+    type: string
+    description: Ip of lo interface for vmx
+    default: '10.199.199.199'
   tun_network_cidr:
     type: string
     default: '10.15.0.0/24'
@@ -184,6 +204,10 @@
   tun_network_pool_end:
     type: string
     default: '10.15.0.99'
+  tun_network_ext_router_ip:
+    type: string
+    description: IP address of vsrx/vmx in data network
+    default: ''
   tun_network_host_routes:
     type: json
     description: >
@@ -191,6 +215,27 @@
       - "destination": "10.100.100.1/32"
         "nexthop": "172.16.1.1"
     default: []
+  evpn_network_cidr:
+    type: string
+    default: '10.20.100.0/24'
+  evpn_network_ipam_pool_start:
+    type: string
+    description: pool start which is used as pool for IPAM and assigned to instances port
+    default: '10.20.100.2'
+  evpn_network_ipam_pool_end:
+    type: string
+    description: pool end which is used as pool for IPAM and assigned to instances port
+    default: '10.20.100.99'
+  evpn_network_pool_start:
+    type: string
+    default: '10.20.100.105'
+  evpn_network_pool_end:
+    type: string
+    default: '10.20.100.200'
+  evpn_network_vmx_ip:
+    type: string
+    description: IP address of vmx in a network for evpn test
+    default: ''
   ucp_metadata:
     type: json
     default: {"role":"ucp"}
@@ -341,12 +386,38 @@
   secure_overlay_enabled:
     type: boolean
     default: false
+  vsrx_enabled:
+    type: boolean
+    default: false
+  vmx_enabled:
+    type: boolean
+    default: false
 
 conditions:
   aio_deploy:
     equals:
     - get_param: single_node
     - 'true'
+  tf:
+    equals:
+      - get_param: tungstenfabric_enabled
+      - true
+  vsrx_deploy:
+    equals:
+      - get_param: vsrx_enabled
+      - true
+  vmx_deploy:
+    and:
+      - tf
+      - equals:
+          - get_param: vmx_enabled
+          - true
+      - not:
+          vsrx_deploy
+  ext_router_deploy:
+    or:
+      - vsrx_deploy
+      - vmx_deploy
 
 resources:
   keypair_name:
@@ -369,7 +440,7 @@
       dns_nameservers: { get_param: dns_nameservers }
       control_network_host_routes: { get_param: control_network_host_routes }
       tungstenfabric_enabled: { get_param: tungstenfabric_enabled }
-      control_network_vsrx_peering_ip: { get_param: control_network_vsrx_peering_ip }
+      control_network_ext_router_ip: { get_param: control_network_ext_router_ip }
       private_floating_network_cidr: { get_param: private_floating_network_cidr }
 
   tun_network:
@@ -386,11 +457,50 @@
       private_floating_network_cidr: { get_param: private_floating_network_cidr }
       private_floating_network_ipam_pool_start: { get_param: private_floating_network_ipam_pool_start }
       private_floating_network_ipam_pool_end: { get_param: private_floating_network_ipam_pool_end }
-      private_floating_network_gateway: {get_param: private_floating_network_gateway}
-      control_network_vsrx_peering_ip: {get_param: control_network_vsrx_peering_ip}
-      accessible_network: { get_attr: [accessible_network, public_network]}
-      data_network_vsrx_ip: { get_param: data_network_vsrx_ip }
-      tun_network: { get_attr: [tun_network, tun_network_id] }
+
+  vmx:
+    depends_on:
+      - private_floating_network
+      - accessible_network
+      - tun_network
+    condition: vmx_deploy
+    type: MCP2::VMX
+    properties:
+      linux_img: { get_param: vmx_linux_img }
+      linux_flav: { get_param: vmx_linux_flav }
+      junos_img: { get_param: vmx_junos_img }
+      junos_flav: { get_param: vmx_junos_flav }
+      vmx_gateway_ip: { get_param: vmx_gateway_ip }
+      vmx_lo_ip: { get_param: vmx_lo_ip }
+      accessible_network_id: { get_attr: [ accessible_network, public_network ] }
+      control_network_cidr: { get_param: control_network_cidr }
+      control_network_vmx_ip: { get_param: control_network_ext_router_ip }
+      tun_network_id: { get_attr: [ tun_network, tun_network_id ] }
+      tun_network_vmx_ip: { get_param: tun_network_ext_router_ip }
+      tun_network_cidr: { get_param: tun_network_cidr }
+      private_floating_network_id: { get_attr: [private_floating_network, private_floating_network_id] }
+      private_floating_network_cidr: { get_param: private_floating_network_cidr }
+      private_floating_network_gateway: { get_param: private_floating_network_gateway }
+      evpn_network_cidr: { get_param: evpn_network_cidr }
+      evpn_network_ipam_pool_start: { get_param: evpn_network_ipam_pool_start }
+      evpn_network_ipam_pool_end: { get_param: evpn_network_ipam_pool_end }
+      evpn_network_vmx_ip: { get_param: evpn_network_vmx_ip }
+      public_net_id: { get_param: public_net_id }
+
+  vsrx:
+    depends_on:
+      - private_floating_network
+      - accessible_network
+      - tun_network
+    condition: vsrx_deploy
+    type: MCP2::VSRX
+    properties:
+      private_floating_network_id: { get_attr: [private_floating_network, private_floating_network_id] }
+      private_floating_network_gateway: { get_param: private_floating_network_gateway }
+      control_network_vsrx_ip: { get_param: control_network_ext_router_ip }
+      accessible_network: { get_attr: [ accessible_network, public_network ] }
+      data_network_vsrx_ip: { get_param: tun_network_ext_router_ip }
+      tun_network: { get_attr: [ tun_network, tun_network_id ] }
       vsrx_image: { get_param: vsrx_image }
       vsrx_flavor: { get_param: vsrx_flavor }
       public_net_id: { get_param: public_net_id }
@@ -1040,15 +1150,27 @@
     value: { get_param: storage_backend_network_cidr }
   tungstenfabric_enabled:
     value: { get_param: tungstenfabric_enabled }
-  data_network_vsrx_ip:
-    description: IP address of vsrx in tungsten fabric data network
-    value: { get_param: data_network_vsrx_ip }
-  control_network_vsrx_peering_ip:
-    description: IP address of vsrx in control/accessible network
-    value: { get_param: control_network_vsrx_peering_ip }
-  public_network_vsrx_ip:
-    description: IP address of vsrx in tungsten fabric public network
-    value: { get_attr: [private_floating_network, server_public_ip] }
+  tun_network_ext_router_ip:
+    condition: ext_router_deploy
+    description: IP address of vsrx/vmx in data network
+    value: { get_param: tun_network_ext_router_ip }
+  control_network_ext_router_ip:
+    condition: ext_router_deploy
+    description: IP address of vsrx/vmx in control/accessible network
+    value: { get_param: control_network_ext_router_ip }
+  public_network_ext_router_ip:
+    condition: ext_router_deploy
+    description: Public IP of vsrx/vmx instance
+    value: { if: [ vmx_deploy, get_attr: [ vmx, re_floating_ip ], get_attr: [ vsrx, server_public_ip ] ] }
   accessible_router:
     description: Router from accessible network to public
     value: { get_attr: [accessible_network, accessible_router] }
+  evpn_network_cidr:
+    description: Network CIDR for evpn tests
+    value: { get_param: evpn_network_cidr }
+  evpn_network_pool_start:
+    description: IPAM pool start for evpn tests
+    value: { get_param: evpn_network_pool_start }
+  evpn_network_pool_end:
+    description: IPAM pool end for evpn tests
+    value: { get_param: evpn_network_pool_end }