* Finish task #77679.

This commit is contained in:
tanghucheng
2022-12-02 08:33:22 +08:00
parent 6a19c0e8e5
commit 319f587f77
22 changed files with 368 additions and 60 deletions
+1
View File
@@ -0,0 +1 @@
ALTER TABLE `zt_image` ADD `from` mediumint(8) NOT NULL DEFAULT '0' AFTER `status`;
+1
View File
@@ -7301,6 +7301,7 @@ CREATE TABLE `zt_image` (
`address` varchar(64) NOT NULL DEFAULT '',
`path` varchar(64) NOT NULL DEFAULT '',
`status` varchar(20) NOT NULL DEFAULT '',
`from` smallint(8) unsigned NOT NULL DEFAULT '0',
`osName` varchar(32) NOT NULL DEFAULT '',
`memory` float unsigned NOT NULL,
`disk` float unsigned NOT NULL,
+2
View File
@@ -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&param=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;
+1
View File
@@ -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;}
+1 -3
View File
@@ -14,9 +14,7 @@ $('#checkServiceStatus').click(function(){
}
};
if(isSuccess){
html += '<h4>' + zahostLang.initHost.initSuccessNotice + '</h4>'
}else{
if(!isSuccess){
html += '<h4 style="margin-top:20px;">' + zahostLang.initHost.initFailNoticeTitle + '</h4>';
html += '<div><span class="dot-symbol">' + zahostLang.initHost.initFailNoticeDesc + '<a href="https://github.com/easysoft/zenagent/" target="_blank">https://github.com/easysoft/zenagent/</a></span></div>'
}
+5 -4
View File
@@ -39,6 +39,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->initHost = new stdclass;
$lang->zahost->initHost->checkStatus = "Check Service Status";
@@ -47,7 +48,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 <br/>2. Review the initialization FAQ";
@@ -56,9 +56,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';
+5 -4
View File
@@ -39,6 +39,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->initHost = new stdclass;
$lang->zahost->initHost->checkStatus = "Check Service Status";
@@ -47,7 +48,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 <br/>2. Review the initialization FAQ";
@@ -56,9 +56,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';
+29 -28
View File
@@ -1,34 +1,34 @@
<?php
$lang->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->editAction = 'Éditer Hôte';
$lang->zahost->delete = 'Supprimer';
$lang->zahost->deleteAction = 'Supprimer Hôte';
$lang->zahost->byQuery = 'Recherche';
$lang->zahost->all = 'Tous les hôtes';
$lang->zahost->edit = 'Edit';
$lang->zahost->editAction = 'Edit Host';
$lang->zahost->delete = 'Delete';
$lang->zahost->deleteAction = 'Delete Host';
$lang->zahost->byQuery = 'Search';
$lang->zahost->all = 'All';
$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;
@@ -39,6 +39,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->initHost = new stdclass;
$lang->zahost->initHost->checkStatus = "Check Service Status";
@@ -47,7 +48,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 <br/>2. Review the initialization FAQ";
@@ -56,9 +56,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';
@@ -99,13 +100,13 @@ $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->confirmDelete = 'Do you want to delete this host?';
$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';
+5 -4
View File
@@ -39,6 +39,7 @@ $lang->zahost->createZanode = '创建执行节点';
$lang->zahost->initHostNotice = '保存成功,请您初始化宿主机或返回列表。';
$lang->zahost->createZanodeNotice = '初始化成功,您现在可以创建执行节点了。';
$lang->zahost->downloadImageNotice = '初始化成功,请下载镜像用于创建执行节点。';
$lang->zahost->undeletedNotice = "宿主机下存在执行节点无法删除。";
$lang->zahost->initHost = new stdclass;
$lang->zahost->initHost->statusTitle = "服务状态";
@@ -48,7 +49,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. 重新执行脚本 <br/>2. 查看初始化常见问题";
$lang->zahost->initHost->serviceStatus = [
@@ -56,9 +56,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 = '镜像列表';
+15
View File
@@ -350,6 +350,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.
*
+3 -1
View File
@@ -70,7 +70,9 @@
<td><?php echo helper::isZeroDate($host->heartbeat) ? '' : $host->heartbeat;?></td>
<td class='c-actions'>
<?php common::printIcon('zahost', 'edit', "hostID={$host->hostID}", $host, 'list');?>
<?php if(common::hasPriv('zahost', 'delete')) echo html::a($this->createLink('zahost', 'delete', "hostID={$host->id}"), '<i class="icon-trash"></i>', 'hiddenwin', "title='{$lang->zahost->delete}' class='btn'");;?>
<?php $disabled = !empty($nodeList[$host->hostID]) ? '' : 'disabled';?>
<?php $title = !empty($nodeList[$host->hostID]) ? $lang->zahost->delete : $lang->zahost->undeletedNotice;?>
<?php if(common::hasPriv('zahost', 'delete')) echo html::a($this->createLink('zahost', 'delete', "hostID={$host->id}"), '<i class="icon-trash"></i>', 'hiddenwin', "title='$title' class='btn $disabled'");;?>
</td>
</tr>
<?php endforeach;?>
+5 -1
View File
@@ -20,9 +20,13 @@
<div class='main-header'>
<h2><?php echo $lang->zahost->initHost->title; ?></h2>
</div>
<div class="host-desc-container">
<h4><?php echo $lang->zahost->initHost->descTitle; ?></h4>
<div><span class='dot-symbol'></span><span><?php echo $lang->zahost->initHost->initDesc . ' ' . $host->secret; ?></span></div>
<div>
<p><?php echo $lang->zahost->initHost->initDescFirst . ' ' . $host->secret; ?></p>
<p><?php echo $lang->zahost->initHost->initDescSecond;?></p>
</div>
<div id="statusContainer">
</div>
+3
View File
@@ -1,8 +1,10 @@
<?php
$config->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');
+49 -1
View File
@@ -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'));
}
// $task = '';
$this->view->task = $task;
$this->view->rate = !empty($task->rate) ? $task->rate : 0;
$this->display();
}
/**
* Desctroy node.
*
@@ -254,4 +286,20 @@ 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));
}
}
+2
View File
@@ -0,0 +1,2 @@
.progress{height: 20px;}
#mainContent{width: 50%; margin: 0 auto;}
+7 -1
View File
@@ -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,12 @@ $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. <a href="%s">Created</a>';
$lang->zanode->apiError['-10100'] = 'Execution node not found.';
@@ -58,5 +63,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';
+7 -1
View File
@@ -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,12 @@ $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. <a href="%s">Created</a>';
$lang->zanode->apiError['-10100'] = 'Execution node not found.';
@@ -58,5 +63,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';
+7 -1
View File
@@ -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,12 @@ $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. <a href="%s">Created</a>';
$lang->zanode->apiError['-10100'] = 'Execution node not found.';
@@ -58,5 +63,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';
+6 -2
View File
@@ -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,13 @@ $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 = '镜像创建成功,您可以使用此镜像创建执行节点。<a href="%s">去创建</a>';
$lang->zanode->apiError['-10100'] = '执行节点不存在';
$lang->zanode->publicList[0] = '不共享';
@@ -61,4 +66,3 @@ $lang->zanode->statusList['suspend'] = '暂停';
$lang->zanode->statusList['offline'] = '下线';
$lang->zanode->statusList['destroy'] = '已销毁';
$lang->zanode->statusList['destroy_fail'] = '销毁失败';
+126 -1
View File
@@ -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;
if($taskID == $task->task) return $task;
}
}
}
public function buildOperateMenu($node)
{
if($node->deleted) return '';
+11 -8
View File
@@ -57,7 +57,7 @@
<th class='c-os'><?php common::printOrderLink('t1.osName', $orderBy, $vars, $lang->zanode->osName); ?></th>
<th class='c-status'><?php common::printOrderLink('t1.status', $orderBy, $vars, $lang->zanode->status); ?></th>
<th class='c-host'><?php common::printOrderLink('t2.id', $orderBy, $vars, $lang->zanode->hostName); ?>
<th class='c-actions-5'><?php echo $lang->actions ?></th>
<th class='c-actions-6 text-center'><?php echo $lang->actions ?></th>
</tr>
</thead>
<tbody>
@@ -74,16 +74,19 @@
<td title="<?php echo $node->hostName; ?>"><?php echo $node->hostName; ?></td>
<td class='c-actions'>
<?php
$suspendAttr = "title='{$lang->zanode->suspend}' class='btn btn-primary' target='hiddenwin'";
$suspendAttr .= $node->status == 'suspend' ? ' disabled' : " target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmSuspend}\")==false) return false;'";
$suspendAttr = "title='{$lang->zanode->suspend}' target='hiddenwin'";
$suspendAttr .= $node->status == 'suspend' ? ' class="btn disabled"' : "class='btn' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmSuspend}\")==false) return false;'";
$resumeAttr = "title='{$lang->zanode->resume}' target='hiddenwin'";
$resumeAttr .= $node->status == 'running' ? ' class="btn disabled"' : "class='btn' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmResume}\")==false) return false;'";
$rebootAttr = "title='{$lang->zanode->reboot}' target='hiddenwin'";
$rebootAttr .= $node->status == 'suspend' ? ' class="btn disabled"' : "class='btn' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmReboot}\")==false) return false;'";
$resumeAttr = "title='{$lang->zanode->resume}' class='btn btn-primary' target='hiddenwin'";
$resumeAttr .= $node->status == 'running' ? 'disabled' : " target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmResume}\")==false) return false;'";
$rebootAttr = "title='{$lang->zanode->reboot}' class='btn btn-primary' target='hiddenwin'";
$rebootAttr .= $node->status == 'suspend' ? ' disabled' : " target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmReboot}\")==false) return false;'";
common::printLink('zanode', 'suspend', "zanodeID={$node->id}", "<i class='icon icon-pause'></i> ", '', $suspendAttr);
common::printLink('zanode', 'resume', "zanodeID={$node->id}", "<i class='icon icon-back'></i> ", '', $resumeAttr);
common::printLink('zanode', 'reboot', "zanodeID={$node->id}", "<i class='icon icon-restart'></i> ", '', $rebootAttr);
common::printLink('zanode', 'createImage', "zanodeID={$node->id}", "<i class='icon icon-plus'></i> ", '', "class='btn iframe' title='{$lang->zanode->createImage}'", '', true);
common::printIcon('zanode', 'edit', "id={$node->id}", $node, 'list');
common::printLink('zanode', 'delete', "zanodeID={$node->id}", "<i class='icon icon-trash'></i> ", '', "title='{$lang->zanode->destroy}' class='btn btn-primary' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmDelete}\")==false) return false;'");
?>
@@ -99,4 +102,4 @@
<?php endif; ?>
</div>
<?php include $app->getModuleRoot() . 'common/view/footer.html.php'; ?>
<?php include $app->getModuleRoot() . 'common/view/footer.html.php'; ?>
+77
View File
@@ -0,0 +1,77 @@
<?php
/**
* The close file of task module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
* @author chunsheng wang <chunsheng@cnezsoft.com>
* @package task
* @version $Id: cancel.html.php 935 2010-07-06 07:49:24Z jajacn@126.com $
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/kindeditor.html.php';?>
<div id='mainContent' class='main-content'>
<div class='center-block'>
<div class='main-header'>
<h2>
<span><?php echo $lang->zanode->createImage;?></span>
</h2>
</div>
<?php if($task):?>
<h5 class='text-center'><?php echo $lang->zanode->createImaging;?></h5>
<div class="progress progress-striped">
<div class="progress-bar progress-bar-success rate" role="progressbar" aria-valuenow="<?php echo $task->rate;?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $task->rate;?>%">
</div>
</div>
<?php $link = helper::createLink('zanode', 'create');?>
<h6 class='hide text-center success'><?php echo sprintf($lang->zanode->createImageSuccess, $link)?></h6>
<?php else:?>
<form class="load-indicator main-form form-ajax" method='post' enctype='multipart/form-data' id='dataform'>
<table class='table table-form'>
<tr>
<th><?php echo $lang->zanode->imageName;?></th>
<td><?php echo html::input('name', '', "class='form-control'");?></td>
</tr>
<tr>
<th><?php echo $lang->zanode->desc;?></th>
<td><?php echo html::textarea('desc', '', "rows='6' class='form-control'");?></td>
</tr>
<tr>
<td colspan='2' class='text-center'>
<?php echo html::submitButton('', "onclick='if(confirm(\"{$lang->zanode->createImageNotice}\")==false) return false;'");?>
</td>
</tr>
</table>
</form>
<?php endif;?>
</div>
</div>
<script>
var i = 1;
var int = self.setInterval("refreshProgress()",100);
function refreshProgress()
{
$('.rate').css('width', i + '%');
if(i == 100)
{
console.log($('.rate').css);
debugger;
$('.success').removeClass('hide');
clearInterval(int);
}
i ++ ;
}
function getTaskProgress()
{
var url = createLink('zanode', 'ajaxGetTaskStatus', 'extranet=' + extranet + '&taskID=' + taskID + '&type=exportVm');
$.get(url, function(data)
{
});
}
</script>
<?php include '../../common/view/footer.html.php';?>