59a3e6b80357d09ff98bfe5a5fa5d98641412033
[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, Interface
5 from sfa.util.config import Config     
6
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
22 class Aggregates(Interfaces):
23
24     default_dict = {'aggregates': {'aggregate': [Interfaces.default_fields]}}
25  
26     def __init__(self, conf_file = "/etc/sfa/aggregates.xml"):
27         Interfaces.__init__(self, conf_file)
28         sfa_config = Config() 
29         # set up a connection to the local aggregate
30         if sfa_config.SFA_AGGREGATE_ENABLED:
31             addr = sfa_config.SFA_AGGREGATE_HOST
32             port = sfa_config.SFA_AGGREGATE_PORT
33             hrn = sfa_config.SFA_INTERFACE_HRN
34             interface = Interface(hrn, addr, port)
35             self[hrn] = interface