Commit 332d0e37 authored by Iustin Pop's avatar Iustin Pop
Browse files

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
parent 6ec66eae
......@@ -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:
......
......@@ -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."""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment