Revision b8716596 lib/config.py
b/lib/config.py | ||
---|---|---|
430 | 430 |
" %s and %s" % (minor, node, instance_a, instance_b)) |
431 | 431 |
|
432 | 432 |
# IP checks |
433 |
ips = { data.cluster.master_ip: ["cluster_ip"] } |
|
434 |
def _helper(ip, name): |
|
435 |
if ip in ips: |
|
436 |
ips[ip].append(name) |
|
437 |
else: |
|
438 |
ips[ip] = [name] |
|
433 |
default_nicparams = data.cluster.nicparams[constants.PP_DEFAULT] |
|
434 |
ips = {} |
|
435 |
|
|
436 |
def _AddIpAddress(ip, name): |
|
437 |
ips.setdefault(ip, []).append(name) |
|
438 |
|
|
439 |
_AddIpAddress(data.cluster.master_ip, "cluster_ip") |
|
439 | 440 |
|
440 | 441 |
for node in data.nodes.values(): |
441 |
_helper(node.primary_ip, "node:%s/primary" % node.name)
|
|
442 |
_AddIpAddress(node.primary_ip, "node:%s/primary" % node.name)
|
|
442 | 443 |
if node.secondary_ip != node.primary_ip: |
443 |
_helper(node.secondary_ip, "node:%s/secondary" % node.name) |
|
444 |
_AddIpAddress(node.secondary_ip, "node:%s/secondary" % node.name) |
|
445 |
|
|
446 |
for instance in data.instances.values(): |
|
447 |
for idx, nic in enumerate(instance.nics): |
|
448 |
if nic.ip is None: |
|
449 |
continue |
|
450 |
|
|
451 |
nicparams = objects.FillDict(default_nicparams, nic.nicparams) |
|
452 |
nic_mode = nicparams[constants.NIC_MODE] |
|
453 |
nic_link = nicparams[constants.NIC_LINK] |
|
454 |
|
|
455 |
if nic_mode == constants.NIC_MODE_BRIDGED: |
|
456 |
link = "bridge:%s" % nic_link |
|
457 |
elif nic_mode == constants.NIC_MODE_ROUTED: |
|
458 |
link = "route:%s" % nic_link |
|
459 |
else: |
|
460 |
raise errors.ProgrammerError("NIC mode '%s' not handled" % nic_mode) |
|
461 |
|
|
462 |
_AddIpAddress("%s/%s" % (link, nic.ip), |
|
463 |
"instance:%s/nic:%d" % (instance.name, idx)) |
|
444 | 464 |
|
445 | 465 |
for ip, owners in ips.items(): |
446 | 466 |
if len(owners) > 1: |
447 | 467 |
result.append("IP address %s is used by multiple owners: %s" % |
448 | 468 |
(ip, ", ".join(owners))) |
469 |
|
|
449 | 470 |
return result |
450 | 471 |
|
451 | 472 |
@locking.ssynchronized(_config_lock, shared=1) |
Also available in: Unified diff