X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fserver%2Finterface.py;h=65b8d83564ddc4f4bc462c75f0e9e00f8eaa03d2;hb=952322d76247f8991f3c2688ed7e1f5a22ca4572;hp=8e5822e9d619ee9f51ae2a341c38e06ff7a6123d;hpb=d61fbd1be2c1012050a4e2f56206a03e2e389332;p=sfa.git diff --git a/sfa/server/interface.py b/sfa/server/interface.py index 8e5822e9..65b8d835 100644 --- a/sfa/server/interface.py +++ b/sfa/server/interface.py @@ -13,7 +13,7 @@ import traceback import sfa.util.xmlrpcprotocol as xmlrpcprotocol import sfa.util.soapprotocol as soapprotocol - + # GeniLight client support is optional try: from egeni.geniLight_client import * @@ -46,10 +46,9 @@ class Interfaces(dict): # defined by the class default_dict = {} - # allowed types - types = ['sa', 'ma'] + types = ['authority'] - def __init__(self, api, conf_file, type): + def __init__(self, api, conf_file, type='authority'): if type not in self.types: raise SfaInfaildArgument('Invalid type %s: must be in %s' % (type, self.types)) dict.__init__(self, {}) @@ -62,11 +61,18 @@ class Interfaces(dict): if not isinstance(interfaces, list): interfaces = [self.interfaces] self.interfaces = {} + required_fields = self.default_fields.keys() for interface in interfaces: - self.interfaces[interface['hrn']] = interface + valid = True + # skp any interface definition that has a null hrn, + # address or port + for field in required_fields: + if field not in interface or not interface[field]: + valid = False + break + if valid: + self.interfaces[interface['hrn']] = interface - # get connections - self.update(self.get_connections(self.interfaces)) def sync_interfaces(self): """ @@ -94,13 +100,15 @@ class Interfaces(dict): return peer_gids trusted_certs_dir = self.api.config.get_trustedroots_dir() for new_hrn in new_hrns: + if not new_hrn: + continue # the gid for this interface should already be installed if new_hrn == self.api.config.SFA_INTERFACE_HRN: continue try: # get gid from the registry interface_info = self.interfaces[new_hrn] - interface = self.get_connections(self.interfaces[new_hrn])[new_hrn] + interface = self[new_hrn] trusted_gids = interface.get_trusted_certs() if trusted_gids: # the gid we want shoudl be the first one in the list, @@ -167,22 +175,21 @@ class Interfaces(dict): record = SfaRecord(dict=record) table.insert(record) - def get_connections(self, interfaces): + def get_connections(self): """ read connection details for the trusted peer registries from file return a dictionary of connections keyed on interface hrn. """ connections = {} required_fields = self.default_fields.keys() - if not isinstance(interfaces, list): - interfaces = [interfaces] - for interface in interfaces: + for interface in self.interfaces.values(): # make sure the required fields are present and not null if not all([interface.get(key) for key in required_fields]): continue - + hrn, address, port = interface['hrn'], interface['addr'], interface['port'] url = 'http://%(address)s:%(port)s' % locals() + # check which client we should use # sfa.util.xmlrpcprotocol is default client_type = 'xmlrpcprotocol'