if check_scheduled.returncode == 0:
break
time.sleep(1)
- if i == retries - 1:
- log.warning("The program %s was not scheduled and is not running", program)
+ else:
+ log.warning("The program %s was not scheduled and is not running", program)
+ return
cmd = "/usr/intranator/bin/arnied_helper --wait-for-program-end " \
+ program.upper() + " --wait-for-program-timeout " + str(timeout)
# add one second to make sure arnied_helper is finished when we expire
return first_instance
-def wait_for_generate(vm=None):
+def wait_for_generate(timeout=300, vm=None):
"""
Wait for the 'generate' program to complete.
- :param vm: vm to run on if running on a guest instead of the host
- :type vm: VM object or None
+ Arguments are similar to the ones from :py:method:`wait_for_run`.
"""
- ahelper = "/usr/intranator/bin/arnied_helper"
- cmd = ahelper + " --is-scheduled-or-running GENERATE"
- need_to_wait = run_cmd(cmd=cmd, ignore_errors=True, vm=vm).returncode == 0
- if need_to_wait:
- cmd = ahelper + " --wait-for-program-end GENERATE"
- result = run_cmd(cmd=cmd, vm=vm)
- log.debug(result)
- cmd = ahelper + " --is-scheduled-or-running GENERATE_OFFLINE"
- need_to_wait = run_cmd(cmd=cmd, ignore_errors=True, vm=vm).returncode == 0
- if need_to_wait:
- cmd = ahelper + " --wait-for-program-end GENERATE_OFFLINE"
- result = run_cmd(cmd=cmd, vm=vm)
- log.debug(result)
+ wait_for_run('generate', timeout=timeout, retries=1, vm=vm)
+ wait_for_run('generate_offline', timeout=timeout, retries=1, vm=vm)
def unset_cnf(varname="", instance="", vm=None):
cmd = "get_cnf %s %s | set_cnf -x" % (varname, instance)
run_cmd(cmd=cmd, vm=vm)
- wait_for_generate(vm)
+ wait_for_generate(vm=vm)
def set_cnf(config_files, kind="cnf", timeout=30, vm=None):
result.returncode))
try:
- wait_for_generate(vm)
+ wait_for_generate(vm=vm)
except Exception as ex:
# handle cases of remote configuration that leads to connection meltdown
if vm is not None and isinstance(ex, sys.modules["aexpect"].ShellProcessTerminatedError):
fail_switch = False
cmds = [
{"cmd": "pgrep -l -x arnied", "stdout": b"", "returncode": 0},
+
{"cmd": 'echo "LICENSE_ACCEPTED,0: \\"1\\"" | set_cnf', "stdout": b"", "returncode": 0},
{"cmd": '/usr/intranator/bin/arnied_helper --wait-for-program-end GENERATE', "stdout": b"", "returncode": 0},
+
{"cmd": 'get_cnf PROVIDER 1', "stdout": b"PRODIVER 1, 'autotest'", "returncode": 0},
{"cmd": 'tell-connd --online P1', "stdout": b"", "returncode": 0},
+
{"cmd": 'get_cnf VIRSCAN_UPDATE_CRON | set_cnf -x', "stdout": b"", "returncode": 0},
{"cmd": '/usr/intranator/bin/arnied_helper --is-scheduled-or-running GENERATE', "stdout": b"", "returncode": 1},
+ {"cmd": '/usr/intranator/bin/arnied_helper --wait-for-program-end GENERATE --wait-for-program-timeout 300', "stdout": b"", "returncode": 1},
{"cmd": '/usr/intranator/bin/arnied_helper --is-scheduled-or-running GENERATE_OFFLINE', "stdout": b"", "returncode": 1},
+ {"cmd": '/usr/intranator/bin/arnied_helper --wait-for-program-end GENERATE_OFFLINE --wait-for-program-timeout 300', "stdout": b"", "returncode": 1},
{"cmd": 'echo \'VIRSCAN_UPDATE_DNS_PUSH,0:"0"\' |set_cnf', "stdout": b"", "returncode": 0},
{"cmd": 'rm -f /var/intranator/schedule/UPDATE_VIRSCAN_NODIAL*', "stdout": b"", "returncode": 0},
+
{"cmd": '/usr/intranator/bin/arnied_helper --transfer-mail', "stdout": b"", "returncode": 0},
]
asserted_cmds = []
- def __init__(self, cmd="", ignore_errors=False, vm=None):
+ def __init__(self, cmd="", ignore_errors=False, vm=None, timeout=60):
self.returncode = 0
self.stdout = b""
self._get_result(cmd)
# arnied_wrapper.go_online(1)
def test_disable_virscan(self):
- DummyCmdOutputMapping.asserted_cmds = self.cmd_db[5:10]
+ DummyCmdOutputMapping.asserted_cmds = self.cmd_db[5:12]
arnied_wrapper.disable_virscan()
def test_email_transfer(self):
- DummyCmdOutputMapping.asserted_cmds = self.cmd_db[10:11]
+ DummyCmdOutputMapping.asserted_cmds = self.cmd_db[12:13]
arnied_wrapper.email_transfer()