* Finish task #68265.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
* @version 1
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
class hostHeartbeatEntry extends Entry
|
||||
class hostHeartbeatEntry extends baseEntry
|
||||
{
|
||||
/**
|
||||
* Listen host heartbeat.
|
||||
@@ -20,16 +20,39 @@ class hostHeartbeatEntry extends Entry
|
||||
*/
|
||||
public function post()
|
||||
{
|
||||
$secret = $this->requestBody->secret;
|
||||
/* Check authorize. */
|
||||
$secret = isset($this->requestBody->secret) ? $this->requestBody->secret : '';
|
||||
$token = isset($_SERVER['HTTP_TOKEN']) ? $_SERVER['HTTP_TOKEN'] : '';
|
||||
if(!$secret and !$token) return $this->sendError(401, 'Unauthorized');
|
||||
|
||||
/* Check param. */
|
||||
$status = $this->requestBody->status;
|
||||
$now = helper::now();
|
||||
if(!$secret or !$status) return $this->sendError(400, 'Params error.');
|
||||
if(!$status) return $this->sendError(400, 'Params error.');
|
||||
|
||||
$this->dao->update(TABLE_HOST)->set('status')->eq($status)->where('secret')->eq($secret)->exec();
|
||||
$conditionField = $secret ? 'secret' : 'token';
|
||||
$conditionValue = $secret ? $secret : $token;
|
||||
$host = new stdclass();
|
||||
$host->status = $status;
|
||||
if($secret)
|
||||
{
|
||||
$host->token = md5($secret . $now);
|
||||
$host->expiredDate = date('Y-m-d H:i:s', time() + 7200);
|
||||
}
|
||||
|
||||
$assetID = $this->dao->select('assetID')->from(TABLE_HOST)->where('secret')->eq($secret)->fetch('assetID');
|
||||
$this->dao = $this->loadModel('common')->dao;
|
||||
$assetID = $this->dao->select('assetID')->from(TABLE_HOST)
|
||||
->beginIF($secret)->where('secret')->eq($secret)->fi()
|
||||
->beginIF(!$secret)->where('token')->eq($token)
|
||||
->andWhere('expiredDate')->gt($now)->fi()
|
||||
->fetch('assetID');
|
||||
if(!$assetID) return $this->sendError(400, 'Secret error.');
|
||||
|
||||
$this->dao->update(TABLE_HOST)->data($host)->where($conditionField)->eq($conditionValue)->exec();
|
||||
$this->dao->update(TABLE_ASSET)->set('registerDate')->eq($now)->where('id')->eq($assetID)->exec();
|
||||
|
||||
$this->sendSuccess(200, 'success');
|
||||
if(!$secret) return $this->send(200, 'success');
|
||||
unset($host->status);
|
||||
return $this->send(200, $host);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
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 `token` varchar(50) NOT NULL DEFAULT '' AFTER `type`;
|
||||
ALTER TABLE `zt_host` ADD `expiredDate` datetime NOT NULL AFTER `type`;
|
||||
ALTER TABLE `zt_host` ADD `virtualSoftware` varchar(30) NOT NULL DEFAULT '' AFTER `secret`;
|
||||
ALTER TABLE `zt_asset` ADD `registerDate` datetime NOT NULL AFTER `editedDate`;
|
||||
ALTER TABLE `zt_vmtemplate` ADD `type` varchar(30) NOT NULL DEFAULT 'normal' AFTER `hostID`;
|
||||
|
||||
@@ -1194,9 +1194,13 @@ $lang->automation->methodOrder[0] = 'browse';
|
||||
$lang->resource->zahost = new stdclass();
|
||||
$lang->resource->zahost->browse = 'browse';
|
||||
$lang->resource->zahost->create = 'create';
|
||||
$lang->resource->zahost->browseTemplate = 'browseTemplate';
|
||||
$lang->resource->zahost->createTemplate = 'createTemplate';
|
||||
|
||||
$lang->zahost->methodOrder[0] = 'browse';
|
||||
$lang->zahost->methodOrder[5] = 'create';
|
||||
$lang->zahost->methodOrder[0] = 'browse';
|
||||
$lang->zahost->methodOrder[5] = 'create';
|
||||
$lang->zahost->methodOrder[10] = 'browseTemplate';
|
||||
$lang->zahost->methodOrder[15] = 'createTemplate';
|
||||
|
||||
$lang->resource->repo = new stdclass();
|
||||
$lang->resource->repo->browse = 'browseAction';
|
||||
|
||||
@@ -24,7 +24,7 @@ $config->zahost->os->type['linux']['debian'] = 'Debian';
|
||||
global $lang;
|
||||
$config->zahost->search['module'] = 'zahost';
|
||||
$config->zahost->search['fields']['name'] = $lang->zahost->name;
|
||||
$config->zahost->search['fields']['id'] = 'ID';
|
||||
$config->zahost->search['fields']['id'] = $lang->zahost->id;
|
||||
$config->zahost->search['fields']['type'] = $lang->zahost->type;
|
||||
$config->zahost->search['fields']['publicIP'] = $lang->zahost->IP;
|
||||
$config->zahost->search['fields']['cpuCores'] = $lang->zahost->cpuCores;
|
||||
@@ -54,3 +54,62 @@ $config->zahost->search['params']['createdDate'] = array('operator' => '=',
|
||||
$config->zahost->search['params']['registerDate'] = array('operator' => '=', 'control' => 'input', 'values' => '', 'class' => 'date');
|
||||
$config->zahost->search['params']['editedBy'] = array('operator' => '=', 'control' => 'select', 'values' => 'users');
|
||||
$config->zahost->search['params']['editedDate'] = array('operator' => '=', 'control' => 'input', 'values' => '', 'class' => 'date');
|
||||
|
||||
$config->vmTemplate = new stdclass();
|
||||
$config->vmTemplate->os = new stdClass();
|
||||
$config->vmTemplate->os->list = array();
|
||||
$config->vmTemplate->os->list['windows'] = 'Windows';
|
||||
$config->vmTemplate->os->list['linux'] = 'Linux';
|
||||
|
||||
$config->vmTemplate->os->cpu = array();
|
||||
$config->vmTemplate->os->cpu['1'] = '1';
|
||||
$config->vmTemplate->os->cpu['2'] = '2';
|
||||
$config->vmTemplate->os->cpu['4'] = '4';
|
||||
$config->vmTemplate->os->cpu['6'] = '6';
|
||||
$config->vmTemplate->os->cpu['8'] = '8';
|
||||
$config->vmTemplate->os->cpu['12'] = '12';
|
||||
$config->vmTemplate->os->cpu['16'] = '16';
|
||||
|
||||
$config->vmTemplate->os->memory = array();
|
||||
$config->vmTemplate->os->memory['512'] = '512MB';
|
||||
$config->vmTemplate->os->memory['1024'] = '1GB';
|
||||
$config->vmTemplate->os->memory['2048'] = '2GB';
|
||||
$config->vmTemplate->os->memory['4096'] = '4GB';
|
||||
$config->vmTemplate->os->memory['9120'] = '8GB';
|
||||
$config->vmTemplate->os->memory['16384'] = '16GB';
|
||||
|
||||
$config->vmTemplate->os->disk = array();
|
||||
$config->vmTemplate->os->disk['10240'] = '10GB';
|
||||
$config->vmTemplate->os->disk['20480'] = '20GB';
|
||||
$config->vmTemplate->os->disk['40960'] = '40GB';
|
||||
$config->vmTemplate->os->disk['61440'] = '60GB';
|
||||
$config->vmTemplate->os->disk['81920'] = '80GB';
|
||||
$config->vmTemplate->os->disk['102400'] = '100GB';
|
||||
$config->vmTemplate->os->disk['204800'] = '200GB';
|
||||
$config->vmTemplate->os->disk['307200'] = '300GB';
|
||||
|
||||
$config->vmTemplate->os->type = array();
|
||||
$config->vmTemplate->os->type['windows']['winServer'] = 'Windows Server';
|
||||
$config->vmTemplate->os->type['windows']['win11'] = 'Windows 11';
|
||||
$config->vmTemplate->os->type['windows']['win10'] = 'Windows 10';
|
||||
$config->vmTemplate->os->type['windows']['win7'] = 'Windows 7';
|
||||
$config->vmTemplate->os->type['windows']['winxp'] = 'Windows XP';
|
||||
$config->vmTemplate->os->type['linux']['ubuntu'] = 'Ubuntu';
|
||||
$config->vmTemplate->os->type['linux']['centos'] = 'CentOS';
|
||||
$config->vmTemplate->os->type['linux']['debian'] = 'Debian';
|
||||
|
||||
$config->vmTemplate->search['module'] = 'vmTemplate';
|
||||
$config->vmTemplate->search['fields']['id'] = $lang->zahost->id;
|
||||
$config->vmTemplate->search['fields']['name'] = $lang->zahost->name;
|
||||
$config->vmTemplate->search['fields']['cpuCoreNum'] = $lang->zahost->cpuCores;
|
||||
$config->vmTemplate->search['fields']['memorySize'] = $lang->zahost->memory;
|
||||
$config->vmTemplate->search['fields']['diskSize'] = $lang->zahost->diskSize;
|
||||
$config->vmTemplate->search['fields']['osType'] = $lang->zahost->vmTemplate->osType;
|
||||
$config->vmTemplate->search['fields']['osVersion'] = $lang->zahost->vmTemplate->osVersion;
|
||||
|
||||
$config->vmTemplate->search['params']['id'] = array('operator' => '=', 'control' => 'input', 'values' => '');
|
||||
$config->vmTemplate->search['params']['name'] = array('operator' => 'include', 'control' => 'input', 'values' => '');
|
||||
$config->vmTemplate->search['params']['memorySize'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $config->vmTemplate->os->memory);
|
||||
$config->vmTemplate->search['params']['diskSize'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $config->vmTemplate->os->disk);
|
||||
$config->vmTemplate->search['params']['osType'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $config->vmTemplate->os->type['windows'] + $config->vmTemplate->os->type['linux']);
|
||||
$config->vmTemplate->search['params']['cpuCoreNum'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $config->vmTemplate->os->cpu);
|
||||
|
||||
@@ -118,11 +118,11 @@ class zahost extends control
|
||||
$templateList = $this->zahost->getVMTemplateList($hostID, $browseType, $queryID, $orderBy, $pager);
|
||||
|
||||
/* Build the search form. */
|
||||
//$actionURL = $this->createLink('zahost', 'browseVM', "browseType=bySearch&queryID=myQueryID");
|
||||
//$this->config->zaTemplate->search['actionURL'] = $actionURL;
|
||||
//$this->config->zaTemplate->search['queryID'] = $queryID;
|
||||
//$this->config->zaTemplate->search['onMenuBar'] = 'no';
|
||||
//$this->loadModel('search')->setSearchParams($this->config->zaTemplate->search);
|
||||
$actionURL = $this->createLink('zahost', 'browseTemplate', "hostID=$hostID&browseType=bySearch&queryID=myQueryID");
|
||||
$this->config->vmTemplate->search['actionURL'] = $actionURL;
|
||||
$this->config->vmTemplate->search['queryID'] = $queryID;
|
||||
$this->config->vmTemplate->search['onMenuBar'] = 'no';
|
||||
$this->loadModel('search')->setSearchParams($this->config->vmTemplate->search);
|
||||
|
||||
$this->view->title = $this->lang->zahost->vmTemplate->common;
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted');
|
||||
|
||||
+13
-10
@@ -1,14 +1,17 @@
|
||||
<?php
|
||||
$lang->zahost->common = 'ZAhost';
|
||||
$lang->zahost->browse = 'Host List';
|
||||
$lang->zahost->create = 'Add Host';
|
||||
$lang->zahost->view = 'Host View';
|
||||
$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->id = 'ID';
|
||||
$lang->zahost->common = 'ZAhost';
|
||||
$lang->zahost->browse = 'Host List';
|
||||
$lang->zahost->create = 'Add Host';
|
||||
$lang->zahost->view = 'Host View';
|
||||
$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->browseTemplate = 'Template Browse';
|
||||
$lang->zahost->createTemplate = 'Create Template';
|
||||
|
||||
$lang->zahost->name = 'Name';
|
||||
$lang->zahost->IP = 'IP';
|
||||
|
||||
+13
-10
@@ -1,14 +1,17 @@
|
||||
<?php
|
||||
$lang->zahost->common = 'ZAhost';
|
||||
$lang->zahost->browse = 'Host List';
|
||||
$lang->zahost->create = 'Add Host';
|
||||
$lang->zahost->view = 'Host View';
|
||||
$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->id = 'ID';
|
||||
$lang->zahost->common = 'ZAhost';
|
||||
$lang->zahost->browse = 'Host List';
|
||||
$lang->zahost->create = 'Add Host';
|
||||
$lang->zahost->view = 'Host View';
|
||||
$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->browseTemplate = 'Template Browse';
|
||||
$lang->zahost->createTemplate = 'Create Template';
|
||||
|
||||
$lang->zahost->name = 'Name';
|
||||
$lang->zahost->IP = 'IP';
|
||||
|
||||
+13
-10
@@ -1,14 +1,17 @@
|
||||
<?php
|
||||
$lang->zahost->common = 'ZAhost';
|
||||
$lang->zahost->browse = 'Host List';
|
||||
$lang->zahost->create = 'Add Host';
|
||||
$lang->zahost->view = 'Host View';
|
||||
$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->id = 'ID';
|
||||
$lang->zahost->common = 'ZAhost';
|
||||
$lang->zahost->browse = 'Host List';
|
||||
$lang->zahost->create = 'Add Host';
|
||||
$lang->zahost->view = 'Host View';
|
||||
$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->browseTemplate = 'Template Browse';
|
||||
$lang->zahost->createTemplate = 'Create Template';
|
||||
|
||||
$lang->zahost->name = 'Name';
|
||||
$lang->zahost->IP = 'IP';
|
||||
|
||||
+13
-10
@@ -1,14 +1,17 @@
|
||||
<?php
|
||||
$lang->zahost->common = 'ZAhost';
|
||||
$lang->zahost->browse = 'Host List';
|
||||
$lang->zahost->create = 'Add Host';
|
||||
$lang->zahost->view = 'Host View';
|
||||
$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->id = 'ID';
|
||||
$lang->zahost->common = 'ZAhost';
|
||||
$lang->zahost->browse = 'Host List';
|
||||
$lang->zahost->create = 'Add Host';
|
||||
$lang->zahost->view = 'Host View';
|
||||
$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->browseTemplate = 'Template Browse';
|
||||
$lang->zahost->createTemplate = 'Create Template';
|
||||
|
||||
$lang->zahost->name = 'Name';
|
||||
$lang->zahost->IP = 'IP';
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
<?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->all = '所有主机';
|
||||
$lang->zahost->id = 'ID';
|
||||
$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->all = '所有主机';
|
||||
$lang->zahost->browseTemplate = '虚拟机模板列表';
|
||||
$lang->zahost->createTemplate = '创建虚拟机模板';
|
||||
|
||||
$lang->zahost->name = '名称';
|
||||
$lang->zahost->IP = 'IP';
|
||||
|
||||
@@ -198,19 +198,19 @@ class zahostModel extends model
|
||||
$query = $this->loadModel('search')->getQuery($param);
|
||||
if($query)
|
||||
{
|
||||
$this->session->set('zaTemplateQuery', $query->sql);
|
||||
$this->session->set('zaTemplateForm', $query->form);
|
||||
$this->session->set('vmTemplateQuery', $query->sql);
|
||||
$this->session->set('vmTemplateForm', $query->form);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->session->set('zaTemplateQuery', ' 1 = 1');
|
||||
$this->session->set('vmTemplateQuery', ' 1 = 1');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->session->zaTemplateQuery == false) $this->session->set('zaTemplateQuery', ' 1 = 1');
|
||||
if($this->session->vmTemplateQuery == false) $this->session->set('vmTemplateQuery', ' 1 = 1');
|
||||
}
|
||||
$query = $this->session->zaTemplateQuery;
|
||||
$query = $this->session->vmTemplateQuery;
|
||||
}
|
||||
|
||||
return $this->dao->select('*')->from(TABLE_VMTEMPLATE)
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
</div>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
<div id='queryBox' class='cell <?php if($browseType =='bysearch') echo 'show';?>' data-module='zahost'></div>
|
||||
<div id='queryBox' class='cell <?php if($browseType =='bysearch') echo 'show';?>' data-module='vmTemplate'></div>
|
||||
<div id='mainContent' class='main-table'>
|
||||
<?php $vars = "hostID=$hostID&browseType=all&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}";?>
|
||||
<?php if(empty($templateList)):?>
|
||||
@@ -41,12 +41,12 @@
|
||||
<tr>
|
||||
<th class='c-id'><?php common::printOrderLink('id', $orderBy, $vars, $lang->idAB);?></th>
|
||||
<th class='c-name'><?php common::printOrderLink('name', $orderBy, $vars, $lang->zahost->name);?></th>
|
||||
<th class='c-number w-100px'><?php common::printOrderLink('cpuCoreNum', $orderBy, $vars, $lang->zahost->cpuCoreNum);?></th>
|
||||
<th class='c-number w-100px'><?php common::printOrderLink('memorySize', $orderBy, $vars, $lang->zahost->memory);?></th>
|
||||
<th class='c-number w-100px'><?php common::printOrderLink('diskSize', $orderBy, $vars, $lang->zahost->diskSize);?></th>
|
||||
<th class='c-type w-150px'><?php common::printOrderLink('osCategory', $orderBy, $vars, $lang->zahost->osCategory);?></th>
|
||||
<th class='c-type w-150px'><?php common::printOrderLink('osType', $orderBy, $vars, $lang->zahost->osType);?></th>
|
||||
<th class='c-type w-150px'><?php common::printOrderLink('osVersion', $orderBy, $vars, $lang->zahost->osVersion);?></th>
|
||||
<th class='c-number'><?php common::printOrderLink('cpuCoreNum', $orderBy, $vars, $lang->zahost->cpuCoreNum);?></th>
|
||||
<th class='c-number'><?php common::printOrderLink('memorySize', $orderBy, $vars, $lang->zahost->memory);?></th>
|
||||
<th class='c-number'><?php common::printOrderLink('diskSize', $orderBy, $vars, $lang->zahost->diskSize);?></th>
|
||||
<th class='c-os'><?php common::printOrderLink('osCategory', $orderBy, $vars, $lang->zahost->osCategory);?></th>
|
||||
<th class='c-os'><?php common::printOrderLink('osType', $orderBy, $vars, $lang->zahost->osType);?></th>
|
||||
<th class='c-os'><?php common::printOrderLink('osVersion', $orderBy, $vars, $lang->zahost->osVersion);?></th>
|
||||
<th class='c-lang'><?php common::printOrderLink('osLang', $orderBy, $vars, $lang->zahost->osLang);?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
Reference in New Issue
Block a user