Merge branch 'zenops_46_tanghucheng' into zenops_46_zhaoke_77683

This commit is contained in:
zhaoke
2022-12-05 03:00:00 +00:00
28 changed files with 431 additions and 77 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 '',
`from` varchar(10) NOT NULL DEFAULT 'zentao',
`memory` float unsigned NOT NULL,
+3 -3
View File
@@ -1,14 +1,14 @@
.m-repo-ajaxgeteditorcontent {overflow: hidden;}
#monacoEditor .tip-circular {background: #2e7fff; border-radius: 10px; padding: 0px 7px;}
#log {margin-top: 2px; display: none; padding: 5px; justify-content: space-between; height: 25px; line-height: 20px;}
#log {margin-top: 8px; display: none; padding: 5px; justify-content: space-between; height: 25px; line-height: 20px; background: #efefef;}
#log .history {margin-left: 5px;}
#log .action-btn .btn {border: none; background: none;}
#related {display: none; margin-top: 2px; background: #fff;}
#related {display: none; margin-top: 2px; background: #fff; height: 0px;}
#relationTabs .nav > li > a {padding: 8px 10px; display: flex; white-space: pre;}
#relationTabs .nav-tabs > li > a > span {margin-right: 5px;}
#relationTabs .tab-pane {display: none;}
#relationTabs .tabs-navbar {background: #F4F5F7;}
#relationTabs .tabs-navbar {background: #FFFFFF;}
#relationTabs .tab-pane.active {display: block;}
#relationTabs .tab-nav-item {max-width: none !important;}
#relationTabs .tab-nav-item .icon {line-height: inherit;}
+5
View File
@@ -32,3 +32,8 @@ table.diff {margin-bottom: 0px;}
#fileTabs .tab-nav-item {max-width: none !important;}
#filesTree #modules {margin-top: 5px;}
#filesTree {overflow-y: auto;}
.file-tree {padding: 0;}
#sidebar > .sidebar-toggle {left: auto; right: 3px;}
#sidebar > .sidebar-toggle > .icon {left : -1px;}
.hide-sidebar #sidebar {width: 0 !important;}
+1 -1
View File
@@ -86,7 +86,7 @@ function arrowTabs(domID, shift, hideRightBtn)
var tabItemWidth = $('#' + domID + ' > .tabs-navbar > .nav-tabs')[0].clientWidth;
var tabsWidth = $('#' + domID)[0].clientWidth;
if($('#' + domID + ' .close-bugs').length) tabsWidth = tabsWidth * 0.6;
if($('#' + domID + ' .close-bugs').length) tabsWidth = tabsWidth * 0.7;
if(tabItemWidth < tabsWidth)
{
+1 -1
View File
@@ -117,7 +117,7 @@ $(document).ready(function()
var paneHeight = $(window).height() - 120;
if(isonlybody) paneHeight = 500;
$('#fileTabs .tab-pane').css('height', paneHeight + 'px')
$('#filesTree').css('height', paneHeight + 45)
$('#filesTree').css('height', paneHeight + 35)
}
setHeight();
+7 -13
View File
@@ -17,25 +17,23 @@ js::set('objectID', $object->id);
<div class="content pane">
<div class="fade main-row split-row in col-md-12">
<div class="left-content col-md-8">
<table class="menu-title">
<table class="table table-borderless">
<?php if($objectType == 'story'):?>
<tr>
<td class="text">
<!-- <span class="detail-title"><?php echo $lang->story->title;?></span> -->
<strong class='text-primary'><?php echo $object->title;?></strong>
</td>
<td></td>
</tr>
<tr>
<td class="text">
<div class="spec-content detail-content article-content">
<!-- <span class="strong detail-title"><?php echo $lang->story->spec;?></span> -->
<?php echo $object->spec; ?>
</div>
</td>
<td class="text right-content">
</tr>
<tr>
<td class="text">
<div class="detail-content article-content">
<!-- <span class="strong detail-title"><?php echo $lang->story->verify;?></span> -->
<?php echo $object->verify; ?>
</div>
</td>
@@ -43,21 +41,19 @@ js::set('objectID', $object->id);
<?php elseif($objectType == 'task'):?>
<tr>
<td class="text">
<!-- <span class="detail-title"><?php echo $lang->task->name;?></span> -->
<strong class='text-primary'><?php echo $object->name;?></strong>
</td>
<td></td>
</tr>
<tr>
<td class="text">
<div class="spec-content detail-content article-content">
<!-- <div class="strong detail-title"><?php echo $lang->task->desc;?></div> -->
<?php echo $object->desc; ?>
</div>
</td>
<td class="text right-content">
</tr>
<tr>
<td class="text">
<div class="detail-content article-content">
<!-- <div class="strong detail-title"><?php echo $lang->task->story;?></div> -->
<?php echo $object->storyTitle; ?>
</div>
</td>
@@ -65,7 +61,6 @@ js::set('objectID', $object->id);
<?php elseif($objectType == 'bug'):?>
<tr>
<td class="text">
<!-- <span class="detail-title"><?php echo $lang->bug->title;?></span> -->
<strong class='text-primary' data-id='<?php echo $object->id;?>'><?php echo $object->title;?></strong>
</td>
</tr>
@@ -73,7 +68,6 @@ js::set('objectID', $object->id);
<tr>
<td class="text">
<div class="spec-content detail-content article-content">
<!-- <span class="strong detail-title"><?php echo $lang->bug->steps;?></span> -->
<?php echo $object->steps; ?>
</div>
</td>
+5 -4
View File
@@ -13,16 +13,17 @@ js::set('openedFiles', array($entry));
js::set('urlParams', "repoID=$repoID&objectID=$objectID&entry=%s&oldRevision=$oldRevision&newRevision=$newRevision&showBug=$showBug&encoding=$encoding");
?>
<?php if(!isonlybody()):?>
<div id="mainContent" class="main-row fade">
<div id="mainContent" class="main-row fade diff-page">
<?php $sideWidth = common::checkNotCN() ? '270' : '240';?>
<div class="side-col" style="width: <?php echo $sideWidth;?>px; padding-top: <?php echo isonlybody() ? 22 : 0;?>px;">
<div class="side-col file-tree" style="width: <?php echo $sideWidth;?>px;" data-min-width="<?php echo $sideWidth;?>">
<div class="side-col" id='sidebar' style="width: <?php echo $sideWidth + 15;?>px; padding-top: <?php echo isonlybody() ? 22 : 0;?>px;">
<div class="sidebar-toggle"><i class="icon icon-angle-left"></i></div>
<div class="cell file-tree" style="width: <?php echo $sideWidth;?>px;" data-min-width="<?php echo $sideWidth;?>">
<div id="filesTree" class="cell load-indicator <?php if(isonlybody()) echo 'pull-left';?>">
<?php echo $this->repo->getFileTree($repo, '', $diffs);?>
</div>
</div>
</div>
<?php endif;?>
<?php endif;?>
<div class="main-col repoCode main">
<div class="content panel">
<div class='btn-toolbar'>
+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 -4
View File
@@ -14,10 +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
@@ -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 <br/>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';
+5 -4
View File
@@ -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 <br/>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';
+22 -21
View File
@@ -1,9 +1,9 @@
<?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->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 <br/>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';
+5 -4
View File
@@ -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. 重新执行脚本 <br/>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 = '镜像仓库';
+15
View File
@@ -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.
*
+4 -1
View File
@@ -69,8 +69,11 @@
<td><?php echo zget($lang->host->statusList, $host->status);?></td>
<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 $disabled = !empty($nodeList[$host->hostID]) ? '' : 'disabled';?>
<?php $title = !empty($nodeList[$host->hostID]) ? $lang->zahost->delete : $lang->zahost->undeletedNotice;?>
<?php if(common::hasPriv('zahost', 'edit')) 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 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'");;?>
<?php if(common::hasPriv('zahost', 'browseImage')) common::printIcon('zahost', 'browseImage', "hostID={$host->hostID}", $host, 'list', 'file', '', 'iframe', true, "data-width='60%'", $lang->zahost->image->list);?>
<?php if(common::hasPriv('zahost', 'initHost')) common::printIcon('zahost', 'initHost', "hostID={$host->hostID}", $host, 'list', 'info', '', '', false, '', $lang->zahost->initHost->title);?>
</td>
+7 -2
View File
@@ -20,10 +20,15 @@
<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 . ' -t ' . getWebRoot(true); ?></span></div>
<div>
<span class='dot-symbol'></span>
<span>
<?php echo $lang->zahost->initHost->initDesc . ' ' . $host->secret . ' -t ' . getWebRoot(true); ?>
</span>
</div>
<div id="statusContainer">
</div>
</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');
+73 -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'));
}
$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));
}
}
}
+2
View File
@@ -0,0 +1,2 @@
.progress{height: 20px;}
#mainContent{margin: 0 auto;}
+8 -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,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. <a href="%s">Created</a>';
$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';
+8 -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,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. <a href="%s">Created</a>';
$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';
+8 -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,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. <a href="%s">Created</a>';
$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';
+7 -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,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 = '镜像创建成功,您可以使用此镜像创建执行节点。<a href="%s">去创建</a>';
$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'] = '销毁失败';
+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;
}
}
return $result;
}
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}' data-width='50%'", '', 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'; ?>
+94
View File
@@ -0,0 +1,94 @@
<?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';?>
<?php if($task):?>
<?php js::set('taskID', $task->task);?>
<?php js::set('extranet', $node->ip);?>
<style>.body-modal #mainContent{width:90%;}
</style>
<?php endif;?>
<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>
<h6 class='hide text-center fail'><?php echo $lang->zanode->createImageFail;?></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>
<?php if($task):?>
<script>
var setProgress = self.setInterval("getTaskProgress()",500);
function getTaskProgress()
{
var url = createLink('zanode', 'ajaxGetTaskStatus', 'extranet=' + extranet + '&taskID=' + taskID + '&type=exportVm');
$.get(url, function(data)
{
var rate = data.rate;
var status = data.status;
if(rate == 1 || status == 'completed') rate = 100;
$('.rate').css('width', rate + '%');
if(rate == 100 || (status != 'inprogress' && status != 'created'))
{
updateStatus(data);
clearInterval(setProgress);
}
}, 'json');
}
function updateStatus(data)
{
var url = createLink('zanode', 'ajaxUpdateImage', 'taskID=' + taskID)
var postData = {"status":data.status, "path":data.path}
$.post(url, postData, function(result)
{
if(data.status == 'completed') $('.success').removeClass('hide');
else $('.fail').removeClass('hide');
}, 'json');
}
</script>
<?php endif;;?>
<?php include '../../common/view/footer.html.php';?>