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