cd6036af3ca44bde4749ea34b7687ca22e5b9078
[sfa.git] / sfa / planetlab / topology.py
1 ##
2 # SFA Topology Info
3 #
4 # This module holds topology configuration for SFA. It is implemnted as a 
5 # list of site_id tuples
6
7 import os.path
8 import traceback
9 from sfa.util.sfalogging import logger
10
11 class Topology(set):
12     """
13     Parse the topology configuration file. 
14     """
15
16     def __init__(self, config_file = "/etc/sfa/topology"):
17         set.__init__(self) 
18         try:
19             # load the links
20             f = open(config_file, 'r')
21             for line in f:
22                 ignore = line.find('#')
23                 if ignore > -1:
24                     line = line[0:ignore]
25                 tup = line.split()
26                 if len(tup) > 1:
27                     self.add((tup[0], tup[1]))    
28         except Exception, e:
29             logger.log_exc("Could not find or load the configuration file: %s" % config_file)
30             raise