Registries/Aggregates now inherit sfa.server.interface.Interfaces base class
[sfa.git] / sfa / server / aggregate.py
1 ### $Id$
2 ### $URL$
3
4
5 from sfa.util.server import SfaServer
6 from sfa.util.faults import *
7 from sfa.server.interface import Interfaces
8 import sfa.util.xmlrpcprotocol as xmlrpcprotocol
9 import sfa.util.soapprotocol as soapprotocol
10
11
12 class Aggregate(SfaServer):
13
14     ##
15     # Create a new aggregate object.
16     #
17     # @param ip the ip address to listen on
18     # @param port the port to listen on
19     # @param key_file private key filename of registry
20     # @param cert_file certificate filename containing public key (could be a GID file)     
21     def __init__(self, ip, port, key_file, cert_file):
22         SfaServer.__init__(self, ip, port, key_file, cert_file)
23         self.server.interface = 'aggregate'
24
25 ##
26 # Aggregates is a dictionary of aggregate connections keyed on the aggregate hrn
27
28 class Aggregates(dict):
29
30     default_dict = {'registries': {'registry': [default_fields]}}
31  
32     def __init__(self, api, file = "/etc/sfa/aggregates.xml"):
33         Interfaces.__init__(self, conf_file, 'sa')
34
35     def connectAggregates(self, interfaces):
36         """
37         Get connection details for the trusted peer aggregates from file and 
38         create an connection to each. 
39         """
40         connections = Interfaces.get_connections(self, interfaces)
41
42         # set up a connection to the local registry
43         address = self.api.config.SFA_AGGREGATE_HOST
44         port = self.api.config.SFA_AGGREGATE_PORT
45         url = 'http://%(address)s:%(port)s' % locals()
46         local_aggregate = {'hrn': self.api.hrn, 'addr': address, 'port': port}
47         self.interfaces.append(local_aggregate) 
48         connections[self.api.hrn] = xmlrpcprotocol.get_server(url, self.api.key_file, self.api.cert_file)
49         return connetions
50