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
34 self.load(config_file)
36 def load(self, config_file):
38 execfile(config_file, self.__dict__)
39 self.config_file = config_file
40 self.config_path = os.path.dirname(config_file)
42 raise IOError, "Could not find the configuration file: %s" % config_file
46 # Very hacky - to change after July 21.
48 # The generation/parsing of RSpecs is based on the value returned by this function. vini and max
49 # use some new code, while pl uses old code. As long as you don't set SFA_AGGREGATE_RSPEC_TYPE in your
50 # config file, the new code will not apply to your deployment.
53 def get_aggregate_rspec_type(self):
54 if (hasattr(self,'SFA_AGGREGATE_RSPEC_TYPE')):
55 return self.SFA_AGGREGATE_RSPEC_TYPE
59 def get_plc_dbinfo(self):
61 'dbname' : self.SFA_PLC_DB_NAME,
62 'address' : self.SFA_PLC_DB_HOST,
63 'port' : self.SFA_PLC_DB_PORT,
64 'user' : self.SFA_PLC_DB_USER,
65 'password' : self.SFA_PLC_DB_PASSWORD
69 # Geniwrapper uses a PLCAPI connection to perform operations on the registry,
70 # such as creating and deleting slices. This connection requires an account
71 # on the PLC server with full administrator access.
73 # The Url parameter controls whether the connection uses PLCAPI directly (i.e.
74 # Geniwrapper is located on the same machine as PLC), or uses a XMLRPC connection
75 # to the PLC machine. If you wish to use the API directly, then remove the Url
76 # field from the dictionary.
78 def get_plc_auth(self):
80 'AuthMethod': 'capability',
81 'Username': self.SFA_PLC_USER,
82 'AuthString': self.SFA_PLC_PASSWORD,
83 "Url": self.SFA_PLC_URL