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]
 
__init__(self, **kwargs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__getattr__(self, name) source code
 
__setstate__(self, state) 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
 
UpgradeConfig(self)
Fill defaults for missing configuration values.
source code

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

Class Methods [hide private]
 
_all_slots(cls)
Compute the list of all declared slots for a class.
source code
 
FromDict(cls, val)
Create an object from a dictionary.
source code
Static Methods [hide private]
 
_ContainerToDicts(container)
Convert the elements of a container to standard python types.
source code
 
_ContainerFromDicts(source, c_type, e_type)
Convert a container from standard python types.
source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, **kwargs)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

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.

_ContainerToDicts(container)
Static Method

source code 

Convert the elements of a container to standard python types.

This method converts a container with elements derived from ConfigData to standard python types. If the container is a dict, we don't touch the keys, only the values.

_ContainerFromDicts(source, c_type, e_type)
Static Method

source code 

Convert a container from standard python types.

This method converts a container with standard python types to ConfigData objects. If the container is a dict, we don't touch the keys, only the values.

__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.