Fix representation of signal.SIG* constants

Pass signals as strings instead of using python constants
which depend on host system and have different types on py27 vs py3.

Change-Id: Ib8d7136bb3aed125a987678672142ce72e33af6f
Closes-bug: #1836736
This commit is contained in:
Ilya Shakhat 2019-07-19 16:02:58 +02:00
parent 82cb432398
commit e55bd553aa
3 changed files with 6 additions and 7 deletions

View File

@ -30,8 +30,8 @@ def main():
'echo -en \'/bin/bash\\npids=`ps ax | '
'grep -v grep | '
'grep %s | awk {{\\047print $1\\047}}`; '
'echo $pids | xargs kill -19; sleep %s; '
'echo $pids | xargs kill -18; rm \' >> $tf; '
'echo $pids | xargs kill -SIGSTOP; sleep %s; '
'echo $pids | xargs kill -SIGCONT; rm \' >> $tf; '
'echo -n $tf >> $tf; '
'chmod 770 $tf; nohup $tf &"') % (grep, sec)
rc, stdout, stderr = module.run_command(cmd, check_rc=True)

View File

@ -19,7 +19,7 @@ def main():
module = AnsibleModule(
argument_spec=dict(
grep=dict(required=True, type='str'),
sig=dict(required=True, type='int')
sig=dict(required=True, type='str')
))
grep = module.params['grep']

View File

@ -12,7 +12,6 @@
# limitations under the License.
import logging
import signal
from os_faults.ansible import executor
from os_faults.api import error
@ -121,7 +120,7 @@ class ServiceAsProcess(service.Service):
def kill(self, nodes=None):
task = {
'kill': {
'grep': self.grep, 'sig': signal.SIGKILL
'grep': self.grep, 'sig': 'SIGKILL'
},
'become': 'yes',
}
@ -138,7 +137,7 @@ class ServiceAsProcess(service.Service):
else:
task = {
'kill': {
'grep': self.grep, 'sig': signal.SIGSTOP
'grep': self.grep, 'sig': 'SIGSTOP'
},
'become': 'yes',
}
@ -148,7 +147,7 @@ class ServiceAsProcess(service.Service):
def unfreeze(self, nodes=None):
task = {
'kill': {
'grep': self.grep, 'sig': signal.SIGCONT
'grep': self.grep, 'sig': 'SIGCONT'
},
'become': 'yes',
}