mediawiki¶
MediaWiki module.
-
class
spicerack.mediawiki.
MediaWiki
(conftool, remote, user, dry_run=True)[source]¶ Bases:
object
Class to manage MediaWiki-specific resources.
-
__init__
(conftool, remote, user, dry_run=True)[source]¶ Initialize the instance.
Parameters: - conftool (spicerack.confctl.ConftoolEntity) -- the conftool instance for the mwconfig type objects.
- remote (spicerack.remote.Remote) -- the Remote instance.
- user (str) -- the name of the effective running user.
- dry_run (bool, optional) -- whether this is a DRY-RUN.
-
static
_check_siteinfo
(datacenter, checks)[source]¶ Check that a specific value in siteinfo matches the expected ones, retrying if doesn't match.
Parameters: - datacenter (str) -- the DC where to query for siteinfo.
- checks (dict) --
dictionary of items to check, in which the keys are tuples with the path of keys to traverse the siteinfo dictionary to get the value and the values are the expected values to check. To check
siteinfo[key1][key2]
for a valuevalue
, use:{('key1', 'key2'): 'value'}
Raises: MediaWikiError
-- if unable to get siteinfo or unable to traverse the siteinfo dictionary after all tries.MediaWikiCheckError
-- if the value doesn't match after all tries.
-
_check_siteinfo_dry_run_aware
(datacenter, checks, samples=1)[source]¶ Dry-run mode aware check_siteinfo. See check_siteinfo() documentation for more details.
Parameters: - datacenter (str) -- the DC where to query for siteinfo.
- checks (dict) --
dictionary of items to check, in which the keys are tuples with the path of keys to traverse the siteinfo dictionary to get the value and the values are the expected values to check. To check
siteinfo[key1][key2]
for a valuevalue
, use:{('key1', 'key2'): 'value'}
- samples (int, optional) -- the number of different calls to siteinfo to perform.
Raises: MediaWikiError
-- if unable to get siteinfo or unable to traverse the siteinfo dictionary after all tries.MediaWikiCheckError
-- if the value doesn't match after all tries.
-
check_config_line
(filename, expected)[source]¶ Check that a MediaWiki configuration file contains some value.
Parameters: Returns: True if the expected string is found in the configuration file, False otherwise.
Return type: Raises: requests.exceptions.RequestException
-- on error.
-
check_cronjobs_disabled
(datacenter)[source]¶ Check that MediaWiki cronjobs are not set in the given DC.
Parameters: datacenter (str) -- the name of the datacenter to work on. Raises: spicerack.remote.RemoteExecutionError
-- on failure.
-
check_cronjobs_enabled
(datacenter)[source]¶ Check that MediaWiki cronjobs are set in the given DC.
Parameters: datacenter (str) -- the name of the datacenter to work on. Raises: spicerack.remote.RemoteExecutionError
-- on failure.
-
static
check_siteinfo
(datacenter, checks, samples=1)[source]¶ Check that a specific value in siteinfo matches the expected ones, on multiple hosts.
Parameters: - datacenter (str) -- the DC where to query for siteinfo.
- checks (dict) --
dictionary of items to check, in which the keys are tuples with the path of keys to traverse the siteinfo dictionary to get the value and the values are the expected values to check. To check
siteinfo[key1][key2]
for a valuevalue
, use:{('key1', 'key2'): 'value'}
- samples (int, optional) -- the number of different calls to siteinfo to perform.
Raises: MediaWikiError
-- if unable to get siteinfo or unable to traverse the siteinfo dictionary after all tries.MediaWikiCheckError
-- if the value doesn't match after all tries.
-
get_maintenance_host
(datacenter)[source]¶ Get an instance to execute commands on the maintenance hosts in a given datacenter.
Parameters: datacenter (str) -- the datacenter to filter for. Returns: the instance for the target host. Return type: spicerack.remote.RemoteHosts
-
static
get_siteinfo
(datacenter)[source]¶ Get the JSON paylod for siteinfo from a random host in a given datacenter.
Parameters: datacenter (str) -- the DC where to query for siteinfo. Returns: the parsed JSON from siteinfo. Return type: dict Raises: requests.exceptions.RequestException
-- on failure.
-
scap_sync_config_file
(filename, message)[source]¶ Execute scap sync-file to deploy a specific configuration file of wmf-config.
Parameters: Raises: spicerack.remote.RemoteExecutionError
-- on error.
-
set_master_datacenter
(datacenter)[source]¶ Set the MediaWiki config master datacenter variable in Conftool.
Parameters: datacenter (str) -- the new master datacenter. Raises: spicerack.confctl.ConfctlError
-- on error.
-
set_readonly
(datacenter, message)[source]¶ Set the Conftool readonly variable for MediaWiki config in a specific datacenter.
Parameters: Raises: spicerack.confctl.ConfctlError
-- on Conftool errors and failed validation.spicerack.mediawiki.MediaWikiError
-- on failed siteinfo validation.
-
set_readwrite
(datacenter)[source]¶ Set the Conftool readonly variable for MediaWiki config to False to make it read-write.
Parameters: datacenter (str) -- the DC for which the configuration must be changed.
Raises: spicerack.confctl.ConfctlError
-- on Conftool errors and failed validation.spicerack.mediawiki.MediaWikiError
-- on failed siteinfo validation.
-
stop_cronjobs
(datacenter)[source]¶ Remove and ensure MediaWiki cronjobs are not present in the given DC.
Parameters: datacenter (str) -- the name of the datacenter to work on. Raises: spicerack.remote.RemoteExecutionError
-- on failure.
-
-
exception
spicerack.mediawiki.
MediaWikiCheckError
[source]¶ Bases:
spicerack.exceptions.SpicerackCheckError
Custom exception class for checking errors in this module.
-
exception
spicerack.mediawiki.
MediaWikiError
[source]¶ Bases:
spicerack.exceptions.SpicerackError
Custom exception class for errors in this module.