diff options
-rw-r--r-- | modules-available/rebootcontrol/inc/rebootcontrol.inc.php | 30 | ||||
-rw-r--r-- | modules-available/rebootcontrol/page.inc.php | 9 |
2 files changed, 31 insertions, 8 deletions
diff --git a/modules-available/rebootcontrol/inc/rebootcontrol.inc.php b/modules-available/rebootcontrol/inc/rebootcontrol.inc.php new file mode 100644 index 00000000..789552cd --- /dev/null +++ b/modules-available/rebootcontrol/inc/rebootcontrol.inc.php @@ -0,0 +1,30 @@ +<?php + +class RebootControl +{ + + /** + * @param string[] $uuids List of machineuuids to reboot + * @return false|array task struct for the reboot job + */ + public static function reboot($uuids) + { + $list = RebootQueries::getMachinesByUuid($uuids); + if (empty($list)) + return false; + return self::execute($list, false, 0, 0); + } + + public static function execute($list, $shutdown, $minutes, $locationId) + { + return Taskmanager::submit("RemoteReboot", array( + "clients" => $list, + "shutdown" => $shutdown, + "minutes" => $minutes, + "locationId" => $locationId, + "sshkey" => SSHKey::getPrivateKey(), + "port" => 9922, // Hard-coded, must match mgmt-sshd module + )); + } + +}
\ No newline at end of file diff --git a/modules-available/rebootcontrol/page.inc.php b/modules-available/rebootcontrol/page.inc.php index d7083528..db7882d9 100644 --- a/modules-available/rebootcontrol/page.inc.php +++ b/modules-available/rebootcontrol/page.inc.php @@ -45,14 +45,7 @@ class Page_RebootControl extends Page // TODO: we could also check if the locationid is equal or a sublocation of the $locationId from above // (this would be more of a sanity check though, or does the UI allow selecting machines from different locations) - $task = Taskmanager::submit("RemoteReboot", array( - "clients" => $list, - "shutdown" => $shutdown, - "minutes" => $minutes, - "locationId" => $locationId, - "sshkey" => $privKey, - "port" => 22, // TODO: Get from ssh config - )); + $task = RebootControl::execute($list, $shutdown, $minutes, $locationId); Util::redirect("?do=rebootcontrol&taskid=".$task["id"]); } |