2 # Registry is a SfaServer that implements the Registry interface
8 from sfa.util.server import SfaServer
9 from sfa.util.faults import *
10 from sfa.server.interface import Interfaces
11 import sfa.util.xmlrpcprotocol as xmlrpcprotocol
12 import sfa.util.soapprotocol as soapprotocol
16 # Registry is a SfaServer that serves registry and slice operations at PLC.
17 class Registry(SfaServer):
19 # Create a new registry object.
21 # @param ip the ip address to listen on
22 # @param port the port to listen on
23 # @param key_file private key filename of registry
24 # @param cert_file certificate filename containing public key (could be a GID file)
26 def __init__(self, ip, port, key_file, cert_file):
27 SfaServer.__init__(self, ip, port, key_file, cert_file)
28 self.server.interface = 'registry'
32 # Registries is a dictionary of registry connections keyed on the registry
35 class Registries(Interfaces):
37 default_dict = {'registries': {'registry': [Interfaces.default_fields]}}
39 def __init__(self, api, conf_file = "/etc/sfa/registries.xml"):
40 Interfaces.__init__(self, api, conf_file, 'sa')
42 def get_connections(self, interfaces):
44 read connection details for the trusted peer registries from file return
45 a dictionary of connections keyed on interface hrn.
47 connections = Interfaces.get_connections(self, interfaces)
49 # set up a connection to the local registry
50 address = self.api.config.SFA_REGISTRY_HOST
51 port = self.api.config.SFA_REGISTRY_PORT
52 url = 'http://%(address)s:%(port)s' % locals()
53 local_registry = {'hrn': self.api.hrn, 'addr': address, 'port': port}
54 self.interfaces[self.api.hrn] = local_registry
55 connections[self.api.hrn] = xmlrpcprotocol.get_server(url, self.api.key_file, self.api.cert_file)