confctl

Confctl module to abstract Conftool.

class spicerack.confctl.Confctl(config='/etc/conftool/config.yaml', schema='/etc/conftool/schema.yaml', dry_run=True)[source]

Bases: object

Confctl class to abstract conftool operations.

Initialize the instance.

Parameters:
  • config (str, optional) -- the path to the configuration file to load.
  • schema (str, optional) -- the path to the Conftool schema to load.
  • dry_run (bool, optional) -- whether this is a DRY-RUN.
entity(entity_name)[source]

Get the Conftool specific entity class.

Parameters:entity_name (str) -- the name of the entiryself.
Returns:and entity-specific class to perform Conftool operations.
Return type:spicerack.confctl.ConftoolEntity
exception spicerack.confctl.ConfctlError[source]

Bases: spicerack.exceptions.SpicerackError

Custom exception class for errors of this module.

class spicerack.confctl.ConftoolEntity(entity, dry_run=True)[source]

Bases: object

ConftoolEntity class to perform operations on a specific Conftool entity.

Initialize the instance.

Parameters:
  • entity (conftool.kvobject.Entity) -- an instance of Conftool entity.
  • dry_run (bool, optional) -- whether this is a DRY-RUN.
get(**tags)[source]

Generator that yields conftool objects corresponding to the selection.

Parameters:**tags -- arbitrary Conftool tags as keyword arguments.
Yields:conftool.kvobject.Entity -- the selected object.
set_and_verify(key, value, **tags)[source]

Set and verify a single Conftool value.

Parameters:
  • key (str) -- the key in Conftool to modify.
  • value (mixed) -- the value to set.
  • **tags -- arbitrary Conftool tags as keyword arguments.
Raises:

spicerack.confctl.ConfctlError -- on etcd or Conftool errors or failing to verify the changes.

update(changed, **tags)[source]

Updates the value of conftool objects corresponding to the selection done with tags.

Parameters:
  • changed (dict) -- the new values to set for the selected objects.
  • **tags -- arbitrary Conftool tags as keyword arguments.
Raises:

spicerack.confctl.ConfctlError -- on etcd or Conftool errors.

Examples

>>> confctl.update({'pooled': False}, service='appservers-.*', name='eqiad')