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
Conftl class to abstract conftool operations.
-
__init__
(config='/etc/conftool/config.yaml', schema='/etc/conftool/schema.yaml', dry_run=True)[source]¶ Initialize the instance.
Parameters:
-
entity
(entity_name)[source]¶ Get the Conftool specific entity class.
- Argumetns:
- 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.
-
__init__
(entity, dry_run=True)[source]¶ Initialize the instance.
Parameters: - entity (conftool.kvobject.Entity) -- an instance of Conftool entity.
- dry_run (bool, optional) -- whether this is a DRY-RUN.
-
_select
(tags)[source]¶ Generator that yields the selected objects based on the provided tags.
Parameters: tags (dict) -- dictionary with tag: expression pairs of Conftool selectors. Yields: conftool.kvobject.Entity -- the selected object. Raises: spicerack.confctl.ConfctlError
-- if not match is found.
-
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')
-