diff --git a/src/rocks-command/remove/host/plugin_sge.py b/src/rocks-command/remove/host/plugin_sge.py index 70d8ceb..eb5cb5b 100644 --- a/src/rocks-command/remove/host/plugin_sge.py +++ b/src/rocks-command/remove/host/plugin_sge.py @@ -94,6 +94,7 @@ import subprocess import shlex import rocks.commands +import syslog class Plugin(rocks.commands.Plugin): @@ -112,24 +113,27 @@ def run(self, host): # remove the host from every defined SGE 'host group' # cmd = 'qconf -shgrpl' - p = subprocess.Popen(shlex.split(cmd), stdin = subprocess.PIPE, - stdout = subprocess.PIPE, stderr = subprocess.PIPE) + try: + p = subprocess.Popen(shlex.split(cmd), stdin = subprocess.PIPE, + stdout = subprocess.PIPE, stderr = subprocess.PIPE) - for group in p.stdout.readlines(): - cmd = 'qconf -dattr hostgroup hostlist %s %s' % \ - (host, group) + for group in p.stdout.readlines(): + cmd = 'qconf -dattr hostgroup hostlist %s %s' % \ + (host, group) + p = subprocess.Popen(shlex.split(cmd), + stdin = subprocess.PIPE, + stdout = subprocess.PIPE, + stderr = subprocess.PIPE) + + # + # remove the host as a SGE 'execution host' + # + cmd = 'qconf -de %s' % host p = subprocess.Popen(shlex.split(cmd), stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE) - - # - # remove the host as a SGE 'execution host' - # - cmd = 'qconf -de %s' % host - p = subprocess.Popen(shlex.split(cmd), - stdin = subprocess.PIPE, - stdout = subprocess.PIPE, - stderr = subprocess.PIPE) + except: + syslog.syslog(syslog.LOG_INFO, 'sge remove fail for %s' % host)