Merge branch 'master' into eucalyptus-devel
[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.util.xrn import hrn_to_urn
11 from sfa.server.interface import Interfaces
12  
13
14 ##
15 # Registry is a SfaServer that serves registry and slice operations at PLC.
16 class Registry(SfaServer):
17     ##
18     # Create a new registry object.
19     #
20     # @param ip the ip address to listen on
21     # @param port the port to listen on
22     # @param key_file private key filename of registry
23     # @param cert_file certificate filename containing public key (could be a GID file)
24     
25     def __init__(self, ip, port, key_file, cert_file):
26         SfaServer.__init__(self, ip, port, key_file, cert_file,'registry')
27
28 ##
29 # Registries is a dictionary of registry connections keyed on the registry
30 # hrn
31
32 class Registries(Interfaces):
33     
34     default_dict = {'registries': {'registry': [Interfaces.default_fields]}}
35
36     def __init__(self, api, conf_file = "/etc/sfa/registries.xml"):
37         Interfaces.__init__(self, api, conf_file) 
38         address = self.api.config.SFA_REGISTRY_HOST
39         port = self.api.config.SFA_REGISTRY_PORT
40         url = 'http://%(address)s:%(port)s' % locals()
41         local_registry = {'hrn': self.api.hrn,
42                            'urn': hrn_to_urn(self.api.hrn, 'authority'),
43                            'addr': address,
44                            'port': port,
45                            'url': url}
46         self.interfaces[self.api.hrn] = local_registry
47        
48         # get connections
49         self.update(self.get_connections())