import sfa.util.xmlrpcprotocol as xmlrpcprotocol
import sfa.util.soapprotocol as soapprotocol
-
+
# GeniLight client support is optional
try:
from egeni.geniLight_client import *
# 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, {})
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):
"""
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,
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'