fe845a36d1275ed23baf75c4a8d1567b49e1d552
[sfa.git] / sfa / server / registry.py
1 #
2 # Registry is a SfaServer that implements the Registry interface
3 #
4 ### $Id$
5 ### $URL$
6 #
7
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
13  
14
15 ##
16 # Registry is a SfaServer that serves registry and slice operations at PLC.
17 class Registry(SfaServer):
18     ##
19     # Create a new registry object.
20     #
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)
25     
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' 
29
30
31 ##
32 # Registries is a dictionary of registry connections keyed on the registry
33 # hrn
34
35 class Registries(Interfaces):
36     
37     default_dict = {'registries': {'registry': [default_fields]}}
38
39     def __init__(self, api, conf_file = "/etc/sfa/registries.xml"):
40         Interfaces.__init__(self, conf_file, 'sa') 
41
42     def get_connections(self, interfaces):
43         """
44         read connection details for the trusted peer registries from file return 
45         a dictionary of connections keyed on interface hrn. 
46         """
47         connections = Interfaces.get_connections(self, interfaces)
48
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         connections[self.api.hrn] = xmlrpcprotocol.get_server(url, self.api.key_file, self.api.cert_file)            
55         return connections