1 from sfa.util.faults import *
2 from sfa.util.server import SfaServer
3 from sfa.util.xrn import hrn_to_urn
4 from sfa.server.interface import Interfaces
6 class Aggregate(SfaServer):
9 # Create a new aggregate object.
11 # @param ip the ip address to listen on
12 # @param port the port to listen on
13 # @param key_file private key filename of registry
14 # @param cert_file certificate filename containing public key (could be a GID file)
15 def __init__(self, ip, port, key_file, cert_file):
16 SfaServer.__init__(self, ip, port, key_file, cert_file,'aggregate')
19 # Aggregates is a dictionary of aggregate connections keyed on the aggregate hrn
21 class Aggregates(Interfaces):
23 default_dict = {'aggregates': {'aggregate': [Interfaces.default_fields]}}
25 def __init__(self, api, conf_file = "/etc/sfa/aggregates.xml"):
26 Interfaces.__init__(self, api, conf_file)
27 # set up a connection to the local aggregate
28 if self.api.config.SFA_AGGREGATE_ENABLED:
29 address = self.api.config.SFA_AGGREGATE_HOST
30 port = self.api.config.SFA_AGGREGATE_PORT
31 url = 'http://%(address)s:%(port)s' % locals()
32 local_aggregate = {'hrn': self.api.hrn,
33 'urn': hrn_to_urn(self.api.hrn, 'authority'),
37 self.interfaces[self.api.hrn] = local_aggregate
40 self.update(self.get_connections())