90fcaf49276965f5e60cc823dbd12b445e5f62ce
[sfa.git] / sfa / server / aggregate.py
1 from sfa.server.sfaserver import SfaServer
2 from sfa.util.xrn import hrn_to_urn
3 from sfa.server.interface import Interfaces, Interface
4 from sfa.util.config import Config     
5
6 # this truly is a server-side object
7 class Aggregate(SfaServer):
8
9     ##
10     # Create a new aggregate object.
11     #
12     # @param ip the ip address to listen on
13     # @param port the port to listen on
14     # @param key_file private key filename of registry
15     # @param cert_file certificate filename containing public key (could be a GID file)     
16     def __init__(self, ip, port, key_file, cert_file):
17         SfaServer.__init__(self, ip, port, key_file, cert_file,'aggregate')
18
19 #
20 # Aggregates is a dictionary of aggregate connections keyed on the aggregate hrn
21 # as such it's more of a client-side thing for aggregate servers to reach their peers
22 #
23 class Aggregates(Interfaces):
24
25     default_dict = {'aggregates': {'aggregate': [Interfaces.default_fields]}}
26  
27     def __init__(self, conf_file = "/etc/sfa/aggregates.xml"):
28         Interfaces.__init__(self, conf_file)
29         sfa_config = Config() 
30         # set up a connection to the local aggregate
31         if sfa_config.SFA_AGGREGATE_ENABLED:
32             addr = sfa_config.SFA_AGGREGATE_HOST
33             port = sfa_config.SFA_AGGREGATE_PORT
34             hrn = sfa_config.SFA_INTERFACE_HRN
35             interface = Interface(hrn, addr, port)
36             self[hrn] = interface