heat_template_version: 2015-04-30

description:
  HOT template that creates a Contrail Virtual Network with L2NODHCP

parameters:
  network_name:
     type: string
     description: Name of direct network (e.g. core, dmz)
     default: ECOMPNetwork
  shared:
     type: boolean
     description: Shared amongst tenants
     default: False
  external:
     type: boolean
     description: router_external for the VirtualNetwork
     default: False
  route_targets:
    type: comma_delimited_list
    description: Network route-targets (RT)
    default: ""
  subnet_list:
     type: json
     description: Network subnets
     default: []
  policy_refs:
     type: comma_delimited_list
     description: Policies referenced by Network
     default: ""
  policy_refsdata:
     type: json
     description: Policies referenced by Network
     default: []
  route_table_refs:
     type: comma_delimited_list
     description: Route Tables referenced by Network
     default: ""
  virtual_network_properties_allow_transit:
     type: boolean
     description: allow_transit for the VirtualNetwork
     default: True
  virtual_network_properties_forwarding_mode:
     type: string
     description: forwarding_mode for the VirtualNetwork
     default: l2
  virtual_network_properties_rpf:
     type: string
     description: rpf for the VirtualNetwork
     default: disable
  flood_unknown_unicast:
     type: boolean
     description: flood_unknown_unicast for the VirtualNetwork
     default: True

outputs:
  network_id:
    description: Openstack network identifier
    value: { get_resource: network }
  network_fqdn:
    description: Openstack network identifier
    value: {list_join: [':', { get_attr: [network, fq_name] } ] }

resources:
  networkIpam:
    type: OS::ContrailV2::NetworkIpam
    properties:
      name: { get_param: network_name }

  network:
    type: OS::ContrailV2::VirtualNetwork
    properties:
      name: { get_param: network_name }
      is_shared: {get_param: shared}
      router_external: { get_param: external }
      route_target_list:
        {
           route_target_list_route_target: { get_param: route_targets }
        }
      network_ipam_refs: [{ get_resource: networkIpam }]
      network_ipam_refs_data:
        [
          {
             network_ipam_refs_data_ipam_subnets: { get_param: subnet_list }
          }
        ]
      network_policy_refs:  { get_param: policy_refs }
      network_policy_refs_data: { get_param: policy_refsdata }
      route_table_refs: { get_param: route_table_refs }
      flood_unknown_unicast: { get_param: flood_unknown_unicast }  
      virtual_network_properties:
        {
           virtual_network_properties_allow_transit: { get_param: virtual_network_properties_allow_transit },
           virtual_network_properties_forwarding_mode: { get_param: virtual_network_properties_forwarding_mode },
           virtual_network_properties_rpf: { get_param: virtual_network_properties_rpf },
        }
