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.
19 from geni.util.debug import log
22 geni = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))+ os.sep + "geni"
26 Parse the bash/Python/PHP version of the configuration file. Very
27 fast but no type conversions.
30 def __init__(self, file = "/etc/geni/geni_config"):
34 path = os.path.dirname(os.path.abspath(__file__))
36 self.basepath = os.path.dirname(self.path)
37 filename = file.split(os.sep)[-1]
38 alt_file = path + os.sep + 'util' + os.sep + filename
39 geni_file = geni + os.sep + 'util' + os.sep + filename
40 files = [file, alt_file, geni_file]
44 execfile(file, self.__dict__)
46 self.config_file = file
52 raise Exception, "Could not find config in " + ", ".join(files)
54 # set up some useful variables
58 execfile(file, self.__dict__)
60 raise Exception, "Could not find config in " + file
62 plcConfig = Config("/etc/planetlab/plc_config")
64 def get_default_dbinfo():
65 dbinfo={ 'dbname' : plcConfig.PLC_DB_NAME,
66 'address' : plcConfig.PLC_DB_HOST,
67 'port' : plcConfig.PLC_DB_PORT,
68 'user' : plcConfig.PLC_DB_USER,
69 'password' : plcConfig.PLC_DB_PASSWORD
75 # Geniwrapper uses a PLCAPI connection to perform operations on the registry,
76 # such as creating and deleting slices. This connection requires an account
77 # on the PLC server with full administrator access.
79 # The Url parameter controls whether the connection uses PLCAPI directly (i.e.
80 # Geniwrapper is located on the same machine as PLC), or uses a XMLRPC connection
81 # to the PLC machine. If you wish to use the API directly, then remove the Url
82 # field from the dictionary.
85 pl_auth = {'Username': plcConfig.PLC_API_MAINTENANCE_USER,
86 'AuthMethod': 'capability',
87 'AuthString': plcConfig.PLC_API_MAINTENANCE_PASSWORD,
88 "Url": 'https://%s:%s%s' %(plcConfig.PLC_API_HOST, plcConfig.PLC_API_PORT, plcConfig.PLC_API_PATH)