예제 #1
0
파일: interface.py 프로젝트: planetlab/sfa
class Interfaces(dict):
    """
    Interfaces is a base class for managing information on the
    peers we are federated with. Provides connections (xmlrpc or soap) to federated peers
    """

    # fields that must be specified in the config file
    default_fields = {
        'hrn': '',
        'addr': '', 
        'port': '', 
    }

    # defined by the class 
    default_dict = {}

    def __init__(self, conf_file):
        dict.__init__(self, {})
        # load config file
        self.interface_info = XmlStorage(conf_file, self.default_dict)
        self.interface_info.load()
        records = self.interface_info.values()[0].values()[0]
        if not isinstance(records, list):
            records = [records]
        
        required_fields = self.default_fields.keys()
        for record in records:
            if not set(required_fields).issubset(record.keys()):
                continue
            # port is appended onto the domain, before the path. Should look like:
            # http://domain:port/path
            hrn, address, port = record['hrn'], record['addr'], record['port']
            interface = Interface(hrn, address, port) 
            self[hrn] = interface

    def get_server(self, hrn, key_file, cert_file, timeout=30):
        return self[hrn].get_server(key_file, cert_file, timeout)
예제 #2
0
파일: interface.py 프로젝트: planetlab/sfa
 def __init__(self, conf_file):
     dict.__init__(self, {})
     # load config file
     self.interface_info = XmlStorage(conf_file, self.default_dict)
     self.interface_info.load()
     records = self.interface_info.values()[0].values()[0]
     if not isinstance(records, list):
         records = [records]
     
     required_fields = self.default_fields.keys()
     for record in records:
         if not set(required_fields).issubset(record.keys()):
             continue
         # port is appended onto the domain, before the path. Should look like:
         # http://domain:port/path
         hrn, address, port = record['hrn'], record['addr'], record['port']
         interface = Interface(hrn, address, port) 
         self[hrn] = interface