On 7 February 2013 12:47, Iustin Pop <[email protected]> wrote:
> OK then, LGTM on moving it.
So, new title and message for the patch:
Moved uniformity check for exclusive_storage flag
Cluster-verify used to check that the value of exclusive_storage is uniform
within node groups. Now, it's impossible to change the flag for a single
node, so that check has been removed and an equivalent one has been added
in ConfigWriter.VerifyConfig(). Unit test provided. The unit test covers
only the new check, not the whole VerifyConfig method.
And interdiff:
diff --git a/lib/config.py b/lib/config.py
index eb37c71..5a882da 100644
--- a/lib/config.py
+++ b/lib/config.py
@@ -745,6 +745,10 @@ class ConfigWriter:
_helper("node %s" % node.name, "ndparams",
cluster.FillND(node, data.nodegroups[node.group]),
constants.NDS_PARAMETER_TYPES)
+ used_globals = constants.NDC_GLOBALS.intersection(node.ndparams)
+ if used_globals:
+ result.append("Node '%s' has some global parameters set: %s" %
+ (node.name, utils.CommaJoin(used_globals)))
# nodegroups checks
nodegroups_names = set()
diff --git a/test/py/ganeti.config_unittest.py
b/test/py/ganeti.config_unittest.py
index 112cdf2..da82fc0 100755
--- a/test/py/ganeti.config_unittest.py
+++ b/test/py/ganeti.config_unittest.py
@@ -74,6 +74,8 @@ class TestConfigRunner(unittest.TestCase):
"""Initializes the cfg object"""
me = netutils.Hostname()
ip = constants.IP4_ADDRESS_LOCALHOST
+ # master_ip must not conflict with the node ip address
+ master_ip = "127.0.0.2"
cluster_config = objects.Cluster(
serial_no=1,
@@ -87,7 +89,7 @@ class TestConfigRunner(unittest.TestCase):
tcpudp_port_pool=set(),
enabled_hypervisors=[constants.HT_FAKE],
master_node=me.name,
- master_ip="127.0.0.1",
+ master_ip=master_ip,
master_netdev=constants.DEFAULT_BRIDGE,
cluster_name="cluster.local",
file_storage_dir="/tmp",
@@ -426,6 +428,27 @@ class TestConfigRunner(unittest.TestCase):
finally:
node2.group = orig_group
+ def testVerifyConfig(self):
+ cfg = self._get_object()
+
+ errs = cfg.VerifyConfig()
+ self.assertFalse(errs)
+
+ node = cfg.GetNodeInfo(cfg.GetNodeList()[0])
+ key = list(constants.NDC_GLOBALS)[0]
+ node.ndparams[key] = constants.NDC_DEFAULTS[key]
+ errs = cfg.VerifyConfig()
+ self.assertTrue(len(errs) >= 1)
+ self.assertTrue(_IsErrorInList("has some global parameters set", errs))
+
+ del node.ndparams[key]
+ errs = cfg.VerifyConfig()
+ self.assertFalse(errs)
+
+
+def _IsErrorInList(err_str, err_list):
+ return any(map(lambda e: err_str in e, err_list))
+
class TestTRM(unittest.TestCase):
EC_ID = 1
Bernardo