/
template.py
227 lines (221 loc) · 22.5 KB
/
template.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
left_net_template = {u'description': u'HOT template to create left network in a service chain. \n',
u'heat_template_version': u'2013-05-23',
u'outputs': {u'left_net_cidr': {u'description': u'CIDR of the left network',
u'value': {u'get_attr': [u'left_subnet',
u'cidr']}},
u'left_net_id': {u'description': u'ID of the left network',
u'value': {u'get_attr': [u'left_net',
u'show',
u'id']}},
u'left_net_name': {u'description': u'Name of the left network',
u'value': {u'get_attr': [u'left_net',
u'name']}}},
u'parameters': {u'left_net_cidr': {u'description': u'Private network address (CIDR notation)',
u'type': u'string'},
u'left_net_gateway': {u'description': u'Private network gateway address',
u'type': u'string'},
u'left_net_name': {u'description': u'Name of private network to be created',
u'type': u'string'},
u'left_net_pool_end': {u'description': u'End of private network IP address allocation pool',
u'type': u'string'},
u'left_net_pool_start': {u'description': u'Start of private network IP address allocation pool',
u'type': u'string'}},
u'resources': {u'left_net': {u'properties': {u'name': {u'get_param': u'left_net_name'}},
u'type': u'OS::Neutron::Net'},
u'left_subnet': {u'properties': {u'allocation_pools': [{u'end': {u'get_param': u'left_net_pool_end'},
u'start': {u'get_param': u'left_net_pool_start'}}],
u'cidr': {u'get_param': u'left_net_cidr'},
u'gateway_ip': {u'get_param': u'left_net_gateway'},
u'network_id': {u'get_resource': u'left_net'}},
u'type': u'OS::Neutron::Subnet'}}}
right_net_template = {u'description': u'HOT template to create right network in a service chain. \n',
u'heat_template_version': u'2013-05-23',
u'outputs': {u'right_net_cidr': {u'description': u'CIDR of the right network',
u'value': {u'get_attr': [u'right_subnet',
u'cidr']}},
u'right_net_id': {u'description': u'ID of the right network',
u'value': {u'get_attr': [u'right_net',
u'show',
u'id']}},
u'right_net_name': {u'description': u'Name of the right network',
u'value': {u'get_attr': [u'right_net',
u'name']}}},
u'parameters': {u'right_net_cidr': {u'description': u'Private network address (CIDR notation)',
u'type': u'string'},
u'right_net_gateway': {u'description': u'Private network gateway address',
u'type': u'string'},
u'right_net_name': {u'description': u'Name of private network to be created',
u'type': u'string'},
u'right_net_pool_end': {u'description': u'End of private network IP address allocation pool',
u'type': u'string'},
u'right_net_pool_start': {u'description': u'Start of private network IP address allocation pool',
u'type': u'string'}},
u'resources': {u'right_net': {u'properties': {u'name': {u'get_param': u'right_net_name'}},
u'type': u'OS::Neutron::Net'},
u'right_subnet': {u'properties': {u'allocation_pools': [{u'end': {u'get_param': u'right_net_pool_end'},
u'start': {u'get_param': u'right_net_pool_start'}}],
u'cidr': {u'get_param': u'right_net_cidr'},
u'gateway_ip': {u'get_param': u'right_net_gateway'},
u'network_id': {u'get_resource': u'right_net'}},
u'type': u'OS::Neutron::Subnet'}}}
vms_template = {u'description': u'HOT template to deploy server into an existing neutron tenant network\n',
u'heat_template_version': u'2013-05-23',
u'outputs': {u'server1_ip': {u'description': u'IP address of the left_vm',
u'value': {u'get_attr': [u'server1',
u'first_address']}},
u'server2_ip': {u'description': u'IP address of the right_vm',
u'value': {u'get_attr': [u'server2',
u'first_address']}}},
u'parameters': {u'flavor': {u'description': u'Flavor to use for servers',
u'type': u'string'},
u'image': {u'description': u'Name of image to use for servers',
u'type': u'string'},
u'left_net_id': {u'description': u'ID of the left network',
u'type': u'string'},
u'right_net_id': {u'description': u'ID of the right network',
u'type': u'string'}},
u'resources': {u'server1': {u'properties': {u'flavor': {u'get_param': u'flavor'},
u'image': {u'get_param': u'image'},
u'name': u'left_vm',
u'networks': [{u'port': {u'get_resource': u'server1_port'}}]},
u'type': u'OS::Nova::Server'},
u'server1_port': {u'properties': {u'network_id': {u'get_param': u'left_net_id'}},
u'type': u'OS::Neutron::Port'},
u'server2': {u'properties': {u'flavor': {u'get_param': u'flavor'},
u'image': {u'get_param': u'image'},
u'name': u'right_vm',
u'networks': [{u'port': {u'get_resource': u'server2_port'}}]},
u'type': u'OS::Nova::Server'},
u'server2_port': {u'properties': {u'network_id': {u'get_param': u'right_net_id'}},
u'type': u'OS::Neutron::Port'}}}
svc_temp_template = {u'description': u'HOT template to create a service template \n',
u'heat_template_version': u'2013-05-23',
u'outputs': {u'service_template_fq_name': {u'description': u'FQ name of the service template',
u'value': {u'get_attr': [u'service_template',
u'fq_name']}}},
u'parameters': {u'flavor': {u'description': u'Flavor', u'type': u'string'},
u'service_scaling': {u'description': u'Flag to enable scaling', u'type': u'string'},
u'image': {u'description': u'Name of the image',
u'type': u'string'},
u'mode': {u'description': u'service mode',
u'type': u'string'},
u'name': {u'description': u'Name of service template',
u'type': u'string'},
u'service_interface_type_list': {u'description': u'List of interface types',
u'type': u'string'},
u'shared_ip_list': {u'description': u'List of shared ip enabled-disabled',
u'type': u'string'},
u'static_routes_list': {u'description': u'List of static routes enabled-disabled',
u'type': u'string'},
u'type': {u'description': u'service type',
u'type': u'string'}},
u'resources': {u'service_template': {u'properties': {u'flavor': {u'get_param': u'flavor'},
u'service_scaling': {u'get_param': u'service_scaling'},
u'image_name': {u'get_param': u'image'},
u'name': {u'get_param': u'name'},
u'service_interface_type_list': {u'Fn::Split': [u',',
{u'Ref': u'service_interface_type_list'}]},
u'service_mode': {u'get_param': u'mode'},
u'service_type': {u'get_param': u'type'},
u'shared_ip_list': {u'Fn::Split': [u',',
{u'Ref': u'shared_ip_list'}]},
u'static_routes_list': {u'Fn::Split': [u',',
{u'Ref': u'static_routes_list'}]}},
u'type': u'OS::Contrail::ServiceTemplate'}}}
svc_inst_template = {u'description': u'HOT template to create service instance.\n',
u'heat_template_version': u'2013-05-23',
u'outputs': {u'num_active_service_instance_vms': {u'description': u'Number of active service VMs',
u'value': {u'get_attr': [u'service_instance',
u'active_service_vms']}},
u'service_instance_fq_name': {u'description': u'FQ name of the service template',
u'value': {u'get_attr': [u'service_instance',
u'fq_name']}},
u'service_instance_uuid': {u'description': u'UUID of the service template',
u'value': {u'get_attr': [u'service_instance',
u'show']}},
u'service_instance_vms': {u'description': u'List of service VMs',
u'value': {u'get_attr': [u'service_instance',
u'virtual_machines']}}},
u'parameters': {u'left_net_id': {u'description': u'ID of the left network \n',
u'type': u'string'},
u'right_net_id': {u'description': u'ID of the right network \n',
u'type': u'string'},
u'service_instance_name': {u'description': u'service instance name',
u'type': u'string'},
u'max_instances': {u'description': u'Number of service VMs',
u'type': u'string'},
u'service_template_fq_name': {u'description': u'service template name or ID',
u'type': u'string'}},
u'resources': {u'service_instance': {u'properties': {u'interface_list': [{u'virtual_network': u'auto'},
{u'virtual_network': {
u'get_param': u'left_net_id'}},
{u'virtual_network': {u'get_param': u'right_net_id'}}],
u'name': {u'get_param': u'service_instance_name'},
u'scale_out': {u'max_instances': {u'get_param': u'max_instances'}},
u'service_template': {u'get_param': u'service_template_fq_name'}},
u'type': u'OS::Contrail::ServiceInstance'}}}
svc_chain_template = {u'description': u'HOT template to create a policy between two virtual network and apply a service. Attach the network policy to two virtual networks\n',
u'heat_template_version': u'2013-05-23',
u'parameters': {u'apply_service': {u'description': u'service instance id',
u'type': u'string'},
u'direction': {u'description': u'Direction of Policy',
u'type': u'string'},
u'dst_port_end': {u'description': u'end of the dst port',
u'type': u'number'},
u'dst_port_start': {u'description': u'start of the dst port',
u'type': u'number'},
u'dst_vn_id': {u'description': u'ID of the destination network',
u'type': u'string'},
u'policy_name': {u'description': u'Policy Name',
u'type': u'string'},
u'protocol': {u'description': u'Protocol',
u'type': u'string'},
u'src_port_end': {u'description': u'end of the src port',
u'type': u'number'},
u'src_port_start': {u'description': u'start of the src port',
u'type': u'number'},
u'src_vn_id': {u'description': u'ID of the source network',
u'type': u'string'}},
u'resources': {u'private_policy': {u'properties': {u'entries': {u'policy_rule': [{u'action_list': {u'apply_service':
{u'Fn::Split': [u',',
{u'Ref': u'apply_service'}]}},
u'direction': {u'get_param': u'direction'},
u'dst_addresses': [{u'virtual_network': {u'get_param': u'dst_vn_id'}}],
u'dst_ports': [{u'end_port': {u'get_param': u'dst_port_end'},
u'start_port': {u'get_param': u'dst_port_start'}}],
u'protocol': {u'get_param': u'protocol'},
u'src_addresses': [{u'virtual_network': {u'get_param': u'src_vn_id'}}],
u'src_ports': [{u'end_port': {u'get_param': u'src_port_end'},
u'start_port': {u'get_param': u'src_port_start'}}]}]},
u'name': {u'get_param': u'policy_name'}},
u'type': u'OS::Contrail::NetworkPolicy'},
u'private_policy_attach_net1': {u'properties': {u'network': {u'get_param': u'src_vn_id'},
u'policy': {u'get_attr': [u'private_policy',
u'fq_name']}},
u'type': u'OS::Contrail::AttachPolicy'},
u'private_policy_attach_net2': {u'properties': {u'network': {u'get_param': u'dst_vn_id'},
u'policy': {u'get_attr': [u'private_policy',
u'fq_name']}},
u'type': u'OS::Contrail::AttachPolicy'}}}
transit_net_template = {'description': 'HOT template to creates a virtual network with allow_transit enabled\n',
'heat_template_version': '2013-05-23',
'outputs': {'transit_net_id': {'description': 'ID of the transit network',
'value': {'get_attr': ['transit_net_horizon',
'show',
'id']}}},
'parameters': {'allow_transit': {'description': 'flag to set for transit vn',
'type': 'string'},
'transit_net_cidr': {'description': 'Transit network block (CIDR notation)',
'type': 'string'},
'transit_net_name': {'description': 'Name of virtual network to be created',
'type': 'string'}},
'resources': {'transit_net': {'properties': {'allow_transit': {'get_param': 'allow_transit'},
'name': {'get_param': 'transit_net_name'}},
'type': 'OS::Contrail::VirtualNetwork'},
'transit_net_horizon': {'properties': {'name': {'get_resource': 'transit_net'}},
'type': 'OS::Neutron::Net'},
'transit_subnet': {'properties': {'cidr': {'get_param': 'transit_net_cidr'},
'enable_dhcp': 'true',
'name': {'get_resource': 'transit_net'},
'network_id': {'get_resource': 'transit_net'}},
'type': 'OS::Neutron::Subnet'}}}