Anastasia Kuznetsova | 3e0ab4d | 2015-03-06 18:10:13 +0400 | [diff] [blame] | 1 | heat_template_version: 2014-10-16 |
| 2 | |
| 3 | description: | |
| 4 | Template which tests neutron load balancing resources |
| 5 | |
| 6 | parameters: |
| 7 | key_name: |
| 8 | type: string |
| 9 | flavor: |
| 10 | type: string |
| 11 | image: |
| 12 | type: string |
| 13 | private_subnet_id: |
| 14 | type: string |
| 15 | external_network_id: |
| 16 | type: string |
| 17 | port: |
| 18 | type: string |
| 19 | default: '80' |
Rabi Mishra | 7205fee | 2015-04-06 07:57:34 +0530 | [diff] [blame] | 20 | timeout: |
| 21 | type: number |
Anastasia Kuznetsova | 3e0ab4d | 2015-03-06 18:10:13 +0400 | [diff] [blame] | 22 | |
| 23 | resources: |
| 24 | sec_group: |
| 25 | type: OS::Neutron::SecurityGroup |
| 26 | properties: |
| 27 | description: Add security group rules for servers |
| 28 | name: security-group |
| 29 | rules: |
| 30 | - remote_ip_prefix: 0.0.0.0/0 |
| 31 | protocol: tcp |
| 32 | port_range_min: { get_param: port } |
| 33 | port_range_max: { get_param: port } |
| 34 | - remote_ip_prefix: 0.0.0.0/0 |
| 35 | protocol: icmp |
| 36 | |
Rabi Mishra | 7205fee | 2015-04-06 07:57:34 +0530 | [diff] [blame] | 37 | wait_condition: |
| 38 | type: OS::Heat::WaitCondition |
| 39 | properties: |
| 40 | handle: { get_resource: wait_condition_handle } |
| 41 | count: 2 |
| 42 | timeout: { get_param: timeout } |
| 43 | |
| 44 | wait_condition_handle: |
| 45 | type: OS::Heat::WaitConditionHandle |
| 46 | |
| 47 | config: |
| 48 | type: OS::Heat::SoftwareConfig |
| 49 | properties: |
| 50 | group: ungrouped |
| 51 | config: |
| 52 | str_replace: |
| 53 | template: | |
| 54 | #!/bin/bash -v |
| 55 | echo $(hostname) > index.html |
| 56 | python -m SimpleHTTPServer port & |
| 57 | wc_notify --data-binary '{"status": "SUCCESS"}' |
| 58 | params: |
| 59 | wc_notify: { get_attr: ['wait_condition_handle', 'curl_cli'] } |
| 60 | port: { get_param: port } |
| 61 | |
Sergey Kraynev | e0ad363 | 2015-03-19 11:34:32 -0400 | [diff] [blame] | 62 | server1: |
Anastasia Kuznetsova | 3e0ab4d | 2015-03-06 18:10:13 +0400 | [diff] [blame] | 63 | type: OS::Nova::Server |
| 64 | properties: |
| 65 | name: Server1 |
| 66 | image: { get_param: image } |
| 67 | flavor: { get_param: flavor } |
| 68 | key_name: { get_param: key_name } |
| 69 | security_groups: [{ get_resource: sec_group }] |
Rabi Mishra | 7205fee | 2015-04-06 07:57:34 +0530 | [diff] [blame] | 70 | user_data_format: SOFTWARE_CONFIG |
| 71 | user_data: { get_resource: config } |
Anastasia Kuznetsova | 3e0ab4d | 2015-03-06 18:10:13 +0400 | [diff] [blame] | 72 | |
Sergey Kraynev | e0ad363 | 2015-03-19 11:34:32 -0400 | [diff] [blame] | 73 | server2: |
Anastasia Kuznetsova | 3e0ab4d | 2015-03-06 18:10:13 +0400 | [diff] [blame] | 74 | type: OS::Nova::Server |
| 75 | properties: |
| 76 | name: Server2 |
| 77 | image: { get_param: image } |
| 78 | flavor: { get_param: flavor } |
| 79 | key_name: { get_param: key_name } |
| 80 | security_groups: [{ get_resource: sec_group }] |
Rabi Mishra | 7205fee | 2015-04-06 07:57:34 +0530 | [diff] [blame] | 81 | user_data_format: SOFTWARE_CONFIG |
| 82 | user_data: { get_resource: config } |
Anastasia Kuznetsova | 3e0ab4d | 2015-03-06 18:10:13 +0400 | [diff] [blame] | 83 | |
| 84 | health_monitor: |
| 85 | type: OS::Neutron::HealthMonitor |
| 86 | properties: |
| 87 | delay: 3 |
| 88 | type: HTTP |
| 89 | timeout: 3 |
| 90 | max_retries: 3 |
| 91 | |
| 92 | test_pool: |
| 93 | type: OS::Neutron::Pool |
| 94 | properties: |
| 95 | lb_method: ROUND_ROBIN |
| 96 | protocol: HTTP |
| 97 | subnet: { get_param: private_subnet_id } |
| 98 | monitors: |
| 99 | - { get_resource: health_monitor } |
| 100 | vip: |
| 101 | protocol_port: { get_param: port } |
| 102 | |
| 103 | floating_ip: |
| 104 | type: OS::Neutron::FloatingIP |
| 105 | properties: |
| 106 | floating_network: { get_param: external_network_id } |
| 107 | port_id: |
| 108 | { get_attr: [test_pool, vip, 'port_id'] } |
| 109 | |
| 110 | LBaaS: |
| 111 | type: OS::Neutron::LoadBalancer |
Rabi Mishra | 7205fee | 2015-04-06 07:57:34 +0530 | [diff] [blame] | 112 | depends_on: wait_condition |
Anastasia Kuznetsova | 3e0ab4d | 2015-03-06 18:10:13 +0400 | [diff] [blame] | 113 | properties: |
| 114 | pool_id: { get_resource: test_pool } |
| 115 | protocol_port: { get_param: port } |
| 116 | members: |
| 117 | - { get_resource: server1 } |
| 118 | |
Sergey Kraynev | e0ad363 | 2015-03-19 11:34:32 -0400 | [diff] [blame] | 119 | outputs: |
| 120 | serv1_ip: |
| 121 | value: {get_attr: [server1, networks, private, 0]} |
| 122 | serv2_ip: |
| 123 | value: {get_attr: [server2, networks, private, 0]} |
| 124 | vip: |
| 125 | value: {get_attr: [test_pool, vip, address]} |
| 126 | fip: |
| 127 | value: {get_attr: [floating_ip, floating_ip_address]} |