From cb79c4771088acd11842246c5c3d701568d5de94 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Wed, 7 Dec 2022 06:53:52 +0000 Subject: [PATCH] * Add init node. --- module/zahost/lang/zh-cn.php | 4 ---- module/zanode/control.php | 4 +++- module/zanode/css/common.css | 7 +++++++ module/zanode/js/common.js | 6 ++++++ module/zanode/lang/de.php | 4 +++- module/zanode/lang/en.php | 4 +++- module/zanode/lang/fr.php | 4 +++- module/zanode/lang/zh-cn.php | 14 ++++++++------ module/zanode/model.php | 9 +++------ module/zanode/view/init.html.php | 4 +++- module/zanode/view/successmodal.html.php | 16 ++++++++++++++++ 11 files changed, 55 insertions(+), 21 deletions(-) create mode 100644 module/zanode/css/common.css create mode 100644 module/zanode/view/successmodal.html.php diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index efa5a6e82b..e4361fef79 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -37,11 +37,7 @@ $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 = "宿主机下存在执行节点无法删除。"; diff --git a/module/zanode/control.php b/module/zanode/control.php index cdb5d2cad5..adad9480c5 100644 --- a/module/zanode/control.php +++ b/module/zanode/control.php @@ -135,7 +135,9 @@ class zanode extends control $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->view->notice = $this->lang->zanode->init->initSuccessNoticeTitle; + $this->view->buttonName = $this->lang->zanode->init->button; + $this->view->modalLink = $this->createLink('zanode', 'browse'); $this->display(); } diff --git a/module/zanode/css/common.css b/module/zanode/css/common.css new file mode 100644 index 0000000000..6f18896c39 --- /dev/null +++ b/module/zanode/css/common.css @@ -0,0 +1,7 @@ +#modalLink{color: #2e7fff;text-decoration: underline;} +.modal-dialog .modal-content{border: 2px solid #75e5c4; background-color: #f1fcf9; border-radius: 4px;} +.icon-check-circle{color: #17ce97; margin-right: 10px; font-size: 20px;} +.modal-dialog{width: fit-content;} +.modal-dialog{border-radius: 4px;} +.modal-header{padding:9px 15px 0px; margin:0px; border-bottom:0;} +.modal-dialog .modal-body{padding: 5px 15px 20px 15px;} diff --git a/module/zanode/js/common.js b/module/zanode/js/common.js index af78b5fd6f..07673afe7e 100644 --- a/module/zanode/js/common.js +++ b/module/zanode/js/common.js @@ -36,3 +36,9 @@ $(function() if(typeof image == 'undefined' || !image) $('#os').change(); }) + +function showModal(url = '') +{ + if(url) $("#modalLink").attr('href', url); + $('#successModal').modal('show', 'center'); +} diff --git a/module/zanode/lang/de.php b/module/zanode/lang/de.php index 8e7ef6c91e..1a36317297 100644 --- a/module/zanode/lang/de.php +++ b/module/zanode/lang/de.php @@ -78,7 +78,9 @@ $lang->zanode->init->not_install = "Not installed"; $lang->zanode->init->not_available = "Installed, Not Started"; $lang->zanode->init->ready = "Ready"; $lang->zanode->init->next = "Next"; +$lang->zanode->init->button = "Go To Settings"; +$lang->zanode->init->initSuccessNoticeTitle = "The initialization is successful, you can perform automated test settings or go to node browse."; $lang->zanode->init->initFailNoticeTitle = "Initialization failed, check the init script execution log and try the following two solutions:"; $lang->zanode->init->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ"; @@ -88,5 +90,5 @@ $lang->zanode->init->serviceStatus = [ ]; $lang->zanode->init->title = "Initialize Node"; $lang->zanode->init->descTitle = "Follow these steps to complete the initialization on the node:"; -$lang->zanode->init->initDesc = "Execute the init script on the node: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -s vm "; +$lang->zanode->init->initDesc = "Execute the init script on the node: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -s vm -k "; $lang->zanode->init->statusTitle = "Service Status"; \ No newline at end of file diff --git a/module/zanode/lang/en.php b/module/zanode/lang/en.php index 5c561f9e28..beef8ae38e 100644 --- a/module/zanode/lang/en.php +++ b/module/zanode/lang/en.php @@ -78,7 +78,9 @@ $lang->zanode->init->not_install = "Not installed"; $lang->zanode->init->not_available = "Installed, Not Started"; $lang->zanode->init->ready = "Ready"; $lang->zanode->init->next = "Next"; +$lang->zanode->init->button = "Go To Settings"; +$lang->zanode->init->initSuccessNoticeTitle = "The initialization is successful, you can perform automated test settings or go to node browse."; $lang->zanode->init->initFailNoticeTitle = "Initialization failed, check the init script execution log and try the following two solutions:"; $lang->zanode->init->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ"; @@ -88,5 +90,5 @@ $lang->zanode->init->serviceStatus = [ ]; $lang->zanode->init->title = "Initialize Node"; $lang->zanode->init->descTitle = "Follow these steps to complete the initialization on the node:"; -$lang->zanode->init->initDesc = "Execute the init script on the node: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -s vm "; +$lang->zanode->init->initDesc = "Execute the init script on the node: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -s vm -k "; $lang->zanode->init->statusTitle = "Service Status"; \ No newline at end of file diff --git a/module/zanode/lang/fr.php b/module/zanode/lang/fr.php index 8e7ef6c91e..1a36317297 100644 --- a/module/zanode/lang/fr.php +++ b/module/zanode/lang/fr.php @@ -78,7 +78,9 @@ $lang->zanode->init->not_install = "Not installed"; $lang->zanode->init->not_available = "Installed, Not Started"; $lang->zanode->init->ready = "Ready"; $lang->zanode->init->next = "Next"; +$lang->zanode->init->button = "Go To Settings"; +$lang->zanode->init->initSuccessNoticeTitle = "The initialization is successful, you can perform automated test settings or go to node browse."; $lang->zanode->init->initFailNoticeTitle = "Initialization failed, check the init script execution log and try the following two solutions:"; $lang->zanode->init->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ"; @@ -88,5 +90,5 @@ $lang->zanode->init->serviceStatus = [ ]; $lang->zanode->init->title = "Initialize Node"; $lang->zanode->init->descTitle = "Follow these steps to complete the initialization on the node:"; -$lang->zanode->init->initDesc = "Execute the init script on the node: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -s vm "; +$lang->zanode->init->initDesc = "Execute the init script on the node: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -s vm -k "; $lang->zanode->init->statusTitle = "Service Status"; \ No newline at end of file diff --git a/module/zanode/lang/zh-cn.php b/module/zanode/lang/zh-cn.php index 669301b0b1..dd28c7dfea 100644 --- a/module/zanode/lang/zh-cn.php +++ b/module/zanode/lang/zh-cn.php @@ -73,13 +73,15 @@ $lang->zanode->statusList['destroy'] = '已销毁'; $lang->zanode->statusList['destroy_fail'] = '销毁失败'; $lang->zanode->init = new stdclass; -$lang->zanode->init->statusTitle = "服务状态"; -$lang->zanode->init->checkStatus = "检测服务状态"; -$lang->zanode->init->not_install = "未安装"; +$lang->zanode->init->statusTitle = "服务状态"; +$lang->zanode->init->checkStatus = "检测服务状态"; +$lang->zanode->init->not_install = "未安装"; $lang->zanode->init->not_available = "已安装,未启动"; -$lang->zanode->init->ready = "已就绪"; -$lang->zanode->init->next = "下一步"; +$lang->zanode->init->ready = "已就绪"; +$lang->zanode->init->next = "下一步"; +$lang->zanode->init->button = "去设置"; +$lang->zanode->init->initSuccessNoticeTitle = "初始化成功,您可以进行自动化测试设置或返回列表。"; $lang->zanode->init->initFailNoticeTitle = "初始化失败,请查看初始化脚本执行日志并尝试以下两种解决方案:"; $lang->zanode->init->initFailNoticeDesc = "1. 重新执行脚本
2. 查看初始化常见问题"; $lang->zanode->init->serviceStatus = [ @@ -88,5 +90,5 @@ $lang->zanode->init->serviceStatus = [ ]; $lang->zanode->init->title = "初始化执行节点"; $lang->zanode->init->descTitle = "请根据引导完成执行节点上的初始化: "; -$lang->zanode->init->initDesc = "1. 在执行节点上执行:bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -s vm "; +$lang->zanode->init->initDesc = "1. 在执行节点上执行:bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -s vm -k "; $lang->zanode->init->statusTitle = "Service Status"; \ No newline at end of file diff --git a/module/zanode/model.php b/module/zanode/model.php index d7f5aaaf5c..10294884c7 100644 --- a/module/zanode/model.php +++ b/module/zanode/model.php @@ -60,9 +60,6 @@ class zanodemodel extends model /* Get host info. */ $host = $this->getHostByID($data->parent); - /* Gen mac address */ - $mac = $this->genmac(); - /* Prepare create params. */ $agnetUrl = 'http://' . $host->extranet . ':' . $host->zap; $param = array( @@ -90,7 +87,7 @@ class zanodemodel extends model /* Prepare create execution node data. */ $data->image = $data->image; $data->parent = $host->id; - $data->mac = $mac; + $data->mac = $result->data->mac; $data->status = static::STATUS_RUNNING; $data->createdBy = $this->app->user->account; $data->createdDate = helper::now(); @@ -122,7 +119,6 @@ class zanodemodel extends model if(dao::isError()) return false; $node = $this->getNodeByID($zanodeID); - $image = $this->getImageByID($node->image); $newImage = new stdClass(); $newImage->host = $node->parent; @@ -456,7 +452,7 @@ class zanodemodel extends model */ public function getNodeByID($id) { - return $this->dao->select('t1.*, t1.name as hostName, t2.extranet as ip,t2.zap as hzap,t3.osName, t2.tokenSN as hTokenSN')->from(TABLE_ZAHOST)->alias('t1') + return $this->dao->select('t1.*, t1.name as hostName, t2.extranet as ip,t2.zap as hzap,t3.osName, t2.tokenSN as hTokenSN, t2.secret as secret')->from(TABLE_ZAHOST)->alias('t1') ->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t1.parent = t2.id') ->leftJoin(TABLE_IMAGE)->alias('t3')->on('t3.id = t1.image') ->where('t1.id')->eq($id) @@ -615,6 +611,7 @@ class zanodemodel extends model "server" => getWebRoot(true), ); $result = json_decode(commonModel::http("http://{$node->extranet}:{$node->zap}/api/v1/service/setup", json_encode($param), array(), array("Authorization:$node->tokenSN"))); + if(empty($result->data) || $result->code != 'success') { $result = new stdclass; diff --git a/module/zanode/view/init.html.php b/module/zanode/view/init.html.php index d1ed31ab37..d46257298a 100644 --- a/module/zanode/view/init.html.php +++ b/module/zanode/view/init.html.php @@ -35,9 +35,11 @@
+ ' . $lang->goback, "data-app='{$app->tab}'", 'btn'); ?> +
- + diff --git a/module/zanode/view/successmodal.html.php b/module/zanode/view/successmodal.html.php new file mode 100644 index 0000000000..819a0197ce --- /dev/null +++ b/module/zanode/view/successmodal.html.php @@ -0,0 +1,16 @@ +