2 # SFA Configuration Info
4 # This module holds configuration parameters for SFA. There are two
5 # main pieces of information that are used: the database connection and
6 # the PLCAPI connection
10 # SFA uses a MYSQL database to store records. This database may be
11 # co-located with the PLC database, or it may be a separate database. The
12 # following parameters define the connection to the database.
14 # Note that SFA does not access any of the PLC databases directly via
15 # a mysql connection; All PLC databases are accessed via PLCAPI.
22 Parse the bash/Python/PHP version of the configuration file. Very
23 fast but no type conversions.
26 def __init__(self, config_file = "/etc/sfa/sfa_config.py"):
27 self.config_file = None
28 self.config_path = None
30 self.load(config_file)
32 def load(self, config_file):
34 execfile(config_file, self.__dict__)
35 self.config_file = config_file
36 # path to configuration data
37 self.config_path = os.path.dirname(config_file)
39 ### xxx todo implement defaults in default_config.xml
41 if not hasattr(self, 'SFA_DATA_DIR'):
42 # default to /var/lib/sfa not specified in config
43 self.SFA_DATA_DIR="/var/lib/sfa"
44 self.data_path = self.SFA_DATA_DIR
46 self.data_path = self.SFA_DATA_DIR
49 if not hasattr(self, 'SFA_CONFIG_DIR'):
50 # default to /etc/sfa not specified in config
51 self.SFA_CONFIG_DIR="/etc/sfa"
53 if not hasattr(self, 'SFA_REGISTRY_LEVEL1_AUTH'):
54 self.SFA_REGISTRY_LEVEL1_AUTH=None
56 # create the data directory if it doesnt exist
57 if not os.path.isdir(self.SFA_DATA_DIR):
59 os.mkdir(self.SFA_DATA_DIR)
63 raise IOError, "Could not find or load the configuration file: %s" % config_file
65 def get_trustedroots_dir(self):
66 return self.config_path + os.sep + 'trusted_roots'
68 def get_openflow_aggrMgr_info(self):
69 aggr_mgr_ip = 'localhost'
70 if (hasattr(self,'OPENFLOW_AGGREGATE_MANAGER_IP')):
71 aggr_mgr_ip = self.OPENFLOW_AGGREGATE_MANAGER_IP
74 if (hasattr(self,'OPENFLOW_AGGREGATE_MANAGER_PORT')):
75 aggr_mgr_port = self.OPENFLOW_AGGREGATE_MANAGER_PORT
77 return (aggr_mgr_ip,aggr_mgr_port)
79 def get_interface_hrn(self):
80 if (hasattr(self,'SFA_INTERFACE_HRN')):
81 return self.SFA_INTERFACE_HRN
85 # TODO: find a better place to put this method
86 def get_max_aggrMgr_info(self):
87 am_apiclient_path = '/usr/local/MAXGENI_AM_APIClient'
88 if (hasattr(self,'MAXGENI_AM_APICLIENT_PATH')):
89 am_client_path = self.MAXGENI_AM_APICLIENT_PATH
91 am_url = 'https://geni.dragon.maxgigapop.net:8443/axis2/services/AggregateGENI'
92 if (hasattr(self,'MAXGENI_AM_URL')):
93 am_url = self.MAXGENI_AM_URL
95 return (am_apiclient_path,am_url)