Merge branch 'master' into eucalyptus-devel
[sfa.git] / sfa / server / aggregate.py
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
5
6 class Aggregate(SfaServer):
7
8     ##
9     # Create a new aggregate object.
10     #
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')
17
18 ##
19 # Aggregates is a dictionary of aggregate connections keyed on the aggregate hrn
20
21 class Aggregates(Interfaces):
22
23     default_dict = {'aggregates': {'aggregate': [Interfaces.default_fields]}}
24  
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'),
34                                'addr': address,
35                                'port': port,
36                                'url': url}
37             self.interfaces[self.api.hrn] = local_aggregate
38
39         # get connections
40         self.update(self.get_connections())