mediawiki¶
MediaWiki module.
- 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.
- class spicerack.mediawiki.MediaWiki(conftool: spicerack.confctl.ConftoolEntity, remote: spicerack.remote.Remote, user: str, dry_run: bool = True)[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, optional) -- 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
- Returns
True if the expected string is found in the configuration file, False otherwise.
- Return type
- 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.
- 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.
- 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) --
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: 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.
- Returns
the instance for the target host.
- Return type
- get_master_datacenter() str [source]¶
Return a string representing the primary DC.
- Returns
the primary DC
- Return type
- get_siteinfo(datacenter: str) Dict [source]¶
Get the JSON paylod for siteinfo from a random host in a given datacenter.
- 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.
- 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.
- 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.
- 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.