Skip to content
motine edited this page Feb 18, 2013 · 5 revisions

Configuration

Administrate

AMsoil has a configuration database which is created with the first start of the src/main.py. The location of the database is specified in src/amsoil/config.py (usually in the deploy folder). In order to administrate the configuration of AMsoil please use the config_client.py in admin. The ConfigClient connects to the AM server - yes the server must be started before via the main.py - and retrieves/sets the entries. Please run admin/config_client.py --help for usage. Also here some examples:

    ./config_client.py --list localhost:8001
    ./config_client.py --interactive localhost:8001
    ./config_client.py --set geniv3rpc.rspec_validation=0 localhost:8001

Develop

A plugin most certainly needs configuration options. Please do not add config.py files all over the place, rather use the config service provided by the configdb plugin. Let's see what it can do:

    # get the service
    import amsoil.core.pluginmanager as pm
    config = pm.getService("config")
    # retrieve a value
    myvalue = config.get("mygroup.mykey")
    # set a value
    config.set("mygroup.mykey", myvalue)
    # install a config item
    config.install("mygroup.mykey", "somedefault", "Some super description.")

So when you want to get a value call get(key) where the key can be an arbitrary string but it would be nice to use some prefix to identify which plugin the entry belongs to. When getting the value, the type/class is preserved. So whatever you put in there via install or set will be given back to you, as long as the value can be serialized via python's pickle.

You always want to install the configuration keys and defaults on the plugin's setup method. When install is called and the key does not exist the entry will be created with the given default value - install will not re-create/overwrite existing entries.

For more details please see the documentation in the configdb plugin (in the plugin.py file).

Clone this wiki locally