From 37482e7b1089fe17a6d86d078b62467f72a7cac3 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Mon, 5 Nov 2007 00:42:03 +0000 Subject: [PATCH] Make the OS object able to represent broken OSes Till now the OS object just represents a correct OS instance. Change it so it can represent a broken one too, by adding a "status" field: if this field is different from the OS_VALID_STATUS constant the object is considered to be an invalid OS, the "status" field to be a debugging message, and its boolean status is set to false. Reviewed-By: iustinp --- lib/constants.py | 3 +++ lib/objects.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/lib/constants.py b/lib/constants.py index 8ade4b680..8cb675fd0 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -130,6 +130,9 @@ LOCALHOST_IP_ADDRESS = "127.0.0.1" TCP_PING_TIMEOUT = 10 GANETI_RUNAS = "root" +# valid os status +OS_VALID_STATUS = "VALID" + # ssh constants SSH_INITD_SCRIPT = _autoconf.SSH_INITD_SCRIPT SSH_CONFIG_DIR = "/etc/ssh/" diff --git a/lib/objects.py b/lib/objects.py index 803b893dd..2f27a270e 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -589,6 +589,7 @@ class OS(ConfigObject): __slots__ = [ "name", "path", + "status", "api_version", "create_script", "export_script", @@ -596,6 +597,10 @@ class OS(ConfigObject): "rename_script", ] + def __nonzero__(self): + return self.status == constants.OS_VALID_STATUS + + __bool__ = __nonzero__ class Node(TaggableObject): """Config object representing a node.""" -- GitLab