From aa227a548f1100eb3cbe85ddf22db866a098f063 Mon Sep 17 00:00:00 2001 From: liyuchun <563917701@qq.com> Date: Mon, 19 Sep 2022 21:09:17 +0800 Subject: [PATCH] * Adjust host api. --- api/v1/entries/hostheartbeat.php | 8 ++++++-- module/executionnode/control.php | 2 +- module/executionnode/lang/de.php | 1 + module/executionnode/lang/en.php | 1 + module/executionnode/lang/fr.php | 1 + module/executionnode/lang/zh-cn.php | 2 ++ module/zahost/model.php | 2 +- 7 files changed, 13 insertions(+), 4 deletions(-) diff --git a/api/v1/entries/hostheartbeat.php b/api/v1/entries/hostheartbeat.php index aefa6ed248..01cfaf2d41 100644 --- a/api/v1/entries/hostheartbeat.php +++ b/api/v1/entries/hostheartbeat.php @@ -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); } } diff --git a/module/executionnode/control.php b/module/executionnode/control.php index ec558f361d..9f117bd1c7 100755 --- a/module/executionnode/control.php +++ b/module/executionnode/control.php @@ -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(); } diff --git a/module/executionnode/lang/de.php b/module/executionnode/lang/de.php index 7ca4d598d2..9f22742c5d 100755 --- a/module/executionnode/lang/de.php +++ b/module/executionnode/lang/de.php @@ -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'; diff --git a/module/executionnode/lang/en.php b/module/executionnode/lang/en.php index 7ca4d598d2..9f22742c5d 100755 --- a/module/executionnode/lang/en.php +++ b/module/executionnode/lang/en.php @@ -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'; diff --git a/module/executionnode/lang/fr.php b/module/executionnode/lang/fr.php index b296f42a32..c67da16437 100755 --- a/module/executionnode/lang/fr.php +++ b/module/executionnode/lang/fr.php @@ -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'; diff --git a/module/executionnode/lang/zh-cn.php b/module/executionnode/lang/zh-cn.php index 7b749e505f..625cd883e1 100755 --- a/module/executionnode/lang/zh-cn.php +++ b/module/executionnode/lang/zh-cn.php @@ -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'] = '销毁失败'; diff --git a/module/zahost/model.php b/module/zahost/model.php index 02b21154b9..adb2203892 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -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;