Project

General

Profile

Revision 798

Utilization-based LWF generation (still needs some work, but mostly done)

View differences:

leases.py
1573 1573
        Argument:
1574 1574
        lwf_file -- LWF file.
1575 1575
        """                
1576
        return cls.__from_xml_element(ET.parse(lwf_file).getroot().find("site"))        
1576
        site_elem = ET.parse(lwf_file).getroot().find("site")
1577
        if site_elem == None:
1578
            return None # LWF file does not contain a <site> element
1579
        else:
1580
            return cls.__from_xml_element(site_elem)        
1577 1581
        
1578 1582
    @classmethod
1579 1583
    def __from_xml_element(cls, element):     
......
1620 1624

  
1621 1625
        resource_str = resource_str.split()
1622 1626
        numnodes = int(resource_str[0])
1623
        resources = resource_str[1:]
1627
        resources = resource_str[1]
1624 1628
        capacity = Capacity.from_resources_string(resources)
1625 1629
        
1626 1630
        nodes = Nodes([(numnodes,capacity)])
......
1659 1663

  
1660 1664
        return max_ninstances
1661 1665
    
1666
    def to_xml(self):
1667
        """Returns an ElementTree XML representation of the nodes
1668
        
1669
        See the Haizea documentation for details on the
1670
        lease XML format.
1671
        
1672
        """   
1673
        site = ET.Element("site")
1674
        resource_types = ET.SubElement(site, "resource-types")
1675
        resource_types.set("names", " ".join(self.resource_types))
1676
        site.append(self.nodes.to_xml())
1677
            
1678
        return site    
1662 1679

  
1663 1680

  
1664 1681
class Nodes(object):

Also available in: Unified diff