6. Plugin SDK services
6.2. Logging
The PluginConfiguration service implements parsing and accessing the textual configuration set for plugin instances. The API is built on Python configparser.ConfigParser module with some additional functionality.
safeguard.sessions.plugin.plugin_configuration.
PluginConfiguration
The PluginConfiguration class represents the plugin configuration service.
get
The get() method returns a configuration option as a string value. If the value of the option is $ the secret identified by the section and option pair is retrieved from the configured credential store
get()
the value of the option or None
str
RequiredConfigurationSettingNotFound
get_certificate
The get_certificate() method returns a configuration option as a dict value. If the value of the option is $ the certificate identified by the section and option pair is retrieved from the configured credential store When the certificate and private key is given in the configuration it should be in PEM format and all the new lines must be indentet with one whitespace
get_certificate()
Example configuration:
[foo] certificate = -----BEGIN CERTIFICATE----- cert -----END CERTIFICATE----- -----BEGIN RSA PRIVATE KEY----- key -----END RSA PRIVATE KEY-----
private key and certificate parsed as dict
dict
getboolean
The getboolean() method returns the boolean value of a configuration option. The configuration option may have the values “yes” and “no” or their upper case variants. In case of invalid value, a PluginSDKValueError exception is raised.
getboolean()
PluginSDKValueError
boolean
getint
The getint() method returns the integer value of a configuration option. If the configuration option cannot be converted to an integer value, then a PluginSDKValueError exception is raised.
getint()
int
getfloat
The getfloat() method returns the floating point value of a configuration option. If the configuration option cannot be converted to a floating point value, then a PluginSDKValueError exception is raised.
getfloat()
float
getienum
The getienum() method returns the value of an option that may only assume certain lower case string values. In other words the lower case value of the configuration option is checked against a list of possible values. In case the configuration value is not one of the allowed values, then a PluginSDKValueError exception is raised.
getienum()
from safeguard.sessions.plugin import PluginConfiguration config = PluginConfiguration(""" [foobar] color1 = LightGreen color2 = LightBlue """) # next line is ok, returns 'lightgreen' config.getienum('foobar', 'color1', ('green', 'lightgreen')) # next line throws PluginSDKValueError exception config.getienum('foobar', 'color2', ('green', 'lightgreen'))
safeguard.sessions.plugin.plugin_configuration_exceptions.
The RequiredConfigurationSettingNotFound excpetion is raised when a required configuration option is not present when requested by the plugin.