-
-
+
+
-
+
+
repo->getFileTree($repo, '', $diffs);?>
diff --git a/module/zahost/control.php b/module/zahost/control.php
index 124ff6d977..299128697a 100644
--- a/module/zahost/control.php
+++ b/module/zahost/control.php
@@ -33,6 +33,7 @@ class zahost extends control
$pager = pager::init($recTotal, $recPerPage, $pageID);
$hostList = $this->zahost->getList($browseType, $param, $orderBy, $pager);
+ $nodeList = $this->zahost->getHostNodeGroup();
/* Build the search form. */
$actionURL = $this->createLink('zahost', 'browse', "browseType=bySearch¶m=myQueryID");
@@ -43,6 +44,7 @@ class zahost extends control
$this->view->title = $this->lang->zahost->common;
$this->view->hostList = $hostList;
+ $this->view->nodeList = $nodeList;
$this->view->users = $this->loadModel('user')->getPairs('noletter,noempty,noclosed');
$this->view->pager = $pager;
$this->view->param = $param;
diff --git a/module/zahost/css/create.css b/module/zahost/css/create.css
index ae37eb5805..cb6b02c7d5 100644
--- a/module/zahost/css/create.css
+++ b/module/zahost/css/create.css
@@ -1,3 +1,4 @@
#unit {padding: 0px !important; width:0px; border-left: 0px;width: 63px;}
.input-group-addon {border: 0px; width: 100px;}
#memory-addon{text-align: center;width: 63px;}
+.modal-dialog{width: 396px;}
diff --git a/module/zahost/js/inithost.js b/module/zahost/js/inithost.js
index 5b0ea3207b..57d4edab15 100644
--- a/module/zahost/js/inithost.js
+++ b/module/zahost/js/inithost.js
@@ -14,10 +14,7 @@ $('#checkServiceStatus').click(function(){
}
};
- if(isSuccess){
- html += '
2. Review the initialization FAQ"; @@ -58,9 +58,10 @@ $lang->zahost->initHost->serviceStatus = [ "novnc" => 'not_install', "websockify" => 'not_install', ]; -$lang->zahost->initHost->title = "Initialize Host"; -$lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; -$lang->zahost->initHost->initDesc = "Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->title = "Initialize Host"; +$lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; +$lang->zahost->initHost->initDesc = "1. Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->initDescSecond = "2. Checking Service Status"; $lang->zahost->image = new stdclass; $lang->zahost->image->list = 'Image List'; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index 5b3885c409..9b92434673 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -40,6 +40,7 @@ $lang->zahost->createZanode = 'Create Zanode'; $lang->zahost->initHostNotice = '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."; $lang->zahost->netError = 'Unable to connect to the host, please check the network and try again.'; $lang->zahost->initHost = new stdclass; @@ -49,7 +50,6 @@ $lang->zahost->initHost->not_available = "Installed, Not Started"; $lang->zahost->initHost->ready = "Ready"; $lang->zahost->initHost->next = "Next"; -$lang->zahost->initHost->initSuccessNotice = "The initialization was successful, click Next to complete the next steps."; $lang->zahost->initHost->initFailNoticeTitle = "Initialization failed, check the init script execution log and try the following two solutions:"; $lang->zahost->initHost->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ"; @@ -58,9 +58,10 @@ $lang->zahost->initHost->serviceStatus = [ "novnc" => 'not_install', "websockify" => 'not_install', ]; -$lang->zahost->initHost->title = "Initialize Host"; -$lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; -$lang->zahost->initHost->initDesc = "Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->title = "Initialize Host"; +$lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; +$lang->zahost->initHost->initDesc = "1. Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->initDescSecond = "2. Checking Service Status"; $lang->zahost->image = new stdclass; $lang->zahost->image->list = 'Image List'; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index 50e57ad928..685998032f 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -1,9 +1,9 @@ zahost->id = 'ID'; $lang->zahost->common = 'ZAhost'; -$lang->zahost->browse = 'Hôte Liste'; -$lang->zahost->create = 'Ajouter Hôte'; -$lang->zahost->view = 'Hôte Détail'; +$lang->zahost->browse = 'Host List'; +$lang->zahost->create = 'Add Host'; +$lang->zahost->view = 'Host View'; $lang->zahost->init = 'Init Host'; $lang->zahost->edit = 'Éditer'; $lang->zahost->cancel = "Cancel"; @@ -15,21 +15,21 @@ $lang->zahost->all = 'Tous les hôtes'; $lang->zahost->browseNode = 'ZAnode Browse'; $lang->zahost->deleted = "Deleted"; -$lang->zahost->name = 'Nom'; -$lang->zahost->IP = 'IP/Domain'; -$lang->zahost->extranet = 'IP'; -$lang->zahost->cpuCore = 'CPU Cores'; -$lang->zahost->memory = 'Mémoire Espace'; -$lang->zahost->diskSize = 'Disque Espace'; +$lang->zahost->name = 'Name'; +$lang->zahost->IP = 'Extranet Address'; +$lang->zahost->extranet = 'Extranet Address'; +$lang->zahost->cpuCores = 'CPU Cores'; +$lang->zahost->memory = 'Memory Size'; +$lang->zahost->diskSize = 'diskSize Size'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; -$lang->zahost->createdBy = 'Créé par'; -$lang->zahost->createdDate = 'Date de création'; -$lang->zahost->editedBy = 'Édité par'; -$lang->zahost->editedDate = "Date d'édition"; -$lang->zahost->registerDate = "RegisterDate"; +$lang->zahost->createdBy = 'CreatedBy'; +$lang->zahost->createdDate = 'CreatedDate'; +$lang->zahost->editedBy = 'EditedBy'; +$lang->zahost->editedDate = 'EditedDate'; +$lang->zahost->registerDate = 'RegisterDate'; $lang->zahost->memorySize = $lang->zahost->memory; $lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; @@ -40,6 +40,7 @@ $lang->zahost->createZanode = 'Create Zanode'; $lang->zahost->initHostNotice = '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."; $lang->zahost->netError = 'Unable to connect to the host, please check the network and try again.'; $lang->zahost->initHost = new stdclass; @@ -49,7 +50,6 @@ $lang->zahost->initHost->not_available = "Installed, Not Started"; $lang->zahost->initHost->ready = "Ready"; $lang->zahost->initHost->next = "Next"; -$lang->zahost->initHost->initSuccessNotice = "The initialization was successful, click Next to complete the next steps."; $lang->zahost->initHost->initFailNoticeTitle = "Initialization failed, check the init script execution log and try the following two solutions:"; $lang->zahost->initHost->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ"; @@ -58,9 +58,10 @@ $lang->zahost->initHost->serviceStatus = [ "novnc" => 'not_install', "websockify" => 'not_install', ]; -$lang->zahost->initHost->title = "Initialize Host"; -$lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; -$lang->zahost->initHost->initDesc = "Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->title = "Initialize Host"; +$lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; +$lang->zahost->initHost->initDesc = "1. Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->initDescSecond = "2. Checking Service Status"; $lang->zahost->image = new stdclass; $lang->zahost->image->list = 'Image List'; @@ -104,14 +105,14 @@ $lang->zahost->softwareList['kvm'] = 'KVM'; $lang->zahost->unitList['GB'] = 'GB'; $lang->zahost->unitList['TB'] = 'TB'; -$lang->zahost->zaHostType = 'Type Hôte'; -$lang->zahost->zaHostTypeList['physical'] = 'Physique'; +$lang->zahost->zaHostType = 'Type'; +$lang->zahost->zaHostTypeList['physical'] = 'Physical'; $lang->zahost->confirmDelete = 'Voulez-vous supprimer cet hôte?'; $lang->zahost->cancelDelete = 'Do you want to cancel this download task?'; $lang->zahost->notice = new stdclass(); -$lang->zahost->notice->ip = '『%s』format incorrect!'; +$lang->zahost->notice->ip = '『%s』incorrect format!'; $lang->zahost->notice->registerCommand = 'Register command: ./zagent-host -t host -s http://%s:%s -i %s -p 8086 -secret %s'; $lang->zahost->notice->loading = 'loading...'; $lang->zahost->notice->noImage = 'No available image'; diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index 6d5d951979..d36d674776 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -40,6 +40,7 @@ $lang->zahost->createZanode = '创建执行节点'; $lang->zahost->initHostNotice = '保存成功,请您初始化宿主机或返回列表。'; $lang->zahost->createZanodeNotice = '初始化成功,您现在可以创建执行节点了。'; $lang->zahost->downloadImageNotice = '初始化成功,请下载镜像用于创建执行节点。'; +$lang->zahost->undeletedNotice = "宿主机下存在执行节点无法删除。"; $lang->zahost->netError = '无法连接到宿主机,请检查网络后重试。'; $lang->zahost->initHost = new stdclass; @@ -50,7 +51,6 @@ $lang->zahost->initHost->not_available = "已安装,未启动"; $lang->zahost->initHost->ready = "已就绪"; $lang->zahost->initHost->next = "下一步"; -$lang->zahost->initHost->initSuccessNotice = "初始化成功,请点击下一步完成后续操作。"; $lang->zahost->initHost->initFailNoticeTitle = "初始化失败,请查看初始化脚本执行日志并尝试以下两种解决方案:"; $lang->zahost->initHost->initFailNoticeDesc = "1. 重新执行脚本
2. 查看初始化常见问题"; $lang->zahost->initHost->serviceStatus = [ @@ -58,9 +58,10 @@ $lang->zahost->initHost->serviceStatus = [ "novnc" => 'not_install', "websockify" => 'not_install', ]; -$lang->zahost->initHost->title = "初始化宿主机"; -$lang->zahost->initHost->descTitle = "请按照以下步骤在宿主机上完成初始化:"; -$lang->zahost->initHost->initDesc = "在宿主机上执行:bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->title = "初始化宿主机"; +$lang->zahost->initHost->descTitle = "请根据引导完成宿主机上的初始化: "; +$lang->zahost->initHost->initDescFirst = "1. 在宿主机上执行:bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k"; +$lang->zahost->initHost->initDescSecond = "2. 检测服务状态"; $lang->zahost->image = new stdclass; $lang->zahost->image->list = '镜像仓库'; diff --git a/module/zahost/model.php b/module/zahost/model.php index cf5e1638a2..57404abfaf 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -460,6 +460,21 @@ class zahostModel extends model ->fetchAll(); } + /** + * Get zanode group by zahost. + * + * @access public + * @return void + */ + public function getHostNodeGroup() + { + return $this->dao->select('t1.id as hostID, t2.*')->from(TABLE_ZAHOST)->alias('t1') + ->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t2.parent = t1.id') + ->where('t2.deleted')->eq('0') + ->andWhere('t1.deleted')->eq('0') + ->fetchGroup('hostID', 'id'); + } + /** * Build test task menu. * diff --git a/module/zahost/view/browse.html.php b/module/zahost/view/browse.html.php index 117741253f..09b5a9ee71 100644 --- a/module/zahost/view/browse.html.php +++ b/module/zahost/view/browse.html.php @@ -69,8 +69,11 @@host->statusList, $host->status);?>
heartbeat) ? '' : $host->heartbeat;?>
+ hostID}", $host, 'list');?>
+ hostID]) ? '' : 'disabled';?>
+ hostID]) ? $lang->zahost->delete : $lang->zahost->undeletedNotice;?>
hostID}", $host, 'list');?>
- createLink('zahost', 'delete', "hostID={$host->id}"), '', 'hiddenwin', "title='{$lang->zahost->delete}' class='btn'");?>
+ createLink('zahost', 'delete', "hostID={$host->id}"), '', 'hiddenwin', "title='$title' class='btn $disabled'");;?>
hostID}", $host, 'list', 'file', '', 'iframe', true, "data-width='60%'", $lang->zahost->image->list);?>
hostID}", $host, 'list', 'info', '', '', false, '', $lang->zahost->initHost->title);?>
diff --git a/module/zahost/view/inithost.html.php b/module/zahost/view/inithost.html.php
index 1091c6e2d0..153347b0e8 100644
--- a/module/zahost/view/inithost.html.php
+++ b/module/zahost/view/inithost.html.php
@@ -20,10 +20,15 @@
+
diff --git a/module/zanode/config.php b/module/zanode/config.php
index 8005b689a2..3bd4ffcf0b 100644
--- a/module/zanode/config.php
+++ b/module/zanode/config.php
@@ -1,8 +1,10 @@
zanode->create = new stdClass();
$config->zanode->edit = new stdClass();
+$config->zanode->createimage = new stdClass();
$config->zanode->create->requiredFields = 'name,host,image,cpu,memory,disk,osName';
$config->zanode->edit->requiredFields = '';
+$config->zanode->createimage->requiredFields = 'name';
$config->zanode->defaultPort = '8086';
@@ -42,3 +44,4 @@ $config->zanode->search['params']['diskSize'] = array('operator' => '=', 'cont
$config->zanode->editor = new stdclass();
$config->zanode->editor->create = array('id' => 'desc', 'tools' => 'simpleTools');
$config->zanode->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools');
+$config->zanode->editor->createimage = array('id' => 'desc', 'tools' => 'simpleTools');
diff --git a/module/zanode/control.php b/module/zanode/control.php
index e51e304214..d3e2de60a2 100644
--- a/module/zanode/control.php
+++ b/module/zanode/control.php
@@ -30,7 +30,6 @@ class zanode extends control
$this->app->loadClass('pager', $static = true);
-
$queryID = ($browseType == 'bysearch') ? (int)$param : 0;
$pager = pager::init($recTotal, $recPerPage, $pageID);
$nodeList = $this->zanode->getListByQuery($browseType, $queryID, $orderBy, $pager);
@@ -181,6 +180,39 @@ class zanode extends control
}
}
+ /**
+ * Create custom image.
+ *
+ * @param int $zanodeID
+ * @access public
+ * @return void
+ */
+ public function createImage($zanodeID = 0)
+ {
+ $task = '';
+ $node = $this->zanode->getNodeByID($zanodeID);
+ $customImage = $this->zanode->getCustomImage($zanodeID, 'created,inprogress');
+ if($customImage) $task = $this->zanode->getTaskStatus($node->ip, $customImage->id, 'exportVm');
+
+ if($_POST)
+ {
+ $this->zanode->createImage($zanodeID);
+
+ if(dao::isError())
+ {
+ $response['result'] = 'fail';
+ $response['message'] = dao::getError();
+ return $this->send($response);
+ }
+ return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent'));
+ }
+
+ $this->view->task = $task;
+ $this->view->node = $node;
+ $this->view->rate = !empty($task->rate) ? $task->rate : 0;
+ $this->display();
+ }
+
/**
* Desctroy node.
*
@@ -254,4 +286,44 @@ class zanode extends control
$template = $this->loadModel('zahost')->getImageByID($imageID);
return print(json_encode($template));
}
+
+ /**
+ * Ajax get task status.
+ *
+ * @param int $extranet
+ * @param int $taskID
+ * @param string $type
+ * @param string $status
+ * @access public
+ * @return void
+ */
+ public function ajaxGetTaskStatus($extranet, $taskID = 0, $type = '', $status = '')
+ {
+ $result = $this->zanode->getTaskStatus($extranet, $taskID, $type, $status);
+ return print(json_encode($result));
+ }
+
+ /**
+ * Update image.
+ *
+ * @param int $imageID
+ * @access public
+ * @return void
+ */
+ public function ajaxUpdateImage($imageID = 0)
+ {
+ if($_POST)
+ {
+ $data = fixer::input('post')->get();
+ $this->dao->update(TABLE_IMAGE)->data($data)->where('id')->eq($imageID)->autoCheck()->exec();
+
+ if(dao::isError())
+ {
+ $response['result'] = 'fail';
+ $response['message'] = dao::getError();
+ return $this->send($response);
+ }
+ return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess));
+ }
+ }
}
diff --git a/module/zanode/css/createimage.css b/module/zanode/css/createimage.css
new file mode 100644
index 0000000000..abeaaa30e9
--- /dev/null
+++ b/module/zanode/css/createimage.css
@@ -0,0 +1,2 @@
+.progress{height: 20px;}
+#mainContent{margin: 0 auto;}
diff --git a/module/zanode/lang/de.php b/module/zanode/lang/de.php
index bbefb5c016..fb5352dff4 100644
--- a/module/zanode/lang/de.php
+++ b/module/zanode/lang/de.php
@@ -16,6 +16,7 @@ $lang->zanode->all = 'All';
$lang->zanode->byQuery = 'Search';
$lang->zanode->osName = 'System';
$lang->zanode->image = 'VM Image';
+$lang->zanode->imageName = 'Image Name';
$lang->zanode->name = 'Name';
$lang->zanode->start = 'Start After Created';
$lang->zanode->hostName = 'Host Name';
@@ -45,8 +46,13 @@ $lang->zanode->notFoundAgent = 'No Agent service is found';
$lang->zanode->createVmFail = 'Failed to create a execution node';
$lang->zanode->noVncPort = 'Failed to get vnc port';
$lang->zanode->nameValid = "The name can only be letters, numbers, '-', '_', '.', and cannot start with a symbol";
+$lang->zanode->empty = 'No zanode is found';
-$lang->zanode->empty = 'No Execution Node';
+$lang->zanode->empty = 'No Execution Node';
+$lang->zanode->createImaging = 'Creating';
+$lang->zanode->createImageNotice = 'The system will be created based on the current node,This process requires the execution node to be shut down. Do you want to continue?';
+$lang->zanode->createImageSuccess = 'Successed, You can use this image to create node. Created';
+$lang->zanode->createImageFail = 'Failed to create';
$lang->zanode->apiError['-10100'] = 'Execution node not found.';
@@ -58,5 +64,6 @@ $lang->zanode->statusList['launch'] = 'Launch';
$lang->zanode->statusList['ready'] = 'Ready';
$lang->zanode->statusList['running'] = 'Running';
$lang->zanode->statusList['suspend'] = 'Suspend';
+$lang->zanode->statusList['offline'] = 'Offline';
$lang->zanode->statusList['destroy'] = 'Destroyed';
$lang->zanode->statusList['destroy_fail'] = 'Destroy Fail';
diff --git a/module/zanode/lang/en.php b/module/zanode/lang/en.php
index bbefb5c016..fb5352dff4 100644
--- a/module/zanode/lang/en.php
+++ b/module/zanode/lang/en.php
@@ -16,6 +16,7 @@ $lang->zanode->all = 'All';
$lang->zanode->byQuery = 'Search';
$lang->zanode->osName = 'System';
$lang->zanode->image = 'VM Image';
+$lang->zanode->imageName = 'Image Name';
$lang->zanode->name = 'Name';
$lang->zanode->start = 'Start After Created';
$lang->zanode->hostName = 'Host Name';
@@ -45,8 +46,13 @@ $lang->zanode->notFoundAgent = 'No Agent service is found';
$lang->zanode->createVmFail = 'Failed to create a execution node';
$lang->zanode->noVncPort = 'Failed to get vnc port';
$lang->zanode->nameValid = "The name can only be letters, numbers, '-', '_', '.', and cannot start with a symbol";
+$lang->zanode->empty = 'No zanode is found';
-$lang->zanode->empty = 'No Execution Node';
+$lang->zanode->empty = 'No Execution Node';
+$lang->zanode->createImaging = 'Creating';
+$lang->zanode->createImageNotice = 'The system will be created based on the current node,This process requires the execution node to be shut down. Do you want to continue?';
+$lang->zanode->createImageSuccess = 'Successed, You can use this image to create node. Created';
+$lang->zanode->createImageFail = 'Failed to create';
$lang->zanode->apiError['-10100'] = 'Execution node not found.';
@@ -58,5 +64,6 @@ $lang->zanode->statusList['launch'] = 'Launch';
$lang->zanode->statusList['ready'] = 'Ready';
$lang->zanode->statusList['running'] = 'Running';
$lang->zanode->statusList['suspend'] = 'Suspend';
+$lang->zanode->statusList['offline'] = 'Offline';
$lang->zanode->statusList['destroy'] = 'Destroyed';
$lang->zanode->statusList['destroy_fail'] = 'Destroy Fail';
diff --git a/module/zanode/lang/fr.php b/module/zanode/lang/fr.php
index bbefb5c016..fb5352dff4 100644
--- a/module/zanode/lang/fr.php
+++ b/module/zanode/lang/fr.php
@@ -16,6 +16,7 @@ $lang->zanode->all = 'All';
$lang->zanode->byQuery = 'Search';
$lang->zanode->osName = 'System';
$lang->zanode->image = 'VM Image';
+$lang->zanode->imageName = 'Image Name';
$lang->zanode->name = 'Name';
$lang->zanode->start = 'Start After Created';
$lang->zanode->hostName = 'Host Name';
@@ -45,8 +46,13 @@ $lang->zanode->notFoundAgent = 'No Agent service is found';
$lang->zanode->createVmFail = 'Failed to create a execution node';
$lang->zanode->noVncPort = 'Failed to get vnc port';
$lang->zanode->nameValid = "The name can only be letters, numbers, '-', '_', '.', and cannot start with a symbol";
+$lang->zanode->empty = 'No zanode is found';
-$lang->zanode->empty = 'No Execution Node';
+$lang->zanode->empty = 'No Execution Node';
+$lang->zanode->createImaging = 'Creating';
+$lang->zanode->createImageNotice = 'The system will be created based on the current node,This process requires the execution node to be shut down. Do you want to continue?';
+$lang->zanode->createImageSuccess = 'Successed, You can use this image to create node. Created';
+$lang->zanode->createImageFail = 'Failed to create';
$lang->zanode->apiError['-10100'] = 'Execution node not found.';
@@ -58,5 +64,6 @@ $lang->zanode->statusList['launch'] = 'Launch';
$lang->zanode->statusList['ready'] = 'Ready';
$lang->zanode->statusList['running'] = 'Running';
$lang->zanode->statusList['suspend'] = 'Suspend';
+$lang->zanode->statusList['offline'] = 'Offline';
$lang->zanode->statusList['destroy'] = 'Destroyed';
$lang->zanode->statusList['destroy_fail'] = 'Destroy Fail';
diff --git a/module/zanode/lang/zh-cn.php b/module/zanode/lang/zh-cn.php
index 1e1b81b5d6..a24562f30d 100644
--- a/module/zanode/lang/zh-cn.php
+++ b/module/zanode/lang/zh-cn.php
@@ -16,6 +16,7 @@ $lang->zanode->all = '全部';
$lang->zanode->byQuery = '搜索';
$lang->zanode->osName = '操作系统';
$lang->zanode->image = '镜像';
+$lang->zanode->imageName = '镜像名称';
$lang->zanode->name = '执行节点名称';
$lang->zanode->start = '创建后自动开启';
$lang->zanode->hostName = '所属宿主机';
@@ -45,9 +46,14 @@ $lang->zanode->notFoundAgent = '没有发现Agent服务';
$lang->zanode->createVmFail = '创建执行节点失败';
$lang->zanode->noVncPort = '无法获取执行节点端口';
$lang->zanode->nameValid = "名称只能是字母、数字,'-','_','.',且不能以符号开头";
-
$lang->zanode->empty = '暂时没有执行节点';
+$lang->zanode->createImage = '创建镜像';
+$lang->zanode->createImaging = '正在创建镜像';
+$lang->zanode->createImageNotice = '系统将基于当前执行节点创建镜像,该过程需要关闭该执行节点,确定要继续么?';
+$lang->zanode->createImageSuccess = '镜像创建成功,您可以使用此镜像创建执行节点。去创建';
+$lang->zanode->createImageFail = '镜像创建失败';
+
$lang->zanode->apiError['-10100'] = '执行节点不存在';
$lang->zanode->publicList[0] = '不共享';
@@ -61,4 +67,3 @@ $lang->zanode->statusList['suspend'] = '暂停';
$lang->zanode->statusList['offline'] = '下线';
$lang->zanode->statusList['destroy'] = '已销毁';
$lang->zanode->statusList['destroy_fail'] = '销毁失败';
-
diff --git a/module/zanode/model.php b/module/zanode/model.php
index 56b9674937..63304c6eb6 100644
--- a/module/zanode/model.php
+++ b/module/zanode/model.php
@@ -25,6 +25,8 @@ class zanodemodel extends model
const KVM_CREATE_PATH = '/api/v1/kvm/create';
const KVM_TOKEN_PATH = '/api/v1/virtual/getVncToken';
+ const KVM_EXPORT_PATH = '/api/v1/kvm/exportVm';
+ const KVM_STATUS_PATH = '/api/v1/task/getStatus';
/**
@@ -105,6 +107,55 @@ class zanodemodel extends model
return true;
}
+ /**
+ * Create Image by zanode.
+ *
+ * @param int $zanodeID
+ * @access public
+ * @return void
+ */
+ public function createImage($zanodeID = 0)
+ {
+ $data = fixer::input('post')->get();
+
+ if(empty($data->name)) dao::$errors['message'][] = '名称不能为空';
+ if(dao::isError()) return false;
+
+ $node = $this->getNodeByID($zanodeID);
+ $image = $this->getImageByID($node->image);
+
+ $newImage = new stdClass();
+ $newImage->name = $data->name;
+ $newImage->status = 'created';
+ $newImage->osName = $node->osName;
+ $newImage->from = $node->id;
+ $newImage->createdDate = helper::now();
+
+ $this->dao->insert(TABLE_IMAGE)
+ ->data($newImage)
+ ->autoCheck()
+ ->exec();
+
+ if(dao::isError()) return false;
+
+ $newID = $this->dao->lastInsertID();
+
+ /* Prepare create params. */
+ $agnetUrl = 'http://' . $node->ip . ':' . $this->config->zanode->defaultPort;
+ $param = array(
+ 'backing' => $data->name,
+ 'task' => $newID,
+ 'vm' => $node->name
+ );
+
+ $result = json_decode(commonModel::http($agnetUrl . static::KVM_EXPORT_PATH, json_encode($param,JSON_NUMERIC_CHECK), null));
+
+ if(!empty($result) and $result->code == 'success') return $newID;
+
+ $this->dao->delete()->from(TABLE_IMAGE)->where('id')->eq($newID)->exec();
+ return false;
+ }
+
/**
* Action Node.
*
@@ -287,6 +338,22 @@ class zanodemodel extends model
->fetchAll();
}
+ /**
+ * Get node list.
+ *
+ * @param string $orderBy
+ * @access public
+ * @return void
+ */
+ public function getList($orderBy = 'id_desc')
+ {
+ return $this->dao->select('*')->from(TABLE_ZAHOST)
+ ->where('deleted')->eq(0)
+ ->andWhere("type")->eq('node')
+ ->orderBy($orderBy)
+ ->fetchAll('id');
+ }
+
/**
* Get node list by hostID.
*
@@ -358,7 +425,29 @@ class zanodemodel extends model
*/
public function getimageList($orderBy = 'id_desc', $pager = null)
{
- return $this->dao->select('*')->from(TABLE_IMAGE)->orderBy($orderBy)->page($pager)->fetchAll();
+ return $this->dao->select('*')->from(TABLE_IMAGE)
+ ->where('from')->eq(0)
+ ->orderBy($orderBy)
+ ->page($pager)
+ ->fetchAll();
+ }
+
+ /**
+ * Get custom image.
+ *
+ * @param int $nodeID
+ * @param string|array $status
+ * @param string $orderBy
+ * @access public
+ * @return void
+ */
+ public function getCustomImage($nodeID = 0, $status = '', $orderBy = 'id_desc')
+ {
+ return $this->dao->select('*')->from(TABLE_IMAGE)
+ ->where('`from`')->eq($nodeID)
+ ->beginIF($status)->andWhere('status')->in($status)->fi()
+ ->orderBy($orderBy)
+ ->fetch();
}
/**
@@ -446,6 +535,42 @@ class zanodemodel extends model
return $returnData;
}
+ /**
+ * Get task status by zagent api.
+ *
+ * @param int $extranet
+ * @param int $taskID
+ * @param string $type
+ * @param string $status
+ * @access public
+ * @return void
+ */
+ public function getTaskStatus($extranet = '', $taskID = 0, $type = '', $status = '')
+ {
+ $agnetUrl = 'http://' . $extranet . ':8086' . static::KVM_STATUS_PATH;
+ $result = json_decode(commonModel::http("$agnetUrl", array(), array(CURLOPT_CUSTOMREQUEST => 'POST'), array(), 'json'));
+
+ if(empty($result) or $result->code != 'success') return false;
+ $data = $result->data;
+ if(empty($data)) return array();
+
+ if($status and !$taskID and isset($data->$status)) return $data->$status;
+
+ if(!$taskID) return $data;
+
+ foreach($data as $status => $tasks)
+ {
+ if(empty($tasks)) continue;
+
+ foreach($tasks as $task)
+ {
+ if($type == $task->type and $taskID == $task->task) return $task;
+ }
+ }
+
+ return $result;
+ }
+
public function buildOperateMenu($node)
{
if($node->deleted) return '';
diff --git a/module/zanode/view/browse.html.php b/module/zanode/view/browse.html.php
index 72ec091362..1eb6b95a72 100644
--- a/module/zanode/view/browse.html.php
+++ b/module/zanode/view/browse.html.php
@@ -57,7 +57,7 @@
zanode->osName); ?>
zanode->status); ?>
zanode->hostName); ?>
- actions ?>
+ actions ?>
' + zahostLang.initHost.initSuccessNotice + '
' - - }else{ + if(!isSuccess){ html += '' + zahostLang.initHost.initFailNoticeTitle + '
'; html += '' + zahostLang.initHost.initFailNoticeDesc + 'https://github.com/easysoft/zenagent/
'
}
diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php
index f62bf33eaf..a4d17173c8 100644
--- a/module/zahost/lang/de.php
+++ b/module/zahost/lang/de.php
@@ -40,6 +40,7 @@ $lang->zahost->createZanode = 'Create Zanode';
$lang->zahost->initHostNotice = '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.";
$lang->zahost->netError = 'Unable to connect to the host, please check the network and try again.';
$lang->zahost->initHost = new stdclass;
@@ -49,7 +50,6 @@ $lang->zahost->initHost->not_available = "Installed, Not Started";
$lang->zahost->initHost->ready = "Ready";
$lang->zahost->initHost->next = "Next";
-$lang->zahost->initHost->initSuccessNotice = "The initialization was successful, click Next to complete the next steps.";
$lang->zahost->initHost->initFailNoticeTitle = "Initialization failed, check the init script execution log and try the following two solutions:";
$lang->zahost->initHost->initFailNoticeDesc = "1. Re-execute the script 2. Review the initialization FAQ"; @@ -58,9 +58,10 @@ $lang->zahost->initHost->serviceStatus = [ "novnc" => 'not_install', "websockify" => 'not_install', ]; -$lang->zahost->initHost->title = "Initialize Host"; -$lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; -$lang->zahost->initHost->initDesc = "Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->title = "Initialize Host"; +$lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; +$lang->zahost->initHost->initDesc = "1. Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->initDescSecond = "2. Checking Service Status"; $lang->zahost->image = new stdclass; $lang->zahost->image->list = 'Image List'; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index 5b3885c409..9b92434673 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -40,6 +40,7 @@ $lang->zahost->createZanode = 'Create Zanode'; $lang->zahost->initHostNotice = '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."; $lang->zahost->netError = 'Unable to connect to the host, please check the network and try again.'; $lang->zahost->initHost = new stdclass; @@ -49,7 +50,6 @@ $lang->zahost->initHost->not_available = "Installed, Not Started"; $lang->zahost->initHost->ready = "Ready"; $lang->zahost->initHost->next = "Next"; -$lang->zahost->initHost->initSuccessNotice = "The initialization was successful, click Next to complete the next steps."; $lang->zahost->initHost->initFailNoticeTitle = "Initialization failed, check the init script execution log and try the following two solutions:"; $lang->zahost->initHost->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ"; @@ -58,9 +58,10 @@ $lang->zahost->initHost->serviceStatus = [ "novnc" => 'not_install', "websockify" => 'not_install', ]; -$lang->zahost->initHost->title = "Initialize Host"; -$lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; -$lang->zahost->initHost->initDesc = "Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->title = "Initialize Host"; +$lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; +$lang->zahost->initHost->initDesc = "1. Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->initDescSecond = "2. Checking Service Status"; $lang->zahost->image = new stdclass; $lang->zahost->image->list = 'Image List'; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index 50e57ad928..685998032f 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -1,9 +1,9 @@ zahost->id = 'ID'; $lang->zahost->common = 'ZAhost'; -$lang->zahost->browse = 'Hôte Liste'; -$lang->zahost->create = 'Ajouter Hôte'; -$lang->zahost->view = 'Hôte Détail'; +$lang->zahost->browse = 'Host List'; +$lang->zahost->create = 'Add Host'; +$lang->zahost->view = 'Host View'; $lang->zahost->init = 'Init Host'; $lang->zahost->edit = 'Éditer'; $lang->zahost->cancel = "Cancel"; @@ -15,21 +15,21 @@ $lang->zahost->all = 'Tous les hôtes'; $lang->zahost->browseNode = 'ZAnode Browse'; $lang->zahost->deleted = "Deleted"; -$lang->zahost->name = 'Nom'; -$lang->zahost->IP = 'IP/Domain'; -$lang->zahost->extranet = 'IP'; -$lang->zahost->cpuCore = 'CPU Cores'; -$lang->zahost->memory = 'Mémoire Espace'; -$lang->zahost->diskSize = 'Disque Espace'; +$lang->zahost->name = 'Name'; +$lang->zahost->IP = 'Extranet Address'; +$lang->zahost->extranet = 'Extranet Address'; +$lang->zahost->cpuCores = 'CPU Cores'; +$lang->zahost->memory = 'Memory Size'; +$lang->zahost->diskSize = 'diskSize Size'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; -$lang->zahost->createdBy = 'Créé par'; -$lang->zahost->createdDate = 'Date de création'; -$lang->zahost->editedBy = 'Édité par'; -$lang->zahost->editedDate = "Date d'édition"; -$lang->zahost->registerDate = "RegisterDate"; +$lang->zahost->createdBy = 'CreatedBy'; +$lang->zahost->createdDate = 'CreatedDate'; +$lang->zahost->editedBy = 'EditedBy'; +$lang->zahost->editedDate = 'EditedDate'; +$lang->zahost->registerDate = 'RegisterDate'; $lang->zahost->memorySize = $lang->zahost->memory; $lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; @@ -40,6 +40,7 @@ $lang->zahost->createZanode = 'Create Zanode'; $lang->zahost->initHostNotice = '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."; $lang->zahost->netError = 'Unable to connect to the host, please check the network and try again.'; $lang->zahost->initHost = new stdclass; @@ -49,7 +50,6 @@ $lang->zahost->initHost->not_available = "Installed, Not Started"; $lang->zahost->initHost->ready = "Ready"; $lang->zahost->initHost->next = "Next"; -$lang->zahost->initHost->initSuccessNotice = "The initialization was successful, click Next to complete the next steps."; $lang->zahost->initHost->initFailNoticeTitle = "Initialization failed, check the init script execution log and try the following two solutions:"; $lang->zahost->initHost->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ"; @@ -58,9 +58,10 @@ $lang->zahost->initHost->serviceStatus = [ "novnc" => 'not_install', "websockify" => 'not_install', ]; -$lang->zahost->initHost->title = "Initialize Host"; -$lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; -$lang->zahost->initHost->initDesc = "Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->title = "Initialize Host"; +$lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; +$lang->zahost->initHost->initDesc = "1. Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->initDescSecond = "2. Checking Service Status"; $lang->zahost->image = new stdclass; $lang->zahost->image->list = 'Image List'; @@ -104,14 +105,14 @@ $lang->zahost->softwareList['kvm'] = 'KVM'; $lang->zahost->unitList['GB'] = 'GB'; $lang->zahost->unitList['TB'] = 'TB'; -$lang->zahost->zaHostType = 'Type Hôte'; -$lang->zahost->zaHostTypeList['physical'] = 'Physique'; +$lang->zahost->zaHostType = 'Type'; +$lang->zahost->zaHostTypeList['physical'] = 'Physical'; $lang->zahost->confirmDelete = 'Voulez-vous supprimer cet hôte?'; $lang->zahost->cancelDelete = 'Do you want to cancel this download task?'; $lang->zahost->notice = new stdclass(); -$lang->zahost->notice->ip = '『%s』format incorrect!'; +$lang->zahost->notice->ip = '『%s』incorrect format!'; $lang->zahost->notice->registerCommand = 'Register command: ./zagent-host -t host -s http://%s:%s -i %s -p 8086 -secret %s'; $lang->zahost->notice->loading = 'loading...'; $lang->zahost->notice->noImage = 'No available image'; diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index 6d5d951979..d36d674776 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -40,6 +40,7 @@ $lang->zahost->createZanode = '创建执行节点'; $lang->zahost->initHostNotice = '保存成功,请您初始化宿主机或返回列表。'; $lang->zahost->createZanodeNotice = '初始化成功,您现在可以创建执行节点了。'; $lang->zahost->downloadImageNotice = '初始化成功,请下载镜像用于创建执行节点。'; +$lang->zahost->undeletedNotice = "宿主机下存在执行节点无法删除。"; $lang->zahost->netError = '无法连接到宿主机,请检查网络后重试。'; $lang->zahost->initHost = new stdclass; @@ -50,7 +51,6 @@ $lang->zahost->initHost->not_available = "已安装,未启动"; $lang->zahost->initHost->ready = "已就绪"; $lang->zahost->initHost->next = "下一步"; -$lang->zahost->initHost->initSuccessNotice = "初始化成功,请点击下一步完成后续操作。"; $lang->zahost->initHost->initFailNoticeTitle = "初始化失败,请查看初始化脚本执行日志并尝试以下两种解决方案:"; $lang->zahost->initHost->initFailNoticeDesc = "1. 重新执行脚本
2. 查看初始化常见问题"; $lang->zahost->initHost->serviceStatus = [ @@ -58,9 +58,10 @@ $lang->zahost->initHost->serviceStatus = [ "novnc" => 'not_install', "websockify" => 'not_install', ]; -$lang->zahost->initHost->title = "初始化宿主机"; -$lang->zahost->initHost->descTitle = "请按照以下步骤在宿主机上完成初始化:"; -$lang->zahost->initHost->initDesc = "在宿主机上执行:bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->title = "初始化宿主机"; +$lang->zahost->initHost->descTitle = "请根据引导完成宿主机上的初始化: "; +$lang->zahost->initHost->initDescFirst = "1. 在宿主机上执行:bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k"; +$lang->zahost->initHost->initDescSecond = "2. 检测服务状态"; $lang->zahost->image = new stdclass; $lang->zahost->image->list = '镜像仓库'; diff --git a/module/zahost/model.php b/module/zahost/model.php index cf5e1638a2..57404abfaf 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -460,6 +460,21 @@ class zahostModel extends model ->fetchAll(); } + /** + * Get zanode group by zahost. + * + * @access public + * @return void + */ + public function getHostNodeGroup() + { + return $this->dao->select('t1.id as hostID, t2.*')->from(TABLE_ZAHOST)->alias('t1') + ->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t2.parent = t1.id') + ->where('t2.deleted')->eq('0') + ->andWhere('t1.deleted')->eq('0') + ->fetchGroup('hostID', 'id'); + } + /** * Build test task menu. * diff --git a/module/zahost/view/browse.html.php b/module/zahost/view/browse.html.php index 117741253f..09b5a9ee71 100644 --- a/module/zahost/view/browse.html.php +++ b/module/zahost/view/browse.html.php @@ -69,8 +69,11 @@
zahost->initHost->title; ?>
zahost->initHost->descTitle; ?>
-zahost->initHost->initDesc . ' ' . $host->secret . ' -t ' . getWebRoot(true); ?>
-
+
+
+
+ zahost->initHost->initDesc . ' ' . $host->secret . ' -t ' . getWebRoot(true); ?>
+
+