mediawiki
MediaWiki module.
- exception spicerack.mediawiki.MediaWikiCheckError[source]
Bases:
SpicerackCheckError
Custom exception class for checking errors in this module.
- exception spicerack.mediawiki.MediaWikiError[source]
Bases:
SpicerackError
Custom exception class for errors in this module.
- class spicerack.mediawiki.MediaWiki(conftool: spicerack.confctl.ConftoolEntity, remote: spicerack.remote.Remote, user: str, dry_run: bool = True) None [source]
Bases:
object
Class to manage MediaWiki-specific resources.
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
, default:True
) -- whether this is a DRY-RUN.
- check_config_line(filename: str, expected: str) bool [source]
Check that a MediaWiki configuration file contains some value.
- Parameters:
- Return type:
- Returns:
True
if the expected string is found in the configuration file,False
otherwise.- Raises:
requests.exceptions.RequestException -- on error.
- check_periodic_jobs_disabled(datacenter: str) None [source]
Check that MediaWiki periodic jobs are not enabled in the given DC.
- Parameters:
datacenter (
str
) -- the name of the datacenter to work on.- Raises:
spicerack.remote.RemoteExecutionError -- on failure.
- Return type:
- check_periodic_jobs_enabled(datacenter: str) None [source]
Check that MediaWiki periodic jobs are enabled in the given DC.
- Parameters:
datacenter (
str
) -- the name of the datacenter to work on.- Raises:
spicerack.remote.RemoteExecutionError -- on failure.
- Return type:
- check_siteinfo(datacenter: str, checks: dict[tuple[str, ...], Any], samples: int = 1) None [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
[tuple
[str
,...
],typing.Any
]) --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
, default:1
) -- the number of different calls to siteinfo to perform.
- Raises:
spicerack.mediawiki.MediaWikiError -- if unable to get siteinfo or unable to traverse the siteinfo dictionary after all tries.
spicerack.mediawiki.MediaWikiCheckError -- if the value doesn't match after all tries.
- Return type:
- get_maintenance_host(datacenter: str) spicerack.remote.RemoteHosts [source]
Get an instance to execute commands on the maintenance hosts in a given datacenter.
- Parameters:
datacenter (
str
) -- the datacenter to filter for.- Return type:
- get_siteinfo(datacenter: str) dict [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.- Raises:
requests.exceptions.RequestException -- on failure.
- Return type:
- scap_sync_config_file(filename: str, message: str) None [source]
Execute scap sync-file to deploy a specific configuration file of wmf-config.
- Parameters:
- Raises:
spicerack.remote.RemoteExecutionError -- on error.
- Return type:
- set_master_datacenter(datacenter: str) None [source]
Set the MediaWiki config master datacenter variable in Conftool.
- Parameters:
datacenter (
str
) -- the new master datacenter.- Raises:
spicerack.confctl.ConfctlError -- on error.
- Return type:
- set_readonly(datacenter: str, message: str) None [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.
- Return type:
- set_readwrite(datacenter: str) None [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.
- Return type: