diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index ed2cffc..2f601d5 100644
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -85,9 +85,9 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->get('delete/(:num)', 'HPILOController::delete/$1', ['filter' => 'authFilter:master']);
$routes->get('toggle/(:num)/(:hash)', 'HPILOController::toggle/$1/$2', ['filter' => 'authFilter:master,director']);
$routes->post('batchjob', 'HPILOController::batchjob', ['filter' => 'authFilter:master']);
- $routes->post('console/(:num)', 'HPILOController::console/$1', ['filter' => 'authFilter:master']);
- $routes->post('reset/(:num)/(:alpha)', 'HPILOController::reset/$1/$2', ['filter' => 'authFilter:master']);
- $routes->post('reload/(:num)', 'HPILOController::reload/$1', ['filter' => 'authFilter:master']);
+ $routes->get('console/(:num)', 'HPILOController::console/$1', ['filter' => 'authFilter:master']);
+ $routes->get('reset/(:num)/(:alpha)', 'HPILOController::reset/$1/$2', ['filter' => 'authFilter:master']);
+ $routes->get('reload/(:num)', 'HPILOController::reload/$1', ['filter' => 'authFilter:master']);
});
});
/*
diff --git a/app/Controllers/Admin/HPILOController.php b/app/Controllers/Admin/HPILOController.php
index 0bc5081..db2823d 100644
--- a/app/Controllers/Admin/HPILOController.php
+++ b/app/Controllers/Admin/HPILOController.php
@@ -65,8 +65,10 @@ class HPILOController extends \App\Controllers\Admin\AdminController
private function getAdapter(HPILOEntity $entity)
{
if (is_null($this->_adapter)) {
- $adapterClass = getenv('hpilo.api.adapter') ? getenv('hpilo.api.adapter') : "\App\Libraries\Log\GuzzleAdapter";
- $this->_adapter = new $adapterClass($entity, getenv('hpilo.api.debug') ? getenv('hpilo.api.debug') : false);
+ $adapterClass = getenv('hpilo.api.adapter') ?: "\App\Libraries\Adapter\API\GuzzleAdapter";
+ $this->_adapter = new $adapterClass(getenv('hpilo.api.debug') ?: false);
+ $this->_adapter->setServerInfo($entity->getIP(), $entity->getPort());
+ $this->_adapter->setAccountInfo($entity->getID(), $entity->getPassword());
}
return $this->_adapter;
}
@@ -131,6 +133,28 @@ class HPILOController extends \App\Controllers\Admin\AdminController
$this->_viewDatas['entity'] = $entity;
return view($this->_viewPath . '/console_iframe', $this->_viewDatas);
}
+
+ final public function reset(int $uid, string $type)
+ {
+ try {
+ $entity = $this->_model->getEntity($uid);
+ if (!in_array($type, ["On", "Off", "Restart"])) {
+ throw new \Exception(__FUNCTION__ . "에서 {$type}은 기능은 없습니다.");
+ }
+ $ilo = new HPILO4($this->getAdapter($entity));
+ $results = $ilo->reset($type);
+ Log::add("warning", var_export($results, true));
+ $message = "{$entity->getTitle()} " . __FUNCTION__ . " 완료하였습니다.";
+ Log::save("{$this->_viewDatas['title']} {$message}");
+ return alert_CommonHelper($message, $this->_session->get(SESSION_NAMES['RETURN_URL']));
+ } catch (\Exception $e) {
+ $message = "{$entity->getTitle()} " . __FUNCTION__ . " 실패하였습니다.";
+ Log::add("warning", $message . "
\n{$e->getMessage()}");
+ Log::save("{$this->_viewDatas['title']} {$message}", false);
+ return alert_CommonHelper($message, 'back');
+ }
+ }
+
private function refresh(HPILO4 $ilo, HPILOEntity $entity)
{
$entity = $ilo->refresh($entity);
@@ -143,28 +167,6 @@ class HPILOController extends \App\Controllers\Admin\AdminController
}
return $entity;
}
- final public function reset(int $uid, string $type)
- {
- try {
- $entity = $this->_model->getEntity($uid);
- if (!in_array($type, ["On", "Off", "Restart"])) {
- throw new \Exception(__FUNCTION__ . "에서 {$type}은 기능은 없습니다.");
- }
- $ilo = new HPILO4($this->getAdapter($entity));
- $results = $ilo->reset($type);
- Log::add("warning", var_export($results, true));
- // sleep(DEFAULT_RERESH_WAITTIME);
- // $entity = $this->refresh($ilo, $entity);
- $message = "{$entity->getTitle()} " . __FUNCTION__ . " 완료하였습니다.";
- Log::save("{$this->_viewDatas['title']} {$message}");
- return alert_CommonHelper($message, $this->_session->get(SESSION_NAMES['RETURN_URL']));
- } catch (\Exception $e) {
- $message = "{$entity->getTitle()} " . __FUNCTION__ . " 실패하였습니다.";
- Log::add("warning", $message . "
\n{$e->getMessage()}");
- Log::save("{$this->_viewDatas['title']} {$message}", false);
- return alert_CommonHelper($message, 'back');
- }
- }
final public function reload(int $uid)
{
try {
diff --git a/app/Entities/HPILOEntity.php b/app/Entities/HPILOEntity.php
index 34dd9cc..9055fbe 100644
--- a/app/Entities/HPILOEntity.php
+++ b/app/Entities/HPILOEntity.php
@@ -22,4 +22,21 @@ class HPILOEntity extends CommonEntity
{
return "uid:{$this->attributes['uid']}|{$this->attributes['customer']}|{$this->attributes['model']}";
}
+
+ public function getIP()
+ {
+ return $this->attributes['ip'];
+ }
+ public function getPort()
+ {
+ return $this->attributes['port'];
+ }
+ public function getID()
+ {
+ return $this->attributes['id'];
+ }
+ public function getPassword()
+ {
+ return $this->attributes['passwd'];
+ }
}
diff --git a/app/Libraries/Adapter/API/Adapter.php b/app/Libraries/Adapter/API/Adapter.php
index fb48909..f8e5217 100644
--- a/app/Libraries/Adapter/API/Adapter.php
+++ b/app/Libraries/Adapter/API/Adapter.php
@@ -2,45 +2,49 @@
namespace App\Libraries\Adapter\API;
-use \App\Entities\HPILOEntity;
-
// 참고:https://github.com/SyntaxPhoenix/iloclient
abstract class Adapter
{
- private $_entity = null;
protected $_client = null;
+ protected $_serverInfo = array();
+ protected $_accountInfo = array();
protected $_debug = false;
- protected function __construct($entity, $debug = false)
+ protected function __construct($debug = false)
{
- $this->_entity = $entity;
$this->_debug = $debug;
}
abstract protected function getClient();
abstract protected function requestURL(string $url, string $method, array $datas = []): object;
- final protected function getEntity()
+ final public function setServerInfo(string $ip, int $port)
{
- return $this->_entity;
+ $this->_serverInfo['ip'] = $ip;
+ $this->_serverInfo['port'] = $port;
}
- protected function getServerInfo($scheme = "https://", $delimeter = ":"): string
+ final protected function getServerInfo($scheme = "https://", $delimeter = ":"): string
{
- return $scheme . $this->getEntity()->getIP() . $delimeter . $this->getEntity()->getPort();
+ return $scheme . $this->_serverInfo['ip'] . $delimeter . $this->_serverInfo['port'];
}
- protected function getAccountInfo($type = 'basic'): array
+ final public function setAccountInfo(string $id, int $password)
+ {
+ $this->_serverInfo['id'] = $id;
+ $this->_serverInfo['password'] = $password;
+ }
+ final protected function getAccountInfo($authType = 'basic'): array
{
//type: basic , digest
- return array($this->getEntity()->getID(), $this->getEntity()->getPassword(), $type);
+ return array($this->_serverInfo['id'], $this->_serverInfo['password'], $authType);
}
protected function isSSLVerifiy(): bool
{
- return getenv('hpilo.ssl') == 'true' ? true : false;
+ return getenv('api.ssl') == 'true' ? true : false;
}
protected function getCookieFile()
{
- return PATHS['API'] . getenv('api.cookie') ? getenv('api.cookie') : "api-cookie_" . date("Ymd") . ".log";
+ return PATHS['API'] . getenv('api.cookie.file') ?: "api-cookie_" . date("Ymd") . ".log";
}
protected function getDebugFile()
{
- return PATHS['API'] . getenv('api.debug') ? getenv('api.debug') : "api-debug_" . date("Ymd") . ".log";
+ return PATHS['API'] . getenv('api.debug.file') ?: "api-debug_" . date("Ymd") . ".log";
}
final public function get(string $url): object
diff --git a/app/Libraries/Adapter/API/CurlAdapter.php b/app/Libraries/Adapter/API/CurlAdapter.php
index 21ee009..53306f6 100644
--- a/app/Libraries/Adapter/API/CurlAdapter.php
+++ b/app/Libraries/Adapter/API/CurlAdapter.php
@@ -7,9 +7,9 @@ namespace App\Libraries\Adapter\API;
// https://github.com/SyntaxPhoenix/iloclient
class CurlAdapter extends Adapter
{
- public function __construct($entity, $debug = false)
+ public function __construct($debug = false)
{
- parent::__construct($entity, $debug);
+ parent::__construct($debug);
}
private function debugging($response, array $datas = array())
{
diff --git a/app/Libraries/Adapter/API/GuzzleAdapter.php b/app/Libraries/Adapter/API/GuzzleAdapter.php
index 3575ac0..ee7232a 100644
--- a/app/Libraries/Adapter/API/GuzzleAdapter.php
+++ b/app/Libraries/Adapter/API/GuzzleAdapter.php
@@ -8,9 +8,9 @@ use GuzzleHttp\Exception\ClientException;
class GuzzleAdapter extends Adapter
{
private $_jar = null;
- public function __construct($entity, $debug = false)
+ public function __construct($debug = false)
{
- parent::__construct($entity, $debug);
+ parent::__construct($debug);
}
private function getCookieJar(): \GuzzleHttp\Cookie\CookieJar
{
diff --git a/app/Libraries/Adapter/API/LocalAdapter.php b/app/Libraries/Adapter/API/LocalAdapter.php
index 13d3b37..3dd0195 100644
--- a/app/Libraries/Adapter/API/LocalAdapter.php
+++ b/app/Libraries/Adapter/API/LocalAdapter.php
@@ -4,9 +4,9 @@ namespace App\Libraries\Adapter\API;
class LocalAdapter extends Adapter
{
- public function __construct($entity, $debug = false)
+ public function __construct($debug = false)
{
- parent::__construct($entity, $debug);
+ parent::__construct($debug);
}
protected function getClient() //Codeigniter4 Service의 curlrequest이용시
@@ -21,7 +21,7 @@ class LocalAdapter extends Adapter
'cookie' => $this->getCookieFile(),
];
if ($this->_debug) {
- $options['debug'] = PATHS['API'] . getenv('api.adapter.debug') ? getenv('api.adapter.debug') : "api-debug_" . date("Ymd");
+ $options['debug'] = $this->getDebugFile();
}
$this->_client = \Config\Services::curlrequest($options);
}
diff --git a/app/Views/layouts/admin/left_menu.php b/app/Views/layouts/admin/left_menu.php
index 44d2638..8d17acd 100644
--- a/app/Views/layouts/admin/left_menu.php
+++ b/app/Views/layouts/admin/left_menu.php
@@ -16,52 +16,8 @@