heat_template_version: newton


description: |
  It references to an external network and creates a router attached to it


parameters:
  external_id:
    description: default value to be assigned to network ports
    type: string
    default: '<no-external-id>'

  has_external_id:
    description: whenever has external network
    type: boolean
    default: true

  router_value_specs:
    description: extra router creation parameters
    type: json
    default: {}

  create_router:
    description: whatever to attach a router to external interface
    type: boolean
    default: true


conditions:
  has_external_id:
    get_param: has_external_id

  create_router:
    and:
      - get_param: has_external_id
      - get_param: create_router


resources:
  _network:
    type: OS::Neutron::Net
    condition: has_external_id
    external_id: {get_param: external_id}

  _router:
    type: OS::Neutron::Router
    condition: create_router
    properties:
      external_gateway_info:
        network: {get_resource: _network}
      value_specs: {get_param: router_value_specs}


outputs:
  network_id:
    description: network ID
    condition: has_external_id
    value: {get_resource: _network}

  router_id:
    description: router ID
    condition: create_router
    value: {get_resource: _router}

  mtu:
    description: Network MTU value (integer)
    value: {get_attr: [_network, mtu]}
    condition: has_external_id
