From f9116d580b0126fb2eaf57d787e3f28825ea1cc9 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Wed, 27 Oct 2010 14:14:47 +0100
Subject: [PATCH] GanetiLockManager, remove default values

The nodes and instances parameters to the constructor are mandatory
anyway, as a value of None will fail when creating the LockSet. Rather
than fixing this adding code lines, since we never used the default
value, let's remove them and require that the parameters are passed.

This also fixes the only places where we inited GanetiLockManager with
keyed parameters and without arguments.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 lib/locking.py                  | 2 +-
 test/ganeti.locking_unittest.py | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/lib/locking.py b/lib/locking.py
index d89388cdd..934638f46 100644
--- a/lib/locking.py
+++ b/lib/locking.py
@@ -1367,7 +1367,7 @@ class GanetiLockManager:
   """
   _instance = None
 
-  def __init__(self, nodes=None, instances=None):
+  def __init__(self, nodes, instances):
     """Constructs a new GanetiLockManager object.
 
     There should be only a GanetiLockManager object at any time, so this
diff --git a/test/ganeti.locking_unittest.py b/test/ganeti.locking_unittest.py
index 9c85886be..b6416aab6 100755
--- a/test/ganeti.locking_unittest.py
+++ b/test/ganeti.locking_unittest.py
@@ -1419,8 +1419,7 @@ class TestGanetiLockManager(_ThreadedTestCase):
     _ThreadedTestCase.setUp(self)
     self.nodes=['n1', 'n2']
     self.instances=['i1', 'i2', 'i3']
-    self.GL = locking.GanetiLockManager(nodes=self.nodes,
-                                        instances=self.instances)
+    self.GL = locking.GanetiLockManager(self.nodes, self.instances)
 
   def tearDown(self):
     # Don't try this at home...
@@ -1435,7 +1434,7 @@ class TestGanetiLockManager(_ThreadedTestCase):
       self.assertEqual(i, locking.LEVELS[i])
 
   def testDoubleGLFails(self):
-    self.assertRaises(AssertionError, locking.GanetiLockManager)
+    self.assertRaises(AssertionError, locking.GanetiLockManager, [], [])
 
   def testLockNames(self):
     self.assertEqual(self.GL._names(locking.LEVEL_CLUSTER), set(['BGL']))
-- 
GitLab