11e0b11500c1576b704ba30c90ca11d523a319fd
[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   ExternalIpSubnet:
13     default: ''
14     description: IP address/subnet on the external network
15     type: string
16   InternalApiIpSubnet:
17     default: ''
18     description: IP address/subnet on the internal API network
19     type: string
20   StorageIpSubnet:
21     default: ''
22     description: IP address/subnet on the storage network
23     type: string
24   StorageMgmtIpSubnet:
25     default: ''
26     description: IP address/subnet on the storage mgmt network
27     type: string
28   TenantIpSubnet:
29     default: ''
30     description: IP address/subnet on the tenant network
31     type: string
32   ManagementIpSubnet: # Only populated when including environments/network-management.yaml
33     default: ''
34     description: IP address/subnet on the management network
35     type: string
36   ExternalNetworkVlanID:
37     default: 10
38     description: Vlan ID for the external network traffic.
39     type: number
40   InternalApiNetworkVlanID:
41     default: 20
42     description: Vlan ID for the internal_api network traffic.
43     type: number
44   StorageNetworkVlanID:
45     default: 30
46     description: Vlan ID for the storage network traffic.
47     type: number
48   StorageMgmtNetworkVlanID:
49     default: 40
50     description: Vlan ID for the storage mgmt network traffic.
51     type: number
52   TenantNetworkVlanID:
53     default: 50
54     description: Vlan ID for the tenant network traffic.
55     type: number
56   ManagementNetworkVlanID:
57     default: 60
58     description: Vlan ID for the management network traffic.
59     type: number
60   ExternalInterfaceDefaultRoute:
61     default: '10.0.0.1'
62     description: default route for the external network
63     type: string
64   ControlPlaneSubnetCidr: # Override this via parameter_defaults
65     default: '24'
66     description: The subnet CIDR of the control plane network.
67     type: string
68   ControlPlaneDefaultRoute: # Override this via parameter_defaults
69     description: The default route of the control plane network.
70     type: string
71   DnsServers: # Override this via parameter_defaults
72     default: []
73     description: A list of DNS servers (2 max for some implementations) that will be added to resolv.conf.
74     type: comma_delimited_list
75   EC2MetadataIp: # Override this via parameter_defaults
76     description: The IP address of the EC2 metadata server.
77     type: string
78
79 resources:
80   OsNetConfigImpl:
81     type: OS::Heat::SoftwareConfig
82     properties:
83       group: script
84       config:
85         str_replace:
86           template:
87             get_file: /usr/share/openstack-tripleo-heat-templates/network/scripts/run-os-net-config.sh
88           params:
89             $network_config:
90               network_config:
91               -
92               {%- 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 %}
93                 type: ovs_bridge
94               {%- if nets['external'][0]['enabled'] and nets['external'][0]['nic_mapping'][role]['vlan'] == 'native' %}
95                 name: br-isolated
96               {%- else %}
97                 name: br-ex
98               {%- endif %}
99                 members:
100                   -
101                     type: interface
102                     name: {{ nets['admin']['nic_mapping'][role]['members'][0] }}
103                     # force the MAC address of the bridge to this interface
104                     primary: true
105                   {%- if nets['external'][0]['enabled'] and nets['external'][0]['nic_mapping'][role]['vlan'] is number %}
106                   -
107                     type: vlan
108                     vlan_id: {get_param: ExternalNetworkVlanID}
109                     addresses:
110                     -
111                       ip_netmask: {get_param: ExternalIpSubnet}
112                     routes:
113                       -
114                         default: true
115                         next_hop: {get_param: ExternalInterfaceDefaultRoute}
116                   {%- endif %}
117                   {%- if nets['tenant']['enabled'] and nets['tenant']['nic_mapping'][role]['vlan'] is number %}
118                   -
119                     type: vlan
120                     vlan_id: {get_param: TenantNetworkVlanID}
121                     addresses:
122                       -
123                         ip_netmask: {get_param: TenantIpSubnet}
124                   {%- endif %}
125                   {%- if nets['storage']['enabled'] and nets['storage']['nic_mapping'][role]['vlan'] is number %}
126                   -
127                     type: vlan
128                     vlan_id: {get_param: StorageNetworkVlanID}
129                     addresses:
130                       -
131                         ip_netmask: {get_param: StorageIpSubnet}
132                   {%- endif %}
133                   {%- if nets['api']['enabled'] and nets['api']['nic_mapping'][role]['vlan'] is number %}
134                   -
135                     type: vlan
136                     vlan_id: {get_param: InternalApiNetworkVlanID}
137                     addresses:
138                       -
139                         ip_netmask: {get_param: InternalApiIpSubnet}
140                   {%- endif %}
141               {%- else %}
142                 type: {{ nets['admin']['nic_mapping'][role]['phys_type'] }}
143                 {%- if nets['admin']['nic_mapping'][role]['phys_type'] == 'linux_bridge' %}
144                 name: br-ctlplane
145                 members:
146                   -
147                     type: interface
148                     name: {{ nets['admin']['nic_mapping'][role]['members'][0] }}
149                     primary: true
150                 {%- else %}
151                 name: {{ nets['admin']['nic_mapping'][role]['members'][0] }}
152                 {%- endif %}
153               {%- endif %}
154                 use_dhcp: false
155                 dns_servers: {get_param: DnsServers}
156                 addresses:
157                   -
158                     ip_netmask:
159                       list_join:
160                         - '/'
161                         - - {get_param: ControlPlaneIp}
162                           - {get_param: ControlPlaneSubnetCidr}
163                 routes:
164                   -
165                     ip_netmask: 169.254.169.254/32
166                     next_hop: {get_param: EC2MetadataIp}
167                   {%- if external_net_af == 6 or role == 'compute' or not nets['external'][0]['enabled'] %}
168                   -
169                     default: true
170                     next_hop: {get_param: ControlPlaneDefaultRoute}
171                   {%- endif %}
172
173               {%- if nets['tenant']['enabled'] and nets['tenant']['nic_mapping'][role]['vlan'] == 'native' %}
174               {%- if ovs_dpdk_bridge == 'br-phy' and role == 'compute' %}
175               -
176                 type: ovs_user_bridge
177                 name: {{ ovs_dpdk_bridge }}
178                 use_dhcp: false
179                 addresses:
180                   -
181                     ip_netmask: {get_param: TenantIpSubnet}
182                 members:
183                   -
184                     type: ovs_dpdk_port
185                     name: dpdk0
186                     driver: {{ nets['tenant']['nic_mapping'][role]['uio_driver'] }}
187                     members:
188                       -
189                         type: interface
190                         name: {{ nets['tenant']['nic_mapping'][role]['members'][0] }}
191                         # force the MAC address of the bridge to this interface
192                         primary: true
193               {%- elif nets['tenant']['segmentation_type'] == 'vlan' %}
194                 type: ovs_bridge
195                 name: br-vlan
196                 use_dhcp: false
197                 addresses:
198                   -
199                     ip_netmask: {get_param: TenantIpSubnet}
200                 members:
201                   -
202                     type: interface
203                     name: {{ nets['tenant']['nic_mapping'][role]['members'][0] }}
204                     primary: true
205               {%- else %}
206               -
207                 type: {{ nets['tenant']['nic_mapping'][role]['phys_type'] }}
208                 name: {{ nets['tenant']['nic_mapping'][role]['members'][0] }}
209                 {%- if 'uio-driver' in nets['tenant']['nic_mapping'][role] %}
210                 uio_driver: {{ nets['tenant']['nic_mapping'][role]['uio-driver'] }}
211                 {%- endif %}
212                 {%- if 'interface-options' in nets['tenant']['nic_mapping'][role] %}
213                 options: '{{ nets['tenant']['nic_mapping'][role]['interface-options'] }}'
214                 {%- endif %}
215                 use_dhcp: false
216                 addresses:
217                   -
218                     ip_netmask: {get_param: TenantIpSubnet}
219               {%- endif %}
220               {%- endif %}
221               {%- if nets['external'][0]['enabled'] and external_net_type != 'br-ex' and nets['external'][0]['nic_mapping'][role]['vlan'] == 'native' %}
222               -
223                 type: {{ nets['external'][0]['nic_mapping'][role]['phys_type'] }}
224                 name: {{ nets['external'][0]['nic_mapping'][role]['members'][0] }}
225                 {%- if 'uio-driver' in nets['external'][0]['nic_mapping'][role] %}
226                 uio_driver: {{ nets['external'][0]['nic_mapping'][role]['uio-driver'] }}
227                 {%- endif %}
228                 {%- if role == 'controller' %}
229                 dns_servers: {get_param: DnsServers}
230                 {%- endif %}
231                 use_dhcp: false
232                 addresses:
233                   -
234                     ip_netmask: {get_param: ExternalIpSubnet}
235                 routes:
236                   -
237                     {%- if role == 'controller' %}
238                     default: true
239                     {%- endif %}
240                     ip_netmask: 0.0.0.0/0
241                     next_hop: {get_param: ExternalInterfaceDefaultRoute}
242               {%- elif nets['external'][0]['enabled'] and external_net_type == 'br-ex' and nets['external'][0]['nic_mapping'][role]['vlan'] == 'native' %}
243               -
244                 {%- if ovs_dpdk_bridge == 'br-phy' and role == 'compute' %}
245                 type: ovs_user_bridge
246                 {%- else %}
247                 type: {{ nets['external'][0]['nic_mapping'][role]['phys_type'] }}
248                 {%- endif %}
249                 name: br-ex
250                 use_dhcp: false
251                 members:
252                   -
253                     type: interface
254                     name: {{ nets['external'][0]['nic_mapping'][role]['members'][0] }}
255                     # force the MAC address of the bridge to this interface
256                     primary: true
257                 dns_servers: {get_param: DnsServers}
258                 addresses:
259                   -
260                     ip_netmask: {get_param: ExternalIpSubnet}
261                 routes:
262                   -
263                     default: true
264                     ip_netmask: 0.0.0.0/0
265                     next_hop: {get_param: ExternalInterfaceDefaultRoute}
266               {%- endif %}
267               {%- if nets['storage']['enabled'] and nets['storage']['nic_mapping'][role]['vlan'] == 'native' %}
268               -
269                 type: interface
270                 name: {{ nets['storage']['nic_mapping'][role]['members'][0] }}
271                 use_dhcp: false
272                 addresses:
273                   -
274                     ip_netmask: {get_param: StorageIpSubnet}
275               {%- endif %}
276               {%- if nets['api']['enabled'] and nets['api']['nic_mapping'][role]['vlan'] == 'native' %}
277               -
278                 type: interface
279                 name: {{ nets['api']['nic_mapping'][role]['members'][0] }}
280                 use_dhcp: false
281                 addresses:
282                   -
283                     ip_netmask: {get_param: InternalApiIpSubnet}
284               {%- endif %}
285
286 outputs:
287   OS::stack_id:
288     description: The OsNetConfigImpl resource.
289     value: {get_resource: OsNetConfigImpl}