sfa-0.9-17 tag
[sfa.git] / sfa / server / registry.py
1 #
2 # Registry is a SfaServer that implements the Registry interface
3 #
4 ### $Id: registry.py 18632 2010-08-16 21:44:19Z tmack $
5 ### $URL: http://svn.planet-lab.org/svn/sfa/trunk/sfa/server/registry.py $
6 #
7
8 from sfa.util.server import SfaServer
9 from sfa.util.faults import *
10 from sfa.util.namespace import hrn_to_urn
11 from sfa.server.interface import Interfaces
12 import sfa.util.xmlrpcprotocol as xmlrpcprotocol
13 import sfa.util.soapprotocol as soapprotocol
14  
15
16 ##
17 # Registry is a SfaServer that serves registry and slice operations at PLC.
18 class Registry(SfaServer):
19     ##
20     # Create a new registry object.
21     #
22     # @param ip the ip address to listen on
23     # @param port the port to listen on
24     # @param key_file private key filename of registry
25     # @param cert_file certificate filename containing public key (could be a GID file)
26     
27     def __init__(self, ip, port, key_file, cert_file):
28         SfaServer.__init__(self, ip, port, key_file, cert_file)
29         self.server.interface = 'registry' 
30
31
32 ##
33 # Registries is a dictionary of registry connections keyed on the registry
34 # hrn
35
36 class Registries(Interfaces):
37     
38     default_dict = {'registries': {'registry': [Interfaces.default_fields]}}
39
40     def __init__(self, api, conf_file = "/etc/sfa/registries.xml"):
41         Interfaces.__init__(self, api, conf_file) 
42         address = self.api.config.SFA_REGISTRY_HOST
43         port = self.api.config.SFA_REGISTRY_PORT
44         url = 'http://%(address)s:%(port)s' % locals()
45         local_registry = {'hrn': self.api.hrn,
46                            'urn': hrn_to_urn(self.api.hrn, 'authority'),
47                            'addr': address,
48                            'port': port,
49                            'url': url}
50         self.interfaces[self.api.hrn] = local_registry
51        
52         # get connections
53         self.update(self.get_connections())