Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Jacobsen Work committed Mar 4, 2021
1 parent f2e2767 commit bca527f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 33 deletions.
39 changes: 20 additions & 19 deletions app/api/WindowsCommand.php → app/api/windows/WindowsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
* THE SOFTWARE.
*/

namespace App\Api;
namespace App\Api\Windows;

/**
* Description of WindowsCommand
*
* @author cjacobsen
*/

use System\App\WindowsLogger;
use System\Core;

class WindowsCommand
Expand All @@ -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)
Expand Down
34 changes: 20 additions & 14 deletions app/api/WindowsRM.php → app/api/windows/WindowsRM.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* THE SOFTWARE.
*/

namespace App\Api;
namespace App\Api\Windows;

/**
* Description of WindowsRM
Expand All @@ -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()
{
Expand All @@ -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");
Expand All @@ -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);
Expand All @@ -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);
}

}

0 comments on commit bca527f

Please sign in to comment.