confctl¶
Confctl module to abstract Conftool.
-
class
spicerack.confctl.
Confctl
(config: str = '/etc/conftool/config.yaml', schema: str = '/etc/conftool/schema.yaml', dry_run: bool = True)[source]¶ Bases:
object
Confctl class to abstract conftool operations.
Initialize the instance.
- Parameters
-
exception
spicerack.confctl.
ConfctlError
[source]¶ Bases:
spicerack.exceptions.SpicerackError
Custom exception class for errors of this module.
-
class
spicerack.confctl.
ConftoolEntity
(entity: conftool.kvobject.Entity, dry_run: bool = 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) → Iterator[conftool.kvobject.Entity][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: str, value: Union[str, int, float], **tags) → None[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: Dict[str, Union[str, int, float]], **tags) → None[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')