Revision 9ccacbc8
b/lib/config.py | ||
---|---|---|
270 | 270 |
""" |
271 | 271 |
return self._config_data.cluster.SimpleFillDP(group.diskparams) |
272 | 272 |
|
273 |
def _UnlockedGetNetworkMACPrefix(self, net): |
|
273 |
def _UnlockedGetNetworkMACPrefix(self, net_uuid):
|
|
274 | 274 |
"""Return the network mac prefix if it exists or the cluster level default. |
275 | 275 |
|
276 | 276 |
""" |
277 | 277 |
prefix = None |
278 |
if net: |
|
279 |
net_uuid = self._UnlockedLookupNetwork(net) |
|
278 |
if net_uuid: |
|
280 | 279 |
nobj = self._UnlockedGetNetwork(net_uuid) |
281 | 280 |
if nobj.mac_prefix: |
282 | 281 |
prefix = nobj.mac_prefix |
... | ... | |
302 | 301 |
return GenMac |
303 | 302 |
|
304 | 303 |
@locking.ssynchronized(_config_lock, shared=1) |
305 |
def GenerateMAC(self, net, ec_id): |
|
304 |
def GenerateMAC(self, net_uuid, ec_id):
|
|
306 | 305 |
"""Generate a MAC for an instance. |
307 | 306 |
|
308 | 307 |
This should check the current instances for duplicates. |
309 | 308 |
|
310 | 309 |
""" |
311 | 310 |
existing = self._AllMACs() |
312 |
prefix = self._UnlockedGetNetworkMACPrefix(net) |
|
311 |
prefix = self._UnlockedGetNetworkMACPrefix(net_uuid)
|
|
313 | 312 |
gen_mac = self._GenerateOneMAC(prefix) |
314 | 313 |
return self._temporary_ids.Generate(existing, gen_mac, ec_id) |
315 | 314 |
|
... | ... | |
358 | 357 |
(constants.RELEASE_ACTION, address, net_uuid)) |
359 | 358 |
|
360 | 359 |
@locking.ssynchronized(_config_lock, shared=1) |
361 |
def ReleaseIp(self, net, address, ec_id): |
|
360 |
def ReleaseIp(self, net_uuid, address, ec_id):
|
|
362 | 361 |
"""Give a specified IP address back to an IP pool. |
363 | 362 |
|
364 | 363 |
This is just a wrapper around _UnlockedReleaseIp. |
365 | 364 |
|
366 | 365 |
""" |
367 |
net_uuid = self._UnlockedLookupNetwork(net)
|
|
368 |
self._UnlockedReleaseIp(net_uuid, address, ec_id) |
|
366 |
if net_uuid:
|
|
367 |
self._UnlockedReleaseIp(net_uuid, address, ec_id)
|
|
369 | 368 |
|
370 | 369 |
@locking.ssynchronized(_config_lock, shared=1) |
371 |
def GenerateIp(self, net, ec_id): |
|
370 |
def GenerateIp(self, net_uuid, ec_id):
|
|
372 | 371 |
"""Find a free IPv4 address for an instance. |
373 | 372 |
|
374 | 373 |
""" |
375 |
net_uuid = self._UnlockedLookupNetwork(net) |
|
376 | 374 |
nobj = self._UnlockedGetNetwork(net_uuid) |
377 | 375 |
pool = network.AddressPool(nobj) |
378 | 376 |
|
... | ... | |
404 | 402 |
address, net_uuid)) |
405 | 403 |
|
406 | 404 |
@locking.ssynchronized(_config_lock, shared=1) |
407 |
def ReserveIp(self, net, address, ec_id): |
|
405 |
def ReserveIp(self, net_uuid, address, ec_id):
|
|
408 | 406 |
"""Reserve a given IPv4 address for use by an instance. |
409 | 407 |
|
410 | 408 |
""" |
411 |
net_uuid = self._UnlockedLookupNetwork(net)
|
|
412 |
return self._UnlockedReserveIp(net_uuid, address, ec_id) |
|
409 |
if net_uuid:
|
|
410 |
return self._UnlockedReserveIp(net_uuid, address, ec_id)
|
|
413 | 411 |
|
414 | 412 |
@locking.ssynchronized(_config_lock, shared=1) |
415 | 413 |
def ReserveLV(self, lv_name, ec_id): |
... | ... | |
2526 | 2524 |
self._config_data.cluster.serial_no += 1 |
2527 | 2525 |
self._WriteConfig() |
2528 | 2526 |
|
2529 |
def _UnlockedGetGroupNetParams(self, net, node): |
|
2527 |
def _UnlockedGetGroupNetParams(self, net_uuid, node):
|
|
2530 | 2528 |
"""Get the netparams (mode, link) of a network. |
2531 | 2529 |
|
2532 | 2530 |
Get a network's netparams for a given node. |
2533 | 2531 |
|
2534 |
@type net: string |
|
2535 |
@param net: network name
|
|
2532 |
@type net_uuid: string
|
|
2533 |
@param net_uuid: network uuid
|
|
2536 | 2534 |
@type node: string |
2537 | 2535 |
@param node: node name |
2538 | 2536 |
@rtype: dict or None |
2539 | 2537 |
@return: netparams |
2540 | 2538 |
|
2541 | 2539 |
""" |
2542 |
net_uuid = self._UnlockedLookupNetwork(net) |
|
2543 | 2540 |
node_info = self._UnlockedGetNodeInfo(node) |
2544 | 2541 |
nodegroup_info = self._UnlockedGetNodeGroup(node_info.group) |
2545 | 2542 |
netparams = nodegroup_info.networks.get(net_uuid, None) |
... | ... | |
2547 | 2544 |
return netparams |
2548 | 2545 |
|
2549 | 2546 |
@locking.ssynchronized(_config_lock, shared=1) |
2550 |
def GetGroupNetParams(self, net, node): |
|
2547 |
def GetGroupNetParams(self, net_uuid, node):
|
|
2551 | 2548 |
"""Locking wrapper of _UnlockedGetGroupNetParams() |
2552 | 2549 |
|
2553 | 2550 |
""" |
2554 |
return self._UnlockedGetGroupNetParams(net, node) |
|
2551 |
return self._UnlockedGetGroupNetParams(net_uuid, node)
|
|
2555 | 2552 |
|
2556 | 2553 |
@locking.ssynchronized(_config_lock, shared=1) |
2557 | 2554 |
def CheckIPInNodeGroup(self, ip, node): |
Also available in: Unified diff