Merge branch 'zenops_46_wangjianhua_68266' into 'zenops_46'

Create VM template.

See merge request easycorp/zentaopms!5311
This commit is contained in:
李玉春
2022-09-13 05:52:10 +00:00
13 changed files with 254 additions and 3 deletions
+1
View File
@@ -249,6 +249,7 @@ define('TABLE_USERTPL', '`' . $config->db->prefix . 'usertpl`');
define('TABLE_ZAHOST', '`' . $config->db->prefix . 'host`');
if(!defined('TABLE_ASSET')) define('TABLE_ASSET', '`' . $config->db->prefix . 'asset`');
if(!defined('TABLE_VMTEMPLATE')) define('TABLE_VMTEMPLATE', '`' . $config->db->prefix . 'vmtemplate`');
define('TABLE_PRODUCT', '`' . $config->db->prefix . 'product`');
define('TABLE_BRANCH', '`' . $config->db->prefix . 'branch`');
+3
View File
@@ -112,6 +112,7 @@ $lang->action->objectTypes['testsuite'] = 'Suite';
$lang->action->objectTypes['testtask'] = 'Test Build';
$lang->action->objectTypes['testreport'] = 'Berichte';
$lang->action->objectTypes['zahost'] = 'Host';
$lang->action->objectTypes['vmtemplate'] = 'Virtual Host Template';
$lang->action->objectTypes['doc'] = 'Dok';
$lang->action->objectTypes['api'] = 'Interface';
$lang->action->objectTypes['doclib'] = 'Dok Bibliothek';
@@ -614,6 +615,8 @@ $lang->action->dynamicAction->caselib['hidden'] = 'Hide Case Lib';
$lang->action->dynamicAction->zahost['created'] = 'Create Host';
$lang->action->dynamicAction->vmtemplate['created'] = 'Create Virtual Host Template';
$lang->action->dynamicAction->doclib['created'] = 'Create Doc Library';
$lang->action->dynamicAction->doclib['edited'] = 'Edit Doc Library';
$lang->action->dynamicAction->doclib['deleted'] = 'Delete Doc Library';
+3
View File
@@ -112,6 +112,7 @@ $lang->action->objectTypes['testsuite'] = 'Suite';
$lang->action->objectTypes['testtask'] = 'Test Build';
$lang->action->objectTypes['testreport'] = 'Report';
$lang->action->objectTypes['zahost'] = 'Host';
$lang->action->objectTypes['vmtemplate'] = 'Virtual Host Template';
$lang->action->objectTypes['doc'] = 'Document';
$lang->action->objectTypes['api'] = 'Interface';
$lang->action->objectTypes['doclib'] = 'Document Library';
@@ -614,6 +615,8 @@ $lang->action->dynamicAction->caselib['hidden'] = 'Hide Case Lib';
$lang->action->dynamicAction->zahost['created'] = 'Create Host';
$lang->action->dynamicAction->vmtemplate['created'] = 'Create Virtual Host Template';
$lang->action->dynamicAction->doclib['created'] = 'Create Doc Library';
$lang->action->dynamicAction->doclib['edited'] = 'Edit Doc Library';
$lang->action->dynamicAction->doclib['deleted'] = 'Delete Doc Library';
+2
View File
@@ -614,6 +614,8 @@ $lang->action->dynamicAction->caselib['hidden'] = 'Masqué CasTest Lib';
$lang->action->dynamicAction->zahost['created'] = 'Create Host';
$lang->action->dynamicAction->vmtemplate['created'] = 'Create Virtual Host Template';
$lang->action->dynamicAction->doclib['created'] = 'Créer Doc Library';
$lang->action->dynamicAction->doclib['edited'] = 'Editer Doc Library';
$lang->action->dynamicAction->doclib['deleted'] = 'Delete Doc Library';
+3
View File
@@ -89,6 +89,7 @@ $lang->action->objectTypes['testsuite'] = 'Suite';
$lang->action->objectTypes['testtask'] = 'Test bản dựng';
$lang->action->objectTypes['testreport'] = 'Báo cáo';
$lang->action->objectTypes['zahost'] = 'Host';
$lang->action->objectTypes['vmtemplate'] = 'Virtual Host Template';
$lang->action->objectTypes['doc'] = 'Tài liệu';
$lang->action->objectTypes['doclib'] = 'Thư viện tài liệu';
$lang->action->objectTypes['todo'] = 'Việc làm';
@@ -475,6 +476,8 @@ $lang->action->dynamicAction->caselib['hidden'] = 'Ẩn Case Lib';
$lang->action->dynamicAction->zahost['created'] = 'Create Host';
$lang->action->dynamicAction->vmtemplate['created'] = 'Create Virtual Host Template';
$lang->action->dynamicAction->doclib['created'] = 'Tạo Doc thư viện';
$lang->action->dynamicAction->doclib['edited'] = 'Sửa Doc thư viện';
$lang->action->dynamicAction->doclib['deleted'] = 'Delete Doc Library';
+3
View File
@@ -112,6 +112,7 @@ $lang->action->objectTypes['testsuite'] = '套件';
$lang->action->objectTypes['testtask'] = '测试单';
$lang->action->objectTypes['testreport'] = '报告';
$lang->action->objectTypes['zahost'] = '宿主机';
$lang->action->objectTypes['vmtemplate'] = '虚拟机模板';
$lang->action->objectTypes['doc'] = '文档';
$lang->action->objectTypes['api'] = '接口';
$lang->action->objectTypes['doclib'] = '文档库';
@@ -614,6 +615,8 @@ $lang->action->dynamicAction->caselib['hidden'] = '隐藏用例库';
$lang->action->dynamicAction->zahost['created'] = '创建宿主机';
$lang->action->dynamicAction->vmtemplate['created'] = '创建虚拟机模板';
$lang->action->dynamicAction->doclib['created'] = '创建文档库';
$lang->action->dynamicAction->doclib['edited'] = '编辑文档库';
$lang->action->dynamicAction->doclib['deleted'] = '删除文档库';
+1 -1
View File
@@ -397,7 +397,7 @@ $lang->qa->menuOrder[40] = 'caselib';
$lang->qa->menuOrder[45] = 'zahost';
$lang->qa->menu->zahost['subMenu'] = new stdclass();
$lang->qa->menu->zahost['subMenu']->browse = array('link' => "{$lang->zahost->common}|zahost|browse", 'alias' => 'browse,create');
$lang->qa->menu->zahost['subMenu']->browse = array('link' => "{$lang->zahost->common}|zahost|browse", 'alias' => 'browse,create,createtemplate');
// $lang->qa->menu->automation['subMenu'] = new stdclass();
// $lang->qa->menu->automation['subMenu']->browse = array('link' => "{$lang->automation->common}|zahost|browse", 'alias' => 'create');
+18
View File
@@ -3,6 +3,24 @@ $config->zahost->create = new stdclass();
$config->zahost->create->requiredFields = 'name,hostType,publicIP,cpuCores,memory,diskSize,virtualSoftware,instanceNum';
$config->zahost->create->ipFields = 'publicIP';
$config->zahost->createTemplate = new stdclass();
$config->zahost->createTemplate->requiredFields = 'name,cpuCoreNum,memorySize,diskSize,osCategory,osType,osVersion,osLang';
$config->zahost->os = new stdClass();
$config->zahost->os->list = array();
$config->zahost->os->list['windows'] = 'Windows';
$config->zahost->os->list['linux'] = 'Linux';
$config->zahost->os->type = array();
$config->zahost->os->type['windows']['winServer'] = 'Windows Server';
$config->zahost->os->type['windows']['win11'] = 'Windows 11';
$config->zahost->os->type['windows']['win10'] = 'Windows 10';
$config->zahost->os->type['windows']['win7'] = 'Windows 7';
$config->zahost->os->type['windows']['winxp'] = 'Windows XP';
$config->zahost->os->type['linux']['ubuntu'] = 'Ubuntu';
$config->zahost->os->type['linux']['centos'] = 'CentOS';
$config->zahost->os->type['linux']['debian'] = 'Debian';
global $lang;
$config->zahost->search['module'] = 'zahost';
$config->zahost->search['fields']['name'] = $lang->zahost->name;
+20
View File
@@ -74,4 +74,24 @@ class zahost extends control
$this->view->title = $this->lang->zahost->create;
$this->display();
}
/**
* Create template.
*
* @access public
* @return void
*/
public function createTemplate()
{
if($_POST)
{
$this->zahost->createTemplate();
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inLink('browse')));
}
$this->view->title = $this->lang->zahost->createTemplate;
$this->display();
}
}
+40
View File
@@ -0,0 +1,40 @@
$(function()
{
$('#osCategory').change(function()
{
var os = $('#osCategory').val();
$('#osType').empty();
var types = zahostConfig.os.type[os];
for(code in types) $('#osType').append('<option value="' + code + '">' + types[code] + '</option>');
$('#osType').chosen().trigger('chosen:updated');
$('#osType').change();
});
$('#osType').change(function()
{
var type = $('#osType').val();
$('#osVersion').empty();
var versions = zahostLang.versionList[type];
for(code in versions) $('#osVersion').append('<option value="' + code + '">' + versions[code] + '</option>');
$('#osVersion').chosen().trigger('chosen:updated');
$('#osVersion').change();
});
$('#osVersion').change(function()
{
if(config.currentMethod != 'create') return;
var os = $('#osCategory').val();
var type = $('#osType').val();
var version = $('#osVersion').val();
var link = createLink('zahost', 'ajaxGetVmTemplateList', 'osCategory=' + os + '&osType=' + type + '&osVersion=' + version);
$.get(link, function(data)
{
$('#template').html('').append(data);
if(template) $('#vmTemplate').val(template.id);
$('#vmTemplate').chosen().trigger("chosen:updated");
});
});
$('#osCategory').change();
})
+55 -1
View File
@@ -13,7 +13,7 @@ $lang->zahost->all = '所有主机';
$lang->zahost->name = '名称';
$lang->zahost->IP = 'IP';
$lang->zahost->publicIP = 'IP';
$lang->zahost->memory = '内存大小';
$lang->zahost->memory = '内存';
$lang->zahost->cpuCores = 'CPU核心数';
$lang->zahost->diskSize = '硬盘容量';
$lang->zahost->instanceNum = '最大实例数';
@@ -26,6 +26,32 @@ $lang->zahost->editedBy = '由谁修改';
$lang->zahost->editedDate = '最后修改时间';
$lang->zahost->registerDate = '最后注册时间';
$lang->zahost->createTemplate = '创建虚拟机模板';
$lang->zahost->memorySize = $lang->zahost->memory;
$lang->zahost->cpuCoreNum = $lang->zahost->cpuCores;
$lang->zahost->osType = '操作系统版本';
$lang->zahost->osCategory = '操作系统平台';
$lang->zahost->osVersion = '操作系统版本号';
$lang->zahost->osLang = '系统语言';
$lang->zahost->imageFile = '镜像文件';
$lang->zahost->vmTemplate = new stdclass;
$lang->zahost->vmTemplate->name = '名称';
$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpuCores;
$lang->zahost->vmTemplate->memorySize = $lang->zahost->memory;
$lang->zahost->vmTemplate->diskSize = $lang->zahost->diskSize;
$lang->zahost->vmTemplate->osType = $lang->zahost->osType;
$lang->zahost->vmTemplate->osCategory = $lang->zahost->osCategory;
$lang->zahost->vmTemplate->osVersion = $lang->zahost->osVersion;
$lang->zahost->vmTemplate->osLang = $lang->zahost->osLang;
$lang->zahost->vmTemplate->imageFile = $lang->zahost->imageFile;
$lang->zahost->langList = array();
$lang->zahost->langList['zh_cn'] = '简体中文';
$lang->zahost->langList['zh_tw'] = '繁体中文';
$lang->zahost->langList['en_us'] = '美式英语';
$lang->zahost->empty = '暂时没有主机';
$lang->zahost->statusList['online'] = '已上架';
@@ -42,5 +68,33 @@ $lang->zahost->zaHostTypeList['physical'] = '实体主机';
$lang->zahost->confirmDelete = '是否删除该主机记录?';
$lang->zahost->versionList = array();
$lang->zahost->versionList['winxp']['all'] = 'Windows XP';
$lang->zahost->versionList['win7']['home'] = '家庭版';
$lang->zahost->versionList['win7']['professional'] = '专业版';
$lang->zahost->versionList['win7']['enterprise'] = '企业版';
$lang->zahost->versionList['win7']['ultimate'] = '旗舰版';
$lang->zahost->versionList['win10']['home'] = '家庭版';
$lang->zahost->versionList['win10']['professional'] = '专业版';
$lang->zahost->versionList['win10']['enterprise'] = '企业版';
$lang->zahost->versionList['win10']['ultimate'] = '旗舰版';
$lang->zahost->versionList['win11']['home'] = '家庭版';
$lang->zahost->versionList['win11']['professional'] = '专业版';
$lang->zahost->versionList['win11']['enterprise'] = '企业版';
$lang->zahost->versionList['win11']['ultimate'] = '旗舰版';
$lang->zahost->versionList['winServer']['2008'] = '2008';
$lang->zahost->versionList['winServer']['2012'] = '2012';
$lang->zahost->versionList['winServer']['2016'] = '2016';
$lang->zahost->versionList['winServer']['2019'] = '2019';
$lang->zahost->versionList['debian']['9'] = '9';
$lang->zahost->versionList['debian']['10'] = '10';
$lang->zahost->versionList['debian']['11'] = '11';
$lang->zahost->versionList['ubuntu']['16'] = '16';
$lang->zahost->versionList['ubuntu']['18'] = '18';
$lang->zahost->versionList['ubuntu']['20'] = '20';
$lang->zahost->versionList['centos']['6'] = '6';
$lang->zahost->versionList['centos']['7'] = '7';
$lang->zahost->versionList['centos']['8'] = '8';
$lang->zahost->notice = new stdclass();
$lang->zahost->notice->ip = '『%s』格式不正确!';
+25 -1
View File
@@ -20,7 +20,8 @@ class zahostModel extends model
public function __construct()
{
parent::__construct();
$this->app->lang->host = $this->lang->zahost;
$this->app->lang->host = $this->lang->zahost;
$this->app->lang->vmtemplate = $this->lang->zahost;
}
/**
@@ -134,4 +135,27 @@ class zahostModel extends model
->page($pager)
->fetchAll();
}
/**
* Create vm template.
*
* @access public
* @return void
*/
public function createTemplate()
{
$template = fixer::input('post')
->setIF($this->post->diskSize > 0, 'diskSize', $this->post->diskSize * 1024)
->get();
$this->dao->insert(TABLE_VMTEMPLATE)->data($template)
->batchCheck($this->config->zahost->createTemplate->requiredFields, 'notempty')
->batchCheck('cpuCoreNum,diskSize,memorySize', 'gt', 0)
->autoCheck()
->exec();
if(dao::isError()) return false;
$templateID = $this->dao->lastInsertID();
$this->loadModel('action')->create('vmtemplate', $templateID, 'Created');
}
}
@@ -0,0 +1,80 @@
<?php
/**
* The create vm template view file of zahost 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 Jianhua Wang<wangjianhua@easycorp.ltd>
* @package zahost
* @version $Id$
* @link http://www.zentao.net
*/
?>
<?php include $app->getModuleRoot() . 'common/view/header.html.php';?>
<?php js::set('zahostConfig', $config->zahost);?>
<?php js::set('zahostLang', $lang->zahost);?>
<?php js::set('templateID', '');?>
<div id='mainContent' class='main-content'>
<div class='main-header'>
<h2><?php echo $lang->zahost->createTemplate;?></h2>
</div>
<form method='post' target='hiddenwin' id='ajaxForm' class="load-indicator main-form form-ajax">
<table class='table table-form'>
<tr>
<th class='w-120px'><?php echo $lang->zahost->name;?></th>
<td><?php echo html::input('name', '', "class='form-control'");?></td>
<td></td>
</tr>
<tr>
<th><?php echo $lang->zahost->cpuCores;?></th>
<td><?php echo html::input('cpuCoreNum', '', "class='form-control'");?></td>
</tr>
<tr>
<th><?php echo $lang->zahost->memory;?></th>
<td>
<div class='input-group'>
<?php echo html::input('memorySize', '', "class='form-control'");?>
<span class="input-group-addon">MB</span>
</div>
</td>
</tr>
<tr>
<th><?php echo $lang->zahost->diskSize;?></th>
<td>
<div class='input-group'>
<?php echo html::input('diskSize', '', "class='form-control'");?>
<span class='input-group-addon id='unit'>GB</span>
</div>
</td>
</tr>
<tr>
<th><?php echo $lang->zahost->vmTemplate->osCategory;?></th>
<td><?php echo html::select('osCategory', $config->zahost->os->list, '', "class='form-control chosen'")?></td>
</tr>
<tr>
<th><?php echo $lang->zahost->vmTemplate->osType;?></th>
<td><?php echo html::select('osType', '', '', "class='form-control chosen'")?></td>
</tr>
<tr>
<th><?php echo $lang->zahost->vmTemplate->osVersion;?></th>
<td><?php echo html::select('osVersion', '', '', "class='form-control chosen'")?></td>
</tr>
<tr>
<th><?php echo $lang->zahost->vmTemplate->osLang;?></th>
<td><?php echo html::select('osLang', $lang->zahost->langList, '', "class='form-control chosen'")?></td>
<tr>
<th><?php echo $lang->zahost->vmTemplate->imageFile;?></th>
<td><?php echo html::select('imageFile', '', '', "class='form-control chosen'")?></td>
</tr>
</tr>
<tr>
<td colspan='2' class='text-center form-actions'>
<?php echo html::submitButton();?>
<?php echo html::backButton();?>
<?php echo html::hidden('type', 'za');?>
</td>
</tr>
</table>
</form>
</div>
<?php include $app->getModuleRoot() . 'common/view/footer.html.php';?>