Revision c85b15c1 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
557 | 557 |
return dict.fromkeys(locking.LEVELS, 1) |
558 | 558 |
|
559 | 559 |
|
560 |
def _CheckInstancesNodeGroups(cfg, instances, owned_groups, owned_nodes, |
|
561 |
cur_group_uuid): |
|
562 |
"""Checks if node groups for locked instances are still correct. |
|
563 |
|
|
564 |
@type cfg: L{config.ConfigWriter} |
|
565 |
@param cfg: Cluster configuration |
|
566 |
@type instances: dict; string as key, L{objects.Instance} as value |
|
567 |
@param instances: Dictionary, instance name as key, instance object as value |
|
568 |
@type owned_groups: iterable of string |
|
569 |
@param owned_groups: List of owned groups |
|
570 |
@type owned_nodes: iterable of string |
|
571 |
@param owned_nodes: List of owned nodes |
|
572 |
@type cur_group_uuid: string or None |
|
573 |
@type cur_group_uuid: Optional group UUID to check against instance's groups |
|
574 |
|
|
575 |
""" |
|
576 |
for (name, inst) in instances.items(): |
|
577 |
assert owned_nodes.issuperset(inst.all_nodes), \ |
|
578 |
"Instance %s's nodes changed while we kept the lock" % name |
|
579 |
|
|
580 |
inst_groups = _CheckInstanceNodeGroups(cfg, name, owned_groups) |
|
581 |
|
|
582 |
assert cur_group_uuid is None or cur_group_uuid in inst_groups, \ |
|
583 |
"Instance %s has no node in group %s" % (name, cur_group_uuid) |
|
584 |
|
|
585 |
|
|
560 | 586 |
def _CheckInstanceNodeGroups(cfg, instance_name, owned_groups): |
561 | 587 |
"""Checks if the owned node groups are still correct for an instance. |
562 | 588 |
|
... | ... | |
3116 | 3142 |
self.instances = dict(self.cfg.GetMultiInstanceInfo(owned_instances)) |
3117 | 3143 |
|
3118 | 3144 |
# Check if node groups for locked instances are still correct |
3119 |
for (instance_name, inst) in self.instances.items(): |
|
3120 |
assert owned_nodes.issuperset(inst.all_nodes), \ |
|
3121 |
"Instance %s's nodes changed while we kept the lock" % instance_name |
|
3122 |
|
|
3123 |
inst_groups = _CheckInstanceNodeGroups(self.cfg, instance_name, |
|
3124 |
owned_groups) |
|
3125 |
|
|
3126 |
assert self.group_uuid in inst_groups, \ |
|
3127 |
"Instance %s has no node in group %s" % (instance_name, self.group_uuid) |
|
3145 |
_CheckInstancesNodeGroups(self.cfg, self.instances, |
|
3146 |
owned_groups, owned_nodes, self.group_uuid) |
|
3128 | 3147 |
|
3129 | 3148 |
def Exec(self, feedback_fn): |
3130 | 3149 |
"""Verify integrity of cluster disks. |
... | ... | |
12523 | 12542 |
self.instances = dict(self.cfg.GetMultiInstanceInfo(owned_instances)) |
12524 | 12543 |
|
12525 | 12544 |
# Check if node groups for locked instances are still correct |
12526 |
for instance_name in owned_instances: |
|
12527 |
inst = self.instances[instance_name] |
|
12528 |
assert owned_nodes.issuperset(inst.all_nodes), \ |
|
12529 |
"Instance %s's nodes changed while we kept the lock" % instance_name |
|
12530 |
|
|
12531 |
inst_groups = _CheckInstanceNodeGroups(self.cfg, instance_name, |
|
12532 |
owned_groups) |
|
12533 |
|
|
12534 |
assert self.group_uuid in inst_groups, \ |
|
12535 |
"Instance %s has no node in group %s" % (instance_name, self.group_uuid) |
|
12545 |
_CheckInstancesNodeGroups(self.cfg, self.instances, |
|
12546 |
owned_groups, owned_nodes, self.group_uuid) |
|
12536 | 12547 |
|
12537 | 12548 |
if self.req_target_uuids: |
12538 | 12549 |
# User requested specific target groups |
Also available in: Unified diff