a little nicer wrt pep8
[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
8
9 class Aggregate(SfaServer):
10
11     ##
12     # Create a new aggregate object.
13     #
14     # @param ip the ip address to listen on
15     # @param port the port to listen on
16     # @param key_file private key filename of registry
17     # @param cert_file certificate filename containing public key (could be a GID file)
18     def __init__(self, ip, port, key_file, cert_file):
19         SfaServer.__init__(self, ip, port, key_file, cert_file, 'aggregate')
20
21 #
22 # Aggregates is a dictionary of aggregate connections keyed on the aggregate hrn
23 # as such it's more of a client-side thing for aggregate servers to reach their peers
24 #
25
26
27 class Aggregates(Interfaces):
28
29     default_dict = {'aggregates': {'aggregate': [Interfaces.default_fields]}}
30
31     def __init__(self, conf_file="/etc/sfa/aggregates.xml"):
32         Interfaces.__init__(self, conf_file)
33         sfa_config = Config()
34         # set up a connection to the local aggregate
35         if sfa_config.SFA_AGGREGATE_ENABLED:
36             addr = sfa_config.SFA_AGGREGATE_HOST
37             port = sfa_config.SFA_AGGREGATE_PORT
38             hrn = sfa_config.SFA_INTERFACE_HRN
39             interface = Interface(hrn, addr, port)
40             self[hrn] = interface