Revision 8e70b181 lib/objects.py

b/lib/objects.py
738 738
  __slots__ = [
739 739
    "name",
740 740
    "path",
741
    "status",
742 741
    "api_versions",
743 742
    "create_script",
744 743
    "export_script",
......
746 745
    "rename_script",
747 746
    ]
748 747

  
749
  @classmethod
750
  def FromInvalidOS(cls, err):
751
    """Create an OS from an InvalidOS error.
752

  
753
    This routine knows how to convert an InvalidOS error to an OS
754
    object representing the broken OS with a meaningful error message.
755

  
756
    """
757
    if not isinstance(err, errors.InvalidOS):
758
      raise errors.ProgrammerError("Trying to initialize an OS from an"
759
                                   " invalid object of type %s" % type(err))
760

  
761
    return cls(name=err.args[0], path=err.args[1], status=err.args[2])
762

  
763
  def __nonzero__(self):
764
    return self.status == constants.OS_VALID_STATUS
765

  
766
  __bool__ = __nonzero__
767

  
768 748

  
769 749
class Node(TaggableObject):
770 750
  """Config object representing a node."""

Also available in: Unified diff