heat_template_version: 2014-10-16

description: >
  This is a nested stack that defines a single Mesos slave, This stack is
  included by a ResourceGroup resource in the parent template
  (mesoscluster.yaml).

parameters:

  server_image:
    type: string
    description: glance image used to boot the server

  slave_flavor:
    type: string
    description: flavor to use when booting the server

  ssh_key_name:
    type: string
    description: name of ssh key to be provisioned on our server

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

  fixed_network:
    type: string
    description: Network from which to allocate fixed addresses.

  fixed_subnet:
    type: string
    description: Subnet from which to allocate fixed addresses.

  secgroup_slave_all_open_id:
    type: string
    description: ID of the security group for slave.

  mesos_slave_software_configs:
    type: string
    description: ID of the multipart mime.

resources:

  ######################################################################
  #
  # a single Mesos slave.
  #

  # do NOT use "_" (underscore) in the Nova server name
  # it creates a mismatch between the generated Nova name and its hostname
  # which can lead to weird problems
  mesos-slave:
    type: OS::Nova::Server
    properties:
      image: {get_param: server_image}
      flavor: {get_param: slave_flavor}
      key_name: {get_param: ssh_key_name}
      user_data_format: RAW
      user_data: {get_param: mesos_slave_software_configs}
      networks:
        - port: {get_resource: mesos_slave_eth0}

  mesos_slave_eth0:
    type: OS::Neutron::Port
    properties:
      network: {get_param: fixed_network}
      security_groups:
        - get_param: secgroup_slave_all_open_id
      fixed_ips:
        - subnet: {get_param: fixed_subnet}
      replacement_policy: AUTO

  mesos_slave_floating:
    type: OS::Neutron::FloatingIP
    properties:
      floating_network: {get_param: external_network}
      port_id: {get_resource: mesos_slave_eth0}

outputs:

  mesos_slave_ip:
    value: {get_attr: [mesos_slave_eth0, fixed_ips, 0, ip_address]}
    description: >
      This is the "private" address of the Mesos slave node.
  mesos_slave_external_ip:
    value: {get_attr: [mesos_slave_floating, floating_ip_address]}
    description: >
      This is the "public" address of the Mesos slave node.
