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:
68 description: Time interval to check the state of the Nexus device
70 NetworkNexusSwitchReplayCount:
72 description: Number of times to attempt config replay
74 NetworkNexusProviderVlanAutoCreate:
76 description: A flag whether to manage the creation and removal of VLANs
78 NetworkNexusProviderVlanAutoTrunk:
80 description: A flag whether to manage the trunk ports on the Nexus
82 NetworkNexusVxlanGlobalConfig:
84 description: A flag whether to manage the VXLAN global settings
86 NetworkNexusHostKeyChecks:
88 description: enable strict host key checks when connecting to Nexus switches
90 NetworkNexusVxlanVniRanges:
92 description: VXLAN Network IDs that are available for tenant network
94 NetworkNexusVxlanMcastRanges:
96 description: Multicast groups for the VXLAN interface.
101 # First we lay down the base configuration via the static hieradata mappings
103 type: OS::Heat::StructuredConfig
105 group: os-apply-config
111 neutron::plugins::ml2::cisco::ucsm::ucsm_ip: {get_input: UCSM_ip}
112 neutron::plugins::ml2::cisco::ucsm::ucsm_username: {get_input: UCSM_username}
113 neutron::plugins::ml2::cisco::ucsm::ucsm_password: {get_input: UCSM_password}
114 neutron::plugins::ml2::cisco::ucsm::ucsm_host_list: {get_input: UCSM_host_list}
115 neutron::plugins::ml2::cisco::ucsm::supported_pci_devs: {get_input: UCSMSupportedPciDevs}
116 neutron::plugins::ml2::cisco::nexus::nexus_config: {get_input: NexusConfig}
117 neutron::plugins::ml2::cisco::nexus::managed_physical_network: {get_input: NexusManagedPhysicalNetwork}
118 neutron::plugins::ml2::cisco::nexus::vlan_name_prefix: {get_input: NexusVlanNamePrefix}
119 neutron::plugins::ml2::cisco::nexus::svi_round_robin: {get_input: NexusSviRoundRobin}
120 neutron::plugins::ml2::cisco::nexus::provider_vlan_name_prefix: {get_input: NexusProviderVlanNamePrefix}
121 neutron::plugins::ml2::cisco::nexus::persistent_switch_config: {get_input: NexusPersistentSwitchConfig}
122 neutron::plugins::ml2::cisco::nexus::switch_heartbeat_time: {get_input: NexusSwitchHeartbeatTime}
123 neutron::plugins::ml2::cisco::nexus::switch_replay_count: {get_input: NexusSwitchReplayCount}
124 neutron::plugins::ml2::cisco::nexus::provider_vlan_auto_create: {get_input: NexusProviderVlanAutoCreate}
125 neutron::plugins::ml2::cisco::nexus::provider_vlan_auto_trunk: {get_input: NexusProviderVlanAutoTrunk}
126 neutron::plugins::ml2::cisco::nexus::vxlan_global_config: {get_input: NexusVxlanGlobalConfig}
127 neutron::plugins::ml2::cisco::nexus::host_key_checks: {get_input: NexusHostKeyChecks}
128 neutron::plugins::ml2::cisco::type_nexus_vxlan::vni_ranges: {get_input: NexusVxlanVniRanges}
129 neutron::plugins::ml2::cisco::type_nexus_vxlan::mcast_ranges: {get_input: NexusVxlanMcastRanges}
131 NetworkCiscoDeployment:
132 type: OS::Heat::StructuredDeployments
134 config: {get_resource: NetworkCiscoConfig}
135 servers: {get_param: controller_servers}
137 UCSM_ip: {get_param: NetworkUCSMIp}
138 UCSM_username: {get_param: NetworkUCSMUsername}
139 UCSM_password: {get_param: NetworkUCSMPassword}
140 UCSM_host_list: {get_attr: [MappingToUCSMDeploymentsController, deploy_stdout]}
141 UCSMSupportedPciDevs: {get_param: NetworkUCSMSupportedPciDevs}
142 NexusConfig: {get_attr: [MappingToNexusDeploymentsController, deploy_stdout]}
143 NexusManagedPhysicalNetwork: {get_param: NetworkNexusManagedPhysicalNetwork}
144 NexusVlanNamePrefix: {get_param: NetworkNexusVlanNamePrefix}
145 NexusSviRoundRobin: {get_param: NetworkNexusSviRoundRobin}
146 NexusProviderVlanNamePrefix: {get_param: NetworkNexusProviderVlanNamePrefix}
147 NexusPersistentSwitchConfig: {get_param: NetworkNexusPersistentSwitchConfig}
148 NexusSwitchHeartbeatTime: {get_param: NetworkNexusSwitchHeartbeatTime}
149 NexusSwitchReplayCount: {get_param: NetworkNexusSwitchReplayCount}
150 NexusProviderVlanAutoCreate: {get_param: NetworkNexusProviderVlanAutoCreate}
151 NexusProviderVlanAutoTrunk: {get_param: NetworkNexusProviderVlanAutoTrunk}
152 NexusVxlanGlobalConfig: {get_param: NetworkNexusVxlanGlobalConfig}
153 NexusHostKeyChecks: {get_param: NetworkNexusHostKeyChecks}
154 NexusVxlanVniRanges: {get_param: NetworkNexusVxlanVniRanges}
155 NexusVxlanMcastRanges: {get_param: NetworkNexusVxlanMcastRanges}
157 # Now we collect the Mac->Hostname mappings for all nodes, which enables
158 # calculation of the neutron::plugins::ml2::cisco::nexus::nexus_config data
160 type: OS::Heat::SoftwareConfig
165 MACS=$(ifconfig | grep ether | awk '{print $2}' | tr "\n" " ")
166 HOST_FQDN=$(hostname -f)
167 if [ -z "$HOST_FQDN" ]; then
168 HOSTNAME=$(hostname -s)
169 # hardcoding the domain name to avoid DNS lookup dependency
170 # same type of hardcoding appears elsewhere
171 # --ie. controller-puppet.yaml
172 # FIXME_HOSTNAME_DOMAIN_HARDCODE
173 echo "$HOSTNAME.localdomain $MACS"
175 echo "$HOST_FQDN $MACS"
178 CollectMacDeploymentsController:
179 type: OS::Heat::SoftwareDeployments
181 servers: {get_param: controller_servers}
182 config: {get_resource: CollectMacConfig}
183 actions: ['CREATE'] # Only do this on CREATE
185 CollectMacDeploymentsCompute:
186 type: OS::Heat::SoftwareDeployments
188 servers: {get_param: compute_servers}
189 config: {get_resource: CollectMacConfig}
190 actions: ['CREATE'] # Only do this on CREATE
192 CollectMacDeploymentsBlockStorage:
193 type: OS::Heat::SoftwareDeployments
195 servers: {get_param: blockstorage_servers}
196 config: {get_resource: CollectMacConfig}
197 actions: ['CREATE'] # Only do this on CREATE
199 CollectMacDeploymentsObjectStorage:
200 type: OS::Heat::SoftwareDeployments
202 servers: {get_param: objectstorage_servers}
203 config: {get_resource: CollectMacConfig}
204 actions: ['CREATE'] # Only do this on CREATE
206 CollectMacDeploymentsCephStorage:
207 type: OS::Heat::SoftwareDeployments
209 servers: {get_param: cephstorage_servers}
210 config: {get_resource: CollectMacConfig}
211 actions: ['CREATE'] # Only do this on CREATE
213 # Now we calculate the additional nexus config based on the mappings
214 MappingToNexusConfig:
215 type: OS::Heat::SoftwareConfig
219 - name: controller_mappings
220 - name: compute_mappings
221 - name: blockstorage_mappings
222 - name: objectstorage_mappings
223 - name: cephstorage_mappings
230 from copy import deepcopy
232 mappings = ['controller_mappings',
234 'blockstorage_mappings',
235 'objectstorage_mappings',
236 'cephstorage_mappings',
240 for map_name in mappings:
241 f_name = '/root/' + map_name
242 map_data = os.getenv(map_name, "Nada")
243 with open(f_name, 'a') as f:
245 if map_data is not "Nada":
246 if map_name is not 'nexus_config':
247 mapdict_list.append(ast.literal_eval(map_data))
249 nexus = ast.literal_eval(map_data)
252 for mapdict in mapdict_list:
253 for (listnum, host2mac_list) in mapdict.iteritems():
254 vals = host2mac_list.rstrip().split()
256 mac2host[mac.lower()] = vals[0]
258 with open('/root/mac2host', 'a') as f:
259 f.write(str(mac2host))
261 # now we have mac to host, map host to switchport in hieradata
262 # nexus = ast.literal_eval(os.getenv('nexus_config', None))
263 nexus_cp = deepcopy(nexus)
264 for nexus_switch in nexus:
265 for (mac,swport) in nexus[nexus_switch]['servers'].iteritems():
268 hostname = mac2host[lmac]
269 # for puppet we need a unique title even at the 2nd key level
270 serv_key = nexus_switch + "::" + hostname
271 if serv_key in nexus_cp[nexus_switch]['servers']:
272 nexus_cp[nexus_switch]['servers'][serv_key]['ports'] += ',' + swport['ports']
274 nexus_cp[nexus_switch]['servers'][serv_key] = swport
275 nexus_cp[nexus_switch]['servers'][serv_key]['hostname'] = hostname
276 del nexus_cp[nexus_switch]['servers'][mac]
277 # Note this echo means you can view the data via heat deployment-show
278 print json.dumps(nexus_cp)
280 MappingToNexusDeploymentsController:
281 type: OS::Heat::SoftwareDeployment
283 server: {get_param: [controller_servers, '0']}
284 config: {get_resource: MappingToNexusConfig}
286 # FIXME(shardy): It'd be more convenient if we could join these
287 # items together but because the returned format is a map (not a list)
288 # we can't use list_join or str_replace. Possible Heat TODO.
289 controller_mappings: {get_attr: [CollectMacDeploymentsController, deploy_stdouts]}
290 compute_mappings: {get_attr: [CollectMacDeploymentsCompute, deploy_stdouts]}
291 blockstorage_mappings: {get_attr: [CollectMacDeploymentsBlockStorage, deploy_stdouts]}
292 objectstorage_mappings: {get_attr: [CollectMacDeploymentsObjectStorage, deploy_stdouts]}
293 cephstorage_mappings: {get_attr: [CollectMacDeploymentsCephStorage, deploy_stdouts]}
294 nexus_config: {get_param: NetworkNexusConfig}
295 actions: ['CREATE'] # Only do this on CREATE
298 type: OS::Heat::SoftwareConfig
307 with open('/root/mac2host', 'r') as f:
309 m2h=ast.literal_eval(s)
310 ucs_config = os.getenv('ucsm_config', "Nada")
312 lines = ucs_config.split(',')
314 entry=line.rsplit(":",1)
315 mac = entry[0].lower().strip()
317 ucs_data.append(m2h[mac] + ":" + entry[1])
319 print ", ".join(ucs_data)
322 MappingToUCSMDeploymentsController:
323 type: OS::Heat::SoftwareDeployment
324 depends_on: MappingToNexusDeploymentsController
326 server: {get_param: [controller_servers, '0']}
327 config: {get_resource: MappingToUCSMConfig}
329 ucsm_config: {get_param: NetworkUCSMHostList}
330 actions: ['CREATE'] # Only do this on CREATE
333 # The Deployment applying the hieradata outputs the derived config-id, which
334 # changes if the input_values change, so if the stdouts from
335 # NetworkCiscoDeployment change, we need to reapply puppet (which will
336 # happen if we return a different config_identifier)
338 value: {get_attr: [NetworkCiscoDeployment, deploy_stdouts]}