Package haizea :: Package core :: Module leases :: Class Nodes
[hide private]
[frames] | no frames]

Class Nodes

source code


Represents a collection of machines ("nodes")

This class is used to load descriptions of nodes from an XML file. These nodes can appear in two places: in a site description (which, in turn, is loaded by the Site class) or in a lease's resource requirements (describing what nodes, with what resources, are required by the lease).

Nodes are stored as one or more "node sets". Each node set has nodes with the exact same resources. So, for example, a lease requiring 100 nodes (all identical, except 50 have 1024MB of memory and the other 50 have 512MB of memory) doesn't need to enumerate all 100 nodes. Instead, it just has to describe the two "node sets" (indicating that there are 50 nodes of one type and 50 of the other). See the Haizea documentation for more details on the XML format.

Like the Site class, this class is distinct from the ResourcePool class, even though they both represent a "collection of nodes". See the Site class documentation for more details.

Instance Methods [hide private]
 
__init__(self, node_sets)
Constructor.
source code
 
to_xml(self)
Returns an ElementTree XML representation of the nodes
source code
 
get_all_nodes(self)
Returns a dictionary mapping individual nodes to capacities
source code
 
add_resource(self, name, amounts)
Adds a new resource to all the nodes
source code

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

Class Methods [hide private]
 
from_xml_element(cls, nodes_element)
Constructs a node collection from an ElementTree element.
source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, node_sets)
(Constructor)

source code 

Constructor.

Arguments: node_sets -- A list of (n,c) pairs (where n is the number of nodes in the set and c is a Capacity object; all nodes in the set have capacity c).

Overrides: object.__init__

from_xml_element(cls, nodes_element)
Class Method

source code 

Constructs a node collection from an ElementTree element.

See the Haizea documentation for details on the <nodes> XML format.

Argument: element -- Element object containing a "<nodes>" element.

to_xml(self)

source code 

Returns an ElementTree XML representation of the nodes

See the Haizea documentation for details on the lease XML format.

add_resource(self, name, amounts)

source code 

Adds a new resource to all the nodes

Argument: name -- Name of the resource type amounts -- A list with the amounts of the resource to add to each node. If the resource is single-instance, then this will just be a list with a single element. If multi-instance, each element of the list represent the amount of an instance of the resource.