From 8e70b1818762446b445c18aacfd759d306d5f494 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Thu, 11 Jun 2009 11:55:22 +0200 Subject: [PATCH] Remove old invalid-os related functionality We no longer need OS objects to be able to represent invalid OSes. This cleans up the code handling those cases. Signed-off-by: Iustin Pop Reviewed-by: Guido Trotter --- lib/backend.py | 13 +++++-------- lib/constants.py | 1 - lib/errors.py | 14 -------------- lib/objects.py | 20 -------------------- 4 files changed, 5 insertions(+), 43 deletions(-) diff --git a/lib/backend.py b/lib/backend.py index bf63168..8a3709a 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -1511,11 +1511,9 @@ def _OSOndiskVersion(name, os_dir): @param name: the OS name we should look for @type os_dir: str @param os_dir: the directory inwhich we should look for the OS - @rtype: int or None - @return: - Either an integer denoting the version or None in the - case when this is not a valid OS name. - @raise errors.InvalidOS: if the OS cannot be found + @rtype: tuple + @return: tuple (status, data) with status denoting the validity and + data holding either the vaid versions or an error message """ api_file = os.path.sep.join([os_dir, "ganeti_api_version"]) @@ -1593,8 +1591,7 @@ def _TryOSFromDisk(name, base_dir=None): """Create an OS instance from disk. This function will return an OS instance if the given name is a - valid OS name. Otherwise, it will raise an appropriate - L{errors.InvalidOS} exception, detailing why this is not a valid OS. + valid OS name. @type base_dir: string @keyword base_dir: Base directory containing OS installations. @@ -1640,7 +1637,7 @@ def _TryOSFromDisk(name, base_dir=None): return False, ("Script '%s' under path '%s' is not a regular file" % (script, os_dir)) - os_obj = objects.OS(name=name, path=os_dir, status=constants.OS_VALID_STATUS, + os_obj = objects.OS(name=name, path=os_dir, create_script=os_scripts[constants.OS_SCRIPT_CREATE], export_script=os_scripts[constants.OS_SCRIPT_EXPORT], import_script=os_scripts[constants.OS_SCRIPT_IMPORT], diff --git a/lib/constants.py b/lib/constants.py index 9fb44ea..48626f2 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -251,7 +251,6 @@ DEFAULT_MAC_PREFIX = "aa:00:00" RPC_ENCODING_ZLIB_BASE64) = range(2) # os related constants -OS_VALID_STATUS = "VALID" OS_SCRIPT_CREATE = 'create' OS_SCRIPT_IMPORT = 'import' OS_SCRIPT_EXPORT = 'export' diff --git a/lib/errors.py b/lib/errors.py index 04dc31b..1951757 100644 --- a/lib/errors.py +++ b/lib/errors.py @@ -98,20 +98,6 @@ class RemoteError(GenericError): pass -class InvalidOS(GenericError): - """Missing OS on node. - - This is raised when an OS exists on the master (or is otherwise - requested to the code) but not on the target node. - - This exception has three arguments: - - the name of the os - - the source directory, if any - - the reason why we consider this an invalid OS (text of error message) - - """ - - class ParameterError(GenericError): """A passed parameter to a command is invalid. diff --git a/lib/objects.py b/lib/objects.py index cde0779..2bae563 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -738,7 +738,6 @@ class OS(ConfigObject): __slots__ = [ "name", "path", - "status", "api_versions", "create_script", "export_script", @@ -746,25 +745,6 @@ class OS(ConfigObject): "rename_script", ] - @classmethod - def FromInvalidOS(cls, err): - """Create an OS from an InvalidOS error. - - This routine knows how to convert an InvalidOS error to an OS - object representing the broken OS with a meaningful error message. - - """ - if not isinstance(err, errors.InvalidOS): - raise errors.ProgrammerError("Trying to initialize an OS from an" - " invalid object of type %s" % type(err)) - - return cls(name=err.args[0], path=err.args[1], status=err.args[2]) - - def __nonzero__(self): - return self.status == constants.OS_VALID_STATUS - - __bool__ = __nonzero__ - class Node(TaggableObject): """Config object representing a node.""" -- 1.7.10.4