The configuration module

This configuration module (called cmod) is dedicated to configuration storage and export.

Every Pyrame module can register in the cmod and store its configuration parameters. The modules are stored in a tree representing the arborescence of the system.

The cmod contains at any time a copy of the configuration of all the modules and it can generate xml files containing all the parameters to be used with calxml.



reload the default parameters file


load a configuration from an xml file


extract the configuration from the tree and aggregate it in a XML file


extract the configuration from the tree and aggregate it in a XML file encoded in base 64

cmd_cmod.apply_phase_cmod(dev_name, phase_name, params='')[source]

apply a phase with name phase_name on the subtree with root dev_name. params is an empty string or a json dictionary containing values that can be passed to modules during the phase

cmd_cmod.transition_cmod(dev_name, goto, transition_name, transition_fallback, params='')[source]

Use transition_name to a system described by the loaded configuration. If the transition fails, use transition_fallback. The optional JSON-encoded params value adds named parameters to the phases.

cmd_cmod.command_cmod(dev_name, async, func, *params)[source]

apply a command on a device. If async is true, the command is done asynchronously.

cmd_cmod.set_param_cmod(dev_name, param_name, param_value)[source]

add or modify a parameter for a device

cmd_cmod.get_param_cmod(dev_name, param_name)[source]

get a parameter from a device


find the type of a device


find the ip of a device


get ip and type of a device


get the list of all device names of a dev_type

cmd_cmod.get_name_sublist_cmod(dev_type, parent_name)[source]

get the list of device names of a dev_type type with parent_name parent

cmd_cmod.exec_apc(node, phase_name, ext_params, fin)[source]

this function apply a a phase to a device

How to use it?

First load the configuration file with load_config_cmod. Then use transition_cmod to make the state machine do a transition.

How does it works?

The module uses the following algorithm to parse the configuration and apply phases. Every time a new module instance is found while parsing, the module:

  • searches in the module API for the name phasename_modulename
  • gets the parameters name of this function
  • gets the parameters values from the xml configuration or from the defaults file.
  • executes the function on the corresponding module with the parameters
  • continues with all the child modules
  • searches in the module API for the name phasename_fin_modulename
  • executes the function on the corresponding module with the parameters

As you can see, two different functions are called for every module: one when the module is first found and another after finding all its child modules.


Imagine we want to initialize a setup with a network switch and two connected cards. We have to initialize the switch with its port number as a parameter, then set the ip address for the two cards and finally calculate the MAC table on the switch. We will implement three functions.

def init_switch(switch_nb_port):

def init_nic(nic_ip):

def init_fin_switch():

Then create an xml file like this:

<switch name="sw">
  <param name="switch_nb_port">6</param>
  <nic name="nic1">
    <param name="nic_ip"></param>
  <nic name="nic2">
    <param name="nic_ip"></param>

When the init phase is applied, these functions will be called in this order:

  • init_switch(“6”)
  • init_nic(“”)
  • init_nic(“”)
  • init_fin_switch()

Note that all parameters are strings. If a function does not exists (like init_fin_nic in the example), it is simply ignored.