2 # Geniwrapper Configuration Info
4 # This module holds configuration parameters for geniwrapper. There are two
5 # main pieces of information that are used: the database connection and
6 # the PLCAPI connection
10 # Geniwrapper 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 Geniwrapper does not access any of the PLC databases directly via
15 # a mysql connection; All PLC databases are accessed via PLCAPI.
23 from sfa.util.debug import log
27 Parse the bash/Python/PHP version of the configuration file. Very
28 fast but no type conversions.
31 def __init__(self, config_file = "/etc/sfa/sfa_config"):
32 self.config_file = None
33 self.config_path = None
35 self.load(config_file)
37 def load(self, config_file):
39 execfile(config_file, self.__dict__)
40 self.config_file = config_file
41 # path to configuration data
42 self.config_path = os.path.dirname(config_file)
44 if not hasattr(self, 'SFA_DATA_DIR'):
45 # default to /var/lib/sfa not specified in config
46 self.SFA_DATA_DIR="/var/lib/sfa"
47 self.data_path = self.SFA_DATA_DIR
49 self.data_path = self.SFA_DATA_DIR
52 if not hasattr(self, 'SFA_CONFIG_DIR'):
53 # default to /var/lib/sfa not specified in config
54 self.SFA_CONFIG_DIR="/etc/sfa"
56 # define interface types
57 # this will determine which manager to use
58 if not hasattr(self, 'SFA_REGISTRY_TYPE'):
59 self.SFA_REGISTRY_TYPE='pl'
61 if not hasattr(self, 'SFA_AGGREGATE_TYPE'):
62 self.SFA_AGGREGATE_TYPE='pl'
64 if not hasattr(self, 'SFA_SM_TYPE'):
67 if not hasattr(self, 'SFA_CM_TYPE'):
68 self.SFA_COMPONENT_TYPE='pl'
70 # create the data directory if it doesnt exist
71 if not os.path.isdir(self.SFA_DATA_DIR):
72 os.mkdir(self.SFA_DATA_DIR)
75 raise IOError, "Could not find the configuration file: %s" % config_file
77 def get_trustedroots_dir(self):
78 return self.config_path + os.sep + 'trusted_roots'
80 def get_openflow_aggrMgr_info(self):
81 aggr_mgr_ip = 'localhost'
82 if (hasattr(self,'OPENFLOW_AGGREGATE_MANAGER_IP')):
83 aggr_mgr_ip = self.OPENFLOW_AGGREGATE_MANAGER_IP
86 if (hasattr(self,'OPENFLOW_AGGREGATE_MANAGER_PORT')):
87 aggr_mgr_port = self.OPENFLOW_AGGREGATE_MANAGER_PORT
89 return (aggr_mgr_ip,aggr_mgr_port)
91 def get_aggregate_rspec_type(self):
92 if (hasattr(self,'SFA_AGGREGATE_RSPEC_TYPE')):
93 return self.SFA_AGGREGATE_RSPEC_TYPE
97 def get_plc_dbinfo(self):
99 'dbname' : self.SFA_PLC_DB_NAME,
100 'address' : self.SFA_PLC_DB_HOST,
101 'port' : self.SFA_PLC_DB_PORT,
102 'user' : self.SFA_PLC_DB_USER,
103 'password' : self.SFA_PLC_DB_PASSWORD
107 # Geniwrapper uses a PLCAPI connection to perform operations on the registry,
108 # such as creating and deleting slices. This connection requires an account
109 # on the PLC server with full administrator access.
111 # The Url parameter controls whether the connection uses PLCAPI directly (i.e.
112 # Geniwrapper is located on the same machine as PLC), or uses a XMLRPC connection
113 # to the PLC machine. If you wish to use the API directly, then remove the Url
114 # field from the dictionary.
116 def get_plc_auth(self):
118 'AuthMethod': 'capability',
119 'Username': self.SFA_PLC_USER,
120 'AuthString': self.SFA_PLC_PASSWORD,
121 "Url": self.SFA_PLC_URL