diff --git a/app/api/WindowsCommand.php b/app/api/windows/WindowsCommand.php similarity index 97% rename from app/api/WindowsCommand.php rename to app/api/windows/WindowsCommand.php index 51699400..573f4458 100644 --- a/app/api/WindowsCommand.php +++ b/app/api/windows/WindowsCommand.php @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -namespace App\Api; +namespace App\Api\Windows; /** * Description of WindowsCommand @@ -32,6 +32,7 @@ * @author cjacobsen */ +use System\App\WindowsLogger; use System\Core; class WindowsCommand @@ -53,48 +54,48 @@ public function getHostname() return $this->hostname; } - public function getCmd() + public function setHostname($hostname) { - return $this->cmd; + $this->hostname = $hostname; + return $this; } - public function getResponse() + public function getCmd() { - return $this->response; + return $this->cmd; } - public function getReturnCode() + public function setCmd($cmd) { - return $this->returnCode; + $this->cmd = $cmd; + return $this; } - public function getLogger() + public function getResponse() { - return $this->logger; + return $this->response; } - public function setHostname($hostname) + public function setResponse($response) { - $this->hostname = $hostname; + $this->response = $response; return $this; } - public function setCmd($cmd) + public function getReturnCode() { - $this->cmd = $cmd; - return $this; + return $this->returnCode; } - public function setResponse($response) + public function setReturnCode($returnCode) { - $this->response = $response; + $this->returnCode = $returnCode; return $this; } - public function setReturnCode($returnCode) + public function getLogger() { - $this->returnCode = $returnCode; - return $this; + return $this->logger; } public function setLogger($logger) diff --git a/app/api/WindowsRM.php b/app/api/windows/WindowsRM.php similarity index 93% rename from app/api/WindowsRM.php rename to app/api/windows/WindowsRM.php index 18ebdaf9..bdf7ff27 100644 --- a/app/api/WindowsRM.php +++ b/app/api/windows/WindowsRM.php @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -namespace App\Api; +namespace App\Api\Windows; /** * Description of WindowsRM @@ -40,15 +40,14 @@ class WindowsRM /** * - * @var AppLogger + * @var WindowsRM */ - private $logger; - + public static $instance; /** * - * @var WindowsRM + * @var AppLogger */ - public static $instance; + private $logger; function __construct() { @@ -73,6 +72,13 @@ public static function get() return self::$instance; } + public static function reboot(string $destination) + { + $cmd = new WindowsCommand(); + $cmd->setCmd('shutdown -r -m ' . $destination . ' -t 60'); + AppLogger::get()->info('Rebooting ' . $destination); + } + public function testConnection($computer) { $this->logger->info("Testing connection to $computer"); @@ -94,14 +100,6 @@ public function testConnection($computer) //return $this->portReachable($computer, 5985); } - public function rebootWorkstation($hostname) - { - - $cmd = new WindowsCommand(); - $cmd->setCmd("shutdown /r /t 30") - ->setHostname($hostname); - } - public function DNSLookup($hostname) { $record = dns_get_record($hostname); @@ -127,4 +125,12 @@ private function portReachable($host, $port) //echo PHP_EOL; } + public function rebootWorkstation($hostname) + { + + $cmd = new WindowsCommand(); + $cmd->setCmd("shutdown /r /t 30") + ->setHostname($hostname); + } + }