X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fserver%2Finterface.py;h=2f4614618d9810918321438302b483f01a8f2067;hb=935de64c2ed3a68566da471c68447a1ac384455d;hp=d2b96b7f753346d294b041ce0ae4e10b1956a0ef;hpb=57b6a99255d4a88be9c0f910f8524677e34ff4bc;p=sfa.git diff --git a/sfa/server/interface.py b/sfa/server/interface.py index d2b96b7f..2f461461 100644 --- a/sfa/server/interface.py +++ b/sfa/server/interface.py @@ -1,6 +1,5 @@ -#from sfa.util.faults import * -from sfa.util.storage import XmlStorage -import sfa.util.xmlrpcprotocol as xmlrpcprotocol +from sfa.client.sfaserverproxy import SfaServerProxy +from sfa.util.xml import XML # GeniLight client support is optional try: @@ -25,13 +24,13 @@ class Interface: url = "http://%s" % "/".join(address_parts) return url - def get_server(self, key_file, cert_file, timeout=30): + def server_proxy(self, key_file, cert_file, timeout=30): server = None if self.client_type == 'geniclientlight' and GeniClientLight: # xxx url and self.api are undefined server = GeniClientLight(url, self.api.key_file, self.api.cert_file) else: - server = xmlrpcprotocol.get_server(self.get_url(), key_file, cert_file, timeout) + server = SfaServerProxy(self.get_url(), key_file, cert_file, timeout) return server ## @@ -57,21 +56,20 @@ class Interfaces(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] - if not isinstance(records, list): - records = [records] - - required_fields = self.default_fields.keys() - for record in records: - if not record or 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 + required_fields = set(self.default_fields.keys()) + self.interface_info = XML(conf_file).todict() + for value in self.interface_info.values(): + if isinstance(value, list): + for record in value: + if isinstance(record, dict) and \ + required_fields.issubset(record.keys()): + hrn, address, port = record['hrn'], record['addr'], record['port'] + # sometime this is called at a very early stage with no config loaded + # avoid to remember this instance in such a case + if not address or not port: + continue + 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) + def server_proxy(self, hrn, key_file, cert_file, timeout=30): + return self[hrn].server_proxy(key_file, cert_file, timeout)