Adding VLAN support
[apex.git] / build / nics-template.yaml.jinja2
1 heat_template_version: 2015-04-30
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::StructuredConfig
82     properties:
83       group: os-apply-config
84       config:
85         os_net_config:
86           network_config:
87             -
88             {%- if vlans['private_network'] != 'native' or vlans['storage_network'] != 'native' or vlans['api_network'] != 'native' %}
89               type: ovs_bridge
90               name: {get_input: bridge_name}
91               members:
92                 -
93                   type: interface
94                   name: nic1
95                   # force the MAC address of the bridge to this interface
96                   primary: true
97                 {%- if 'public_network' in enabled_networks and vlans['private_network'] != 'native' %}
98                 -
99                   type: vlan
100                   vlan_id: {get_param: ExternalNetworkVlanID}
101                   addresses:
102                   -
103                     ip_netmask: {get_param: ExternalIpSubnet}
104                   routes:
105                     -
106                       default: true
107                       next_hop: {get_param: ExternalInterfaceDefaultRoute}
108                 {%- endif %}
109                 {%- if 'private_network' in enabled_networks and vlans['private_network'] != 'native' %}
110                 -
111                   type: vlan
112                   vlan_id: {get_param: TenantNetworkVlanID}
113                   addresses:
114                     -
115                       ip_netmask: {get_param: TenantIpSubnet}
116                 {%- endif %}
117                 {%- if 'storage_network' in enabled_networks and vlans['storage_network'] != 'native' %}
118                 -
119                   type: vlan
120                   vlan_id: {get_param: StorageNetworkVlanID}
121                   addresses:
122                     -
123                       ip_netmask: {get_param: StorageIpSubnet}
124                 {%- endif %}
125                 {%- if 'api_network' in enabled_networks and vlans['api_network'] != 'native' %}
126                 -
127                   type: vlan
128                   vlan_id: {get_param: InternalApiNetworkVlanID}
129                   addresses:
130                     -
131                       ip_netmask: {get_param: InternalApiIpSubnet}
132                 {%- endif %}
133             {%- else %}
134               type: interface
135               name: nic1
136             {%- endif %}
137               use_dhcp: false
138               dns_servers: {get_param: DnsServers}
139               addresses:
140                 -
141                   ip_netmask:
142                     list_join:
143                       - '/'
144                       - - {get_param: ControlPlaneIp}
145                         - {get_param: ControlPlaneSubnetCidr}
146               routes:
147                 -
148                   ip_netmask: 169.254.169.254/32
149                   next_hop: {get_param: EC2MetadataIp}
150                 {%- if external_net_af == 6 or role == 'compute' %}
151                 -
152                   default: true
153                   next_hop: {get_param: ControlPlaneDefaultRoute}
154                 {%- endif %}
155
156             {%- set nic_index = 2 %}
157             {%- if 'private_network' in enabled_networks and vlans['private_network'] == 'native' %}
158             {%- if ovs_dpdk_bridge == 'br-phy' %}
159             -
160               type: interface
161               name: nic{{ nic_index }}{% set nic_index = nic_index + 1 %}
162               use_dhcp: false
163
164             -
165               type: ovs_bridge
166               name: {{ ovs_dpdk_bridge }}
167               use_dhcp: false
168               addresses:
169                 -
170                   ip_netmask: {get_param: TenantIpSubnet}
171             -
172               type: ovs_bridge
173               name: br-tun
174               use_dhcp: false
175             {%- else %}
176             -
177               type: interface
178               name: nic{{ nic_index }}{% set nic_index = nic_index + 1 %}
179               use_dhcp: false
180               addresses:
181                 -
182                   ip_netmask: {get_param: TenantIpSubnet}
183             {%- endif %}
184             {%- endif %}
185             {%- if 'public_network' in enabled_networks and external_net_type == 'interface' and vlans['public_network'] == 'native' %}
186             -
187               type: interface
188               name: nic{{ nic_index }}{% set nic_index = nic_index + 1 %}
189               {%- if role == 'controller' %}
190               dns_servers: {get_param: DnsServers}
191               {%- endif %}
192               use_dhcp: false
193               addresses:
194                 -
195                   ip_netmask: {get_param: ExternalIpSubnet}
196               routes:
197                 -
198                   {%- if role == 'controller' %}
199                   default: true
200                   {%- endif %}
201                   ip_netmask: 0.0.0.0/0
202                   next_hop: {get_param: ExternalInterfaceDefaultRoute}
203             {%- elif 'public_network' in enabled_networks  and external_net_type == 'br-ex' and vlans['public_network'] == 'native' %}
204             -
205               type: ovs_bridge
206               name: {get_input: bridge_name}
207               use_dhcp: false
208               members:
209                 -
210                   type: interface
211                   name: nic{{ nic_index }}{% set nic_index = nic_index + 1 %}
212                   # force the MAC address of the bridge to this interface
213                   primary: true
214             {%- endif %}
215             {%- if 'storage_network' in enabled_networks and vlans['storage_network'] == 'native' %}
216             -
217               type: interface
218               name: nic{{ nic_index }}{% set nic_index = nic_index + 1 %}
219               use_dhcp: false
220               addresses:
221                 -
222                   ip_netmask: {get_param: StorageIpSubnet}
223             {%- endif %}
224             {%- if 'api_network' in enabled_networks and vlans['api_network'] == 'native' %}
225             -
226               type: interface
227               name: nic{{ nic_index }}{% set nic_index = nic_index + 1 %}
228               use_dhcp: false
229               addresses:
230                 -
231                   ip_netmask: {get_param: InternalApiIpSubnet}
232             {%- endif %}
233
234 outputs:
235   OS::stack_id:
236     description: The OsNetConfigImpl resource.
237     value: {get_resource: OsNetConfigImpl}