af8f47aa449bfd5a72804d009031fb56b0f41e5f
[apex-tripleo-heat-templates.git] / ci / pingtests / scenario001-multinode.yaml
1 heat_template_version: ocata
2
3 description: >
4   HOT template to created resources deployed by scenario001.
5 parameters:
6   key_name:
7     type: string
8     description: Name of keypair to assign to servers
9     default: 'pingtest_key'
10   image:
11     type: string
12     description: Name of image to use for servers
13     default: 'pingtest_image'
14   public_net_name:
15     type: string
16     default: 'nova'
17     description: >
18       ID or name of public network for which floating IP addresses will be allocated
19   private_net_name:
20     type: string
21     description: Name of private network to be created
22     default: 'default-net'
23   private_net_cidr:
24     type: string
25     description: Private network address (CIDR notation)
26     default: '192.168.2.0/24'
27   private_net_gateway:
28     type: string
29     description: Private network gateway address
30     default: '192.168.2.1'
31   private_net_pool_start:
32     type: string
33     description: Start of private network IP address allocation pool
34     default: '192.168.2.100'
35   private_net_pool_end:
36     type: string
37     default: '192.168.2.200'
38     description: End of private network IP address allocation pool
39
40 resources:
41
42   key_pair:
43     type: OS::Nova::KeyPair
44     properties:
45       save_private_key: true
46       name: {get_param: key_name }
47
48   private_net:
49     type: OS::Neutron::Net
50     properties:
51       name: { get_param: private_net_name }
52
53   private_subnet:
54     type: OS::Neutron::Subnet
55     properties:
56       network_id: { get_resource: private_net }
57       cidr: { get_param: private_net_cidr }
58       gateway_ip: { get_param: private_net_gateway }
59       allocation_pools:
60         - start: { get_param: private_net_pool_start }
61           end: { get_param: private_net_pool_end }
62
63   router:
64     type: OS::Neutron::Router
65     properties:
66       external_gateway_info:
67         network: { get_param: public_net_name }
68
69   router_interface:
70     type: OS::Neutron::RouterInterface
71     properties:
72       router_id: { get_resource: router }
73       subnet_id: { get_resource: private_subnet }
74
75   volume1:
76     type: OS::Cinder::Volume
77     properties:
78       name: Volume1
79       image: { get_param: image }
80       size: 1
81
82   server1:
83     type: OS::Nova::Server
84     depends_on: volume1
85     properties:
86       name: Server1
87       block_device_mapping:
88         - device_name: vda
89           volume_id: { get_resource: volume1 }
90       flavor: { get_resource: test_flavor }
91       key_name: { get_resource: key_pair }
92       networks:
93         - port: { get_resource: server1_port }
94
95   server1_port:
96     type: OS::Neutron::Port
97     properties:
98       network_id: { get_resource: private_net }
99       fixed_ips:
100         - subnet_id: { get_resource: private_subnet }
101       security_groups: [{ get_resource: server_security_group }]
102
103   server1_floating_ip:
104     type: OS::Neutron::FloatingIP
105     # TODO: investigate why we need this depends_on and if we could
106     # replace it by router_id with get_resource: router_interface
107     depends_on: router_interface
108     properties:
109       floating_network: { get_param: public_net_name }
110       port_id: { get_resource: server1_port }
111
112   server_security_group:
113     type: OS::Neutron::SecurityGroup
114     properties:
115       description: Add security group rules for server
116       name: pingtest-security-group
117       rules:
118         - remote_ip_prefix: 0.0.0.0/0
119           protocol: tcp
120           port_range_min: 22
121           port_range_max: 22
122         - remote_ip_prefix: 0.0.0.0/0
123           protocol: icmp
124
125   test_flavor:
126     type: OS::Nova::Flavor
127     properties:
128       ram: 512
129       vcpus: 1
130
131   gnocchi_res_alarm:
132     type: OS::Aodh::GnocchiResourcesAlarm
133     properties:
134       description: Do stuff with gnocchi
135       metric: cpu_util
136       aggregation_method: mean
137       granularity: 60
138       evaluation_periods: 1
139       threshold: 50
140       alarm_actions: []
141       resource_type: instance
142       resource_id: { get_resource: server1 }
143       comparison_operator: gt
144
145   asg:
146     type: OS::Heat::AutoScalingGroup
147     properties:
148       max_size: 5
149       min_size: 1
150       resource:
151         type: OS::Heat::RandomString
152
153   scaleup_policy:
154     type: OS::Heat::ScalingPolicy
155     properties:
156       adjustment_type: change_in_capacity
157       auto_scaling_group_id: {get_resource: asg}
158       cooldown: 0
159       scaling_adjustment: 1
160
161   alarm:
162     type: OS::Aodh::Alarm
163     properties:
164       description: Scale-up if the average CPU > 50% for 1 minute
165       meter_name: test_meter
166       statistic: count
167       comparison_operator: ge
168       threshold: 1
169       period: 60
170       evaluation_periods: 1
171       alarm_actions:
172         - {get_attr: [scaleup_policy, alarm_url]}
173       matching_metadata:
174         metadata.metering.stack_id: {get_param: "OS::stack_id"}
175
176 outputs:
177   server1_private_ip:
178     description: IP address of server1 in private network
179     value: { get_attr: [ server1, first_address ] }
180   server1_public_ip:
181     description: Floating IP address of server1 in public network
182     value: { get_attr: [ server1_floating_ip, floating_ip_address ] }
183   asg_size:
184     value: {get_attr: [asg, current_size]}