diff --git a/api/v1/entries/zanodeheartbeat.php b/api/v1/entries/zanodeheartbeat.php
index ebfb8272ae..dc2af26f0f 100644
--- a/api/v1/entries/zanodeheartbeat.php
+++ b/api/v1/entries/zanodeheartbeat.php
@@ -33,19 +33,19 @@ class zanodeHeartbeatEntry extends baseEntry
if(!$status || !$mac) return $this->sendError(400, 'Params error.');
$this->dao = $this->loadModel('common')->dao;
- $hostID = $this->dao->select('id')->from(TABLE_ZAHOST)
+ $host = $this->dao->select('id,extranet')->from(TABLE_ZAHOST)
->beginIF($secret)->where('secret')->eq($secret)->fi()
->beginIF(!$secret)->where('tokenSN')->eq($token)
->andWhere('tokenTime')->gt($now)->fi()
- ->fetch('id');
- if(!$hostID) return $this->sendError(400, 'Secret error.');
+ ->fetch();
+ if(empty($host)) return $this->sendError(400, 'Secret error.');
- $node = $this->dao->select('id')->from(TABLE_ZAHOST)
+ $node = $this->dao->select('id,parent')->from(TABLE_ZAHOST)
->where('mac')->eq($mac)
->fetch();
- if(empty($node) || ($node->parent != $hostID || $node->id != $hostID)) return $this->sendError(400, 'Secret error.');
+
+ if(empty($node) || ($node->parent != $host->id && $node->id != $host->id)) return $this->sendError(400, 'Secret error.');
- $node = new stdclass();
$node->zap = $this->requestBody->agentPortOnHost;
$node->status = $this->requestBody->status;
@@ -57,6 +57,19 @@ class zanodeHeartbeatEntry extends baseEntry
$this->dao->update(TABLE_ZAHOST)->data($node)->where('id')->eq($node->id)->exec();
+ if($secret)
+ {
+ //install services
+ $node->ip = $host->extranet;
+ $nodeStatus = $this->loadModel('zanode')->getServiceStatus($node);
+ if($nodeStatus['ZTF'] != "ready")
+ {
+ $node->secret = $secret;
+ $node->extranet = $host->extranet;
+ $this->loadModel('zanode')->installService($node, "ZTF");
+ }
+ }
+
if(!$secret) return $this->sendSuccess(200, 'success');
$node->tokenTimeUnix = strtotime($node->tokenTime);
diff --git a/module/zahost/control.php b/module/zahost/control.php
index 299128697a..62811fb8cc 100644
--- a/module/zahost/control.php
+++ b/module/zahost/control.php
@@ -95,13 +95,13 @@ class zahost extends control
return $this->send(array('result' => 'fail', 'message' => array("extranet" => array($this->lang->zahost->netError))));
}
- $initLink = $this->createLink('zahost', 'inithost', "hostID=$hostID");
+ $initLink = $this->createLink('zahost', 'init', "hostID=$hostID");
return print("");
}
$this->view->title = $this->lang->zahost->create;
- $this->view->notice = $this->lang->zahost->initHostNotice;
- $this->view->buttonName = $this->lang->zahost->init;
+ $this->view->notice = $this->lang->zahost->initNotice;
+ $this->view->buttonName = $this->lang->zahost->initTitle;
$this->display();
}
@@ -325,11 +325,11 @@ class zahost extends control
* @param int $hostID
* @return void
*/
- public function initHost($hostID)
+ public function init($hostID)
{
$imageList = $this->zahost->getImagePairs($hostID);
- $this->view->title = $this->lang->zahost->init;
+ $this->view->title = $this->lang->zahost->initTitle;
$this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted');
$this->view->hostID = $hostID;
$this->view->host = $this->zahost->getById($hostID);
@@ -344,7 +344,6 @@ class zahost extends control
* Check service status by ajax.
*
* @param int $hostID
- * @param int $templateID
* @access public
* @return void
*/
diff --git a/module/zahost/css/inithost.css b/module/zahost/css/init.css
similarity index 100%
rename from module/zahost/css/inithost.css
rename to module/zahost/css/init.css
diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php
index 17ddec75fd..ed905d6b09 100644
--- a/module/zahost/lang/de.php
+++ b/module/zahost/lang/de.php
@@ -37,7 +37,7 @@ $lang->zahost->os = 'System';
$lang->zahost->imageName = 'Image File';
$lang->zahost->createZanode = 'Create Zanode';
-$lang->zahost->initNotice = 'Save successfully, initialize the ZAhost or return list';
+$lang->zahost->initNotice = 'Save successfully, initialize the ZAhost or return list';
$lang->zahost->createZanodeNotice = 'Initialization successful, ready to create the zanode';
$lang->zahost->downloadImageNotice = 'Initialization successful, download the image to create zanode';
$lang->zahost->undeletedNotice = "The host has nodes that cannot be deleted.";
@@ -54,8 +54,9 @@ $lang->zahost->init->initFailNoticeTitle = "Initialization failed, check the ini
$lang->zahost->init->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ";
$lang->zahost->init->serviceStatus = [
- "kvm" => 'not_install',
- "novnc" => 'not_install',
+ "kvm" => 'not_install',
+ "nginx" => 'not_install',
+ "novnc" => 'not_install',
"websockify" => 'not_install',
];
$lang->zahost->init->title = "Initialize Host";
diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php
index 17ddec75fd..ed905d6b09 100644
--- a/module/zahost/lang/en.php
+++ b/module/zahost/lang/en.php
@@ -37,7 +37,7 @@ $lang->zahost->os = 'System';
$lang->zahost->imageName = 'Image File';
$lang->zahost->createZanode = 'Create Zanode';
-$lang->zahost->initNotice = 'Save successfully, initialize the ZAhost or return list';
+$lang->zahost->initNotice = 'Save successfully, initialize the ZAhost or return list';
$lang->zahost->createZanodeNotice = 'Initialization successful, ready to create the zanode';
$lang->zahost->downloadImageNotice = 'Initialization successful, download the image to create zanode';
$lang->zahost->undeletedNotice = "The host has nodes that cannot be deleted.";
@@ -54,8 +54,9 @@ $lang->zahost->init->initFailNoticeTitle = "Initialization failed, check the ini
$lang->zahost->init->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ";
$lang->zahost->init->serviceStatus = [
- "kvm" => 'not_install',
- "novnc" => 'not_install',
+ "kvm" => 'not_install',
+ "nginx" => 'not_install',
+ "novnc" => 'not_install',
"websockify" => 'not_install',
];
$lang->zahost->init->title = "Initialize Host";
diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php
index de43964680..fdba9f2d53 100644
--- a/module/zahost/lang/fr.php
+++ b/module/zahost/lang/fr.php
@@ -37,7 +37,7 @@ $lang->zahost->os = 'System';
$lang->zahost->imageName = 'Image File';
$lang->zahost->createZanode = 'Create Zanode';
-$lang->zahost->initNotice = 'Save successfully, initialize the ZAhost or return list';
+$lang->zahost->initNotice = 'Save successfully, initialize the ZAhost or return list';
$lang->zahost->createZanodeNotice = 'Initialization successful, ready to create the zanode';
$lang->zahost->downloadImageNotice = 'Initialization successful, download the image to create zanode';
$lang->zahost->undeletedNotice = "The host has nodes that cannot be deleted.";
@@ -54,8 +54,9 @@ $lang->zahost->init->initFailNoticeTitle = "Initialization failed, check the ini
$lang->zahost->init->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ";
$lang->zahost->init->serviceStatus = [
- "kvm" => 'not_install',
- "novnc" => 'not_install',
+ "kvm" => 'not_install',
+ "nginx" => 'not_install',
+ "novnc" => 'not_install',
"websockify" => 'not_install',
];
$lang->zahost->init->title = "Initialize Host";
diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php
index 1e2dac5f59..c947fbbfbd 100644
--- a/module/zahost/lang/vi.php
+++ b/module/zahost/lang/vi.php
@@ -40,7 +40,7 @@ $lang->zahost->osLang = 'Language';
$lang->zahost->imageName = 'Image File';
$lang->zahost->createZanode = 'Create Zanode';
-$lang->zahost->initNotice = 'Save successfully, initialize the ZAhost or return list';
+$lang->zahost->initNotice = 'Save successfully, initialize the ZAhost or return list';
$lang->zahost->createZanodeNotice = 'Initialization successful, ready to create the zanode';
$lang->zahost->downloadImageNotice = 'Initialization successful, download the image to create zanode';
$lang->zahost->netError = 'Unable to connect to the host, please check the network and try again.';
@@ -57,9 +57,9 @@ $lang->zahost->init->initFailNoticeTitle = "Initialization failed, check the ini
$lang->zahost->init->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ";
$lang->zahost->init->serviceStatus = [
- "nginx" => 'not_install',
- "kvm" => 'not_install',
- "novnc" => 'not_install',
+ "kvm" => 'not_install',
+ "nginx" => 'not_install',
+ "novnc" => 'not_install',
"websockify" => 'not_install',
];
$lang->zahost->init->title = "Initialize Host";
diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php
index ecbdeee76c..efa5a6e82b 100644
--- a/module/zahost/lang/zh-cn.php
+++ b/module/zahost/lang/zh-cn.php
@@ -37,7 +37,11 @@ $lang->zahost->os = '操作系统';
$lang->zahost->imageName = '镜像文件';
$lang->zahost->createZanode = '创建执行节点';
+<<<<<<< HEAD
$lang->zahost->initNotice = '保存成功,请您初始化宿主机或返回列表。';
+=======
+$lang->zahost->initNotice = '保存成功,请您初始化宿主机或返回列表。';
+>>>>>>> zenops_46_zhaoke_77683
$lang->zahost->createZanodeNotice = '初始化成功,您现在可以创建执行节点了。';
$lang->zahost->downloadImageNotice = '初始化成功,请下载镜像用于创建执行节点。';
$lang->zahost->undeletedNotice = "宿主机下存在执行节点无法删除。";
@@ -54,14 +58,15 @@ $lang->zahost->init->next = "下一步";
$lang->zahost->init->initFailNoticeTitle = "初始化失败,请查看初始化脚本执行日志并尝试以下两种解决方案:";
$lang->zahost->init->initFailNoticeDesc = "1. 重新执行脚本
2. 查看初始化常见问题";
$lang->zahost->init->serviceStatus = [
- "kvm" => 'not_install',
- "novnc" => 'not_install',
+ "kvm" => 'not_install',
+ "nginx" => 'not_install',
+ "novnc" => 'not_install',
"websockify" => 'not_install',
];
$lang->zahost->init->title = "初始化宿主机";
$lang->zahost->init->descTitle = "请根据引导完成宿主机上的初始化: ";
$lang->zahost->init->initDesc = "1. 在宿主机上执行:bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k ";
-$lang->zahost->init->statusTitle = "Service Status";
+$lang->zahost->init->statusTitle = "服务状态";
$lang->zahost->image = new stdclass;
$lang->zahost->image->list = '镜像仓库';
diff --git a/module/zanode/control.php b/module/zanode/control.php
index a5ef74c9a8..cdb5d2cad5 100644
--- a/module/zanode/control.php
+++ b/module/zanode/control.php
@@ -123,6 +123,23 @@ class zanode extends control
$this->display();
}
+ /*
+ * Init node.
+ *
+ * @param int $hostID
+ * @return void
+ */
+ public function init($nodeID)
+ {
+ $this->view->title = $this->lang->zanode->initTitle;
+ $this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted');
+ $this->view->nodeID = $nodeID;
+ $this->view->node = $this->zanode->getNodeById($nodeID);
+ // $this->view->modalLink = $imageList ? $this->createLink('zanode', 'create', "nodeID=$nodeID") : $this->createLink('zanode', 'browseImage', "nodeID=$nodeID");
+
+ $this->display();
+ }
+
/**
* Suspend Node.
*
@@ -329,4 +346,19 @@ class zanode extends control
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess));
}
}
+
+ /**
+ * Check service status by ajax.
+ *
+ * @param int $nodeID
+ * @access public
+ * @return void
+ */
+ public function ajaxGetServiceStatus($hostID)
+ {
+ $node = $this->zanode->getNodeById($hostID);
+ $serviceStatus = $this->zanode->getServiceStatus($node);
+
+ return $this->send(array('result' => 'success', 'message' => '', 'data' => $serviceStatus));
+ }
}
diff --git a/module/zanode/css/init.css b/module/zanode/css/init.css
new file mode 100644
index 0000000000..adb9649d82
--- /dev/null
+++ b/module/zanode/css/init.css
@@ -0,0 +1,16 @@
+.dot-symbol{
+ margin-right: 10px;
+}
+#statusContainer h5{
+ line-height: 20px;
+}
+.host-desc-container{
+ margin-top: 20px;
+}
+.host-action{
+ margin-top: 60px;
+}
+.host-action .btn{
+ margin-left: 20px;
+ min-width: 100px;
+}
diff --git a/module/zanode/js/init.js b/module/zanode/js/init.js
new file mode 100644
index 0000000000..e59547b527
--- /dev/null
+++ b/module/zanode/js/init.js
@@ -0,0 +1,25 @@
+$('#checkServiceStatus').click(function(){
+ $.get(createLink('zanode', 'ajaxGetServiceStatus', 'nodeID=' + nodeID), function(response)
+ {
+ var resultData = JSON.parse(response);
+ let html = "