Skip to content
Snippets Groups Projects
Commit e03b3525 authored by Eric Kooistra's avatar Eric Kooistra
Browse files

Utility to run a command in parallel on multiple LCUs.

parent 814288ec
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python
###############################################################################
#
# Copyright (C) 2017
# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
# Author:
# . Daniel van der Schuur
# . Eric Kooistra
# Purpose:
# . Run same UniBoard command on remote dish LCUs in parallel
# Usage:
# . python run_command_on_lcus.py --tel <telescopes 2,3,4,..,c,d> -s <'command string, in quotes if it has spaces'>
#
# For example to read current time on different LCUs, all LCUs should report nearly the same time:
#
# python run_command_on_lcus.py --tel 2,5,6,8,9,c,d -s 'python $UPE/base/print_time.py'
import sys
import os
import time
import shell
import common as cm
import test_case
tc = test_case.Testcase('RUN_ON_LCUs - ', '')
lcu_str = 'Targetting LCUs: '
LCUS = []
for tel in tc.telStrList:
if tel == '':
continue
LCUS.append('lcu-rt' + str(tel))
lcu_str = lcu_str + ' lcu-rt' + str(tel) + ','
tc.append_log(0, lcu_str[:-1])
#tc.append_log(0, 'Wait for PPS')
#cmd_str = 'python $UPE/peripherals/util_ppsh.py --unb 0 --bn 0 -n 4'
#print 'cmd_str = %s' % cmd_str
#shell.ssh_cmd(LCUS[0], cmd_str, tc)
tc.append_log(0, 'Issue parallel command')
cmd_str = tc.gpString
for lcu in LCUS:
lcu_cmd = ['/usr/bin/ssh', 'ssh', lcu, cmd_str]
print lcu_cmd
os.spawnl(os.P_NOWAIT, *lcu_cmd)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment