From 4e070776e64d8f326f87f8a8e30b3baafb2733fb Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Wed, 2 Nov 2011 13:15:38 +0100 Subject: [PATCH] Add new lock level for node resource modifications This is in preparation for implementing a new resource model. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/locking.py | 21 ++++++++++++++++----- lib/server/masterd.py | 2 ++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/locking.py b/lib/locking.py index 26345632e..03441408a 100644 --- a/lib/locking.py +++ b/lib/locking.py @@ -1389,20 +1389,30 @@ LEVEL_CLUSTER = 0 LEVEL_INSTANCE = 1 LEVEL_NODEGROUP = 2 LEVEL_NODE = 3 +LEVEL_NODE_RES = 4 -LEVELS = [LEVEL_CLUSTER, - LEVEL_INSTANCE, - LEVEL_NODEGROUP, - LEVEL_NODE] +LEVELS = [ + LEVEL_CLUSTER, + LEVEL_INSTANCE, + LEVEL_NODEGROUP, + LEVEL_NODE, + LEVEL_NODE_RES, + ] # Lock levels which are modifiable -LEVELS_MOD = [LEVEL_NODE, LEVEL_NODEGROUP, LEVEL_INSTANCE] +LEVELS_MOD = frozenset([ + LEVEL_NODE_RES, + LEVEL_NODE, + LEVEL_NODEGROUP, + LEVEL_INSTANCE, + ]) LEVEL_NAMES = { LEVEL_CLUSTER: "cluster", LEVEL_INSTANCE: "instance", LEVEL_NODEGROUP: "nodegroup", LEVEL_NODE: "node", + LEVEL_NODE_RES: "nodes-res", } # Constant for the big ganeti lock @@ -1443,6 +1453,7 @@ class GanetiLockManager: self.__keyring = { LEVEL_CLUSTER: LockSet([BGL], "BGL", monitor=self._monitor), LEVEL_NODE: LockSet(nodes, "nodes", monitor=self._monitor), + LEVEL_NODE_RES: LockSet(nodes, "nodes-res", monitor=self._monitor), LEVEL_NODEGROUP: LockSet(nodegroups, "nodegroups", monitor=self._monitor), LEVEL_INSTANCE: LockSet(instances, "instances", monitor=self._monitor), diff --git a/lib/server/masterd.py b/lib/server/masterd.py index cc86d8a13..198a89919 100644 --- a/lib/server/masterd.py +++ b/lib/server/masterd.py @@ -429,6 +429,7 @@ class GanetiContext(object): # Add the new node to the Ganeti Lock Manager self.glm.add(locking.LEVEL_NODE, node.name) + self.glm.add(locking.LEVEL_NODE_RES, node.name) def ReaddNode(self, node): """Updates a node that's already in the configuration @@ -449,6 +450,7 @@ class GanetiContext(object): # Remove the node from the Ganeti Lock Manager self.glm.remove(locking.LEVEL_NODE, name) + self.glm.remove(locking.LEVEL_NODE_RES, name) def _SetWatcherPause(until): -- GitLab