From 7ccf5e8c8bcc64a743e241ff9219c13a62d9765f Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Wed, 14 Jul 2021 13:09:23 +0200 Subject: [PATCH] NEW FEATURE: reboot jobs can fail as well --- src/Repository/Job.php | 9 ++++----- templates/job/add.html.twig | 9 +++++++-- templates/job/edit.html.twig | 9 +++++++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Repository/Job.php b/src/Repository/Job.php index c7e3dd8..f2cf31e 100644 --- a/src/Repository/Job.php +++ b/src/Repository/Job.php @@ -134,13 +134,11 @@ class Job extends Repository } if($job['data']['hosttype'] == 'local') { $return = $this->runLocalCommand($command); - $return['failed'] = !in_array($return['exitcode'], $job['data']['response']); - return $return; } elseif($job['data']['hosttype'] == 'ssh') { $return = $this->runSshCommand($command, $job['data']['host'], $job['data']['user'], $job['data']['ssh-privkey'], $job['data']['privkey-password']); - $return['failed'] = !in_array($return['exitcode'], $job['data']['response']); - return $return; } + $return['failed'] = !in_array($return['exitcode'], $job['data']['response']); + return $return; } private function runLocalCommand(string $command): array @@ -229,7 +227,7 @@ class Job extends Repository } elseif($job['data']['hosttype'] == 'local') { $return = $this->runLocalCommand($job['data']['getservices-command']); } - + $return['failed'] = !in_array($return['exitcode'], $job['data']['getservices-response']); return $return; } } @@ -385,6 +383,7 @@ class Job extends Repository case 'reboot': $values['data']['reboot-command'] = $values['reboot-command']; $values['data']['getservices-command'] = $values['getservices-command']; + $values['data']['getservices-response'] = explode(',',$values['getservices-response']); $values['data']['reboot-duration'] = $values['reboot-duration']; if(!empty($values['reboot-delay'])) { $newsecretkey = count($values['var-value']); diff --git a/templates/job/add.html.twig b/templates/job/add.html.twig index 6a2d486..821749f 100644 --- a/templates/job/add.html.twig +++ b/templates/job/add.html.twig @@ -95,13 +95,18 @@

Reboot job details

- + Use {reboot-delay} or {reboot-delay-secs} to add the delay in your command
- + +
+ +
+ +
diff --git a/templates/job/edit.html.twig b/templates/job/edit.html.twig index e264903..a23b301 100644 --- a/templates/job/edit.html.twig +++ b/templates/job/edit.html.twig @@ -113,13 +113,18 @@

Reboot job details

- + Use {reboot-delay} or {reboot-delay-secs} to add the delay in your command
- + +
+ +
+ +