* Adjust host api.
This commit is contained in:
@@ -21,8 +21,9 @@ class hostHeartbeatEntry extends baseEntry
|
||||
public function post()
|
||||
{
|
||||
/* Check authorize. */
|
||||
$header = getallheaders();
|
||||
$token = isset($header['Authorization']) ? substr($header['Authorization'], 7) : '';
|
||||
$secret = isset($this->requestBody->secret) ? $this->requestBody->secret : '';
|
||||
$token = isset($_SERVER['HTTP_TOKEN']) ? $_SERVER['HTTP_TOKEN'] : '';
|
||||
if(!$secret and !$token) return $this->sendError(401, 'Unauthorized');
|
||||
|
||||
/* Check param. */
|
||||
@@ -51,8 +52,11 @@ class hostHeartbeatEntry extends baseEntry
|
||||
$this->dao->update(TABLE_HOST)->data($host)->where($conditionField)->eq($conditionValue)->exec();
|
||||
$this->dao->update(TABLE_ASSET)->set('registerDate')->eq($now)->where('id')->eq($assetID)->exec();
|
||||
|
||||
if(!$secret) return $this->send(200, 'success');
|
||||
if(!$secret) return $this->sendSuccess(200, 'success');
|
||||
|
||||
$host->expiredTimeUnix = strtotime($host->expiredDate);
|
||||
unset($host->status);
|
||||
unset($host->expiredDate);
|
||||
return $this->send(200, $host);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class executionnode extends control
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->executionnode->create;
|
||||
$this->view->hostPairs = $this->loadModel('zahost')->getPairs('host');
|
||||
$this->view->hostPairs = array('' => '') + $this->loadModel('zahost')->getPairs('host');
|
||||
|
||||
return $this->display();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ $lang->executionnode->vmTemplate = 'VM Template';
|
||||
$lang->executionnode->name = 'Name';
|
||||
$lang->executionnode->start = 'Start After Created';
|
||||
$lang->executionnode->hostName = 'Host Name';
|
||||
$lang->executionnode->hostID = $lang->executionnode->hostName;
|
||||
$lang->executionnode->ip = 'IP';
|
||||
$lang->executionnode->osArch = 'Arch';
|
||||
$lang->executionnode->osLang = 'Language';
|
||||
|
||||
@@ -20,6 +20,7 @@ $lang->executionnode->vmTemplate = 'VM Template';
|
||||
$lang->executionnode->name = 'Name';
|
||||
$lang->executionnode->start = 'Start After Created';
|
||||
$lang->executionnode->hostName = 'Host Name';
|
||||
$lang->executionnode->hostID = $lang->executionnode->hostName;
|
||||
$lang->executionnode->ip = 'IP';
|
||||
$lang->executionnode->osArch = 'Arch';
|
||||
$lang->executionnode->osLang = 'Language';
|
||||
|
||||
@@ -20,6 +20,7 @@ $lang->executionnode->vmTemplate = 'VM Template';
|
||||
$lang->executionnode->name = 'Name';
|
||||
$lang->executionnode->start = 'Start After Created';
|
||||
$lang->executionnode->hostName = 'Host Name';
|
||||
$lang->executionnode->hostID = $lang->executionnode->hostName;
|
||||
$lang->executionnode->ip = 'IP';
|
||||
$lang->executionnode->osArch = 'Arch';
|
||||
$lang->executionnode->osLang = 'Language';
|
||||
|
||||
@@ -20,6 +20,7 @@ $lang->executionnode->vmTemplate = '虚拟机模板';
|
||||
$lang->executionnode->name = '执行节点名称';
|
||||
$lang->executionnode->start = '创建后自动开启';
|
||||
$lang->executionnode->hostName = '所属宿主机';
|
||||
$lang->executionnode->hostID = $lang->executionnode->hostName;
|
||||
$lang->executionnode->ip = 'IP';
|
||||
$lang->executionnode->osArch = '架构';
|
||||
$lang->executionnode->osLang = '系统语言';
|
||||
@@ -59,6 +60,7 @@ $lang->executionnode->statusList['launch'] = '启动中';
|
||||
$lang->executionnode->statusList['ready'] = '运行中';
|
||||
$lang->executionnode->statusList['running'] = '运行中';
|
||||
$lang->executionnode->statusList['suspend'] = '暂停';
|
||||
$lang->executionnode->statusList['offline'] = '下线';
|
||||
$lang->executionnode->statusList['destroy'] = '已销毁';
|
||||
$lang->executionnode->statusList['destroy_fail'] = '销毁失败';
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ class zahostModel extends model
|
||||
*/
|
||||
public function getImageList($host, $templateID = 0)
|
||||
{
|
||||
$result = json_decode(commonModel::http("http://{$host->publicIP}:8086/api/v1/kvm/listTmpl?token={$host->secret}"));
|
||||
$result = json_decode(commonModel::http("http://{$host->publicIP}:8086/api/v1/kvm/listTmpl"));
|
||||
if(empty($result) || $result->code != 200)
|
||||
{
|
||||
$result = new stdclass;
|
||||
|
||||
Reference in New Issue
Block a user