Commit 8e70b181 authored by Iustin Pop's avatar Iustin Pop
Browse files

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: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 255dcebd
......@@ -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],
......
......@@ -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'
......
......@@ -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.
......
......@@ -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."""
......
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