189654cad96766007f89332fa4de1de1e8454227
[apex.git] / build / nics-template.yaml.jinja2
1 heat_template_version: 2016-10-14
2
3 description: >
4   Software Config to drive os-net-config to configure multiple interfaces
5   for the {{ role }} role.
6
7 parameters:
8   ControlPlaneIp:
9     default: ''
10     description: IP address/subnet on the ctlplane network
11     type: string
12   ExternalNetworkVlanID:
13     default: 10
14     description: Vlan ID for the external network traffic.
15     type: number
16   InternalApiNetworkVlanID:
17     default: 20
18     description: Vlan ID for the internal_api network traffic.
19     type: number
20   StorageNetworkVlanID:
21     default: 30
22     description: Vlan ID for the storage network traffic.
23     type: number
24   StorageMgmtNetworkVlanID:
25     default: 40
26     description: Vlan ID for the storage mgmt network traffic.
27     type: number
28   TenantNetworkVlanID:
29     default: 50
30     description: Vlan ID for the tenant network traffic.
31     type: number
32   ManagementNetworkVlanID:
33     default: 60
34     description: Vlan ID for the management network traffic.
35     type: number
36   ExternalInterfaceDefaultRoute:
37     default: '10.0.0.1'
38     description: default route for the external network
39     type: string
40   ControlPlaneSubnetCidr: # Override this via parameter_defaults
41     default: '24'
42     description: The subnet CIDR of the control plane network.
43     type: string
44   ControlPlaneDefaultRoute: # Override this via parameter_defaults
45     description: The default route of the control plane network.
46     type: string
47   DnsServers: # Override this via parameter_defaults
48     default: []
49     description: A list of DNS servers (2 max for some implementations) that will be added to resolv.conf.
50     type: comma_delimited_list
51   EC2MetadataIp: # Override this via parameter_defaults
52     description: The IP address of the EC2 metadata server.
53     type: string
54   ExternalIpSubnet:
55     default: ''
56     description: IP address/subnet on the external network
57     type: string
58   ExternalInterfaceRoutes:
59     default: []
60     description: >
61       Routes for the external network traffic.
62       JSON route e.g. [{'destination':'10.0.0.0/16', 'nexthop':'10.0.0.1'}]
63       Unless the default is changed, the parameter is automatically resolved
64       from the subnet host_routes attribute.
65     type: json
66   InternalApiIpSubnet:
67     default: ''
68     description: IP address/subnet on the internal_api network
69     type: string
70   InternalApiInterfaceRoutes:
71     default: []
72     description: >
73       Routes for the internal_api network traffic.
74       JSON route e.g. [{'destination':'10.0.0.0/16', 'nexthop':'10.0.0.1'}]
75       Unless the default is changed, the parameter is automatically resolved
76       from the subnet host_routes attribute.
77     type: json
78   StorageIpSubnet:
79     default: ''
80     description: IP address/subnet on the storage network
81     type: string
82   StorageInterfaceRoutes:
83     default: []
84     description: >
85       Routes for the storage network traffic.
86       JSON route e.g. [{'destination':'10.0.0.0/16', 'nexthop':'10.0.0.1'}]
87       Unless the default is changed, the parameter is automatically resolved
88       from the subnet host_routes attribute.
89     type: json
90   StorageMgmtIpSubnet:
91     default: ''
92     description: IP address/subnet on the storage_mgmt network
93     type: string
94   StorageMgmtInterfaceRoutes:
95     default: []
96     description: >
97       Routes for the storage_mgmt network traffic.
98       JSON route e.g. [{'destination':'10.0.0.0/16', 'nexthop':'10.0.0.1'}]
99       Unless the default is changed, the parameter is automatically resolved
100       from the subnet host_routes attribute.
101     type: json
102   StorageNFSIpSubnet:
103     default: ''
104     description: IP address/subnet on the storage_nfs network
105     type: string
106   StorageNFSRoutes:
107     default: []
108     description: >
109       Routes for the storage_nfs network traffic.
110       JSON route e.g. [{'destination':'10.0.0.0/16', 'nexthop':'10.0.0.1'}]
111       Unless the default is changed, the parameter is automatically resolved
112       from the subnet host_routes attribute.
113     type: json
114   TenantIpSubnet:
115     default: ''
116     description: IP address/subnet on the tenant network
117     type: string
118   TenantInterfaceRoutes:
119     default: []
120     description: >
121       Routes for the tenant network traffic.
122       JSON route e.g. [{'destination':'10.0.0.0/16', 'nexthop':'10.0.0.1'}]
123       Unless the default is changed, the parameter is automatically resolved
124       from the subnet host_routes attribute.
125     type: json
126   ManagementIpSubnet:
127     default: ''
128     description: IP address/subnet on the management network
129     type: string
130   ManagementInterfaceRoutes:
131     default: []
132     description: >
133       Routes for the management network traffic.
134       JSON route e.g. [{'destination':'10.0.0.0/16', 'nexthop':'10.0.0.1'}]
135       Unless the default is changed, the parameter is automatically resolved
136       from the subnet host_routes attribute.
137     type: json
138
139 resources:
140   OsNetConfigImpl:
141     type: OS::Heat::SoftwareConfig
142     properties:
143       group: script
144       config:
145         str_replace:
146           template:
147             get_file: /usr/share/openstack-tripleo-heat-templates/network/scripts/run-os-net-config.sh
148           params:
149             $network_config:
150               network_config:
151               -
152               {%- if not nets['external'][0]['enabled'] or nets['tenant']['nic_mapping'][role]['vlan'] is number or nets['storage']['nic_mapping'][role]['vlan'] is number or nets['api']['nic_mapping'][role]['vlan'] is number or  nets['external'][0]['nic_mapping'][role]['vlan'] is number %}
153                 type: ovs_bridge
154               {%- if nets['external'][0]['enabled'] and nets['external'][0]['nic_mapping'][role]['vlan'] == 'native' %}
155                 name: br-isolated
156               {%- else %}
157                 name: br-ex
158               {%- endif %}
159                 members:
160                   -
161                     type: interface
162                     name: {{ nets['admin']['nic_mapping'][role]['members'][0] }}
163                     # force the MAC address of the bridge to this interface
164                     primary: true
165                   {%- if nets['external'][0]['enabled'] and nets['external'][0]['nic_mapping'][role]['vlan'] is number %}
166                   -
167                     type: vlan
168                     vlan_id: {get_param: ExternalNetworkVlanID}
169                     addresses:
170                     -
171                       ip_netmask: {get_param: ExternalIpSubnet}
172                     routes:
173                       -
174                         default: true
175                         next_hop: {get_param: ExternalInterfaceDefaultRoute}
176                   {%- endif %}
177                   {%- if nets['tenant']['enabled'] and nets['tenant']['nic_mapping'][role]['vlan'] is number %}
178                   -
179                     type: vlan
180                     vlan_id: {get_param: TenantNetworkVlanID}
181                     addresses:
182                       -
183                         ip_netmask: {get_param: TenantIpSubnet}
184                   {%- endif %}
185                   {%- if nets['storage']['enabled'] and nets['storage']['nic_mapping'][role]['vlan'] is number %}
186                   -
187                     type: vlan
188                     vlan_id: {get_param: StorageNetworkVlanID}
189                     addresses:
190                       -
191                         ip_netmask: {get_param: StorageIpSubnet}
192                   {%- endif %}
193                   {%- if nets['api']['enabled'] and nets['api']['nic_mapping'][role]['vlan'] is number %}
194                   -
195                     type: vlan
196                     vlan_id: {get_param: InternalApiNetworkVlanID}
197                     addresses:
198                       -
199                         ip_netmask: {get_param: InternalApiIpSubnet}
200                   {%- endif %}
201               {%- else %}
202                 type: {{ nets['admin']['nic_mapping'][role]['phys_type'] }}
203                 {%- if nets['admin']['nic_mapping'][role]['phys_type'] == 'linux_bridge' %}
204                 name: br-ctlplane
205                 members:
206                   -
207                     type: interface
208                     name: {{ nets['admin']['nic_mapping'][role]['members'][0] }}
209                     primary: true
210                 {%- else %}
211                 name: {{ nets['admin']['nic_mapping'][role]['members'][0] }}
212                 {%- endif %}
213               {%- endif %}
214                 use_dhcp: false
215                 dns_servers: {get_param: DnsServers}
216                 addresses:
217                   -
218                     ip_netmask:
219                       list_join:
220                         - '/'
221                         - - {get_param: ControlPlaneIp}
222                           - {get_param: ControlPlaneSubnetCidr}
223                 routes:
224                   -
225                     ip_netmask: 169.254.169.254/32
226                     next_hop: {get_param: EC2MetadataIp}
227                   {%- if external_net_af == 6 or role == 'compute' or not nets['external'][0]['enabled'] %}
228                   -
229                     default: true
230                     next_hop: {get_param: ControlPlaneDefaultRoute}
231                   {%- endif %}
232
233               {%- if nets['tenant']['enabled'] and nets['tenant']['nic_mapping'][role]['vlan'] == 'native' %}
234               {%- if ovs_dpdk_bridge == 'br-phy' and role == 'compute' %}
235               -
236                 type: ovs_user_bridge
237                 name: {{ ovs_dpdk_bridge }}
238                 use_dhcp: false
239                 addresses:
240                   -
241                     ip_netmask: {get_param: TenantIpSubnet}
242                 members:
243                   -
244                     type: ovs_dpdk_port
245                     name: dpdk0
246                     driver: {{ nets['tenant']['nic_mapping'][role]['uio_driver'] }}
247                     members:
248                       -
249                         type: interface
250                         name: {{ nets['tenant']['nic_mapping'][role]['members'][0] }}
251                         # force the MAC address of the bridge to this interface
252                         primary: true
253               {%- elif nets['tenant']['segmentation_type'] == 'vlan' %}
254                 type: ovs_bridge
255                 name: br-vlan
256                 use_dhcp: false
257                 addresses:
258                   -
259                     ip_netmask: {get_param: TenantIpSubnet}
260                 members:
261                   -
262                     type: interface
263                     name: {{ nets['tenant']['nic_mapping'][role]['members'][0] }}
264                     primary: true
265               {%- else %}
266               -
267                 type: {{ nets['tenant']['nic_mapping'][role]['phys_type'] }}
268                 name: {{ nets['tenant']['nic_mapping'][role]['members'][0] }}
269                 {%- if 'uio-driver' in nets['tenant']['nic_mapping'][role] %}
270                 uio_driver: {{ nets['tenant']['nic_mapping'][role]['uio-driver'] }}
271                 {%- endif %}
272                 {%- if 'interface-options' in nets['tenant']['nic_mapping'][role] %}
273                 options: '{{ nets['tenant']['nic_mapping'][role]['interface-options'] }}'
274                 {%- endif %}
275                 use_dhcp: false
276                 addresses:
277                   -
278                     ip_netmask: {get_param: TenantIpSubnet}
279               {%- endif %}
280               {%- endif %}
281               {%- if nets['external'][0]['enabled'] and external_net_type != 'br-ex' and nets['external'][0]['nic_mapping'][role]['vlan'] == 'native' %}
282               -
283                 type: {{ nets['external'][0]['nic_mapping'][role]['phys_type'] }}
284                 name: {{ nets['external'][0]['nic_mapping'][role]['members'][0] }}
285                 {%- if 'uio-driver' in nets['external'][0]['nic_mapping'][role] %}
286                 uio_driver: {{ nets['external'][0]['nic_mapping'][role]['uio-driver'] }}
287                 {%- endif %}
288                 {%- if role == 'controller' %}
289                 dns_servers: {get_param: DnsServers}
290                 {%- endif %}
291                 use_dhcp: false
292                 addresses:
293                   -
294                     ip_netmask: {get_param: ExternalIpSubnet}
295                 routes:
296                   -
297                     {%- if role == 'controller' %}
298                     default: true
299                     {%- endif %}
300                     ip_netmask: 0.0.0.0/0
301                     next_hop: {get_param: ExternalInterfaceDefaultRoute}
302               {%- elif nets['external'][0]['enabled'] and external_net_type == 'br-ex' and nets['external'][0]['nic_mapping'][role]['vlan'] == 'native' %}
303               -
304                 {%- if ovs_dpdk_bridge == 'br-phy' and role == 'compute' %}
305                 type: ovs_user_bridge
306                 {%- else %}
307                 type: {{ nets['external'][0]['nic_mapping'][role]['phys_type'] }}
308                 {%- endif %}
309                 name: br-ex
310                 use_dhcp: false
311                 members:
312                   -
313                     type: interface
314                     name: {{ nets['external'][0]['nic_mapping'][role]['members'][0] }}
315                     # force the MAC address of the bridge to this interface
316                     primary: true
317                 dns_servers: {get_param: DnsServers}
318                 addresses:
319                   -
320                     ip_netmask: {get_param: ExternalIpSubnet}
321                 routes:
322                   -
323                     default: true
324                     ip_netmask: 0.0.0.0/0
325                     next_hop: {get_param: ExternalInterfaceDefaultRoute}
326               {%- endif %}
327               {%- if nets['storage']['enabled'] and nets['storage']['nic_mapping'][role]['vlan'] == 'native' %}
328               -
329                 type: interface
330                 name: {{ nets['storage']['nic_mapping'][role]['members'][0] }}
331                 use_dhcp: false
332                 addresses:
333                   -
334                     ip_netmask: {get_param: StorageIpSubnet}
335               {%- endif %}
336               {%- if nets['api']['enabled'] and nets['api']['nic_mapping'][role]['vlan'] == 'native' %}
337               -
338                 type: interface
339                 name: {{ nets['api']['nic_mapping'][role]['members'][0] }}
340                 use_dhcp: false
341                 addresses:
342                   -
343                     ip_netmask: {get_param: InternalApiIpSubnet}
344               {%- endif %}
345
346 outputs:
347   OS::stack_id:
348     description: The OsNetConfigImpl resource.
349     value: {get_resource: OsNetConfigImpl}