Volans has submitted this change and it was merged. ( 
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(-)

Approvals:
  Giuseppe Lavagetto: Looks good to me, but someone else must approve
  jenkins-bot: Verified
  Volans: Looks good to me, approved



diff --git a/switchdc/lib/mediawiki.py b/switchdc/lib/mediawiki.py
index 93a3a9c..461d14d 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': datacenter}, 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: merged
Gerrit-Change-Id: Ie3427d5db053a7a28b449438b86a6ca1008f9a39
Gerrit-PatchSet: 3
Gerrit-Project: operations/switchdc
Gerrit-Branch: master
Gerrit-Owner: Volans <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: Volans <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to