Migrating to Mitaka
[apex.git] / build / nics-compute.yaml.template
1 #!/bin/bash
2 if [[ $nics_cfg == *_private* ]]; then
3     private_net=$( cat << END
4
5             -
6               # Create a bridge which can also be used for VLAN-mode bridge mapping
7               type: ovs_bridge
8               name: br-tenant
9               use_dhcp: false
10               addresses:
11                 -
12                   ip_netmask: {get_param: TenantIpSubnet}
13               members:
14                 -
15                   type: interface
16                   name: nic2
17                   use_dhcp: false
18                   # force the MAC address of the bridge to this interface
19                   primary: true
20 END
21 )
22 fi
23
24 if [[ $nics_cfg == *_storage* ]]; then
25     storage_net=$( cat << END
26             -
27               type: interface
28               name: nic4
29               use_dhcp: false
30               addresses:
31                 -
32                   ip_netmask: {get_param: StorageIpSubnet}
33 END
34 )
35 fi
36
37 if [[ $nics_cfg == *_br-ex* ]]; then
38     br_ex=$( cat << END
39
40               members:
41                 -
42                   type: interface
43                   name: nic3
44                   # force the MAC address of the bridge to this interface
45                   primary: true
46
47 END
48 )
49     nic3=$( cat << END
50
51             -
52               type: ovs_bridge
53               name: {get_input: bridge_name}
54 END
55 )
56 else
57     nic3=$( cat << END
58
59             -
60               type: interface
61               name: nic3
62
63 END
64 )
65 fi
66
67 if [[ $nics_cfg == *_no-public-ip* ]]; then
68     if [[ $nics_cfg == *_br-ex* ]]; then
69         nic3+=$( cat << END
70
71               use_dhcp: false
72 END
73 )
74     else
75         nic3=""
76     fi
77 else
78     nic3+=$( cat << END
79
80               use_dhcp: false
81               addresses:
82                 -
83                   ip_netmask: {get_param: ExternalIpSubnet}
84               routes:
85                 -
86                   ip_netmask: 0.0.0.0/0
87                   next_hop: {get_param: ExternalInterfaceDefaultRoute}
88 END
89 )
90 fi
91
92 cat <<END
93 heat_template_version: 2015-04-30
94
95 description: >
96   Software Config to drive os-net-config to configure multiple interfaces
97   for the compute role.
98
99 parameters:
100   ControlPlaneIp:
101     default: ''
102     description: IP address/subnet on the ctlplane network
103     type: string
104   ExternalIpSubnet:
105     default: ''
106     description: IP address/subnet on the external network
107     type: string
108   InternalApiIpSubnet:
109     default: ''
110     description: IP address/subnet on the internal API network
111     type: string
112   StorageIpSubnet:
113     default: ''
114     description: IP address/subnet on the storage network
115     type: string
116   StorageMgmtIpSubnet:
117     default: ''
118     description: IP address/subnet on the storage mgmt network
119     type: string
120   StorageMgmtNetworkVlanID:
121     default: 40
122     description: Vlan ID for the storage mgmt network traffic.
123     type: number
124   TenantIpSubnet:
125     default: ''
126     description: IP address/subnet on the tenant network
127     type: string
128   ManagementIpSubnet: # Only populated when including environments/network-management.yaml
129     default: ''
130     description: IP address/subnet on the management network
131     type: string
132   ExternalNetworkVlanID:
133     default: 10
134     description: Vlan ID for the external network traffic.
135     type: number
136   InternalApiNetworkVlanID:
137     default: 20
138     description: Vlan ID for the internal_api network traffic.
139     type: number
140   StorageNetworkVlanID:
141     default: 30
142     description: Vlan ID for the storage network traffic.
143     type: number
144   TenantNetworkVlanID:
145     default: 50
146     description: Vlan ID for the tenant network traffic.
147     type: number
148   ManagementNetworkVlanID:
149     default: 60
150     description: Vlan ID for the management network traffic.
151     type: number
152   ExternalInterfaceDefaultRoute:
153     default: '10.0.0.1'
154     description: default route for the external network
155     type: string
156   ControlPlaneSubnetCidr: # Override this via parameter_defaults
157     default: '24'
158     description: The subnet CIDR of the control plane network.
159     type: string
160   ControlPlaneDefaultRoute: # Override this via parameter_defaults
161     description: The default route of the control plane network.
162     type: string
163   DnsServers: # Override this via parameter_defaults
164     default: []
165     description: A list of DNS servers (2 max for some implementations) that will be added to resolv.conf.
166     type: comma_delimited_list
167   EC2MetadataIp: # Override this via parameter_defaults
168     description: The IP address of the EC2 metadata server.
169     type: string
170
171 resources:
172   OsNetConfigImpl:
173     type: OS::Heat::StructuredConfig
174     properties:
175       group: os-apply-config
176       config:
177         os_net_config:
178           network_config:
179             -
180               type: interface
181               name: nic1
182               use_dhcp: false
183               dns_servers: {get_param: DnsServers}
184               addresses:
185                 -
186                   ip_netmask:
187                     list_join:
188                       - '/'
189                       - - {get_param: ControlPlaneIp}
190                         - {get_param: ControlPlaneSubnetCidr}
191               routes:
192                 -
193                   ip_netmask: 169.254.169.254/32
194                   next_hop: {get_param: EC2MetadataIp}
195                 -
196                   default: true
197                   next_hop: {get_param: ControlPlaneDefaultRoute}$private_net$nic3$br_ex
198 $storage_net
199 outputs:
200   OS::stack_id:
201     description: The OsNetConfigImpl resource.
202     value: {get_resource: OsNetConfigImpl}
203 END