Revision 271fee18 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
5751 | 5751 |
lu.needed_locks[locking.LEVEL_INSTANCE] = self.wanted |
5752 | 5752 |
lu.needed_locks[locking.LEVEL_NODEGROUP] = [] |
5753 | 5753 |
lu.needed_locks[locking.LEVEL_NODE] = [] |
5754 |
lu.needed_locks[locking.LEVEL_NETWORK] = [] |
|
5754 | 5755 |
lu.recalculate_locks[locking.LEVEL_NODE] = constants.LOCKS_REPLACE |
5755 | 5756 |
|
5756 | 5757 |
self.do_grouplocks = (self.do_locking and |
... | ... | |
5770 | 5771 |
elif level == locking.LEVEL_NODE: |
5771 | 5772 |
lu._LockInstancesNodes() # pylint: disable=W0212 |
5772 | 5773 |
|
5774 |
elif level == locking.LEVEL_NETWORK: |
|
5775 |
lu.needed_locks[locking.LEVEL_NETWORK] = \ |
|
5776 |
frozenset(net_uuid |
|
5777 |
for instance_name in lu.owned_locks(locking.LEVEL_INSTANCE) |
|
5778 |
for net_uuid in lu.cfg.GetInstanceNetworks(instance_name)) |
|
5779 |
|
|
5773 | 5780 |
@staticmethod |
5774 | 5781 |
def _CheckGroupLocks(lu): |
5775 | 5782 |
owned_instances = frozenset(lu.owned_locks(locking.LEVEL_INSTANCE)) |
... | ... | |
12823 | 12830 |
|
12824 | 12831 |
self.needed_locks[locking.LEVEL_NODEGROUP] = [] |
12825 | 12832 |
self.needed_locks[locking.LEVEL_NODE] = [] |
12833 |
self.needed_locks[locking.LEVEL_NETWORK] = [] |
|
12826 | 12834 |
self.recalculate_locks[locking.LEVEL_NODE] = constants.LOCKS_REPLACE |
12827 | 12835 |
|
12828 | 12836 |
def DeclareLocks(self, level): |
12829 | 12837 |
if self.op.use_locking: |
12838 |
owned_instances = self.owned_locks(locking.LEVEL_INSTANCE) |
|
12830 | 12839 |
if level == locking.LEVEL_NODEGROUP: |
12831 |
owned_instances = self.owned_locks(locking.LEVEL_INSTANCE) |
|
12832 | 12840 |
|
12833 | 12841 |
# Lock all groups used by instances optimistically; this requires going |
12834 | 12842 |
# via the node before it's locked, requiring verification later on |
... | ... | |
12841 | 12849 |
elif level == locking.LEVEL_NODE: |
12842 | 12850 |
self._LockInstancesNodes() |
12843 | 12851 |
|
12852 |
elif level == locking.LEVEL_NETWORK: |
|
12853 |
self.needed_locks[locking.LEVEL_NETWORK] = \ |
|
12854 |
frozenset(net_uuid |
|
12855 |
for instance_name in owned_instances |
|
12856 |
for net_uuid in |
|
12857 |
self.cfg.GetInstanceNetworks(instance_name)) |
|
12858 |
|
|
12844 | 12859 |
def CheckPrereq(self): |
12845 | 12860 |
"""Check prerequisites. |
12846 | 12861 |
|
... | ... | |
12850 | 12865 |
owned_instances = frozenset(self.owned_locks(locking.LEVEL_INSTANCE)) |
12851 | 12866 |
owned_groups = frozenset(self.owned_locks(locking.LEVEL_NODEGROUP)) |
12852 | 12867 |
owned_nodes = frozenset(self.owned_locks(locking.LEVEL_NODE)) |
12868 |
owned_networks = frozenset(self.owned_locks(locking.LEVEL_NETWORK)) |
|
12853 | 12869 |
|
12854 | 12870 |
if self.wanted_names is None: |
12855 | 12871 |
assert self.op.use_locking, "Locking was not used" |
... | ... | |
12861 | 12877 |
_CheckInstancesNodeGroups(self.cfg, instances, owned_groups, owned_nodes, |
12862 | 12878 |
None) |
12863 | 12879 |
else: |
12864 |
assert not (owned_instances or owned_groups or owned_nodes) |
|
12880 |
assert not (owned_instances or owned_groups or |
|
12881 |
owned_nodes or owned_networks) |
|
12865 | 12882 |
|
12866 | 12883 |
self.wanted_instances = instances.values() |
12867 | 12884 |
|
... | ... | |
12945 | 12962 |
for node in nodes.values())) |
12946 | 12963 |
|
12947 | 12964 |
group2name_fn = lambda uuid: groups[uuid].name |
12948 |
|
|
12949 | 12965 |
for instance in self.wanted_instances: |
12950 | 12966 |
pnode = nodes[instance.primary_node] |
12951 | 12967 |
|
Also available in: Unified diff