Package ganeti :: Module objects :: Class ConfigObject
[hide private]
[frames] | no frames]

Class ConfigObject

source code


A generic config object.

It has the following properties:

Classes derived from this must always declare __slots__ (we use many config objects and the memory reduction is useful)

Instance Methods [hide private]
 
__getattr__(self, name) source code
 
__setstate__(self, state) source code
NoneType
Validate(self)
Validates the slots.
source code
 
ToDict(self)
Convert to a dict holding only standard python types.
source code
 
__getstate__(self)
Convert to a dict holding only standard python types.
source code
 
Copy(self)
Makes a deep copy of the current object and its children.
source code
 
__repr__(self)
Implement __repr__ for ConfigObjects.
source code
 
__eq__(self, other)
Implement __eq__ for ConfigObjects.
source code
 
UpgradeConfig(self)
Fill defaults for missing configuration values.
source code

Inherited from outils.ValidatedSlots: __init__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
FromDict(cls, val)
Create an object from a dictionary.
source code

Inherited from outils.ValidatedSlots: GetAllSlots

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

Validate(self)

source code 

Validates the slots.

This method returns None if the validation succeeds, or raises an exception otherwise.

This method must be implemented by the child classes.

Returns: NoneType
None, if the validation succeeds
Raises:
  • Exception - validation fails
Overrides: outils.ValidatedSlots.Validate

ToDict(self)

source code 

Convert to a dict holding only standard python types.

The generic routine just dumps all of this object's attributes in a dict. It does not work if the class has children who are ConfigObjects themselves (e.g. the nics list in an Instance), in which case the object should subclass the function in order to make sure all objects returned are only standard python types.

__getstate__(self)

source code 

Convert to a dict holding only standard python types.

The generic routine just dumps all of this object's attributes in a dict. It does not work if the class has children who are ConfigObjects themselves (e.g. the nics list in an Instance), in which case the object should subclass the function in order to make sure all objects returned are only standard python types.

FromDict(cls, val)
Class Method

source code 

Create an object from a dictionary.

This generic routine takes a dict, instantiates a new instance of the given class, and sets attributes based on the dict content.

As for `ToDict`, this does not work if the class has children who are ConfigObjects themselves (e.g. the nics list in an Instance), in which case the object should subclass the function and alter the objects.

__repr__(self)
(Representation operator)

source code 

Implement __repr__ for ConfigObjects.

Overrides: object.__repr__

UpgradeConfig(self)

source code 

Fill defaults for missing configuration values.

This method will be called at configuration load time, and its implementation will be object dependent.