def ExpandNames(self): """Expand names and set required locks. This expands the node list, if any. """ self.needed_locks = {} if self.op.duration <= 0: raise errors.OpPrereqError("Duration must be greater than zero") if not self.op.no_locks and (self.op.on_nodes or self.op.on_master): self.needed_locks[locking.LEVEL_NODE] = [] self.op.on_node_uuids = [] if self.op.on_nodes: # _GetWantedNodes can be used here, but is not always appropriate to use # this way in ExpandNames. Check LogicalUnit.ExpandNames docstring for # more information. (self.op.on_node_uuids, self.op.on_nodes) = \ GetWantedNodes(self, self.op.on_nodes) master_uuid = self.cfg.GetMasterNode() if self.op.on_master and master_uuid not in self.op.on_node_uuids: self.op.on_node_uuids.append(master_uuid) self.needed_locks = {} self.needed_locks[locking.LEVEL_NODE] = self.op.on_node_uuids
def ExpandNames(self): if self.op.nodes: (self.op.node_uuids, self.op.nodes) = GetWantedNodes(self, self.op.nodes) self.needed_locks = { locking.LEVEL_NODE: self.op.node_uuids, } self.share_locks = { locking.LEVEL_NODE: not self.op.use_locking, }
def ExpandNames(self): # These raise errors.OpPrereqError on their own: self.group_uuid = self.cfg.LookupNodeGroup(self.op.group_name) (self.op.node_uuids, self.op.nodes) = GetWantedNodes(self, self.op.nodes) # We want to lock all the affected nodes and groups. We have readily # available the list of nodes, and the *destination* group. To gather the # list of "source" groups, we need to fetch node information later on. self.needed_locks = { locking.LEVEL_NODEGROUP: set([self.group_uuid]), locking.LEVEL_NODE: self.op.node_uuids, }
def ExpandNames(self): """Gather locks we need. """ if self.op.node_names: (self.op.node_uuids, self.op.node_names) = \ GetWantedNodes(self, self.op.node_names) lock_node_uuids = self.op.node_uuids else: lock_node_uuids = locking.ALL_SET self.needed_locks = { locking.LEVEL_NODE: lock_node_uuids, }
def ExpandNames(self): """Gather locks we need. """ if self.op.node_names: (self.op.node_uuids, self.op.node_names) = \ GetWantedNodes(self, self.op.node_names) lock_node_uuids = self.op.node_uuids else: lock_node_uuids = locking.ALL_SET self.needed_locks = { locking.LEVEL_NODE: lock_node_uuids, } self.share_locks[locking.LEVEL_NODE_ALLOC] = 1 if not self.op.node_names: # Acquire node allocation lock only if all nodes are affected self.needed_locks[locking.LEVEL_NODE_ALLOC] = locking.ALL_SET
def ExpandNames(self): """Expand names and set required locks. This expands the node list, if any. """ self.needed_locks = {} if self.op.on_nodes or self.op.on_master: self.needed_locks[locking.LEVEL_NODE] = [] if self.op.on_nodes: # _GetWantedNodes can be used here, but is not always appropriate to use # this way in ExpandNames. Check LogicalUnit.ExpandNames docstring for # more information. (self.op.on_node_uuids, self.op.on_nodes) = \ GetWantedNodes(self, self.op.on_nodes) self.needed_locks[locking.LEVEL_NODE].extend(self.op.on_node_uuids) if self.op.on_master: # The node lock should be acquired for the master as well. self.needed_locks[locking.LEVEL_NODE].append(self.cfg.GetMasterNode())