Merge branch 'zenops_46_wangjianhua_68262' into zenops_46
This commit is contained in:
@@ -246,6 +246,9 @@ define('TABLE_TESTTASK', '`' . $config->db->prefix . 'testtask`');
|
||||
define('TABLE_TESTRUN', '`' . $config->db->prefix . 'testrun`');
|
||||
define('TABLE_TESTRESULT', '`' . $config->db->prefix . 'testresult`');
|
||||
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`');
|
||||
|
||||
define('TABLE_PRODUCT', '`' . $config->db->prefix . 'product`');
|
||||
define('TABLE_BRANCH', '`' . $config->db->prefix . 'branch`');
|
||||
@@ -402,4 +405,4 @@ $config->waterfallModules = array('workestimation', 'durationestimation', 'budge
|
||||
$config->showMainMenu = true;
|
||||
$config->maxPriValue = '256';
|
||||
|
||||
$config->importWhiteList = array('user', 'task', 'story', 'bug', 'testcase', 'feedback');
|
||||
$config->importWhiteList = array('user', 'task', 'story', 'bug', 'testcase', 'feedback');
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
ALTER TABLE `zt_host` ADD `type` varchar(30) NOT NULL DEFAULT 'normal' AFTER `admin`;
|
||||
ALTER TABLE `zt_host` ADD `secret` varchar(50) NOT NULL DEFAULT '' AFTER `type`;
|
||||
ALTER TABLE `zt_host` ADD `virtualSoftware` varchar(30) NOT NULL DEFAULT '' AFTER `secret`;
|
||||
ALTER TABLE `zt_vmtemplate` ADD `type` varchar(30) NOT NULL DEFAULT 'normal' AFTER `hostID`;
|
||||
|
||||
@@ -394,7 +394,13 @@ $lang->qa->menuOrder[25] = 'testsuite';
|
||||
$lang->qa->menuOrder[30] = 'testtask';
|
||||
$lang->qa->menuOrder[35] = 'report';
|
||||
$lang->qa->menuOrder[40] = 'caselib';
|
||||
$lang->qa->menuOrder[45] = 'automation';
|
||||
$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|productID=%s", 'alias' => '');
|
||||
|
||||
//$lang->qa->menu->automation['subMenu'] = new stdclass();
|
||||
//$lang->qa->menu->automation['subMenu']->browse = array('link' => "{$lang->zahost->common}|zahost|browse|productID=%s", 'alias' => '');
|
||||
|
||||
$lang->qa->menu->automation['subMenu'] = new stdclass();
|
||||
$lang->qa->menu->automation['subMenu']->browse = array('link' => "{$lang->zahost->common}|zahost|browse", 'alias' => 'create');
|
||||
@@ -651,7 +657,8 @@ $lang->navGroup->qa = 'qa';
|
||||
$lang->navGroup->bug = 'qa';
|
||||
$lang->navGroup->testcase = 'qa';
|
||||
$lang->navGroup->testtask = 'qa';
|
||||
$lang->navGroup->automation = 'qa';
|
||||
//$lang->navGroup->automation = 'qa';
|
||||
$lang->navGroup->zahost = 'qa';
|
||||
$lang->navGroup->testreport = 'qa';
|
||||
$lang->navGroup->testcase = 'qa';
|
||||
$lang->navGroup->testtask = 'qa';
|
||||
|
||||
@@ -39,7 +39,7 @@ $lang->moduleOrder[85] = 'testtask';
|
||||
$lang->moduleOrder[90] = 'testsuite';
|
||||
$lang->moduleOrder[95] = 'testreport';
|
||||
$lang->moduleOrder[100] = 'caselib';
|
||||
$lang->moduleOrder[105] = 'automation';
|
||||
$lang->moduleOrder[105] = 'zahost';
|
||||
|
||||
$lang->moduleOrder[110] = 'doc';
|
||||
$lang->moduleOrder[115] = 'report';
|
||||
@@ -1191,6 +1191,13 @@ $lang->resource->automation->browse = 'browse';
|
||||
|
||||
$lang->automation->methodOrder[0] = 'browse';
|
||||
|
||||
$lang->resource->zahost = new stdclass();
|
||||
$lang->resource->zahost->browse = 'browse';
|
||||
$lang->resource->zahost->create = 'create';
|
||||
|
||||
$lang->zahost->methodOrder[0] = 'browse';
|
||||
$lang->zahost->methodOrder[5] = 'create';
|
||||
|
||||
$lang->resource->repo = new stdclass();
|
||||
$lang->resource->repo->browse = 'browseAction';
|
||||
$lang->resource->repo->view = 'view';
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
$config->zahost->create = new stdclass();
|
||||
$config->zahost->create->requiredFields = 'name,hostType,publicIP,cpuCores,memory,diskSize,virtualSoftware,instanceNum';
|
||||
$config->zahost->create->ipFields = 'publicIP';
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* The control file of zahost 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
|
||||
*/
|
||||
class zahost extends control
|
||||
{
|
||||
/**
|
||||
* Create host.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
if($_POST)
|
||||
{
|
||||
$this->zahost->create();
|
||||
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->create;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#unit {padding: 0px !important; width:0px; border-left: 0px;}
|
||||
.input-group-addon {border: 0px;}
|
||||
#unit_chosen a {border-left: 0px; border-radius: 0 2px;}
|
||||
@@ -0,0 +1,5 @@
|
||||
$(document).ready(function(){
|
||||
$('#publicIP').change(function(){
|
||||
//@todo check IP
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
$lang->zahost->common = '宿主机';
|
||||
$lang->zahost->browse = '主机列表';
|
||||
$lang->zahost->create = '添加宿主机';
|
||||
$lang->zahost->view = '主机详情';
|
||||
$lang->zahost->edit = '编辑';
|
||||
$lang->zahost->editAction = '编辑主机';
|
||||
$lang->zahost->delete = '删除';
|
||||
$lang->zahost->deleteAction = '删除主机';
|
||||
$lang->zahost->byQuery = '搜索';
|
||||
|
||||
$lang->zahost->name = '名称';
|
||||
$lang->zahost->IP = 'IP';
|
||||
$lang->zahost->publicIP = 'IP';
|
||||
$lang->zahost->memory = '内存大小';
|
||||
$lang->zahost->cpuCores = 'CPU核心数';
|
||||
$lang->zahost->diskSize = '硬盘容量';
|
||||
$lang->zahost->instanceNum = '最大实例数';
|
||||
|
||||
$lang->zahost->createdBy = '由谁创建';
|
||||
$lang->zahost->createdDate = '创建时间';
|
||||
$lang->zahost->editedBy = '由谁编辑';
|
||||
$lang->zahost->editedDate = '编辑时间';
|
||||
$lang->zahost->all = '所有主机';
|
||||
|
||||
$lang->zahost->empty = '暂时没有主机';
|
||||
|
||||
$lang->zahost->virtualSoftware = '虚拟化软件';
|
||||
$lang->zahost->softwareList['kvm'] = 'KVM';
|
||||
|
||||
$lang->zahost->unitList['GB'] = 'GB';
|
||||
$lang->zahost->unitList['TB'] = 'TB';
|
||||
|
||||
$lang->zahost->zaHostType = '主机类型';
|
||||
$lang->zahost->zaHostTypeList['physical'] = '实体主机';
|
||||
//$lang->zahost->zaHostTypeList['virtual'] = '虚拟主机';
|
||||
|
||||
$lang->zahost->confirmDelete = '是否删除该主机记录?';
|
||||
|
||||
$lang->zahost->notice = new stdclass();
|
||||
$lang->zahost->notice->ip = '『%s』格式不正确!';
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* The model 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 Wang Jianhua <wangjiahua@easycorp.ltd>
|
||||
* @package zahost
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
class zahostModel extends model
|
||||
{
|
||||
/**
|
||||
* Set lang;
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->app->lang->host = $this->lang->zahost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get host by id.
|
||||
*
|
||||
* @param int $hostID
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getById($hostID)
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_ZAHOST)->where('id')->eq($hostID) ->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a host.
|
||||
*
|
||||
* @access public
|
||||
* @return int|bool
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$hostInfo = fixer::input('post')
|
||||
->setDefault('cpuNumber,cpuCores,diskSize,memory', 0)
|
||||
->get();
|
||||
|
||||
$this->dao->table = 'zahost';
|
||||
$this->dao->update(TABLE_ZAHOST)->data($hostInfo)
|
||||
->batchCheck($this->config->zahost->create->requiredFields, 'notempty')
|
||||
->batchCheck('cpuCores,instanceNum', 'int')
|
||||
->batchCheck('cpuCores,diskSize,instanceNum', 'gt', 0)
|
||||
->batchCheck('diskSize,memory', 'float')
|
||||
->autoCheck();
|
||||
if(dao::isError()) return false;
|
||||
|
||||
if(!preg_match('/((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/', $hostInfo->publicIP))
|
||||
{
|
||||
dao::$errors['publicIP'][] = sprintf($this->lang->zahost->notice->ip, $this->lang->zahost->publicIP);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->dao->update(TABLE_ASSET)->data($hostInfo)->check('name', 'unique');
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$assetInfo['name'] = $hostInfo->name;
|
||||
$assetInfo['type'] = 'zahost';
|
||||
$assetInfo['status'] = 'normal';
|
||||
$assetInfo['createdBy'] = $this->app->user->account;
|
||||
$assetInfo['createdDate'] = helper::now();
|
||||
|
||||
$this->dao->insert(TABLE_ASSET)->data($assetInfo)->autoCheck()->exec();
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$hostInfo->assetID = $this->dao->lastInsertID();
|
||||
|
||||
$this->dao->insert(TABLE_ZAHOST)->data($hostInfo, $skipFields='name')->autoCheck()->exec();
|
||||
$hostID = $this->dao->lastInsertID();
|
||||
if(!dao::isError())
|
||||
{
|
||||
$this->loadModel('action')->create('zahost', $hostID, 'created');
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* The create 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';?>
|
||||
<div id='mainContent' class='main-content'>
|
||||
<div class='main-header'>
|
||||
<h2><?php echo $lang->zahost->create?></h2>
|
||||
</div>
|
||||
<form method='post' target='hiddenwin' id='ajaxForm'>
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th class='w-100px'><?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->zaHostType;?></th>
|
||||
<td><?php echo html::select('hostType', $lang->zahost->zaHostTypeList, 'virtual', "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->zahost->IP;?></th>
|
||||
<td><?php echo html::input('publicIP', '', "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->zahost->cpuCores;?></th>
|
||||
<td><?php echo html::input('cpuCores', '', "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->zahost->memory;?></th>
|
||||
<td>
|
||||
<div class='input-group'>
|
||||
<?php echo html::input('memory', '', "class='form-control'");?>
|
||||
<span class="input-group-addon"><?php echo $lang->zahost->unitList['GB'];?></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 fix-border fix-padding' id='unit'>
|
||||
<?php echo html::select('unit', $lang->zahost->unitList, 'GB', "class='form-control chosen w-50px'");?>
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->zahost->virtualSoftware;?></th>
|
||||
<td><?php echo html::select('virtualSoftware', $lang->zahost->softwareList, '', "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->zahost->instanceNum?></th>
|
||||
<td><?php echo html::input('instanceNum', '', "class='form-control'");?></td>
|
||||
</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';?>
|
||||
Reference in New Issue
Block a user