def ExpandNames(self):
        self.needed_locks = {}

        # Use locking if requested or when non-static information is wanted
        if not (self.op.static or self.op.use_locking):
            self.LogWarning(
                "Non-static data requested, locks need to be acquired")
            self.op.use_locking = True

        if self.op.instances or not self.op.use_locking:
            # Expand instance names right here
            (_,
             self.wanted_names) = GetWantedInstances(self, self.op.instances)
        else:
            # Will use acquired locks
            self.wanted_names = None

        if self.op.use_locking:
            self.share_locks = ShareAll()

            if self.wanted_names is None:
                self.needed_locks[locking.LEVEL_INSTANCE] = locking.ALL_SET
            else:
                self.needed_locks[locking.LEVEL_INSTANCE] = self.wanted_names

            self.needed_locks[locking.LEVEL_NODEGROUP] = []
            self.needed_locks[locking.LEVEL_NODE] = []
            self.needed_locks[locking.LEVEL_NETWORK] = []
            self.recalculate_locks[
                locking.LEVEL_NODE] = constants.LOCKS_REPLACE
            self.dont_collate_locks[locking.LEVEL_NODEGROUP] = True
            self.dont_collate_locks[locking.LEVEL_NODE] = True
            self.dont_collate_locks[locking.LEVEL_NETWORK] = True
Exemplo n.º 2
0
    def ExpandNames(self):
        # This raises errors.OpPrereqError on its own:
        self.group_uuid = self.cfg.LookupNodeGroup(self.op.group_name)

        if self.op.target_groups:
            self.req_target_uuids = map(self.cfg.LookupNodeGroup,
                                        self.op.target_groups)
        else:
            self.req_target_uuids = []

        if self.group_uuid in self.req_target_uuids:
            raise errors.OpPrereqError(
                "Group to be evacuated (%s) can not be used"
                " as a target group (targets are %s)" %
                (self.group_uuid, utils.CommaJoin(self.req_target_uuids)),
                errors.ECODE_INVAL)

        self.op.iallocator = GetDefaultIAllocator(self.cfg, self.op.iallocator)

        self.share_locks = ShareAll()
        self.needed_locks = {
            locking.LEVEL_INSTANCE: [],
            locking.LEVEL_NODEGROUP: [],
            locking.LEVEL_NODE: [],
        }
Exemplo n.º 3
0
    def ExpandNames(self):
        """Calculate the locks.

    """
        self.share_locks = ShareAll()
        self.needed_locks = {}

        if self.op.iallocator:
            self.needed_locks[locking.LEVEL_NODE] = locking.ALL_SET
            self.needed_locks[locking.LEVEL_NODE_RES] = locking.ALL_SET

            if self.op.opportunistic_locking:
                self.opportunistic_locks[locking.LEVEL_NODE] = True
                self.opportunistic_locks[locking.LEVEL_NODE_RES] = True
        else:
            nodeslist = []
            for inst in self.op.instances:
                (inst.pnode_uuid, inst.pnode) = \
                  ExpandNodeUuidAndName(self.cfg, inst.pnode_uuid, inst.pnode)
                nodeslist.append(inst.pnode_uuid)
                if inst.snode is not None:
                    (inst.snode_uuid, inst.snode) = \
                      ExpandNodeUuidAndName(self.cfg, inst.snode_uuid, inst.snode)
                    nodeslist.append(inst.snode_uuid)

            self.needed_locks[locking.LEVEL_NODE] = nodeslist
            # Lock resources of instance's primary and secondary nodes (copy to
            # prevent accidential modification)
            self.needed_locks[locking.LEVEL_NODE_RES] = list(nodeslist)
Exemplo n.º 4
0
    def ExpandNames(self):
        # Raises errors.OpPrereqError on its own if group can't be found
        self.group_uuid = self.cfg.LookupNodeGroup(self.op.group_name)

        self.share_locks = ShareAll()
        self.needed_locks = {
            locking.LEVEL_INSTANCE: [],
            locking.LEVEL_NODEGROUP: [],
            locking.LEVEL_NODE: [],
        }
        self.dont_collate_locks[locking.LEVEL_NODEGROUP] = True
        self.dont_collate_locks[locking.LEVEL_NODE] = True
Exemplo n.º 5
0
    def ExpandNames(self):
        self.share_locks = ShareAll()

        self.needed_locks = {
            locking.LEVEL_NODEGROUP: [],
            locking.LEVEL_NODE: [],
        }

        self._ExpandAndLockInstance()

        if self.op.target_groups:
            self.req_target_uuids = map(self.cfg.LookupNodeGroup,
                                        self.op.target_groups)
        else:
            self.req_target_uuids = None

        self.op.iallocator = GetDefaultIAllocator(self.cfg, self.op.iallocator)
Exemplo n.º 6
0
 def ExpandNames(self):
     self.share_locks = ShareAll()
     self._ExpandAndLockInstance()
Exemplo n.º 7
0
    def ExpandNames(self):
        TagsLU.ExpandNames(self)

        # Share locks as this is only a read operation
        self.share_locks = ShareAll()