heat_template_version: 2015-04-30

description: This template deploys a resourcegroup of two VE servers, ready for clustering

parameters:
  data_secgroup:
    type: string
    label: Security Group for the data network
  control_secgroup:
    type: string
    label: Security Group for the control network
  mgmt_secgroup:
    type: string
    label: Security Group for the management network
  ve_image:
    type: string
    label: F5 VE Image
    description: The image to be used on the compute instance.
    constraints:
      - custom_constraint: glance.image
  ve_flavor:
    type: string
    label: F5 VE Flavor
    description: Type of instance (flavor) to be used for the VE.
    constraints:
      - custom_constraint: nova.flavor
  use_config_drive:
    type: boolean
    label: Use Config Drive
    description: Use config drive to provider meta and user data.
    default: false
  ssh_key:
    type: string
    label: SSH Key Name
    description: Name of key-pair to be installed on the instances.
    constraints:
      - custom_constraint: nova.keypair
  admin_password:
    type: string
    label: F5 VE Admin User Password
    description: Password used to perform image import services
  root_password:
    type: string
    label: F5 VE Root User Password
    description: Password used to perform image import services
  license:
    type: string
    label: Primary VE License Base Key
    description: F5 TMOS License Basekey
  external_network:
    type: string
    label: External Network
    description: Network for Floating IPs
    constraints:
      - custom_constraint: neutron.network
  mgmt_network:
    type: string
    label: VE Management Network
    description: Management Interface Network.
    constraints:
      - custom_constraint: neutron.network
  ha_network:
    type: string
    label: VE HA Network
    description: HA Interface Network.
    constraints:
      - custom_constraint: neutron.network
  network_1:
    type: string
    label: VE Network for the 1.2 Interface
    description: 1.2 TMM network.
    constraints:
      - custom_constraint: neutron.network
  network_1_name:
    type: string
    label: Name for Network 1.2
    default: data1
  network_2:
    type: string
    label: VE Network for the 1.3 Interface
    description: 1.3 TMM Network.
    constraints:
      - custom_constraint: neutron.network
  network_2_name:
    type: string
    label: Name for Network 1.3
    default: data2
  default_gateway:
    type: string
    label: Default Gateway IP
    default: None
    description: Upstream Gateway IP Address for VE instances

parameter_groups:
- parameters:
  - ve_image
  - ve_flavor
  - use_config_drive
- parameters:
  - ssh_key
  - admin_password
  - root_password
  - data_secgroup
  - control_secgroup
  - mgmt_secgroup
- parameters:
  - license
- parameters:
  - external_network
  - mgmt_network
  - ha_network
  - network_1
  - network_1_name
  - network_2
  - network_2_name
  - default_gateway

resources:
  two_bigip_devices:
    type: OS::Heat::ResourceGroup
    properties:
      count: 2
      resource_def:
        type: https://raw.githubusercontent.com/F5Networks/f5-openstack-heat/liberty/f5_supported/ve/common/cluster_ready_ve_4_nic.yaml
        properties:
          ve_image: { get_param: ve_image }
          ve_flavor: { get_param: ve_flavor }
          ssh_key: { get_param: ssh_key }
          use_config_drive: { get_param: use_config_drive }
          data_secgroup: { get_param: data_secgroup }
          control_secgroup: { get_param: control_secgroup }
          mgmt_secgroup: { get_param: mgmt_secgroup }
          admin_password: { get_param: admin_password }
          root_password: { get_param: root_password }
          license: { get_param: license }
          external_network: { get_param: external_network }
          mgmt_network: { get_param: mgmt_network } 
          ha_network: { get_param: ha_network }
          network_1: { get_param: network_1 }
          network_2: { get_param: network_2 }
          network_1_name: { get_param: network_1_name }
          network_2_name: { get_param: network_2_name }

outputs:
  bigip1_floating_ip:
    description: Floating IP addresses of VE servers
    value: { get_attr: [ two_bigip_devices, resource.0.floating_ip ] }
  bigip2_floating_ip:
    description: Floating IP addresses of VE servers
    value: { get_attr: [ two_bigip_devices, resource.1.floating_ip ] }
