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:
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.

Return type:

bool

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:

None

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:

None

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

    {('key1', 'key2'): 'value'}
    

  • samples (int, default: 1) -- the number of different calls to siteinfo to perform.

Raises:
Return type:

None

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:

spicerack.remote.RemoteHosts

get_master_datacenter() str[source]

Return a string representing 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.

Raises:

requests.exceptions.RequestException -- on failure.

Return type:

dict

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.

Return type:

None

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:

None

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:
Return type:

None

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:
Return type:

None

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.

Return type:

None