Remove old invalid-os related functionality
authorIustin Pop <iustin@google.com>
Thu, 11 Jun 2009 09:55:22 +0000 (11:55 +0200)
committerIustin Pop <iustin@google.com>
Mon, 15 Jun 2009 17:08:22 +0000 (19:08 +0200)
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 <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

lib/backend.py
lib/constants.py
lib/errors.py
lib/objects.py

index bf63168..8a3709a 100644 (file)
@@ -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],
index 9fb44ea..48626f2 100644 (file)
@@ -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'
index 04dc31b..1951757 100644 (file)
@@ -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.
 
index cde0779..2bae563 100644 (file)
@@ -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."""