Muehlenhoff has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/373079 )
Change subject: Migrate Cumin interface into a separate function
......................................................................
Migrate Cumin interface into a separate function
To be used by various commands.
Change-Id: I11f1142268cdaf6d72ce3e3ade6ee5ccb393343b
---
M server/debdeploy.py
1 file changed, 35 insertions(+), 26 deletions(-)
Approvals:
Muehlenhoff: Looks good to me, approved
jenkins-bot: Verified
diff --git a/server/debdeploy.py b/server/debdeploy.py
index 5ca64be..f5f36ba 100755
--- a/server/debdeploy.py
+++ b/server/debdeploy.py
@@ -65,6 +65,37 @@
print self.buf
+def run_cumin(cmd):
+ '''
+ Run Cumin and discard the output shown by the transport
+
+ cmd : The Command to be executed
+ '''
+
+ with open('/dev/null', 'w') as discard_output:
+ oldstdout = sys.stdout
+ oldstderr = sys.stderr
+ sys.stdout = discard_output
+ sys.stderr = discard_output
+
+ worker = transport.Transport.new(cumin_config, logging)
+ hosts = query.Query(cumin_config).execute('A:all')
+
+ worker.target = transports.Target(hosts, batch_size=100,
batch_sleep=None, logger=logging)
+ worker.commands = [cmd]
+
+ worker.timeout = None
+ worker.handler = 'sync'
+ worker.success_threshold = 0.1
+ worker.batch_size = 100
+ worker.batch_sleep = None
+ exit_code = worker.execute()
+ sys.stdout = oldstdout
+ sys.stderr = oldstderr
+
+ return worker
+
+
def deploy_update(source, update_type, update_file, servergroup,
supported_distros, fixes):
'''
Initiate a deployment.
@@ -115,9 +146,6 @@
for nodeset, output in worker.get_results():
print output
-# print worker.handler.counters
-
-
def detect_restarts(libnames, servergroup, verbose):
'''
Query for necessary restarts after a library or interpreter upgrade
@@ -128,30 +156,11 @@
verbose : If enabled, the full of hosts needing a restart is shown
(boolean)
'''
- with open('/dev/null', 'w') as discard_output:
- oldstdout = sys.stdout
- oldstderr = sys.stderr
- sys.stdout = discard_output
- sys.stderr = discard_output
+ cmd = '/usr/bin/debdeploy-restarts --json --libname '
+ for lib in libnames:
+ cmd += lib + " "
- worker = transport.Transport.new(cumin_config, logging)
- hosts = query.Query(cumin_config).execute('A:all')
-
- cmd = '/usr/bin/debdeploy-restarts --json --libname '
- for lib in libnames:
- cmd += lib + " "
-
- worker.target = transports.Target(hosts, batch_size=100,
batch_sleep=None, logger=logging)
- worker.commands = [cmd]
-
- worker.timeout = None
- worker.handler = 'sync'
- worker.success_threshold = 0.1
- worker.batch_size = 100
- worker.batch_sleep = None
- exit_code = worker.execute()
- sys.stdout = oldstdout
- sys.stderr = oldstderr
+ worker = run_cumin(cmd)
restarts_per_lib = {}
for nodeset, output in worker.get_results():
--
To view, visit https://gerrit.wikimedia.org/r/373079
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I11f1142268cdaf6d72ce3e3ade6ee5ccb393343b
Gerrit-PatchSet: 1
Gerrit-Project: operations/debs/debdeploy
Gerrit-Branch: master
Gerrit-Owner: Muehlenhoff <[email protected]>
Gerrit-Reviewer: Muehlenhoff <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits