Volans has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/351295 )

Change subject: Mediawiki: allow to manage ReadOnly and master DC via conftool
......................................................................

Mediawiki: allow to manage ReadOnly and master DC via conftool

Bug: T163398
Change-Id: Ie3427d5db053a7a28b449438b86a6ca1008f9a39
---
M switchdc/lib/mediawiki.py
1 file changed, 32 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/switchdc 
refs/changes/95/351295/1

diff --git a/switchdc/lib/mediawiki.py b/switchdc/lib/mediawiki.py
index 93a3a9c..c39b23a 100644
--- a/switchdc/lib/mediawiki.py
+++ b/switchdc/lib/mediawiki.py
@@ -4,7 +4,9 @@
 import requests
 
 from switchdc import SwitchdcError
+from switchdc.dry_run import is_dry_run
 from switchdc.log import logger
+from switchdc.lib.confctl import Confctl
 from switchdc.lib.remote import Remote, RemoteExecutionError
 
 
@@ -46,6 +48,36 @@
     remote.sync(command)
 
 
+def set_readonly(readonly, dc):
+    """Set the Conftool readonly variable for MediaWiki config in a specific 
dc.
+
+    Arguments:
+    readonly -- the readonly message to set it read-only, False to set it 
read-write.
+    dc       -- the DC for which the configuration must be changed.
+    """
+    mwconfig = Confctl('mwconfig')
+    mwconfig.update({'val': readonly}, name='ReadOnly', scope=dc)
+    for obj in mwconfig.get(scope=dc, name='ReadOnly'):
+        if obj.val != readonly and not is_dry_run():
+            logger.error('MediaWiki config readonly record was not set: 
{record}'.format(record=obj.key))
+            raise SwitchdcError(1)
+
+
+def set_master_datacenter(datacenter):
+    """Set the MediaWiki config master datacenter variable in Conftool.
+
+    Arguments:
+    datacenter -- the new master datacenter.
+    """
+    mwconfig = Confctl('mwconfig')
+    mwconfig.update({'val': True}, name='WMFMasterDatacenter', scope='common')
+    for obj in mwconfig.get(name='WMFMasterDatacenter', scope='common'):
+        if obj.val != datacenter and not is_dry_run():
+            logger.error('MediaWiki config WMFMasterDatacenter record was not 
set: {record}'.format(
+                record=obj.key))
+            raise SwitchdcError(1)
+
+
 def check_siteinfo(jq_query, dc=None, attempts=1, sleep=5):
     """Check that siteinfo JSON matches the jq_query. Raises SwitchdcError on 
failure.
 

-- 
To view, visit https://gerrit.wikimedia.org/r/351295
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie3427d5db053a7a28b449438b86a6ca1008f9a39
Gerrit-PatchSet: 1
Gerrit-Project: operations/switchdc
Gerrit-Branch: master
Gerrit-Owner: Volans <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to