From 332d0e37e0e1e9d391736c457a39f80a38b778fe Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 27 Jan 2009 15:41:38 +0000 Subject: [PATCH] Implement disk verify checks in config verify This patch adds a simple check that the 'mode' attribute of top-level disks is correct. It does not recurse over children. The framework could be extended with other checks in the future. Reviewed-by: imsnah --- lib/config.py | 5 +++++ lib/objects.py | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/config.py b/lib/config.py index 1d792d1c5..9256bb958 100644 --- a/lib/config.py +++ b/lib/config.py @@ -269,6 +269,11 @@ class ConfigWriter: ports[net_port] = [] ports[net_port].append((instance.name, "network port")) + # instance disk verify + for idx, disk in enumerate(instance.disks): + result.extend(["instance '%s' disk %d error: %s" % + (instance.name, idx, msg) for msg in disk.Verify()]) + # cluster-wide pool of free ports for free_port in data.cluster.tcpudp_port_pool: if free_port not in ports: diff --git a/lib/objects.py b/lib/objects.py index 89473fec7..0feefbedf 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -497,6 +497,15 @@ class Disk(ConfigObject): val += ", size=%dm)>" % self.size return val + def Verify(self): + """Checks that this disk is correctly configured. + + """ + errors = [] + if self.mode not in constants.DISK_ACCESS_SET: + errors.append("Disk access mode '%s' is invalid" % (self.mode, )) + return errors + class Instance(TaggableObject): """Config object representing an instance.""" -- GitLab