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
check_config_line(filename: str, expected: str) bool[source]

Check that a MediaWiki configuration file contains some value.

Parameters
  • filename (str) -- filename without extension in wmf-config.

  • expected (str) -- string expected to be found in the configuration file.

Returns

True if the expected string is found in the configuration file, False otherwise.

Return type

bool

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 value value, 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

spicerack.remote.RemoteHosts

get_master_datacenter() str[source]

Return a string representing the primary DC.

Returns

the primary DC

Return type

str

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.

Returns

the parsed JSON from siteinfo.

Return type

dict

Raises

requests.exceptions.RequestException -- on failure.

scap_sync_config_file(filename: str, message: str) None[source]

Execute scap sync-file to deploy a specific configuration file of wmf-config.

Parameters
  • filename (str) -- the filename without extension of wmf-config.

  • message (str) -- the message to use for the scap sync-file execution.

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
  • datacenter (str) -- the DC for which the configuration must be changed.

  • message (str) -- the readonly message string to set in MediaWiki.

Raises
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
stop_periodic_jobs(datacenter: str) None[source]

Remove and ensure MediaWiki periodic jobs are disabled in the given DC.

Parameters

datacenter (str) -- the name of the datacenter to work on.

Raises

spicerack.remote.RemoteExecutionError -- on failure.