There was a bug which made 'gnt-cluster renew-crypto'
crash if it is a one-node cluster. This patch fixes
it by checking if there are any non-master nodes
to update at all.

Signed-off-by: Helga Velroyen <[email protected]>
Reviewed-by: Klaus Aehlig <[email protected]>
---
 lib/backend.py                     | 6 ------
 test/py/ganeti.backend_unittest.py | 6 ++----
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/lib/backend.py b/lib/backend.py
index 520a6e7..a5da270 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -1502,12 +1502,6 @@ def AddNodeSshKeyBulk(node_list,
                             node_list])
   to_public_keys = any([node_info.to_public_keys for node_info in
                         node_list])
-  get_public_keys = any([node_info.get_public_keys for node_info in
-                         node_list])
-
-  # assure that at least one of those flags is true, as the function would
-  # not do anything otherwise
-  assert (to_authorized_keys or to_public_keys or get_public_keys)
 
   if not ssconf_store:
     ssconf_store = ssconf.SimpleStore()
diff --git a/test/py/ganeti.backend_unittest.py 
b/test/py/ganeti.backend_unittest.py
index 6a70592..acb06bf 100755
--- a/test/py/ganeti.backend_unittest.py
+++ b/test/py/ganeti.backend_unittest.py
@@ -1238,8 +1238,7 @@ class 
TestAddRemoveGenerateNodeSshKey(testutils.GanetiTestCase):
         is_potential_master_candidate, is_master_candidate,
         is_master)
 
-    self.assertRaises(
-        AssertionError, backend.AddNodeSshKey, new_node_uuid, new_node_name,
+    backend.AddNodeSshKey(new_node_uuid, new_node_name,
         self._potential_master_candidates,
         to_authorized_keys=is_master_candidate,
         to_public_keys=is_potential_master_candidate,
@@ -1257,8 +1256,7 @@ class 
TestAddRemoveGenerateNodeSshKey(testutils.GanetiTestCase):
     (node_list, key_map) = self._SetupNodeBulk(
         num_nodes, self._GetNewNumberedNormalNode)
 
-    self.assertRaises(
-        AssertionError, backend.AddNodeSshKeyBulk, node_list,
+    backend.AddNodeSshKeyBulk(node_list,
         self._potential_master_candidates,
         pub_key_file=self._pub_key_file,
         ssconf_store=self._ssconf_mock,
-- 
2.6.0.rc2.230.g3dd15c0

Reply via email to