2.2. libmace.providers

Providers related defines.

class libmace.providers.BaseProvider

All providers need to inherit this class.

comment

String that is being used to start comment line in config files.

name

Provider identification string.

provides

List of names that are associated with a provider.

By default providers are associated only with theirs names.

service

Shell command to control service daemon.

For example, /etc/init.d/httd to start and stop HTTP server.

service_command

Command to run in shell mode to control service daemon.

confiles

Configuration files supported by provider.

Property contains fake names internally associated with final configuration files. If there is only one configuration file supported by provider, names don’t make sense and even None is fine.

is_active()

Is service running.

confpath(confile=None)

Get configuration path relatively to –output directory.

Parameters:confile – one of confiles names
Returns:path to the final configuration file associated with filename, TODO, redesign: None if confile should be treated as an .ini file, False custom configl processing
confpath_header(confpath, conftext)

Final configuration file header.

The header that will be added to each final configuration file.

Parameters:
  • confpath – path to the final configuration file
  • conftextlibmace.files.Conftext object with full configuration
Returns:

list of lines to add

confile_header(confile, conftext)

Confile header.

These lines will be added to the final configuration file before each confile, even if several confiles go to the same final configuration file.

Parameters:
  • confile – one of confiles names
  • conftextlibmace.files.Conftext object with full configuration
Returns:

list of lines to add

footer(path, conftext)

Final configuration file footer.

The footer that will be added to each final configuration file.

Parameters:
  • path – path to the final configuration file
  • conftextlibmace.files.Conftext object with full configuration
Returns:

list of lines to add

Confile footer.

These lines will be added to the final configuration file after each confile, even if several confiles go to the same final configuration file.

Parameters:
  • confile – one of confiles names
  • conftextlibmace.files.Conftext object with full configuration
Returns:

list of lines to add

activate(force=False)

Start service.

Parameters:force – force activating without checking current status
Returns:True is service was started
deactivate()

Stop service.

Returns:True is service was stapped
export(envars)

Export variables that might be used in configuration sources.

Parameters:envars – dictionary to export variables to
convert(confile, lines)

Convert configuration file.

Parameters:
  • confile – one of confiles names that lines belong to
  • lines – configuration file text lines
Returns:

function should return new lines

ensure(conftext, tran)

Does environment needs to be prepared.

Will be called after applying new configuration to make sure that final environment for consistence and tunning it otherwise.

Parameters:
  • conftextlibmace.files.Conftext object with full configuration
  • tran – any changes in environment should happen via this object to make it possible to revert made changes on applying fails
Returns:

True if environment was changed

apply(conftext, tran)

Apply configuration changes, e.g., restart service.

Parameters:
  • conftextlibmace.files.Conftext object with full configuration
  • tran – any changes in environment should happen via this object to make it possible to revert made changes on applying fails
Returns:

True if provider has done something for applying changes, e.g., restarted daemon

get_depends(conftext)

Providers that current one requires.

Parameters:conftextlibmace.files.Conftext object with full configuration
Returns:list of provider names

All depending providers need to be included to the same configuration as the current one belongs to. It is only about dependencies between providers, not between services they configure, e.g., some provider might depend on envars exported by enother one.

get_requires(conftext)

Packages that provider requires.

Parameters:conftextlibmace.files.Conftext object with full configuration
Returns:list of native package names
write_config(tran, confpath, lines)

Add finale configuration files to transation.

Parameters:
  • tran – transaction to add files to
  • confpath – destination for configuration file on final system
  • lines – final configuration text
libmace.providers.load()

Populate list of providers.

Needs to be called on program start.

Previous topic

2.1. libmace.env

Next topic

2.3. libmace.files

This Page