NEW FEATURE: reboot jobs can fail as well
This commit is contained in:
parent
3c41845316
commit
7ccf5e8c8b
|
@ -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']);
|
||||
|
|
|
@ -95,13 +95,18 @@
|
|||
<h4>Reboot job details</h4>
|
||||
<div class="mb-3">
|
||||
<label for="reboot-command">Reboot command</label>
|
||||
<input type="text" name="reboot-command" class="form-control" id="command" placeholder="systemctl reboot">
|
||||
<input type="text" name="reboot-command" class="form-control" id="reboot-command" placeholder="systemctl reboot">
|
||||
<small id="reboot-command-help" class="form-text text-muted">Use {reboot-delay} or {reboot-delay-secs} to add the delay in your command</small>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="getservices-command">Get services command</label>
|
||||
<input type="text" name="getservices-command" class="form-control" id="command" placeholder="systemctl list-units">
|
||||
<input type="text" name="getservices-command" class="form-control" id="getservices-command" placeholder="systemctl list-units">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="getservices-response">Get services command exit code</label>
|
||||
<input type="text" name="getservices-response" class="form-control" id="getservices-response" placeholder="0">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
|
|
|
@ -113,13 +113,18 @@
|
|||
<h4>Reboot job details</h4>
|
||||
<div class="mb-3">
|
||||
<label for="reboot-command">Reboot command</label>
|
||||
<input type="text" name="reboot-command" class="form-control" id="command" placeholder="systemctl reboot" value="{% if attribute(data, 'reboot-command') is not empty %}{{ attribute(data, 'reboot-command') }}{% endif %}">
|
||||
<input type="text" name="reboot-command" class="form-control" id="reboot-command" placeholder="systemctl reboot" value="{% if attribute(data, 'reboot-command') is not empty %}{{ attribute(data, 'reboot-command') }}{% endif %}">
|
||||
<small id="reboot-command-help" class="form-text text-muted">Use {reboot-delay} or {reboot-delay-secs} to add the delay in your command</small>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="getservices-command">Get services command</label>
|
||||
<input type="text" name="getservices-command" class="form-control" id="command" placeholder="systemctl list-units" value="{% if attribute(data, 'getservices-command') is not empty %}{{ attribute(data, 'getservices-command') }}{% endif %}">
|
||||
<input type="text" name="getservices-command" class="form-control" id="getservices)command" placeholder="systemctl list-units" value="{% if attribute(data, 'getservices-command') is not empty %}{{ attribute(data, 'getservices-command') }}{% endif %}">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="getservices-response">Get services command exit code</label>
|
||||
<input type="text" name="getservices-response" class="form-control" id="getservices-response" placeholder="0" value="{% if attribute(data, 'getservices-response') is not empty %}{{ attribute(data, 'getservices-response') | join(',') }}{% endif %}">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
|
|
Loading…
Reference in New Issue