1 heat_template_version: 2015-04-30
3 description: Configure hieradata for Network Cisco configuration
6 # Parameters passed from the parent template
13 objectstorage_servers:
18 # extra parameters passed via parameter_defaults
21 description: Cisco UCSM IP
25 description: Cisco UCSM username
29 description: Cisco UCSM password
34 Mac address to service profile mapping for UCSM-controlled hosts
36 '<host1-mac>:<profile>, <host2-mac>:<profile>, ...'
38 NetworkUCSMSupportedPciDevs:
40 description: Cisco UCSM SR-IOV and VM-FEX vendors supported
44 description: Nexus switch configuration
46 NetworkNexusManagedPhysicalNetwork:
48 description: The name of the physical_network
50 NetworkNexusVlanNamePrefix:
52 description: A short prefix to prepend to the VLAN name
54 NetworkNexusSviRoundRobin:
56 description: A flag to enable round robin scheduling
58 NetworkNexusProviderVlanNamePrefix:
60 description: A short prefix to prepend to the VLAN name
62 NetworkNexusPersistentSwitchConfig:
64 description: To make Nexus device persistent
66 NetworkNexusSwitchHeartbeatTime:
69 Time interval to check the state of the Nexus device. The units of this
70 object are seconds. Setting this object to a value of 0 disables the
73 NetworkNexusSwitchReplayCount:
76 This configuration item is OBSOLETE. The Nexus driver replay behavior
77 is to continue to attempt to connect to the down Nexus device with a
78 period equal to the heartbeat time interval. This was previously the
79 Number of times to attempt config replay.
81 NetworkNexusProviderVlanAutoCreate:
83 description: A flag whether to manage the creation and removal of VLANs
85 NetworkNexusProviderVlanAutoTrunk:
87 description: A flag whether to manage the trunk ports on the Nexus
89 NetworkNexusVxlanGlobalConfig:
91 description: A flag whether to manage the VXLAN global settings
93 NetworkNexusHostKeyChecks:
95 description: enable strict host key checks when connecting to Nexus switches
97 NetworkNexusVxlanVniRanges:
99 description: VXLAN Network IDs that are available for tenant network
101 NetworkNexusVxlanMcastRanges:
103 description: Multicast groups for the VXLAN interface.
108 # First we lay down the base configuration via the static hieradata mappings
110 type: OS::Heat::StructuredConfig
112 group: os-apply-config
118 neutron::plugins::ml2::cisco::ucsm::ucsm_ip: {get_input: UCSM_ip}
119 neutron::plugins::ml2::cisco::ucsm::ucsm_username: {get_input: UCSM_username}
120 neutron::plugins::ml2::cisco::ucsm::ucsm_password: {get_input: UCSM_password}
121 neutron::plugins::ml2::cisco::ucsm::ucsm_host_list: {get_input: UCSM_host_list}
122 neutron::plugins::ml2::cisco::ucsm::supported_pci_devs: {get_input: UCSMSupportedPciDevs}
123 neutron::plugins::ml2::cisco::nexus::nexus_config: {get_input: NexusConfig}
124 neutron::plugins::ml2::cisco::nexus::managed_physical_network: {get_input: NexusManagedPhysicalNetwork}
125 neutron::plugins::ml2::cisco::nexus::vlan_name_prefix: {get_input: NexusVlanNamePrefix}
126 neutron::plugins::ml2::cisco::nexus::svi_round_robin: {get_input: NexusSviRoundRobin}
127 neutron::plugins::ml2::cisco::nexus::provider_vlan_name_prefix: {get_input: NexusProviderVlanNamePrefix}
128 neutron::plugins::ml2::cisco::nexus::persistent_switch_config: {get_input: NexusPersistentSwitchConfig}
129 neutron::plugins::ml2::cisco::nexus::switch_heartbeat_time: {get_input: NexusSwitchHeartbeatTime}
130 neutron::plugins::ml2::cisco::nexus::switch_replay_count: {get_input: NexusSwitchReplayCount}
131 neutron::plugins::ml2::cisco::nexus::provider_vlan_auto_create: {get_input: NexusProviderVlanAutoCreate}
132 neutron::plugins::ml2::cisco::nexus::provider_vlan_auto_trunk: {get_input: NexusProviderVlanAutoTrunk}
133 neutron::plugins::ml2::cisco::nexus::vxlan_global_config: {get_input: NexusVxlanGlobalConfig}
134 neutron::plugins::ml2::cisco::nexus::host_key_checks: {get_input: NexusHostKeyChecks}
135 neutron::plugins::ml2::cisco::type_nexus_vxlan::vni_ranges: {get_input: NexusVxlanVniRanges}
136 neutron::plugins::ml2::cisco::type_nexus_vxlan::mcast_ranges: {get_input: NexusVxlanMcastRanges}
138 NetworkCiscoDeployment:
139 type: OS::Heat::StructuredDeployments
141 name: NetworkCiscoDeployment
142 config: {get_resource: NetworkCiscoConfig}
143 servers: {get_param: controller_servers}
145 UCSM_ip: {get_param: NetworkUCSMIp}
146 UCSM_username: {get_param: NetworkUCSMUsername}
147 UCSM_password: {get_param: NetworkUCSMPassword}
148 UCSM_host_list: {get_attr: [MappingToUCSMDeploymentsController, deploy_stdout]}
149 UCSMSupportedPciDevs: {get_param: NetworkUCSMSupportedPciDevs}
150 NexusConfig: {get_attr: [MappingToNexusDeploymentsController, deploy_stdout]}
151 NexusManagedPhysicalNetwork: {get_param: NetworkNexusManagedPhysicalNetwork}
152 NexusVlanNamePrefix: {get_param: NetworkNexusVlanNamePrefix}
153 NexusSviRoundRobin: {get_param: NetworkNexusSviRoundRobin}
154 NexusProviderVlanNamePrefix: {get_param: NetworkNexusProviderVlanNamePrefix}
155 NexusPersistentSwitchConfig: {get_param: NetworkNexusPersistentSwitchConfig}
156 NexusSwitchHeartbeatTime: {get_param: NetworkNexusSwitchHeartbeatTime}
157 NexusSwitchReplayCount: {get_param: NetworkNexusSwitchReplayCount}
158 NexusProviderVlanAutoCreate: {get_param: NetworkNexusProviderVlanAutoCreate}
159 NexusProviderVlanAutoTrunk: {get_param: NetworkNexusProviderVlanAutoTrunk}
160 NexusVxlanGlobalConfig: {get_param: NetworkNexusVxlanGlobalConfig}
161 NexusHostKeyChecks: {get_param: NetworkNexusHostKeyChecks}
162 NexusVxlanVniRanges: {get_param: NetworkNexusVxlanVniRanges}
163 NexusVxlanMcastRanges: {get_param: NetworkNexusVxlanMcastRanges}
165 # Now we collect the Mac->Hostname mappings for all nodes, which enables
166 # calculation of the neutron::plugins::ml2::cisco::nexus::nexus_config data
168 type: OS::Heat::SoftwareConfig
173 MACS=$(ifconfig | grep ether | awk '{print $2}' | tr "\n" " ")
174 HOST_FQDN=$(hostname -f)
175 if [ -z "$HOST_FQDN" ]; then
176 HOSTNAME=$(hostname -s)
177 # hardcoding the domain name to avoid DNS lookup dependency
178 # same type of hardcoding appears elsewhere
179 # --ie. controller-puppet.yaml
180 # FIXME_HOSTNAME_DOMAIN_HARDCODE
181 echo "$HOSTNAME.localdomain $MACS"
183 echo "$HOST_FQDN $MACS"
186 CollectMacDeploymentsController:
187 type: OS::Heat::SoftwareDeployments
189 name: CollectMacDeploymentsController
190 servers: {get_param: controller_servers}
191 config: {get_resource: CollectMacConfig}
192 actions: ['CREATE'] # Only do this on CREATE
194 CollectMacDeploymentsCompute:
195 type: OS::Heat::SoftwareDeployments
197 name: CollectMacDeploymentsCompute
198 servers: {get_param: compute_servers}
199 config: {get_resource: CollectMacConfig}
200 actions: ['CREATE'] # Only do this on CREATE
202 CollectMacDeploymentsBlockStorage:
203 type: OS::Heat::SoftwareDeployments
205 name: CollectMacDeploymentsBlockStorage
206 servers: {get_param: blockstorage_servers}
207 config: {get_resource: CollectMacConfig}
208 actions: ['CREATE'] # Only do this on CREATE
210 CollectMacDeploymentsObjectStorage:
211 type: OS::Heat::SoftwareDeployments
213 name: CollectMacDeploymentsObjectStorage
214 servers: {get_param: objectstorage_servers}
215 config: {get_resource: CollectMacConfig}
216 actions: ['CREATE'] # Only do this on CREATE
218 CollectMacDeploymentsCephStorage:
219 type: OS::Heat::SoftwareDeployments
221 name: CollectMacDeploymentsCephStorage
222 servers: {get_param: cephstorage_servers}
223 config: {get_resource: CollectMacConfig}
224 actions: ['CREATE'] # Only do this on CREATE
226 # Now we calculate the additional nexus config based on the mappings
227 MappingToNexusConfig:
228 type: OS::Heat::SoftwareConfig
232 - name: controller_mappings
233 - name: compute_mappings
234 - name: blockstorage_mappings
235 - name: objectstorage_mappings
236 - name: cephstorage_mappings
243 from copy import deepcopy
245 mappings = ['controller_mappings',
247 'blockstorage_mappings',
248 'objectstorage_mappings',
249 'cephstorage_mappings',
253 for map_name in mappings:
254 f_name = '/root/' + map_name
255 map_data = os.getenv(map_name, "Nada")
256 with open(f_name, 'a') as f:
258 if map_data is not "Nada":
259 if map_name is not 'nexus_config':
260 mapdict_list.append(ast.literal_eval(map_data))
262 nexus = ast.literal_eval(map_data)
265 for mapdict in mapdict_list:
266 for (listnum, host2mac_list) in mapdict.iteritems():
267 vals = host2mac_list.rstrip().split()
269 mac2host[mac.lower()] = vals[0]
271 with open('/root/mac2host', 'a') as f:
272 f.write(str(mac2host))
274 # now we have mac to host, map host to switchport in hieradata
275 # nexus = ast.literal_eval(os.getenv('nexus_config', None))
276 nexus_cp = deepcopy(nexus)
277 for nexus_switch in nexus:
278 for (mac,swport) in nexus[nexus_switch]['servers'].iteritems():
281 hostname = mac2host[lmac]
282 # for puppet we need a unique title even at the 2nd key level
283 serv_key = nexus_switch + "::" + hostname
284 if serv_key in nexus_cp[nexus_switch]['servers']:
285 nexus_cp[nexus_switch]['servers'][serv_key]['ports'] += ',' + swport['ports']
287 nexus_cp[nexus_switch]['servers'][serv_key] = swport
288 nexus_cp[nexus_switch]['servers'][serv_key]['hostname'] = hostname
289 del nexus_cp[nexus_switch]['servers'][mac]
290 # Note this echo means you can view the data via heat deployment-show
291 print json.dumps(nexus_cp)
293 MappingToNexusDeploymentsController:
294 type: OS::Heat::SoftwareDeployment
296 name: MappingToNexusDeploymentsController
297 server: {get_param: [controller_servers, '0']}
298 config: {get_resource: MappingToNexusConfig}
300 # FIXME(shardy): It'd be more convenient if we could join these
301 # items together but because the returned format is a map (not a list)
302 # we can't use list_join or str_replace. Possible Heat TODO.
303 controller_mappings: {get_attr: [CollectMacDeploymentsController, deploy_stdouts]}
304 compute_mappings: {get_attr: [CollectMacDeploymentsCompute, deploy_stdouts]}
305 blockstorage_mappings: {get_attr: [CollectMacDeploymentsBlockStorage, deploy_stdouts]}
306 objectstorage_mappings: {get_attr: [CollectMacDeploymentsObjectStorage, deploy_stdouts]}
307 cephstorage_mappings: {get_attr: [CollectMacDeploymentsCephStorage, deploy_stdouts]}
308 nexus_config: {get_param: NetworkNexusConfig}
309 actions: ['CREATE'] # Only do this on CREATE
312 type: OS::Heat::SoftwareConfig
321 with open('/root/mac2host', 'r') as f:
323 m2h=ast.literal_eval(s)
324 ucs_config = os.getenv('ucsm_config', "Nada")
326 lines = ucs_config.split(',')
328 entry=line.rsplit(":",1)
329 mac = entry[0].lower().strip()
331 ucs_data.append(m2h[mac] + ":" + entry[1])
333 print ", ".join(ucs_data)
336 MappingToUCSMDeploymentsController:
337 type: OS::Heat::SoftwareDeployment
338 depends_on: MappingToNexusDeploymentsController
340 name: MappingToUCSMDeploymentsController
341 server: {get_param: [controller_servers, '0']}
342 config: {get_resource: MappingToUCSMConfig}
344 ucsm_config: {get_param: NetworkUCSMHostList}
345 actions: ['CREATE'] # Only do this on CREATE