-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-2vm-diffvn.yaml
282 lines (241 loc) · 10 KB
/
create-2vm-diffvn.yaml
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
heat_template_version: 2015-04-30
description: Heat template to create two VirtualNetworks and 1VM in each of it
parameters:
domain:
type: string
description: Domain for the VirtualNetwork
default: default-domain
tenant_name:
type: string
description: tenant/project for the VirtualNetwork
ipam1_name:
type: string
description: Name of IPAM1 to be created
ipam2_name:
type: string
description: Name of IPAM2 to be created
network1_name:
type: string
description: Name of VirtualNetwork1 to be created
network1_subnet_prefix:
type: string
description: Prefix of the VirtualNetwork1
network1_subnet_prefix_len:
type: number
description: Prefix length of the VirtualNetwork1
network1_subnet_default_gw:
type: string
description: Default Gateway of the VirtualNetwork1
network1_is_shared:
type: boolean
description: Is the VirtualNetwork1 shared or not
route_target1:
type: string
description: Route Target of the VirtualNetwork1
network2_name:
type: string
description: Name of VirtualNetwork2 to be created
network2_subnet_prefix:
type: string
description: Prefix of the VirtualNetwork2
network2_subnet_prefix_len:
type: number
description: Prefix length of the VirtualNetwork2
network2_subnet_default_gw:
type: string
description: Default Gateway of the VirtualNetwork2
network2_is_shared:
type: boolean
description: Is the VirtualNetwork2 shared or not
route_target2:
type: string
description: Route Target of the VirtualNetwork2
vm1_name:
type: string
description: VM1 name to be created
vm2_name:
type: string
description: VM2 name to be created
vm_image:
type: string
description: Name of the VM image
vm_flavor:
type: string
description: Flavor of the VM image
network_policy_name:
type: string
description: Name of the Network Policy
simple_action:
type: string
description: Pass or Deny
protocol:
type: string
description: Protocol
src_port_end:
type: number
description: End of the Source Port Range
src_port_start:
type: number
description: Start of the Source Port Range
direction:
type: string
description: Direction of the Policy
dst_port_end:
type: number
description: End of the Destination Port Range
dst_port_start:
type: number
description: Start of the Destination Port Range
resources:
template_NetworkIpam_1:
type: OS::ContrailV2::NetworkIpam
properties:
name: { get_param: ipam1_name }
fq_name: { list_join: [':', [ { get_param: domain }, { get_param: tenant_name }, { get_param: ipam1_name }]] }
project: { list_join: [':', [ { get_param: domain }, { get_param: tenant_name }]] }
template_VirtualNetwork_1:
type: OS::ContrailV2::VirtualNetwork
depends_on: [ template_NetworkIpam_1, template_NetworkPolicy ]
properties:
name: { get_param: network1_name }
network_ipam_refs: [{ get_resource: template_NetworkIpam_1 }]
network_ipam_refs_data:
[{
network_ipam_refs_data_ipam_subnets:
[{
network_ipam_refs_data_ipam_subnets_subnet:
{
network_ipam_refs_data_ipam_subnets_subnet_ip_prefix: { get_param: network1_subnet_prefix },
network_ipam_refs_data_ipam_subnets_subnet_ip_prefix_len: { get_param: network1_subnet_prefix_len },
},
network_ipam_refs_data_ipam_subnets_default_gateway: { get_param: network1_subnet_default_gw },
}]
}]
route_target_list:
{
route_target_list_route_target: [{ get_param: route_target1 }],
}
network_policy_refs: [{ list_join: [':', [ { get_param: domain }, { get_param: tenant_name }, { get_param: network_policy_name }]] }]
is_shared: { get_param: network1_is_shared }
project: { list_join: [':', [ { get_param: domain }, { get_param: tenant_name }]] }
network_policy_refs_data:
[{
network_policy_refs_data_sequence:
{
network_policy_refs_data_sequence_major: 0,
network_policy_refs_data_sequence_minor: 0,
},
}]
template_VirtualMachineInterface_1:
type: OS::ContrailV2::VirtualMachineInterface
properties:
name: { get_param: vm1_name }
virtual_network_refs: [{ list_join: [':', { get_attr: [ template_VirtualNetwork_1, fq_name ] } ] }]
template_InstanceIp_1:
type: OS::ContrailV2::InstanceIp
depends_on: [ template_VirtualMachineInterface_1, template_VirtualNetwork_1 ]
properties:
virtual_machine_interface_refs: [{ get_resource: template_VirtualMachineInterface_1 }]
virtual_network_refs: [{ list_join: [':', { get_attr: [ template_VirtualNetwork_1, fq_name ] } ] }]
vm1:
type: OS::Nova::Server
depends_on: [ template_InstanceIp_1 ]
properties:
name: {get_param: vm1_name }
image: { get_param: vm_image }
flavor: { get_param: vm_flavor }
networks:
- port: { get_resource: template_VirtualMachineInterface_1 }
template_NetworkIpam_2:
type: OS::ContrailV2::NetworkIpam
properties:
name: { get_param: ipam2_name }
fq_name: { list_join: [':', [ { get_param: domain }, { get_param: tenant_name }, { get_param: ipam2_name }]] }
project: { list_join: [':', [ { get_param: domain }, { get_param: tenant_name }]] }
template_VirtualNetwork_2:
type: OS::ContrailV2::VirtualNetwork
depends_on: [ template_NetworkIpam_2, template_NetworkPolicy ]
properties:
name: { get_param: network2_name }
network_ipam_refs: [{ get_resource: template_NetworkIpam_2 }]
network_ipam_refs_data:
[{
network_ipam_refs_data_ipam_subnets:
[{
network_ipam_refs_data_ipam_subnets_subnet:
{
network_ipam_refs_data_ipam_subnets_subnet_ip_prefix: { get_param: network2_subnet_prefix },
network_ipam_refs_data_ipam_subnets_subnet_ip_prefix_len: { get_param: network2_subnet_prefix_len },
},
network_ipam_refs_data_ipam_subnets_default_gateway: { get_param: network2_subnet_default_gw },
}]
}]
route_target_list:
{
route_target_list_route_target: [{ get_param: route_target2 }],
}
network_policy_refs: [{ list_join: [':', [ { get_param: domain }, { get_param: tenant_name }, { get_param: network_policy_name }]] }]
is_shared: { get_param: network2_is_shared }
project: { list_join: [':', [ { get_param: domain }, { get_param: tenant_name }]] }
network_policy_refs_data:
[{
network_policy_refs_data_sequence:
{
network_policy_refs_data_sequence_major: 0,
network_policy_refs_data_sequence_minor: 0,
},
}]
template_VirtualMachineInterface_2:
type: OS::ContrailV2::VirtualMachineInterface
properties:
name: { get_param: vm2_name }
virtual_network_refs: [{ list_join: [':', { get_attr: [ template_VirtualNetwork_2, fq_name ] } ] }]
template_InstanceIp_2:
type: OS::ContrailV2::InstanceIp
depends_on: [ template_VirtualMachineInterface_2, template_VirtualNetwork_2 ]
properties:
virtual_machine_interface_refs: [{ get_resource: template_VirtualMachineInterface_2 }]
virtual_network_refs: [{ list_join: [':', { get_attr: [ template_VirtualNetwork_2, fq_name ] } ] }]
vm2:
type: OS::Nova::Server
depends_on: [ template_InstanceIp_2 ]
properties:
name: {get_param: vm2_name }
image: { get_param: vm_image }
flavor: { get_param: vm_flavor }
networks:
- port: { get_resource: template_VirtualMachineInterface_2 }
template_NetworkPolicy:
type: OS::ContrailV2::NetworkPolicy
properties:
name: { get_param: network_policy_name }
network_policy_entries: { network_policy_entries_policy_rule: [{
network_policy_entries_policy_rule_direction: { get_param: direction },
network_policy_entries_policy_rule_protocol: { get_param: protocol },
network_policy_entries_policy_rule_src_ports: [{
network_policy_entries_policy_rule_src_ports_start_port: { get_param: src_port_start },
network_policy_entries_policy_rule_src_ports_end_port: { get_param: src_port_end }
}],
network_policy_entries_policy_rule_dst_ports: [{
network_policy_entries_policy_rule_dst_ports_start_port: { get_param: dst_port_start },
network_policy_entries_policy_rule_dst_ports_end_port: { get_param: dst_port_end }
}],
network_policy_entries_policy_rule_dst_addresses: [{
network_policy_entries_policy_rule_dst_addresses_virtual_network: { list_join: [':', [ {get_param: domain}, {get_param: tenant_name}, {get_param: network2_name} ]] }
}],
network_policy_entries_policy_rule_src_addresses: [{
network_policy_entries_policy_rule_src_addresses_virtual_network: { list_join: [':', [ {get_param: domain}, {get_param: tenant_name}, {get_param: network1_name} ]] }
}],
network_policy_entries_policy_rule_action_list: {
network_policy_entries_policy_rule_action_list_simple_action: { get_param: simple_action },
network_policy_entries_policy_rule_action_list_log: true
},
}]
}
outputs:
vm1_ip:
description: VM1 IP
value: { get_attr: [ template_InstanceIp_1, instance_ip_address]}
vm2_ip:
description: VM2 IP
value: { get_attr: [ template_InstanceIp_2, instance_ip_address]}