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

Class Site

source code


Represents a site containing machines ("nodes").

This class is used to load site descriptions in XML format or using a "resources string". Site descriptions can appear in two places: in a LWF file (where the site required for the lease workload is embedded in the LWF file) or in the Haizea configuration file. In both cases, the site description is only used in simulation (in OpenNebula mode, the available nodes and resources are obtained by querying OpenNebula).

Note that this class is distinct from the ResourcePool class, even though both are used to represent "collections of nodes". The Site class is used purely as a convenient way to load site information from an XML file and to manipulate that information elsewhere in Haizea, while the ResourcePool class is responsible for sending enactment commands to nodes, monitoring nodes, etc.

Instance Methods [hide private]
 
__init__(self, nodes, resource_types, attr_types)
Constructor.
source code
 
add_resource(self, name, amounts)
Adds a new resource to all nodes in the site.
source code
 
get_resource_types(self)
Returns the resource types in this site.
source code

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

Class Methods [hide private]
 
from_xml_file(cls, xml_file)
Constructs a site from an XML file.
source code
 
from_lwf_file(cls, lwf_file)
Constructs a site from an LWF file.
source code
 
__from_xml_element(cls, element)
Constructs a site from an ElementTree element.
source code
 
from_resources_string(cls, resource_str)
Constructs a site from a "resources string"
source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, nodes, resource_types, attr_types)
(Constructor)

source code 

Constructor.

Arguments: nodes -- A Nodes object resource_types -- A list of valid resource types in this site. attr_types -- A list of valid attribute types in this site

Overrides: object.__init__

from_xml_file(cls, xml_file)
Class Method

source code 

Constructs a site from an XML file.

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

Argument: xml_file -- XML file containing the site in XML format.

from_lwf_file(cls, lwf_file)
Class Method

source code 

Constructs a site from an LWF file.

LWF files can have site information embedded in them. This method loads this site information from an LWF file. See the Haizea documentation for details on the LWF format.

Argument: lwf_file -- LWF file.

__from_xml_element(cls, element)
Class Method

source code 

Constructs a site from an ElementTree element.

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

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

from_resources_string(cls, resource_str)
Class Method

source code 

Constructs a site from a "resources string"

A "resources string" is a shorthand way of specifying a site with homogeneous resources and no attributes. The format is:

<numnodes> <resource_type>:<resource_quantity>[,<resource_type>:<resource_quantity>]*

For example: 4 CPU:100,Memory:1024

Argument: resource_str -- resources string

add_resource(self, name, amounts)

source code 

Adds a new resource to all nodes in the site.

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.

get_resource_types(self)

source code 
Returns the resource types in this site.

This method returns a list, each item being a pair with
1. the name of the resource type and 2. the maximum number of
instances for that resource type across all nodes.