From 9513b6abd82048ef71cd3316911401cacc617fe1 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Tue, 9 Sep 2008 10:41:38 +0000
Subject: [PATCH] _LockInstancesNodes: support append mode

This will be used to lock the instance's nodes in addition to some more.

Reviewed-by: iustinp
---
 lib/cmdlib.py    | 6 +++++-
 lib/constants.py | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 272f07f21..6bd14b8ec 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -298,7 +298,11 @@ class LogicalUnit(object):
       wanted_nodes.append(instance.primary_node)
       if not primary_only:
         wanted_nodes.extend(instance.secondary_nodes)
-    self.needed_locks[locking.LEVEL_NODE] = wanted_nodes
+
+    if self.recalculate_locks[locking.LEVEL_NODE] == constants.LOCKS_REPLACE:
+      self.needed_locks[locking.LEVEL_NODE] = wanted_nodes
+    elif self.recalculate_locks[locking.LEVEL_NODE] == constants.LOCKS_APPEND:
+      self.needed_locks[locking.LEVEL_NODE].extend(wanted_nodes)
 
     del self.recalculate_locks[locking.LEVEL_NODE]
 
diff --git a/lib/constants.py b/lib/constants.py
index c3863ea70..ba0e1d76e 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -190,6 +190,7 @@ REPLACE_DISK_ALL = "replace_all"
 
 # lock recalculate mode
 LOCKS_REPLACE = 'replace'
+LOCKS_APPEND = 'append'
 
 # instance creation modes
 INSTANCE_CREATE = "create"
-- 
GitLab