X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/1a732a74937bccba6d9ee3a8308d3bfdfaa795e3..1c3231aad9e5dddbe9490d49896434000cec6dd9:/lib/cmdlib/base.py diff --git a/lib/cmdlib/base.py b/lib/cmdlib/base.py index 142981f..dcb0826 100644 --- a/lib/cmdlib/base.py +++ b/lib/cmdlib/base.py @@ -28,7 +28,7 @@ from ganeti import constants from ganeti import locking from ganeti import query from ganeti import utils -from ganeti.cmdlib.common import _ExpandInstanceName +from ganeti.cmdlib.common import ExpandInstanceName class ResultWithJobs: @@ -181,7 +181,7 @@ class LogicalUnit(object): } # Acquire just two nodes self.needed_locks = { - locking.LEVEL_NODE: ['node1.example.com', 'node2.example.com'], + locking.LEVEL_NODE: ['node1-uuid', 'node2-uuid'], } # Acquire no locks self.needed_locks = {} # No, you can't leave it to the default value None @@ -269,11 +269,14 @@ class LogicalUnit(object): def BuildHooksNodes(self): """Build list of nodes to run LU's hooks. - @rtype: tuple; (list, list) - @return: Tuple containing a list of node names on which the hook - should run before the execution and a list of node names on which the - hook should run after the execution. No nodes should be returned as an - empty list (and not None). + @rtype: tuple; (list, list) or (list, list, list) + @return: Tuple containing a list of node UUIDs on which the hook + should run before the execution and a list of node UUIDs on which the + hook should run after the execution. As it might be possible that the + node UUID is not known at the time this method is invoked, an optional + third list can be added which contains node names on which the hook + should run after the execution (in case of node add, for instance). + No nodes should be returned as an empty list (and not None). @note: If the C{HPATH} attribute of the LU class is C{None}, this function will not be called. @@ -319,8 +322,8 @@ class LogicalUnit(object): else: assert locking.LEVEL_INSTANCE not in self.needed_locks, \ "_ExpandAndLockInstance called with instance-level locks set" - self.op.instance_name = _ExpandInstanceName(self.cfg, - self.op.instance_name) + self.op.instance_name = ExpandInstanceName(self.cfg, + self.op.instance_name) self.needed_locks[locking.LEVEL_INSTANCE] = self.op.instance_name def _LockInstancesNodes(self, primary_only=False, @@ -356,17 +359,17 @@ class LogicalUnit(object): # For now we'll replace self.needed_locks[locking.LEVEL_NODE], but in the # future we might want to have different behaviors depending on the value # of self.recalculate_locks[locking.LEVEL_NODE] - wanted_nodes = [] + wanted_node_uuids = [] locked_i = self.owned_locks(locking.LEVEL_INSTANCE) for _, instance in self.cfg.GetMultiInstanceInfo(locked_i): - wanted_nodes.append(instance.primary_node) + wanted_node_uuids.append(instance.primary_node) if not primary_only: - wanted_nodes.extend(instance.secondary_nodes) + wanted_node_uuids.extend(instance.secondary_nodes) if self.recalculate_locks[level] == constants.LOCKS_REPLACE: - self.needed_locks[level] = wanted_nodes + self.needed_locks[level] = wanted_node_uuids elif self.recalculate_locks[level] == constants.LOCKS_APPEND: - self.needed_locks[level].extend(wanted_nodes) + self.needed_locks[level].extend(wanted_node_uuids) else: raise errors.ProgrammerError("Unknown recalculation mode") @@ -444,7 +447,7 @@ class Tasklet: raise NotImplementedError -class _QueryBase: +class QueryBase: """Base for query utility classes. """