heat_template_version: 2014-10-16

description: >
  Creates network resources for the cluster. allocate a network and
  router for our server.

parameters:
  existing_network:
    type: string
    default: ""

  existing_subnet:
    type: string
    default: ""

  private_network_cidr:
    type: string
    description: network range for fixed ip network

  private_network_name:
    type: string
    description: fixed network name
    default: ""

  dns_nameserver:
    type: string
    description: address of a dns nameserver reachable in your environment

  external_network:
    type: string
    description: uuid/name of a network to use for floating ip addresses

resources:
  private_network:
    type: Magnum::Optional::Neutron::Net
    properties:
      name: {get_param: private_network_name}

  private_subnet:
    type: Magnum::Optional::Neutron::Subnet
    properties:
      cidr: {get_param: private_network_cidr}
      network: {get_resource: private_network}
      dns_nameservers:
        - {get_param: dns_nameserver}

  extrouter:
    type: Magnum::Optional::Neutron::Router
    properties:
      external_gateway_info:
        network: {get_param: external_network}

  extrouter_inside:
    type: Magnum::Optional::Neutron::RouterInterface
    properties:
      router_id: {get_resource: extrouter}
      subnet: {get_resource: private_subnet}

  network_switch:
    type: Magnum::NetworkSwitcher
    properties:
      private_network: {get_resource: private_network}
      private_subnet: {get_resource: private_subnet}
      existing_network: {get_param: existing_network}
      existing_subnet: {get_param: existing_subnet}

outputs:
    fixed_network:
      description: >
        Network ID where to provision machines
      value: {get_attr: [network_switch, network]}
    fixed_subnet:
      description: >
        Subnet ID where to provision machines
      value: {get_attr: [network_switch, subnet]}
