Revision 5f06ce5e lib/objects.py

b/lib/objects.py
989 989
    return cls.SplitNameVariant(name)[1]
990 990

  
991 991

  
992
class NodeHvState(ConfigObject):
993
  """Hypvervisor state on a node.
994

  
995
  @ivar mem_total: Total amount of memory
996
  @ivar mem_node: Memory used by, or reserved for, the node itself (not always
997
    available)
998
  @ivar mem_hv: Memory used by hypervisor or lost due to instance allocation
999
    rounding
1000
  @ivar mem_inst: Memory used by instances living on node
1001
  @ivar cpu_total: Total node CPU core count
1002
  @ivar cpu_node: Number of CPU cores reserved for the node itself
1003

  
1004
  """
1005
  __slots__ = [
1006
    "mem_total",
1007
    "mem_node",
1008
    "mem_hv",
1009
    "mem_inst",
1010
    "cpu_total",
1011
    "cpu_node",
1012
    ] + _TIMESTAMPS
1013

  
1014

  
1015
class NodeDiskState(ConfigObject):
1016
  """Disk state on a node.
1017

  
1018
  """
1019
  __slots__ = [
1020
    "total",
1021
    "reserved",
1022
    "overhead",
1023
    ] + _TIMESTAMPS
1024

  
1025

  
992 1026
class Node(TaggableObject):
993 1027
  """Config object representing a node.
994 1028

  
......
1035 1069
    if self.powered is None:
1036 1070
      self.powered = True
1037 1071

  
1072
  def ToDict(self):
1073
    """Custom function for serializing.
1074

  
1075
    """
1076
    data = super(Node, self).ToDict()
1077

  
1078
    hv_state = data.get("hv_state", None)
1079
    if hv_state is not None:
1080
      data["hv_state"] = self._ContainerToDicts(hv_state)
1081

  
1082
    disk_state = data.get("disk_state", None)
1083
    if disk_state is not None:
1084
      data["disk_state"] = \
1085
        dict((key, self._ContainerToDicts(value))
1086
             for (key, value) in disk_state.items())
1087

  
1088
    return data
1089

  
1090
  @classmethod
1091
  def FromDict(cls, val):
1092
    """Custom function for deserializing.
1093

  
1094
    """
1095
    obj = super(Node, cls).FromDict(val)
1096

  
1097
    if obj.hv_state is not None:
1098
      obj.hv_state = cls._ContainerFromDicts(obj.hv_state, dict, NodeHvState)
1099

  
1100
    if obj.disk_state is not None:
1101
      obj.disk_state = \
1102
        dict((key, cls._ContainerFromDicts(value, dict, NodeDiskState))
1103
             for (key, value) in obj.disk_state.items())
1104

  
1105
    return obj
1106

  
1038 1107

  
1039 1108
class NodeGroup(TaggableObject):
1040 1109
  """Config object representing a node group."""

Also available in: Unified diff