Python API¶
Spicerack Python API autodoc.
Spicerack package.
-
class
spicerack.
Spicerack
(*, verbose: bool = False, dry_run: bool = True, cumin_config: str = '/etc/cumin/config.yaml', conftool_config: str = '/etc/conftool/config.yaml', conftool_schema: str = '/etc/conftool/schema.yaml', debmonitor_config: str = '/etc/debmonitor.conf', spicerack_config_dir: str = '/etc/spicerack', http_proxy: str = '')[source]¶ Bases:
object
Spicerack service locator.
Initialize the service locator for the Spicerack library.
- Parameters
verbose (bool, optional) -- whether to set the verbose mode.
dry_run (bool, optional) -- whether this is a DRY-RUN.
cumin_config (str, optional) -- the path to Cumin's configuration file.
conftool_config (str, optional) -- the path to Conftool's configuration file.
conftool_schema (str, optional) -- the path to Conftool's schema file.
debmonitor_config (str, optional) --
the path to Debmonitor's INI configuration file. It must have at least the following schema:
[DEFAULT] server=debmonitor.example.com cert=/etc/debmonitor/ssl/cert.pem key=/etc/debmonitor/ssl/server.key
spicerack_config_dir (str, optional) -- the path for the root configuration directory for Spicerack. Module-specific configuration will be loaded from config_dir/module_name/.
http_proxy (str, optional) -- the scheme://url:port of the HTTP proxy to use for external calls.
-
admin_reason
(reason: str, task_id: Optional[str] = None) → spicerack.administrative.Reason[source]¶ Get an administrative Reason instance.
- Parameters
- Returns
the administrative Reason instance.
- Return type
-
confctl
(entity_name: str) → spicerack.confctl.ConftoolEntity[source]¶ Access a Conftool specific entity instance.
- Parameters
entity_name (str) -- the name of a Conftool entity. Possible values:
node
,service
,discovery
,mwconfig
.- Returns
the confctl entity instance.
- Return type
-
debmonitor
() → spicerack.debmonitor.Debmonitor[source]¶ Get a Debmonitor instance to interact with a Debmonitor website.
- Returns
the instance.
- Return type
- Raises
KeyError -- if any configuration option is missing.
-
discovery
(*records: str) → spicerack.dnsdisc.Discovery[source]¶ Get a Discovery instance.
- Parameters
*records (str) -- arbitrary positional arguments, each one must be a Discovery DNS record name.
- Returns
the pre-configured Discovery instance for the given records.
- Return type
-
dns
() → wmflib.dns.Dns[source]¶ Get a Dns instance.
- Returns
a Dns instance that will use the operating system default namserver(s).
- Return type
-
elasticsearch_clusters
(clustergroup: str, write_queue_datacenters: Sequence[str]) → spicerack.elasticsearch_cluster.ElasticsearchClusters[source]¶ Get an ElasticsearchClusters instance.
- Parameters
- Returns
ElasticsearchClusters instance.
- Return type
-
ganeti
() → spicerack.ganeti.Ganeti[source]¶ Get an instance to interact with Ganeti.
- Returns
the instance
- Return type
- Raises
KeyError -- If the configuration file does not contain the correct keys.
-
icinga
() → spicerack.icinga.Icinga[source]¶ Get an Icinga instance.
- Returns
Icinga instance.
- Return type
-
ipmi
(*, cached: bool = False) → spicerack.ipmi.Ipmi[source]¶ Get an Ipmi instance to send remote IPMI commands to management consoles.
- Parameters
cached (bool, optional) -- whether to cache the Ipmi instance and allow to re-use it without re-asking the management password. The cached instance will be returned at each future call of this method with the cached parameter set to
True
.- Returns
the instance to run ipmitool commands.
- Return type
-
management
() → spicerack.management.Management[source]¶ Get a Management instance to interact with the management interfaces.
- Returns
the instance.
- Return type
-
mediawiki
() → spicerack.mediawiki.MediaWiki[source]¶ Get a MediaWiki instance.
- Returns
the MediaWiki instance.
- Return type
-
mysql
() → spicerack.mysql.Mysql[source]¶ Get a Mysql instance.
- Returns
the Mysql instance.
- Return type
-
mysql_legacy
() → spicerack.mysql_legacy.MysqlLegacy[source]¶ Get a MysqlLegacy instance.
- Returns
the MysqlLegacy instance.
- Return type
-
netbox
(*, read_write: bool = False) → spicerack.netbox.Netbox[source]¶ Get a Netbox instance to interact with Netbox's API.
- Parameters
read_write (bool, optional) -- whether to use a read-write token.
- Returns
the instance
- Return type
-
phabricator
(bot_config_file: str, section: str = 'phabricator_bot') → wmflib.phabricator.Phabricator[source]¶ Get a Phabricator instance to interact with a Phabricator website.
- Parameters
bot_config_file (str) --
the path to the configuration file for the Phabricator bot, with the following structure:
[section_name] host = https://phabricator.example.com/api/ username = phab-bot token = api-12345
section (str, optional) -- the name of the section of the configuration file where to find the required parameters.
- Returns
the instance.
- Return type
-
prometheus
() → spicerack.prometheus.Prometheus[source]¶ Get an Prometheus instance.
- Returns
Prometheus instance.
- Return type
-
puppet
(remote_hosts: spicerack.remote.RemoteHosts) → spicerack.puppet.PuppetHosts[source]¶ Get a PuppetHosts instance for the given remote hosts.
- Parameters
remote_hosts (spicerack.remote.RemoteHosts) -- the instance with the target hosts.
- Returns
the instance to manage Puppet on the target hosts.
- Return type
-
puppet_master
() → spicerack.puppet.PuppetMaster[source]¶ Get a PuppetMaster instance to manage hosts and certificates from a Puppet master.
- Returns
the instance to manage Puppet hosts and certificates.
- Return type
-
redis_cluster
(cluster: str) → spicerack.redis_cluster.RedisCluster[source]¶ Get a RedisCluster instance.
- Parameters
cluster (str) -- the name of the cluster.
- Returns
the cluster instance.
- Return type
-
remote
() → spicerack.remote.Remote[source]¶ Get a Remote instance.
- Returns
the Remote instance.
- Return type
-
requests_session
(name: str, *, timeout: float = 5.0, tries: int = 3, backoff: float = 1.0) → requests.sessions.Session[source]¶ Return a new requests Session with timeout and retry logic.
- Params:
according to
wmflib.requests.http_session()
.
- Returns
the pre-configured session.
- Return type
-
property
actions
¶ Getter for the
actions
property.- Returns
a dictionary to log and record cookbook actions.
- Return type
-
property
config_dir
¶ Getter for Spicerack's configuration file directory.
- Returns
a filesystem location of configuration files.
- Return type
-
property
dry_run
¶ Getter for the
dry_run
property.- Returns
True if the DRY-RUN mode is set, False otherwise.
- Return type
-
property
http_proxy
¶ Getter for the HTTP PROXY to use for external calls.
- Returns
the scheme://url:port of the proxy.
- Return type
-
property
icinga_master_host
¶ Getter for the
icinga_master_host
property.- Returns
the instance to execute commands on the Icinga master host.
- Return type
-
property
irc_logger
¶ Getter for the
irc_logger
property.- Returns
the logger instance to write to IRC.
- Return type
-
property
netbox_master_host
¶ Getter for the
netbox_master_host
property.- Returns
the instance to execute commands on the Netbox master host.
- Return type
-
property
requests_proxies
¶ Getter to return the HTTP proxy configuration for the Requests module.
-
property
username
¶ Getter for the current username.
- Returns
the name of the effective running user.
- Return type
Subpackages and Submodules