From 72f4ecbb2b4d782b004fa015feba05a8e3b6e727 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Wed, 9 Nov 2022 00:52:08 +0000 Subject: [PATCH 01/36] * Add sql. --- db/update18.0.sql | 30 ++++++++++++++++++++++++++++++ db/zentao.sql | 31 +++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/db/update18.0.sql b/db/update18.0.sql index 2246ae9857..ea77e9d220 100644 --- a/db/update18.0.sql +++ b/db/update18.0.sql @@ -3,6 +3,36 @@ ALTER TABLE `zt_project` ADD `hasProduct` tinyint(1) unsigned NOT NULL DEFAULT 1 ALTER table `zt_project` ADD `multiple` enum('0', '1') NOT NULL DEFAULT '1'; ALTER TABLE `zt_repo` ADD `projects` varchar(255) NOT NULL AFTER `product`; +ALTER TABLE `zt_host` ADD `vnc` int NOT NULL; +ALTER TABLE `zt_host` ADD `registerDate` datetime NOT NULL; +ALTER TABLE `zt_host` ADD `createdBy` varchar(30) NOT NULL; +ALTER TABLE `zt_host` ADD `createdDate` datetime NOT NULL AFTER `createdBy`; +ALTER TABLE `zt_host` ADD `editedBy` varchar(30) NOT NULL AFTER `createdDate`; +ALTER TABLE `zt_host` ADD `editedDate` datetime NOT NULL AFTER `editedBy`; +ALTER TABLE `zt_host` ADD `deleted` enum ('0', '1') NOT NULL DEFAULT '0' AFTER `editedDate`; +CREATE TABLE `zt_executionnode` ( + `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `hostID` int(11) unsigned NOT NULL DEFAULT 0, + `name` varchar(64) NOT NULL DEFAULT '', + `imageID` int(11) unsigned NOT NULL DEFAULT 0, + `osCategory` varchar(32) NOT NULL DEFAULT '', + `osType` varchar(32) NOT NULL DEFAULT '', + `osVersion` varchar(32) NOT NULL DEFAULT '', + `osLang` varchar(32) NOT NULL DEFAULT '', + `memory` float unsigned NOT NULL, + `disk` float unsigned NOT NULL, + `status` char(20) NOT NULL, + `mac` char(64) NOT NULL, + `vnc` int(11) unsigned NOT NULL DEFAULT 0, + `registerDate` datetime NOT NULL, + `createdBy` datetime NOT NULL, + `createdDate` datetime NOT NULL, + `editedBy` datetime NOT NULL, + `editedDate` datetime NOT NULL, + `deleted` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8; + CREATE OR REPLACE VIEW `ztv_normalproduct` AS SELECT * FROM `zt_product` WHERE `shadow` = 0; REPLACE INTO `zt_report` (`code`, `name`, `module`, `sql`, `vars`, `langs`, `params`, `step`, `desc`, `addedBy`, `addedDate`) VALUES diff --git a/db/zentao.sql b/db/zentao.sql index 0a289ef9fe..c43ae9761b 100755 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -7312,9 +7312,40 @@ CREATE TABLE IF NOT EXISTS `zt_host` ( `cloudAccount` varchar(255) NOT NULL DEFAULT '', `cloudPassword` varchar(255) NOT NULL DEFAULT '', `couldVPC` varchar(255) NOT NULL DEFAULT '', + `vnc` int(11) NOT NULL, + `registerDate` datetime NOT NULL, + `createdBy` varchar(30) NOT NULL, + `createdDate` datetime NOT NULL, + `editedBy` varchar(30) NOT NULL, + `editedDate` datetime NOT NULL, + `deleted` enum('0','1') NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- DROP TABLE IF EXISTS `zt_executionnode`; +CREATE TABLE `zt_executionnode` ( + `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `hostID` int(11) unsigned NOT NULL DEFAULT 0, + `name` varchar(64) NOT NULL DEFAULT '', + `imageID` int(11) unsigned NOT NULL DEFAULT 0, + `osCategory` varchar(32) NOT NULL DEFAULT '', + `osType` varchar(32) NOT NULL DEFAULT '', + `osVersion` varchar(32) NOT NULL DEFAULT '', + `osLang` varchar(32) NOT NULL DEFAULT '', + `memory` float unsigned NOT NULL, + `disk` float unsigned NOT NULL, + `status` char(20) NOT NULL, + `mac` char(64) NOT NULL, + `vnc` int(11) unsigned NOT NULL DEFAULT 0, + `registerDate` datetime NOT NULL, + `createdBy` datetime NOT NULL, + `createdDate` datetime NOT NULL, + `editedBy` datetime NOT NULL, + `editedDate` datetime NOT NULL, + `deleted` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8; + -- DROP TABLE IF EXISTS `zt_service`; CREATE TABLE IF NOT EXISTS `zt_service` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, From 7550e05863a7a9891e008d8e72a41e46ae1f7861 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Thu, 10 Nov 2022 08:02:07 +0000 Subject: [PATCH 02/36] * Add init host page. --- config/zentaopms.php | 3 +- db/update18.0.sql | 40 ++++++++++++++----- db/zentao.sql | 39 +++++++++++++----- module/executionnode/config.php | 7 ++++ module/executionnode/lang/zh-cn.php | 1 + module/executionnode/view/create.html.php | 14 +++++-- module/zahost/config.php | 6 ++- module/zahost/control.php | 35 ++++++++++++++++- module/zahost/css/create.css | 1 + module/zahost/css/edit.css | 1 + module/zahost/css/inithost.css | 16 ++++++++ module/zahost/js/create.js | 48 +++++++++++------------ module/zahost/js/inithost.js | 25 ++++++++++++ module/zahost/lang/de.php | 25 +++++++++++- module/zahost/lang/en.php | 25 +++++++++++- module/zahost/lang/fr.php | 25 +++++++++++- module/zahost/lang/vi.php | 25 +++++++++++- module/zahost/lang/zh-cn.php | 25 +++++++++++- module/zahost/model.php | 21 +++++++++- module/zahost/view/browse.html.php | 2 - module/zahost/view/create.html.php | 18 +++++---- module/zahost/view/edit.html.php | 18 +++++---- module/zahost/view/inithost.html.php | 39 ++++++++++++++++++ 23 files changed, 378 insertions(+), 81 deletions(-) create mode 100644 module/zahost/css/inithost.css create mode 100644 module/zahost/js/inithost.js create mode 100644 module/zahost/view/inithost.html.php diff --git a/config/zentaopms.php b/config/zentaopms.php index e542fd9dd3..af5d41838c 100644 --- a/config/zentaopms.php +++ b/config/zentaopms.php @@ -254,6 +254,7 @@ 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`'); +define('TABLE_EXECUTIONNODE', '`' . $config->db->prefix . 'executionnode`'); if(!defined('TABLE_ASSET')) define('TABLE_ASSET', '`' . $config->db->prefix . 'asset`'); if(!defined('TABLE_VMTEMPLATE')) define('TABLE_VMTEMPLATE', '`' . $config->db->prefix . 'vmtemplate`'); @@ -400,7 +401,7 @@ $config->objectTables['stage'] = TABLE_STAGE; $config->objectTables['apistruct'] = TABLE_APISTRUCT; $config->objectTables['repo'] = TABLE_REPO; $config->objectTables['zahost'] = TABLE_ZAHOST; -$config->objectTables['executionnode'] = TABLE_VM; +$config->objectTables['executionnode'] = TABLE_EXECUTIONNODE; $config->newFeatures = array('introduction', 'tutorial', 'youngBlueTheme', 'visions'); $config->disabledFeatures = ''; diff --git a/db/update18.0.sql b/db/update18.0.sql index ea77e9d220..d3d740868c 100644 --- a/db/update18.0.sql +++ b/db/update18.0.sql @@ -3,13 +3,9 @@ ALTER TABLE `zt_project` ADD `hasProduct` tinyint(1) unsigned NOT NULL DEFAULT 1 ALTER table `zt_project` ADD `multiple` enum('0', '1') NOT NULL DEFAULT '1'; ALTER TABLE `zt_repo` ADD `projects` varchar(255) NOT NULL AFTER `product`; -ALTER TABLE `zt_host` ADD `vnc` int NOT NULL; -ALTER TABLE `zt_host` ADD `registerDate` datetime NOT NULL; -ALTER TABLE `zt_host` ADD `createdBy` varchar(30) NOT NULL; -ALTER TABLE `zt_host` ADD `createdDate` datetime NOT NULL AFTER `createdBy`; -ALTER TABLE `zt_host` ADD `editedBy` varchar(30) NOT NULL AFTER `createdDate`; -ALTER TABLE `zt_host` ADD `editedDate` datetime NOT NULL AFTER `editedBy`; -ALTER TABLE `zt_host` ADD `deleted` enum ('0', '1') NOT NULL DEFAULT '0' AFTER `editedDate`; +ALTER TABLE `zt_host` ADD `desc` text NOT NULL AFTER `token`; +ALTER TABLE `zt_host` CHANGE COLUMN `publicIP` `address` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,CHANGE COLUMN `cpuCores` `cpu` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,CHANGE COLUMN `diskSize` `disk` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,CHANGE COLUMN `heartbeatTime` `heartbeat` datetime NOT NULL; + CREATE TABLE `zt_executionnode` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `hostID` int(11) unsigned NOT NULL DEFAULT 0, @@ -21,8 +17,8 @@ CREATE TABLE `zt_executionnode` ( `osLang` varchar(32) NOT NULL DEFAULT '', `memory` float unsigned NOT NULL, `disk` float unsigned NOT NULL, - `status` char(20) NOT NULL, - `mac` char(64) NOT NULL, + `status` varchar(20) NOT NULL, + `mac` varchar(64) NOT NULL, `vnc` int(11) unsigned NOT NULL DEFAULT 0, `registerDate` datetime NOT NULL, `createdBy` datetime NOT NULL, @@ -31,7 +27,31 @@ CREATE TABLE `zt_executionnode` ( `editedDate` datetime NOT NULL, `deleted` datetime NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; + +CREATE TABLE `zt_image` ( + `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(64) NOT NULL DEFAULT '', + `address` varchar(64) NOT NULL DEFAULT '', + `from` varchar(64) NOT NULL DEFAULT '', + `path` varchar(64) NOT NULL DEFAULT '', + `status` varchar(20) NOT NULL DEFAULT '', + `osCategory` varchar(32) NOT NULL DEFAULT '', + `osType` varchar(32) NOT NULL DEFAULT '', + `osVersion` varchar(32) NOT NULL DEFAULT '', + `osLang` varchar(32) NOT NULL DEFAULT '', + `memory` float unsigned NOT NULL, + `disk` float unsigned NOT NULL, + `fileSize` float unsigned NOT NULL, + `md5` varchar(64) NOT NULL, + `registerDate` datetime NOT NULL, + `createdBy` datetime NOT NULL, + `createdDate` datetime NOT NULL, + `editedBy` datetime NOT NULL, + `editedDate` datetime NOT NULL, + `deleted` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE OR REPLACE VIEW `ztv_normalproduct` AS SELECT * FROM `zt_product` WHERE `shadow` = 0; diff --git a/db/zentao.sql b/db/zentao.sql index c43ae9761b..48a0d6f860 100755 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -7271,6 +7271,7 @@ CREATE TABLE IF NOT EXISTS `zt_host` ( `type` varchar(30) NOT NULL DEFAULT 'normal', `secret` varchar(50) NOT NULL DEFAULT '', `token` varchar(50) NOT NULL DEFAULT '', + `desc` text NOT NULL, `expiredDate` datetime NOT NULL, `serverRoom` mediumint(8) UNSIGNED NOT NULL, `cabinet` varchar(128) NOT NULL, @@ -7312,13 +7313,6 @@ CREATE TABLE IF NOT EXISTS `zt_host` ( `cloudAccount` varchar(255) NOT NULL DEFAULT '', `cloudPassword` varchar(255) NOT NULL DEFAULT '', `couldVPC` varchar(255) NOT NULL DEFAULT '', - `vnc` int(11) NOT NULL, - `registerDate` datetime NOT NULL, - `createdBy` varchar(30) NOT NULL, - `createdDate` datetime NOT NULL, - `editedBy` varchar(30) NOT NULL, - `editedDate` datetime NOT NULL, - `deleted` enum('0','1') NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -7334,8 +7328,8 @@ CREATE TABLE `zt_executionnode` ( `osLang` varchar(32) NOT NULL DEFAULT '', `memory` float unsigned NOT NULL, `disk` float unsigned NOT NULL, - `status` char(20) NOT NULL, - `mac` char(64) NOT NULL, + `status` varchar(20) NOT NULL, + `mac` varchar(64) NOT NULL, `vnc` int(11) unsigned NOT NULL DEFAULT 0, `registerDate` datetime NOT NULL, `createdBy` datetime NOT NULL, @@ -7344,7 +7338,32 @@ CREATE TABLE `zt_executionnode` ( `editedDate` datetime NOT NULL, `deleted` datetime NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; + +-- DROP TABLE IF EXISTS `zt_image`; +CREATE TABLE `zt_image` ( + `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(64) NOT NULL DEFAULT '', + `address` varchar(64) NOT NULL DEFAULT '', + `from` varchar(64) NOT NULL DEFAULT '', + `path` varchar(64) NOT NULL DEFAULT '', + `status` varchar(20) NOT NULL DEFAULT '', + `osCategory` varchar(32) NOT NULL DEFAULT '', + `osType` varchar(32) NOT NULL DEFAULT '', + `osVersion` varchar(32) NOT NULL DEFAULT '', + `osLang` varchar(32) NOT NULL DEFAULT '', + `memory` float unsigned NOT NULL, + `disk` float unsigned NOT NULL, + `fileSize` float unsigned NOT NULL, + `md5` varchar(64) NOT NULL, + `registerDate` datetime NOT NULL, + `createdBy` datetime NOT NULL, + `createdDate` datetime NOT NULL, + `editedBy` datetime NOT NULL, + `editedDate` datetime NOT NULL, + `deleted` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; -- DROP TABLE IF EXISTS `zt_service`; CREATE TABLE IF NOT EXISTS `zt_service` ( diff --git a/module/executionnode/config.php b/module/executionnode/config.php index cf3727c872..84c36be428 100755 --- a/module/executionnode/config.php +++ b/module/executionnode/config.php @@ -19,6 +19,9 @@ $config->executionnode->os->cpu['6'] = '6'; $config->executionnode->os->cpu['8'] = '8'; $config->executionnode->os->cpu['12'] = '12'; $config->executionnode->os->cpu['16'] = '16'; +$config->executionnode->os->cpu['24'] = '24'; +$config->executionnode->os->cpu['32'] = '32'; +$config->executionnode->os->cpu['64'] = '64'; $config->executionnode->os->type = array(); $config->executionnode->os->type['windows']['winServer'] = 'Windows Server'; @@ -49,3 +52,7 @@ $config->executionnode->search['params']['status'] = array('operator' => '=' $config->executionnode->search['params']['osCpu'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $config->executionnode->os->cpu); $config->executionnode->search['params']['osMemory'] = array('operator' => '=', 'control' => 'input', 'values' => ''); $config->executionnode->search['params']['osDisk'] = array('operator' => '=', 'control' => 'input', 'values' => ''); + +$config->executionnode->editor = new stdclass(); +$config->executionnode->editor->create = array('id' => 'desc', 'tools' => 'simpleTools'); +$config->executionnode->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools'); diff --git a/module/executionnode/lang/zh-cn.php b/module/executionnode/lang/zh-cn.php index 1bb1dc695a..c4b8367a35 100755 --- a/module/executionnode/lang/zh-cn.php +++ b/module/executionnode/lang/zh-cn.php @@ -27,6 +27,7 @@ $lang->executionnode->osLang = '系统语言'; $lang->executionnode->cpu = 'CPU核心数'; $lang->executionnode->osMemory = '内存'; $lang->executionnode->osDisk = '硬盘'; +$lang->executionnode->desc = '描述'; $lang->executionnode->status = '状态'; $lang->executionnode->macAddress = 'MAC地址'; $lang->executionnode->vnc = 'VNC端口'; diff --git a/module/executionnode/view/create.html.php b/module/executionnode/view/create.html.php index a25ef88315..a4306f0d5a 100755 --- a/module/executionnode/view/create.html.php +++ b/module/executionnode/view/create.html.php @@ -11,6 +11,7 @@ */ ?> +getModuleRoot() . 'common/view/kindeditor.html.php';?>
@@ -19,15 +20,15 @@
+ + + + - - - - @@ -72,6 +73,11 @@ + + + + + - @@ -68,7 +67,6 @@ -
executionnode->hostName;?>
executionnode->name;?> executionnode->nameValid}\"");?>
executionnode->hostName;?>
executionnode->vmTemplate;?> executionnode->osLang;?>
executionnode->desc ?>
diff --git a/module/zahost/config.php b/module/zahost/config.php index 7cda82f889..89527d1e7c 100644 --- a/module/zahost/config.php +++ b/module/zahost/config.php @@ -26,6 +26,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'; +$config->zahost->cpuCoreList = [1 => 1, 2 => 2, 4 => 4, 6 => 6, 8 => 8, 10 => 10, 12 => 12, 16 => 16, 24 => 24, 32 => 32, 64 => 64]; global $lang; $config->zahost->search['module'] = 'zahost'; @@ -38,7 +39,6 @@ $config->zahost->search['fields']['memory'] = $lang->zahost->memory; $config->zahost->search['fields']['diskSize'] = $lang->zahost->diskSize; $config->zahost->search['fields']['virtualSoftware'] = $lang->zahost->virtualSoftware; $config->zahost->search['fields']['status'] = $lang->zahost->status; -$config->zahost->search['fields']['instanceNum'] = $lang->zahost->instanceNum; $config->zahost->search['fields']['createdBy'] = $lang->zahost->createdBy; $config->zahost->search['fields']['createdDate'] = $lang->zahost->createdDate; $config->zahost->search['fields']['registerDate'] = $lang->zahost->registerDate; @@ -61,6 +61,10 @@ $config->zahost->search['params']['registerDate'] = array('operator' => '=', $config->zahost->search['params']['editedBy'] = array('operator' => '=', 'control' => 'select', 'values' => 'users'); $config->zahost->search['params']['editedDate'] = array('operator' => '=', 'control' => 'input', 'values' => '', 'class' => 'date'); +$config->zahost->editor = new stdclass(); +$config->zahost->editor->create = array('id' => 'desc', 'tools' => 'simpleTools'); +$config->zahost->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools'); + $config->vmTemplate = new stdclass(); $config->vmTemplate->os = new stdClass(); $config->vmTemplate->os->list = array(); diff --git a/module/zahost/control.php b/module/zahost/control.php index def6586261..baa0b3e178 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -62,13 +62,13 @@ class zahost extends control { if($_POST) { - $this->zahost->create(); + $hostID = $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'))); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('inithost', "hostID=$hostID"))); } $this->view->title = $this->lang->zahost->create; @@ -311,4 +311,35 @@ class zahost extends control return $this->send(array('result' => 'fail', 'message' => array('imageName' => array($this->lang->zahost->notice->noImage)))); } + + /* + * Init host. + * + * @param int $hostID + * @return void + */ + public function initHost($hostID) + { + $this->view->title = $this->lang->zahost->vmTemplate->common; + $this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted'); + $this->view->hostID = $hostID; + + $this->display(); + } + + /** + * Check service status by ajax. + * + * @param int $hostID + * @param int $templateID + * @access public + * @return void + */ + public function ajaxGetServiceStatus($hostID) + { + $host = $this->zahost->getById($hostID); + $serviceStatus = $this->zahost->getServiceStatus($host); + + return $this->send(array('result' => 'success', 'message' => '', 'data' => $serviceStatus)); + } } diff --git a/module/zahost/css/create.css b/module/zahost/css/create.css index 662cc09295..f3e53739f3 100644 --- a/module/zahost/css/create.css +++ b/module/zahost/css/create.css @@ -1,3 +1,4 @@ #unit {padding: 0px !important; width:0px; border-left: 0px;} .input-group-addon {border: 0px; width: 100px;} #unit_chosen a {border-left: 0px; border-radius: 0 2px;} +#memory-addon{padding-left: 30px;text-align: left;} \ No newline at end of file diff --git a/module/zahost/css/edit.css b/module/zahost/css/edit.css index 5c73ea1c78..b03b48e58d 100644 --- a/module/zahost/css/edit.css +++ b/module/zahost/css/edit.css @@ -2,3 +2,4 @@ .input-group-addon {border: 0px; width: 100px;} #unit_chosen a {border-left: 0px; border-radius: 0 2px;} html[lang='en'] .table-form > tbody > tr > th {width: 120px;} +#memory-addon{padding-left: 30px;text-align: left;} \ No newline at end of file diff --git a/module/zahost/css/inithost.css b/module/zahost/css/inithost.css new file mode 100644 index 0000000000..b7a3c5c1f4 --- /dev/null +++ b/module/zahost/css/inithost.css @@ -0,0 +1,16 @@ +.dot-symbol{ + margin-right: 10px; +} +#statusContainer h5{ + line-height: 20px; +} +.host-desc-container{ + margin-top: 40px; +} +.host-action{ + margin-top: 60px; +} +.host-action .btn{ + margin-left: 20px; + min-width: 100px; +} diff --git a/module/zahost/js/create.js b/module/zahost/js/create.js index 31f671a597..a5c85b84d8 100644 --- a/module/zahost/js/create.js +++ b/module/zahost/js/create.js @@ -1,31 +1,31 @@ $(document).ready(function() { - $('#publicIP').on('blur', function() - { - var url = createLink('zahost', 'ajaxCheckPublicIP', "IP=" + $('#publicIP').val()); + // $('#publicIP').on('blur', function() + // { + // var url = createLink('zahost', 'ajaxCheckPublicIP', "IP=" + $('#publicIP').val()); - $.get(url, function(response) - { - $('#publicIPLabel').remove(); - $('#publicIP').removeClass('has-error'); - $('#registerCommand').remove(); - $('#Secret').remove(); + // $.get(url, function(response) + // { + // $('#publicIPLabel').remove(); + // $('#publicIP').removeClass('has-error'); + // $('#registerCommand').remove(); + // $('#Secret').remove(); - var resultData= JSON.parse(response); - if(resultData.result == 'success') - { - $('input#type').after(""); - $('#publicIP').after("
" + resultData.data.registerCommand + "
"); - return; - } + // var resultData= JSON.parse(response); + // if(resultData.result == 'success') + // { + // $('input#type').after(""); + // $('#publicIP').after("
" + resultData.data.registerCommand + "
"); + // return; + // } - $('#publicIP').addClass('has-error'); + // $('#publicIP').addClass('has-error'); - if(resultData.message.publicIP) - { - var errors = resultData.message.publicIP.join(''); - $('#publicIP').after("
" + errors + "
"); - } - }); - }); + // if(resultData.message.publicIP) + // { + // var errors = resultData.message.publicIP.join(''); + // $('#publicIP').after("
" + errors + "
"); + // } + // }); + // }); }); diff --git a/module/zahost/js/inithost.js b/module/zahost/js/inithost.js new file mode 100644 index 0000000000..2ea492e7d0 --- /dev/null +++ b/module/zahost/js/inithost.js @@ -0,0 +1,25 @@ +$('#checkServiceStatus').click(function(){ + $.get(createLink('zahost', 'ajaxGetServiceStatus', 'hostID=' + hostID), function(response) + { + var resultData = JSON.parse(response); + let html = "

" + zahostLang.initHost.statusTitle + "

"; + let isSuccess = true + + for (let key in resultData.data) { + if(resultData.data[key] == 'ready'){ + html += "
●" + key + ' ' + zahostLang.initHost[resultData.data[key]] + "
" + }else{ + isSuccess = false + html += "
●" + key + ' ' + zahostLang.initHost[resultData.data[key]] + "
" + } + }; + + if(isSuccess){ + html += '
' + zahostLang.initHost.initSuccessNotice + '
' + }else{ + html += '
' + zahostLang.initHost.initFailNotice + 'https://github.com/easysoft/zenagent/
' + } + $('#statusContainer').html(html) + }); + return +}) \ No newline at end of file diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index b34bfae7a7..54fcd4467c 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -16,12 +16,12 @@ $lang->zahost->editTemplate = 'Edit Template'; $lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Name'; -$lang->zahost->IP = 'IP'; +$lang->zahost->IP = 'IP/Domain'; $lang->zahost->publicIP = 'IP'; $lang->zahost->cpuCores = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; $lang->zahost->diskSize = 'Disk Size'; -$lang->zahost->instanceNum = 'Instance Number'; +$lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -39,6 +39,27 @@ $lang->zahost->osVersion = 'Os Version No'; $lang->zahost->osLang = 'Language'; $lang->zahost->imageName = 'Image File'; +$lang->zahost->initHost = new stdclass; +$lang->zahost->initHost->checkStatus = "Check Service Status"; +$lang->zahost->initHost->not_install = "Not installed"; +$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->initFailNotice = "Initialization failed, check the init script execution log and try the following two solutions:
1. Re-execute the script
2. Review the initialization FAQ"; +$lang->zahost->initHost->serviceStatus = [ + "kvm" => 'not_install', + "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->descLi = [ + "Download the init script to the host:wget xxx -o xxx", + "Execute the init script on the host and execute the command example under Ubuntu:xxxx" +]; +$lang->zahost->initHost->statusTitle = "Service Status"; + $lang->zahost->vmTemplate = new stdclass; $lang->zahost->vmTemplate->name = 'Name'; $lang->zahost->vmTemplate->common = 'VM Template'; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index b34bfae7a7..54fcd4467c 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -16,12 +16,12 @@ $lang->zahost->editTemplate = 'Edit Template'; $lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Name'; -$lang->zahost->IP = 'IP'; +$lang->zahost->IP = 'IP/Domain'; $lang->zahost->publicIP = 'IP'; $lang->zahost->cpuCores = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; $lang->zahost->diskSize = 'Disk Size'; -$lang->zahost->instanceNum = 'Instance Number'; +$lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -39,6 +39,27 @@ $lang->zahost->osVersion = 'Os Version No'; $lang->zahost->osLang = 'Language'; $lang->zahost->imageName = 'Image File'; +$lang->zahost->initHost = new stdclass; +$lang->zahost->initHost->checkStatus = "Check Service Status"; +$lang->zahost->initHost->not_install = "Not installed"; +$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->initFailNotice = "Initialization failed, check the init script execution log and try the following two solutions:
1. Re-execute the script
2. Review the initialization FAQ"; +$lang->zahost->initHost->serviceStatus = [ + "kvm" => 'not_install', + "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->descLi = [ + "Download the init script to the host:wget xxx -o xxx", + "Execute the init script on the host and execute the command example under Ubuntu:xxxx" +]; +$lang->zahost->initHost->statusTitle = "Service Status"; + $lang->zahost->vmTemplate = new stdclass; $lang->zahost->vmTemplate->name = 'Name'; $lang->zahost->vmTemplate->common = 'VM Template'; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index a3be1a830d..077cbe0174 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -16,12 +16,12 @@ $lang->zahost->editTemplate = 'Edit Template'; $lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Nom'; -$lang->zahost->IP = 'IP'; +$lang->zahost->IP = 'IP/Domain'; $lang->zahost->publicIP = 'IP'; $lang->zahost->cpuCores = 'CPU Cores'; $lang->zahost->memory = 'Mémoire Espace'; $lang->zahost->diskSize = 'Disque Espace'; -$lang->zahost->instanceNum = 'Max instances'; +$lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -39,6 +39,27 @@ $lang->zahost->osVersion = 'Os Version No'; $lang->zahost->osLang = 'Language'; $lang->zahost->imageName = 'Image File'; +$lang->zahost->initHost = new stdclass; +$lang->zahost->initHost->checkStatus = "Check Service Status"; +$lang->zahost->initHost->not_install = "Not installed"; +$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->initFailNotice = "Initialization failed, check the init script execution log and try the following two solutions:
1. Re-execute the script
2. Review the initialization FAQ"; +$lang->zahost->initHost->serviceStatus = [ + "kvm" => 'not_install', + "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->descLi = [ + "Download the init script to the host:wget xxx -o xxx", + "Execute the init script on the host and execute the command example under Ubuntu:xxxx" +]; +$lang->zahost->initHost->statusTitle = "Service Status"; + $lang->zahost->vmTemplate = new stdclass; $lang->zahost->vmTemplate->name = 'Nom'; $lang->zahost->vmTemplate->common = 'VM Template'; diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php index 0f06360118..49762bac56 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -16,12 +16,12 @@ $lang->zahost->editTemplate = 'Edit Template'; $lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Name'; -$lang->zahost->IP = 'IP'; +$lang->zahost->IP = 'IP/Domain'; $lang->zahost->publicIP = 'IP'; $lang->zahost->cpuCores = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; $lang->zahost->diskSize = 'Disk Size'; -$lang->zahost->instanceNum = 'Instance Number'; +$lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -39,6 +39,27 @@ $lang->zahost->osVersion = 'Os Version No'; $lang->zahost->osLang = 'Language'; $lang->zahost->imageName = 'Image File'; +$lang->zahost->initHost = new stdclass; +$lang->zahost->initHost->checkStatus = "Check Service Status"; +$lang->zahost->initHost->not_install = "Not installed"; +$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->initFailNotice = "Initialization failed, check the init script execution log and try the following two solutions:
1. Re-execute the script
2. Review the initialization FAQ"; +$lang->zahost->initHost->serviceStatus = [ + "kvm" => 'not_install', + "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->descLi = [ + "Download the init script to the host:wget xxx -o xxx", + "Execute the init script on the host and execute the command example under Ubuntu:xxxx" +]; +$lang->zahost->initHost->statusTitle = "Service Status"; + $lang->zahost->vmTemplate = new stdclass; $lang->zahost->vmTemplate->name = 'Name'; $lang->zahost->vmTemplate->common = 'VM Template'; diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index a0c0e9110d..a7d73b50a5 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -16,12 +16,12 @@ $lang->zahost->editTemplate = '编辑虚拟机模板'; $lang->zahost->deleteTemplate = '删除虚拟机模板'; $lang->zahost->name = '名称'; -$lang->zahost->IP = 'IP'; +$lang->zahost->IP = 'IP/域名'; $lang->zahost->publicIP = 'IP'; $lang->zahost->memory = '内存'; $lang->zahost->cpuCores = 'CPU核心数'; $lang->zahost->diskSize = '硬盘容量'; -$lang->zahost->instanceNum = '最大实例数'; +$lang->zahost->desc = '描述'; $lang->zahost->type = '类型'; $lang->zahost->status = '状态'; @@ -39,6 +39,27 @@ $lang->zahost->osVersion = '操作系统版本号'; $lang->zahost->osLang = '系统语言'; $lang->zahost->imageName = '镜像文件'; +$lang->zahost->initHost = new stdclass; +$lang->zahost->initHost->checkStatus = "检测服务状态"; +$lang->zahost->initHost->not_install = "未安装"; +$lang->zahost->initHost->not_available = "已安装,未启动"; +$lang->zahost->initHost->ready = "已就绪"; +$lang->zahost->initHost->next = "下一步"; +$lang->zahost->initHost->initSuccessNotice = "初始化成功,请点击下一步完成后续操作。"; +$lang->zahost->initHost->initFailNotice = "初始化失败,请查看初始化脚本执行日志并尝试以下两种解决方案:
1. 重新执行脚本
2. 查看初始化常见问题"; +$lang->zahost->initHost->serviceStatus = [ + "kvm" => 'not_install', + "novnc" => 'not_install', + "websockify" => 'not_install', +]; +$lang->zahost->initHost->title = "初始化宿主机"; +$lang->zahost->initHost->descTitle = "请按照以下步骤在宿主机上完成初始化:"; +$lang->zahost->initHost->descLi = [ + "下载初始化脚本至宿主机:wget xxx -o xxx", + "在宿主机上执行初始化脚本,Ubuntu下执行命令示例:xxxx" +]; +$lang->zahost->initHost->statusTitle = "服务状态"; + $lang->zahost->vmTemplate = new stdclass; $lang->zahost->vmTemplate->name = '名称'; $lang->zahost->vmTemplate->common = '虚拟机模板'; diff --git a/module/zahost/model.php b/module/zahost/model.php index 08f956f26e..7d5bcac791 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -69,7 +69,7 @@ class zahostModel extends model if(!dao::isError()) { $this->loadModel('action')->create('zahost', $hostID, 'created'); - return true; + return $hostID; } return false; @@ -364,4 +364,23 @@ class zahostModel extends model { return $this->dao->select('*')->from(TABLE_VMTEMPLATE)->where('id')->eq($templateID)->fetch(); } + + /** + * Get service status from ZAgent server. + * + * @param object $host + * @access public + * @return array + */ + public function getServiceStatus($host) + { + $result = json_decode(commonModel::http("http://{$host->publicIP}:8086/api/v1/service/check", json_encode(array("services" => "all")))); + if(empty($result) || $result->code != 'success') + { + $result = new stdclass; + $result->data = $this->lang->zahost->initHost->serviceStatus; + } + + return $result->data; + } } diff --git a/module/zahost/view/browse.html.php b/module/zahost/view/browse.html.php index 508fbb0291..6a356e0462 100644 --- a/module/zahost/view/browse.html.php +++ b/module/zahost/view/browse.html.php @@ -51,7 +51,6 @@
zahost->diskSize);?> zahost->virtualSoftware);?> zahost->status);?>zahost->instanceNum);?> zahost->registerDate);?> actions;?>
diskSize . zget($lang->zahost->unitList, $host->unit);?> virtualSoftware;?> host->statusList, $host->status);?>instanceNum;?> registerDate) ? '' : $host->registerDate;?> hostID}", $host, 'list');?> diff --git a/module/zahost/view/create.html.php b/module/zahost/view/create.html.php index 861a17515a..235e413d78 100644 --- a/module/zahost/view/create.html.php +++ b/module/zahost/view/create.html.php @@ -11,6 +11,7 @@ */ ?> getModuleRoot() . 'common/view/header.html.php';?> +getModuleRoot() . 'common/view/kindeditor.html.php';?>
@@ -19,6 +20,10 @@
+ + + + @@ -34,14 +39,14 @@ - + @@ -57,12 +62,9 @@ - - - - - - + + + - + @@ -63,11 +63,11 @@ - + From 2a361532b46593d96035a29c37eee9186260666f Mon Sep 17 00:00:00 2001 From: wangjianhua Date: Fri, 11 Nov 2022 13:19:06 +0800 Subject: [PATCH 08/36] * Modify zt_image table. --- db/update18.0.sql | 2 +- db/zentao.sql | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/db/update18.0.sql b/db/update18.0.sql index ec7ab6d81b..23c76c415c 100644 --- a/db/update18.0.sql +++ b/db/update18.0.sql @@ -33,7 +33,7 @@ CREATE TABLE `zt_image` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `hostID` int(11) unsigned NOT NULL DEFAULT 0, `name` varchar(64) NOT NULL DEFAULT '', - `address` varchar(64) NOT NULL DEFAULT '', + `address` varchar(500) NOT NULL DEFAULT '', `from` varchar(64) NOT NULL DEFAULT '', `path` varchar(64) NOT NULL DEFAULT '', `status` varchar(20) NOT NULL DEFAULT '', diff --git a/db/zentao.sql b/db/zentao.sql index 48a0d6f860..0d484daf20 100755 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -7343,8 +7343,9 @@ CREATE TABLE `zt_executionnode` ( -- DROP TABLE IF EXISTS `zt_image`; CREATE TABLE `zt_image` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `hostID` int(11) unsigned NOT NULL DEFAULT 0, `name` varchar(64) NOT NULL DEFAULT '', - `address` varchar(64) NOT NULL DEFAULT '', + `address` varchar(500) NOT NULL DEFAULT '', `from` varchar(64) NOT NULL DEFAULT '', `path` varchar(64) NOT NULL DEFAULT '', `status` varchar(20) NOT NULL DEFAULT '', From 74beb1f75a5504b558267d84bc0623228a447179 Mon Sep 17 00:00:00 2001 From: wangjianhua Date: Fri, 11 Nov 2022 17:09:24 +0800 Subject: [PATCH 09/36] * Finish download image. --- module/common/model.php | 1 + module/zahost/control.php | 26 +++++++++- module/zahost/js/browseimage.js | 18 +++++++ module/zahost/js/common.js | 33 ------------ module/zahost/lang/zh-cn.php | 14 ++--- module/zahost/model.php | 69 +++++++++++++++++++++++-- module/zahost/view/browseimage.html.php | 3 +- 7 files changed, 119 insertions(+), 45 deletions(-) create mode 100644 module/zahost/js/browseimage.js diff --git a/module/common/model.php b/module/common/model.php index eb225fad72..446b9c9f4e 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -3199,6 +3199,7 @@ EOD; curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); curl_setopt($curl, CURLOPT_HEADER, FALSE); + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 2); curl_setopt($curl, CURLINFO_HEADER_OUT, TRUE); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_URL, $url); diff --git a/module/zahost/control.php b/module/zahost/control.php index 2cde051ac1..7f04b881b0 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -209,8 +209,32 @@ class zahost extends control $image = $this->zahost->getImageByID($imageID); $this->zahost->downloadImage($image); + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => $this->lang->zahost->image->downloadImageFail)); - return $this->send(array('result' => 'success', 'message' => $this->lang->zahost->image->startDowload)); + return $this->send(array('result' => 'success', 'message' => $this->lang->zahost->image->downloadImageSuccess)); + } + + /** + * Query downloading progress of images of host. + * + * @param int $hostID + * @access public + * @return void + */ + public function ajaxImageDownloadProgress($hostID) + { + $statusList = array(); + + $imageList = $this->zahost->getImageList($hostID); + foreach($imageList as $image) + { + $statusCode = $this->zahost->queryDownloadImageStatus($image); + $statusName = zget($this->lang->zahost->image->statusList, $statusCode,''); + + $statusList[$image->id] = array('statusCode' => $statusCode, 'statusName' => $statusName); + } + + return $this->send(array('result' => 'success', 'message' => '', 'data' => $statusList)); } /** diff --git a/module/zahost/js/browseimage.js b/module/zahost/js/browseimage.js new file mode 100644 index 0000000000..a481773274 --- /dev/null +++ b/module/zahost/js/browseimage.js @@ -0,0 +1,18 @@ +$(function() +{ + setInterval(function() + { + $.get(createLink('zahost', 'ajaxImageDownloadProgress', 'hostID=' + hostID)).done(function(response) + { + var result = JSON.parse(response); + var statusList = result.data; + + console.log(statusList); + for(var imageID in statusList) + { + $('.image-status-' + imageID).text(statusList[imageID].statusName); + } + + }); + }, 5000); +}); diff --git a/module/zahost/js/common.js b/module/zahost/js/common.js index 3cecfab163..65357a2674 100755 --- a/module/zahost/js/common.js +++ b/module/zahost/js/common.js @@ -1,38 +1,5 @@ $(function() { - if(typeof(hostID) != 'undefined') - { - var templateID = 0; - if(typeof(template) == 'object') templateID = template.id; - $.get(createLink('zahost', 'ajaxImageList', 'hostID=' + hostID + '&templateID=' + templateID), function(response) - { - var resultData = JSON.parse(response); - var options = ''; - if(resultData.result == 'success') - { - resultData.data.forEach(function(item) - { - options += ""; - }); - } - - $('#imageName').replaceWith(""); - $("#imageName_chosen").remove(); - $("#imageName").next('.picker').remove(); - $('#imageName').chosen(); - - if(resultData.result == 'fail') - { - $('#imageName_chosen a:first-child').addClass('has-error'); - if(resultData.message.imageName) - { - var errors = resultData.message.imageName.join(''); - $('#imageName_chosen').after("
" + errors + "
"); - } - } - }); - } - $('#osCategory').change(function() { var os = $('#osCategory').val(); diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index 5d35100120..f58baef81d 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -79,13 +79,15 @@ $lang->zahost->image->osVersion = $lang->zahost->osVersion; $lang->zahost->image->osLang = $lang->zahost->osLang; $lang->zahost->image->imageName = $lang->zahost->imageName; -$lang->zahost->image->imageEmpty = '无镜像'; - -$lang->zahost->image->statusList['waiting'] = '未下载'; -$lang->zahost->image->statusList['downloading'] = '下载中'; -$lang->zahost->image->statusList['finish'] = '已下载'; -$lang->zahost->image->statusList['fail'] = '下载失败'; +$lang->zahost->image->statusList['created'] = '已创建'; +$lang->zahost->image->statusList['canceled'] = '已取消'; +$lang->zahost->image->statusList['inprogress'] = '下载中'; +$lang->zahost->image->statusList['completed'] = '已下载'; +$lang->zahost->image->statusList['failed'] = '下载失败'; +$lang->zahost->image->imageEmpty = '无镜像'; +$lang->zahost->image->downloadImageFail = '创建下载镜像任务失败'; +$lang->zahost->image->downloadImageSuccess = '创建下载镜像任务成功'; $lang->zahost->vmTemplate = new stdclass; $lang->zahost->vmTemplate->name = '名称'; diff --git a/module/zahost/model.php b/module/zahost/model.php index 311e9cf9fd..46e06ed261 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -230,19 +230,80 @@ class zahostModel extends model */ public function downloadImage($image) { - $host = $this->getById($image->hostID); - $downloadApi = 'http://' . $host->address . '/api/v1/download/add'; + $host = $this->getById($image->hostID); + $apiUrl = 'http://' . $host->publicIP. '/api/v1/download/add'; $apiParams['md5'] = $image->md5; - $apiParams['task'] = 1; $apiParams['url'] = $image->address; + $apiParams['task'] = intval($image->id); - $response = json_decode(commonModel::http($downloadApi, $apiParams)); + $response = json_decode(commonModel::http($apiUrl, array($apiParams), array(CURLOPT_CUSTOMREQUEST => 'POST'), array(), 'json')); + if($response and $response->code == 'success') + { + $this->dao->update(TABLE_IMAGE) + ->set('status')->eq('created') + ->where('id')->eq($image->id)->exec(); + return true; + } + + dao::$errors[] = $this->lang->zahost->image->downloadImageFail; + return false; + } + + /** + * Query image download progress. + * + * @param object $image + * @access public + * @return string Return Status code. + */ + public function queryDownloadImageStatus($image) + { + $host = $this->getById($image->hostID); + $apiUrl = 'http://' . $host->publicIP. '/api/v1/task/status'; + + $result = json_decode(commonModel::http($apiUrl, array(), array(CURLOPT_CUSTOMREQUEST => 'GET'), array(), 'json')); + if(!$result or $result->code != 'success') return $image->status; + + foreach($result->data as $status => $group) + { + $task = array_filter($group, function($task) + { + $task->id == $image->id; + }); + + if($task) + { + $image->status = $status; + break; + } + } + + $this->dao->update(TABLE_IMAGE)->set('status')->eq($status)->where('id')->eq($image->id)->exec(); + return $image->status; + } + + /** + * Query download image status. + * + * @param object $image + * @access public + * @return object + */ + public function downloadImageStatus($image) + { + $host = $this->getById($image->hostID); + $statusApi = 'http://' . $host->address . '/api/v1/task/status'; + + $response = json_decode(commonModel::http($statusApi, array(), array(CURLOPT_CUSTOMREQUEST => 'GET'), array(), 'json')); + + a($response); if($response->code == 200) return true; dao::$errors[] = $response->msg; return false; + } /** diff --git a/module/zahost/view/browseimage.html.php b/module/zahost/view/browseimage.html.php index 8890ab3af6..a2c0bfd4f3 100755 --- a/module/zahost/view/browseimage.html.php +++ b/module/zahost/view/browseimage.html.php @@ -11,6 +11,7 @@ */ ?> +
- + - - - - - - + + + + @@ -67,13 +65,10 @@ - - - - executionnode->os->type[$node->osCategory][$node->osType] . ' ' . $lang->executionnode->versionList[$node->osType][$node->osVersion];?> - - - + + + + - - + + - + - + - + - - - - - - - - - - - - - - + + diff --git a/module/executionnode/view/view.html.php b/module/executionnode/view/view.html.php index db464de934..366af00a58 100644 --- a/module/executionnode/view/view.html.php +++ b/module/executionnode/view/view.html.php @@ -48,7 +48,7 @@ - + diff --git a/module/zahost/config.php b/module/zahost/config.php index 89527d1e7c..0c2c10ecf3 100644 --- a/module/zahost/config.php +++ b/module/zahost/config.php @@ -1,16 +1,16 @@ zahost->create = new stdclass(); -$config->zahost->create->requiredFields = 'name,hostType,publicIP,cpuCores,memory,diskSize,virtualSoftware,instanceNum'; -$config->zahost->create->ipFields = 'publicIP'; +$config->zahost->create->requiredFields = 'name,hostType,address,cpu,memory,disk,virtualSoftware'; +$config->zahost->create->ipFields = 'address'; $config->zahost->edit = new stdclass(); -$config->zahost->edit->requiredFields = 'name,hostType,cpuCores,memory,diskSize,virtualSoftware,instanceNum'; +$config->zahost->edit->requiredFields = 'name,hostType,cpu,memory,disk,virtualSoftware'; $config->zahost->createtemplate = new stdclass(); -$config->zahost->createtemplate->requiredFields = 'name,cpuCoreNum,memorySize,diskSize,osCategory,osType,osVersion,osLang,imageName'; +$config->zahost->createtemplate->requiredFields = 'name,cpuCoreNum,memorySize,disk,osCategory,osType,osVersion,osLang,imageName'; $config->zahost->edittemplate = new stdclass(); -$config->zahost->edittemplate->requiredFields = 'name,cpuCoreNum,memorySize,diskSize,osCategory,osType,osVersion,osLang,imageName'; +$config->zahost->edittemplate->requiredFields = 'name,cpuCoreNum,memorySize,disk,osCategory,osType,osVersion,osLang,imageName'; $config->zahost->os = new stdClass(); $config->zahost->os->list = array(); @@ -33,10 +33,10 @@ $config->zahost->search['module'] = 'zahost'; $config->zahost->search['fields']['name'] = $lang->zahost->name; $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; +$config->zahost->search['fields']['address'] = $lang->zahost->IP; +$config->zahost->search['fields']['cpu'] = $lang->zahost->cpu; $config->zahost->search['fields']['memory'] = $lang->zahost->memory; -$config->zahost->search['fields']['diskSize'] = $lang->zahost->diskSize; +$config->zahost->search['fields']['disk'] = $lang->zahost->disk; $config->zahost->search['fields']['virtualSoftware'] = $lang->zahost->virtualSoftware; $config->zahost->search['fields']['status'] = $lang->zahost->status; $config->zahost->search['fields']['createdBy'] = $lang->zahost->createdBy; @@ -48,10 +48,10 @@ $config->zahost->search['fields']['editedDate'] = $lang->zahost->editedDate $config->zahost->search['params']['name'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); $config->zahost->search['params']['id'] = array('operator' => '=', 'control' => 'input', 'values' => ''); $config->zahost->search['params']['type'] = array('operator' => '=', 'control' => 'input', 'values' => $lang->zahost->zaHostType); -$config->zahost->search['params']['publicIP'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); -$config->zahost->search['params']['cpuCores'] = array('operator' => '=', 'control' => 'input', 'values' => ''); +$config->zahost->search['params']['address'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); +$config->zahost->search['params']['cpu'] = array('operator' => '=', 'control' => 'input', 'values' => ''); $config->zahost->search['params']['memory'] = array('operator' => '=', 'control' => 'input', 'values' => ''); -$config->zahost->search['params']['diskSize'] = array('operator' => '=', 'control' => 'input', 'values' => ''); +$config->zahost->search['params']['disk'] = array('operator' => '=', 'control' => 'input', 'values' => ''); $config->zahost->search['params']['virtualSoftware'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); $config->zahost->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => $lang->zahost->statusList); $config->zahost->search['params']['instanceNum'] = array('operator' => '=', 'control' => 'input', 'values' => ''); @@ -111,15 +111,15 @@ $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']['cpuCoreNum'] = $lang->zahost->cpu; $config->vmTemplate->search['fields']['memorySize'] = $lang->zahost->memory; -$config->vmTemplate->search['fields']['diskSize'] = $lang->zahost->diskSize; +$config->vmTemplate->search['fields']['disk'] = $lang->zahost->disk; $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']['disk'] = 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); diff --git a/module/zahost/control.php b/module/zahost/control.php index 2cde051ac1..4e0af333f8 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -354,9 +354,9 @@ class zahost extends control * @access public * @return void */ - public function ajaxCheckPublicIP($IP) + public function ajaxCheckaddress($IP) { - if(!validater::checkIP($IP)) return $this->send(array('result' => 'fail', 'message' => array('publicIP' => array(sprintf($this->lang->zahost->notice->ip, $this->lang->zahost->publicIP))))); + if(!validater::checkIP($IP)) return $this->send(array('result' => 'fail', 'message' => array('address' => array(sprintf($this->lang->zahost->notice->ip, $this->lang->zahost->address))))); $secret = md5(time()); $registerCommand = sprintf($this->lang->zahost->notice->registerCommand, $this->server->server_addr, $this->server->server_port, $IP, $secret); diff --git a/module/zahost/css/create.css b/module/zahost/css/create.css index f3e53739f3..6affb4df70 100644 --- a/module/zahost/css/create.css +++ b/module/zahost/css/create.css @@ -1,4 +1,3 @@ -#unit {padding: 0px !important; width:0px; border-left: 0px;} +#unit {padding: 0px !important; width:0px; border-left: 0px;width: 63px;} .input-group-addon {border: 0px; width: 100px;} -#unit_chosen a {border-left: 0px; border-radius: 0 2px;} -#memory-addon{padding-left: 30px;text-align: left;} \ No newline at end of file +#memory-addon{padding-left: 30px;text-align: left;width: 63px;} \ No newline at end of file diff --git a/module/zahost/css/edit.css b/module/zahost/css/edit.css index b03b48e58d..c4a1a000f2 100644 --- a/module/zahost/css/edit.css +++ b/module/zahost/css/edit.css @@ -1,5 +1,5 @@ -#unit {padding: 0px !important; width:0px; border-left: 0px;} +#unit {padding: 0px !important; width:0px; border-left: 0px;width: 63px;} .input-group-addon {border: 0px; width: 100px;} #unit_chosen a {border-left: 0px; border-radius: 0 2px;} html[lang='en'] .table-form > tbody > tr > th {width: 120px;} -#memory-addon{padding-left: 30px;text-align: left;} \ No newline at end of file +#memory-addon{padding-left: 30px;text-align: left;width: 63px;} \ No newline at end of file diff --git a/module/zahost/css/inithost.css b/module/zahost/css/inithost.css index b7a3c5c1f4..adb9649d82 100644 --- a/module/zahost/css/inithost.css +++ b/module/zahost/css/inithost.css @@ -5,7 +5,7 @@ line-height: 20px; } .host-desc-container{ - margin-top: 40px; + margin-top: 20px; } .host-action{ margin-top: 60px; diff --git a/module/zahost/js/create.js b/module/zahost/js/create.js index a5c85b84d8..283ee28487 100644 --- a/module/zahost/js/create.js +++ b/module/zahost/js/create.js @@ -1,13 +1,13 @@ $(document).ready(function() { - // $('#publicIP').on('blur', function() + // $('#address').on('blur', function() // { - // var url = createLink('zahost', 'ajaxCheckPublicIP', "IP=" + $('#publicIP').val()); + // var url = createLink('zahost', 'ajaxCheckaddress', "IP=" + $('#address').val()); // $.get(url, function(response) // { - // $('#publicIPLabel').remove(); - // $('#publicIP').removeClass('has-error'); + // $('#addressLabel').remove(); + // $('#address').removeClass('has-error'); // $('#registerCommand').remove(); // $('#Secret').remove(); @@ -15,16 +15,16 @@ $(document).ready(function() // if(resultData.result == 'success') // { // $('input#type').after(""); - // $('#publicIP').after("
" + resultData.data.registerCommand + "
"); + // $('#address').after("
" + resultData.data.registerCommand + "
"); // return; // } - // $('#publicIP').addClass('has-error'); + // $('#address').addClass('has-error'); - // if(resultData.message.publicIP) + // if(resultData.message.address) // { - // var errors = resultData.message.publicIP.join(''); - // $('#publicIP').after("
" + errors + "
"); + // var errors = resultData.message.address.join(''); + // $('#address').after("
" + errors + "
"); // } // }); // }); diff --git a/module/zahost/js/inithost.js b/module/zahost/js/inithost.js index 2ea492e7d0..b84f68bb0d 100644 --- a/module/zahost/js/inithost.js +++ b/module/zahost/js/inithost.js @@ -2,7 +2,7 @@ $('#checkServiceStatus').click(function(){ $.get(createLink('zahost', 'ajaxGetServiceStatus', 'hostID=' + hostID), function(response) { var resultData = JSON.parse(response); - let html = "

" + zahostLang.initHost.statusTitle + "

"; + let html = "

" + zahostLang.initHost.statusTitle + "

"; let isSuccess = true for (let key in resultData.data) { @@ -15,9 +15,9 @@ $('#checkServiceStatus').click(function(){ }; if(isSuccess){ - html += '
' + zahostLang.initHost.initSuccessNotice + '
' + html += '

' + zahostLang.initHost.initSuccessNotice + '

' }else{ - html += '
' + zahostLang.initHost.initFailNotice + 'https://github.com/easysoft/zenagent/
' + html += '

' + zahostLang.initHost.initFailNotice + '
https://github.com/easysoft/zenagent/

' } $('#statusContainer').html(html) }); diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index 54fcd4467c..0169323d48 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -17,10 +17,10 @@ $lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Name'; $lang->zahost->IP = 'IP/Domain'; -$lang->zahost->publicIP = 'IP'; -$lang->zahost->cpuCores = 'CPU Cores'; +$lang->zahost->address = 'IP'; +$lang->zahost->cpu = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; -$lang->zahost->diskSize = 'Disk Size'; +$lang->zahost->disk = 'Disk Size'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -32,7 +32,7 @@ $lang->zahost->editedDate = 'EditedDate'; $lang->zahost->registerDate = 'RegisterDate'; $lang->zahost->memorySize = $lang->zahost->memory; -$lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; +$lang->zahost->cpuCoreNum = $lang->zahost->cpu; $lang->zahost->osType = 'Os Version'; $lang->zahost->osCategory = 'System'; $lang->zahost->osVersion = 'Os Version No'; @@ -55,17 +55,17 @@ $lang->zahost->initHost->serviceStatus = [ $lang->zahost->initHost->title = "Initialize Host"; $lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; $lang->zahost->initHost->descLi = [ - "Download the init script to the host:wget xxx -o xxx", - "Execute the init script on the host and execute the command example under Ubuntu:xxxx" + "Download the init script to the host:wget https://pkg-1308438674.cos.ap-shanghai.myqcloud.com/zenagent/zagentenv", + "Execute the init script on the host and execute the command example under Ubuntu:./zagentenv" ]; $lang->zahost->initHost->statusTitle = "Service Status"; $lang->zahost->vmTemplate = new stdclass; $lang->zahost->vmTemplate->name = 'Name'; $lang->zahost->vmTemplate->common = 'VM Template'; -$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpuCores; +$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpu; $lang->zahost->vmTemplate->memorySize = $lang->zahost->memory; -$lang->zahost->vmTemplate->diskSize = $lang->zahost->diskSize; +$lang->zahost->vmTemplate->diskSize = $lang->zahost->disk; $lang->zahost->vmTemplate->osType = $lang->zahost->osType; $lang->zahost->vmTemplate->osCategory = $lang->zahost->osCategory; $lang->zahost->vmTemplate->osVersion = $lang->zahost->osVersion; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index 54fcd4467c..b5cdf59e26 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -17,10 +17,10 @@ $lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Name'; $lang->zahost->IP = 'IP/Domain'; -$lang->zahost->publicIP = 'IP'; -$lang->zahost->cpuCores = 'CPU Cores'; +$lang->zahost->address = 'IP'; +$lang->zahost->cpu = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; -$lang->zahost->diskSize = 'Disk Size'; +$lang->zahost->disk = 'Disk Size'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -32,7 +32,7 @@ $lang->zahost->editedDate = 'EditedDate'; $lang->zahost->registerDate = 'RegisterDate'; $lang->zahost->memorySize = $lang->zahost->memory; -$lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; +$lang->zahost->cpuCoreNum = $lang->zahost->cpu ; $lang->zahost->osType = 'Os Version'; $lang->zahost->osCategory = 'System'; $lang->zahost->osVersion = 'Os Version No'; @@ -55,17 +55,17 @@ $lang->zahost->initHost->serviceStatus = [ $lang->zahost->initHost->title = "Initialize Host"; $lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; $lang->zahost->initHost->descLi = [ - "Download the init script to the host:wget xxx -o xxx", - "Execute the init script on the host and execute the command example under Ubuntu:xxxx" + "Download the init script to the host:wget https://pkg-1308438674.cos.ap-shanghai.myqcloud.com/zenagent/zagentenv", + "Execute the init script on the host and execute the command example under Ubuntu:./zagentenv" ]; $lang->zahost->initHost->statusTitle = "Service Status"; $lang->zahost->vmTemplate = new stdclass; $lang->zahost->vmTemplate->name = 'Name'; $lang->zahost->vmTemplate->common = 'VM Template'; -$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpuCores; +$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpu ; $lang->zahost->vmTemplate->memorySize = $lang->zahost->memory; -$lang->zahost->vmTemplate->diskSize = $lang->zahost->diskSize; +$lang->zahost->vmTemplate->diskSize = $lang->zahost->disk; $lang->zahost->vmTemplate->osType = $lang->zahost->osType; $lang->zahost->vmTemplate->osCategory = $lang->zahost->osCategory; $lang->zahost->vmTemplate->osVersion = $lang->zahost->osVersion; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index 077cbe0174..f721628840 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -17,10 +17,10 @@ $lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Nom'; $lang->zahost->IP = 'IP/Domain'; -$lang->zahost->publicIP = 'IP'; -$lang->zahost->cpuCores = 'CPU Cores'; +$lang->zahost->address = 'IP'; +$lang->zahost->cpu = 'CPU Cores'; $lang->zahost->memory = 'Mémoire Espace'; -$lang->zahost->diskSize = 'Disque Espace'; +$lang->zahost->disk = 'Disque Espace'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -32,7 +32,7 @@ $lang->zahost->editedDate = "Date d'édition"; $lang->zahost->registerDate = "RegisterDate"; $lang->zahost->memorySize = $lang->zahost->memory; -$lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; +$lang->zahost->cpuCoreNum = $lang->zahost->cpu ; $lang->zahost->osType = 'Os Version'; $lang->zahost->osCategory = 'System'; $lang->zahost->osVersion = 'Os Version No'; @@ -55,17 +55,17 @@ $lang->zahost->initHost->serviceStatus = [ $lang->zahost->initHost->title = "Initialize Host"; $lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; $lang->zahost->initHost->descLi = [ - "Download the init script to the host:wget xxx -o xxx", - "Execute the init script on the host and execute the command example under Ubuntu:xxxx" + "Download the init script to the host:wget https://pkg-1308438674.cos.ap-shanghai.myqcloud.com/zenagent/zagentenv", + "Execute the init script on the host and execute the command example under Ubuntu:./zagentenv" ]; $lang->zahost->initHost->statusTitle = "Service Status"; $lang->zahost->vmTemplate = new stdclass; $lang->zahost->vmTemplate->name = 'Nom'; $lang->zahost->vmTemplate->common = 'VM Template'; -$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpuCores; +$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpu ; $lang->zahost->vmTemplate->memorySize = $lang->zahost->memory; -$lang->zahost->vmTemplate->diskSize = $lang->zahost->diskSize; +$lang->zahost->vmTemplate->diskSize = $lang->zahost->disk; $lang->zahost->vmTemplate->osType = $lang->zahost->osType; $lang->zahost->vmTemplate->osCategory = $lang->zahost->osCategory; $lang->zahost->vmTemplate->osVersion = $lang->zahost->osVersion; diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php index 49762bac56..0f642697fb 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -17,10 +17,10 @@ $lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Name'; $lang->zahost->IP = 'IP/Domain'; -$lang->zahost->publicIP = 'IP'; -$lang->zahost->cpuCores = 'CPU Cores'; +$lang->zahost->address = 'IP'; +$lang->zahost->cpu = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; -$lang->zahost->diskSize = 'Disk Size'; +$lang->zahost->disk = 'Disk Size'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -32,7 +32,7 @@ $lang->zahost->editedDate = 'EditedDate'; $lang->zahost->registerDate = 'RegisterDate'; $lang->zahost->memorySize = $lang->zahost->memory; -$lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; +$lang->zahost->cpuCoreNum = $lang->zahost->cpu ; $lang->zahost->osType = 'Os Version'; $lang->zahost->osCategory = 'System'; $lang->zahost->osVersion = 'Os Version No'; @@ -55,17 +55,17 @@ $lang->zahost->initHost->serviceStatus = [ $lang->zahost->initHost->title = "Initialize Host"; $lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; $lang->zahost->initHost->descLi = [ - "Download the init script to the host:wget xxx -o xxx", - "Execute the init script on the host and execute the command example under Ubuntu:xxxx" + "Download the init script to the host:wget https://pkg-1308438674.cos.ap-shanghai.myqcloud.com/zenagent/zagentenv", + "Execute the init script on the host and execute the command example under Ubuntu:./zagentenv" ]; $lang->zahost->initHost->statusTitle = "Service Status"; $lang->zahost->vmTemplate = new stdclass; $lang->zahost->vmTemplate->name = 'Name'; $lang->zahost->vmTemplate->common = 'VM Template'; -$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpuCores; +$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpu ; $lang->zahost->vmTemplate->memorySize = $lang->zahost->memory; -$lang->zahost->vmTemplate->diskSize = $lang->zahost->diskSize; +$lang->zahost->vmTemplate->diskSize = $lang->zahost->disk; $lang->zahost->vmTemplate->osType = $lang->zahost->osType; $lang->zahost->vmTemplate->osCategory = $lang->zahost->osCategory; $lang->zahost->vmTemplate->osVersion = $lang->zahost->osVersion; diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index 5d35100120..f8532c3336 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -17,10 +17,10 @@ $lang->zahost->deleteTemplate = '删除虚拟机模板'; $lang->zahost->name = '名称'; $lang->zahost->IP = 'IP/域名'; -$lang->zahost->publicIP = 'IP'; +$lang->zahost->address = 'IP/域名'; $lang->zahost->memory = '内存'; -$lang->zahost->cpuCores = 'CPU核心数'; -$lang->zahost->diskSize = '硬盘容量'; +$lang->zahost->cpu = 'CPU核心数'; +$lang->zahost->disk = '硬盘容量'; $lang->zahost->desc = '描述'; $lang->zahost->type = '类型'; $lang->zahost->status = '状态'; @@ -32,7 +32,7 @@ $lang->zahost->editedDate = '最后修改时间'; $lang->zahost->registerDate = '最后注册时间'; $lang->zahost->memorySize = $lang->zahost->memory; -$lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; +$lang->zahost->cpuCoreNum = $lang->zahost->cpu ; $lang->zahost->osType = '操作系统版本'; $lang->zahost->osCategory = '操作系统平台'; $lang->zahost->osVersion = '操作系统版本号'; @@ -57,8 +57,8 @@ $lang->zahost->initHost->serviceStatus = [ $lang->zahost->initHost->title = "初始化宿主机"; $lang->zahost->initHost->descTitle = "请按照以下步骤在宿主机上完成初始化:"; $lang->zahost->initHost->descLi = [ - "下载初始化脚本至宿主机:wget xxx -o xxx", - "在宿主机上执行初始化脚本,Ubuntu下执行命令示例:xxxx" + "下载初始化脚本至宿主机:wget https://pkg-1308438674.cos.ap-shanghai.myqcloud.com/zenagent/zagentenv", + "在宿主机上执行初始化脚本,Ubuntu下执行命令示例:./zagentenv" ]; $lang->zahost->image = new stdclass; @@ -72,7 +72,7 @@ $lang->zahost->image->startDowload = '开始下载'; $lang->zahost->image->name = '名称'; $lang->zahost->image->common = '镜像'; $lang->zahost->image->memory = $lang->zahost->memory; -$lang->zahost->image->disk = $lang->zahost->diskSize; +$lang->zahost->image->disk = $lang->zahost->disk; $lang->zahost->image->osType = $lang->zahost->osType; $lang->zahost->image->osCategory = $lang->zahost->osCategory; $lang->zahost->image->osVersion = $lang->zahost->osVersion; @@ -90,9 +90,9 @@ $lang->zahost->image->statusList['fail'] = '下载失败'; $lang->zahost->vmTemplate = new stdclass; $lang->zahost->vmTemplate->name = '名称'; $lang->zahost->vmTemplate->common = '虚拟机模板'; -$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpuCores; +$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpu ; $lang->zahost->vmTemplate->memorySize = $lang->zahost->memory; -$lang->zahost->vmTemplate->diskSize = $lang->zahost->diskSize; +$lang->zahost->vmTemplate->diskSize = $lang->zahost->disk; $lang->zahost->vmTemplate->osType = $lang->zahost->osType; $lang->zahost->vmTemplate->osCategory = $lang->zahost->osCategory; $lang->zahost->vmTemplate->osVersion = $lang->zahost->osVersion; diff --git a/module/zahost/model.php b/module/zahost/model.php index 311e9cf9fd..5232c3eacd 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -33,23 +33,17 @@ class zahostModel extends model public function create() { $hostInfo = fixer::input('post') - ->setDefault('cpuNumber,cpuCores,diskSize,memory', 0) + ->setDefault('cpuNumber,cpu,disk,memory', 0) ->get(); $this->dao->table = 'zahost'; $this->dao->update(TABLE_ZAHOST)->data($hostInfo) ->batchCheck($this->config->zahost->create->requiredFields, 'notempty') - ->batchCheck('cpuCores,diskSize,instanceNum', 'gt', 0) - ->batchCheck('diskSize,memory', 'float') + ->batchCheck('cpu,disk', 'gt', 0) + ->batchCheck('disk,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; @@ -89,7 +83,7 @@ class zahostModel extends model $this->dao->update(TABLE_ZAHOST)->data($hostInfo) ->batchCheck($this->config->zahost->create->requiredFields, 'notempty') - ->batchCheck('diskSize,memory', 'float'); + ->batchCheck('disk,memory', 'float'); if(dao::isError()) return false; $assetInfo['name'] = $hostInfo->name; @@ -103,8 +97,8 @@ class zahostModel extends model if(dao::isError()) return false; $this->dao->update(TABLE_ZAHOST)->data($hostInfo, 'name')->autoCheck() - ->batchCheck('cpuCores,diskSize,instanceNum', 'gt', 0) - ->batchCheck('diskSize,memory', 'float') + ->batchCheck('cpu,disk', 'gt', 0) + ->batchCheck('disk,memory', 'float') ->where('id')->eq($hostID)->exec(); return common::createChanges($oldHost, $hostInfo); } @@ -119,13 +113,13 @@ class zahostModel extends model public function createTemplate($host) { $template = fixer::input('post') - ->setIF($this->post->diskSize > 0, 'diskSize', $this->post->diskSize * 1024) + ->setIF($this->post->disk > 0, 'disk', $this->post->disk * 1024) ->setDefault('imageName', '') ->get(); $this->dao->insert(TABLE_VMTEMPLATE)->data($template) ->batchCheck($this->config->zahost->createtemplate->requiredFields, 'notempty') - ->batchCheck('cpuCoreNum,diskSize,memorySize', 'gt', 0) + ->batchCheck('cpuCoreNum,disk,memorySize', 'gt', 0) ->autoCheck(); if(dao::isError()) return false; @@ -151,12 +145,12 @@ class zahostModel extends model { $oldHost = $this->getTemplateById($templateID); $templateInfo = fixer::input('post') - ->setIF($this->post->diskSize > 0, 'diskSize', $this->post->diskSize * 1024) + ->setIF($this->post->disk > 0, 'disk', $this->post->disk * 1024) ->get(); $this->dao->update(TABLE_VMTEMPLATE)->data($templateInfo) ->batchCheck($this->config->zahost->edittemplate->requiredFields, 'notempty') - ->batchCheck('cpuCoreNum,diskSize,memorySize', 'gt', 0) + ->batchCheck('cpuCoreNum,disk,memorySize', 'gt', 0) ->autoCheck(); if(dao::isError()) return false; @@ -373,15 +367,27 @@ class zahostModel extends model foreach($templateList as $template) { $template->unit = zget($this->lang->zahost->unitList, 'MB'); - if($template->diskSize > 1024) + if($template->disk > 1024) { - $template->diskSize = round($template->diskSize / 1024); + $template->disk = round($template->disk / 1024); $template->unit = zget($this->lang->zahost->unitList, 'GB'); } } return $templateList; } + /** + * Get image pairs by host. + * + * @param int $hostID + * @access public + * @return array + */ + public function getImagePairs($hostID) + { + return $this->dao->select('id,name')->from(TABLE_IMAGE)->where('hostID')->eq($hostID)->fetchPairs(); + } + /** * Get template pairs by host. * @@ -415,7 +421,7 @@ class zahostModel extends model */ public function getServiceStatus($host) { - $result = json_decode(commonModel::http("http://{$host->publicIP}:8086/api/v1/service/check", json_encode(array("services" => "all")))); + $result = json_decode(commonModel::http("http://{$host->address}:8086/api/v1/service/check", json_encode(array("services" => "all")))); if(empty($result) || $result->code != 'success') { $result = new stdclass; diff --git a/module/zahost/view/browse.html.php b/module/zahost/view/browse.html.php index 6a356e0462..671b951583 100644 --- a/module/zahost/view/browse.html.php +++ b/module/zahost/view/browse.html.php @@ -45,10 +45,10 @@ - - + + - + @@ -61,10 +61,10 @@ - - + + - + diff --git a/module/zahost/view/browsetemplate.html.php b/module/zahost/view/browsetemplate.html.php index e9a7fb7d47..33410c8553 100755 --- a/module/zahost/view/browsetemplate.html.php +++ b/module/zahost/view/browsetemplate.html.php @@ -44,7 +44,7 @@ - + diff --git a/module/zahost/view/create.html.php b/module/zahost/view/create.html.php index 235e413d78..e52016eded 100644 --- a/module/zahost/view/create.html.php +++ b/module/zahost/view/create.html.php @@ -35,11 +35,11 @@ - + - - + + @@ -51,12 +51,12 @@ - + diff --git a/module/zahost/view/createimage.html.php b/module/zahost/view/createimage.html.php index c78c79f70c..ded6cb2492 100644 --- a/module/zahost/view/createimage.html.php +++ b/module/zahost/view/createimage.html.php @@ -43,7 +43,7 @@ - + - + @@ -39,7 +39,7 @@ - + - + - - + + @@ -51,12 +51,12 @@ - + diff --git a/module/zahost/view/editimage.html.php b/module/zahost/view/editimage.html.php index e7faa05750..ac53dce825 100644 --- a/module/zahost/view/editimage.html.php +++ b/module/zahost/view/editimage.html.php @@ -27,7 +27,7 @@ - + @@ -40,7 +40,7 @@ - + - + @@ -40,7 +40,7 @@ - + + @@ -46,6 +47,7 @@ + - + diff --git a/module/zahost/view/editimage.html.php b/module/zahost/view/editimage.html.php deleted file mode 100644 index ac53dce825..0000000000 --- a/module/zahost/view/editimage.html.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @package zahost - * @version $Id$ - * @link http://www.zentao.net - */ -?> -getModuleRoot() . 'common/view/header.html.php';?> -zahost);?> -zahost);?> - -hostID);?> -
-
-

zahost->createTemplate;?>

-
-
-
zahost->virtualSoftware;?>zahost->softwareList, '', "class='form-control chosen'");?>
zahost->zaHostType;?> zahost->zaHostTypeList, 'virtual', "class='form-control chosen'");?>
zahost->cpuCores;?>zahost->cpuCoreList, '2', "class='form-control chosen'");?>
zahost->memory;?>
- zahost->unitList['GB'];?> + zahost->unitList['GB'];?>
zahost->virtualSoftware;?>zahost->softwareList, '', "class='form-control chosen'");?>
zahost->instanceNum?>zahost->desc ?>
diff --git a/module/zahost/view/edit.html.php b/module/zahost/view/edit.html.php index b73712b481..6e2d4ac43d 100644 --- a/module/zahost/view/edit.html.php +++ b/module/zahost/view/edit.html.php @@ -11,6 +11,7 @@ */ ?> getModuleRoot() . 'common/view/header.html.php';?> +getModuleRoot() . 'common/view/kindeditor.html.php';?>
@@ -19,6 +20,10 @@
+ + + + @@ -34,14 +39,14 @@ - + @@ -57,12 +62,9 @@ - - - - - - + + + - + From 38b5b41a6498596a7dd04bb4480887f0a3b10d44 Mon Sep 17 00:00:00 2001 From: wangjianhua Date: Fri, 11 Nov 2022 08:58:23 +0800 Subject: [PATCH 04/36] * Add image list page of zahost module. --- config/zentaopms.php | 1 + module/zahost/control.php | 63 ++++++++++++++++-- module/zahost/lang/zh-cn.php | 26 ++++++++ module/zahost/model.php | 85 ++++++++++++++++++------- module/zahost/view/browseimage.html.php | 82 ++++++++++++++++++++++++ module/zahost/view/createimage.html.php | 79 +++++++++++++++++++++++ module/zahost/view/editimage.html.php | 80 +++++++++++++++++++++++ 7 files changed, 390 insertions(+), 26 deletions(-) create mode 100755 module/zahost/view/browseimage.html.php create mode 100644 module/zahost/view/createimage.html.php create mode 100644 module/zahost/view/editimage.html.php diff --git a/config/zentaopms.php b/config/zentaopms.php index e542fd9dd3..4f694bbca5 100644 --- a/config/zentaopms.php +++ b/config/zentaopms.php @@ -254,6 +254,7 @@ 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`'); +define('TABLE_IMAGE', '`' . $config->db->prefix . 'image`'); if(!defined('TABLE_ASSET')) define('TABLE_ASSET', '`' . $config->db->prefix . 'asset`'); if(!defined('TABLE_VMTEMPLATE')) define('TABLE_VMTEMPLATE', '`' . $config->db->prefix . 'vmtemplate`'); diff --git a/module/zahost/control.php b/module/zahost/control.php index def6586261..cc9f562933 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -143,6 +143,63 @@ class zahost extends control return print(js::locate($this->createLink('zahost', 'browse'), 'parent')); } + public function browseImage($hostID, $browseType = 'all', $param = 0, $orderBy = 'id', $recTotal = 0, $recPerPage = 20, $pageID = 1) + { + $this->app->session->set('imageList', $this->app->getURI(true)); + $this->app->loadClass('pager', $static = true); + $pager = pager::init($recTotal, $recPerPage, $pageID); + + $imageList = $this->zahost->getImageList($hostID, $browseType, $param, $orderBy, $pager); + + $this->view->title = $this->lang->zahost->image->list; + $this->view->hostID = $hostID; + $this->view->imageList = $imageList; + $this->view->pager = $pager; + $this->view->param = $param; + $this->view->orderBy = $orderBy; + $this->view->browseType = $browseType; + + $this->display(); + } + + /** + * Create template. + * + * @access public + * @return void + */ + public function createImage($hostID) + { + $host = $this->zahost->getById($hostID); + if($_POST) + { + $this->zahost->createImage(); + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); + + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inLink('browseTemplate', "id={$hostID}"))); + } + + $this->view->imageOptions = array('' => $this->lang->zahost->notice->loading); + $this->view->host = $host; + $this->display(); + } + + /** + * Sent download image request to Host. + * + * @param int $imageID + * @access public + * @return object + */ + public function ajaxDownloadImage($imageID) + { + $image = $this->zahost->getImageByID($imageID); + + $this->zahost->downloadImage($image); + + return $this->send(array('result' => 'success', 'message' => $this->lang->zahost->image->startDowload))); + } + /** * Create template. * @@ -302,11 +359,9 @@ class zahost extends control * @access public * @return void */ - public function ajaxImageList($hostID, $templateID = 0) + public function ajaxImageList() { - $host = $this->zahost->getById($hostID); - $imageList = $this->zahost->getImageList($host, $templateID); - + $imageList = array('1' => 'Ubuntu20'); if($imageList) return $this->send(array('result' => 'success', 'message' => '', 'data' => $imageList)); return $this->send(array('result' => 'fail', 'message' => array('imageName' => array($this->lang->zahost->notice->noImage)))); diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index a0c0e9110d..18434030b5 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -39,6 +39,32 @@ $lang->zahost->osVersion = '操作系统版本号'; $lang->zahost->osLang = '系统语言'; $lang->zahost->imageName = '镜像文件'; +$lang->zahost->image = new stdclass; +$lang->zahost->image->list = '镜像列表'; +$lang->zahost->image->browseImage = '镜像列表'; +$lang->zahost->image->createImage = '创建镜像'; +$lang->zahost->image->choseImage = '选择镜像'; +$lang->zahost->image->downloadImage = '下载镜像'; +$lang->zahost->image->startDowload = '开始下载'; + +$lang->zahost->image->name = '名称'; +$lang->zahost->image->common = '镜像'; +$lang->zahost->image->memory = $lang->zahost->memory; +$lang->zahost->image->disk = $lang->zahost->diskSize; +$lang->zahost->image->osType = $lang->zahost->osType; +$lang->zahost->image->osCategory = $lang->zahost->osCategory; +$lang->zahost->image->osVersion = $lang->zahost->osVersion; +$lang->zahost->image->osLang = $lang->zahost->osLang; +$lang->zahost->image->imageName = $lang->zahost->imageName; + +$lang->zahost->image->imageEmpty = '无镜像'; + +$lang->zahost->image->statusList['waiting'] = '未下载'; +$lang->zahost->image->statusList['downloading'] = '下载中'; +$lang->zahost->image->statusList['finish'] = '已下载'; +$lang->zahost->image->statusList['fail'] = '下载失败'; + + $lang->zahost->vmTemplate = new stdclass; $lang->zahost->vmTemplate->name = '名称'; $lang->zahost->vmTemplate->common = '虚拟机模板'; diff --git a/module/zahost/model.php b/module/zahost/model.php index 08f956f26e..cdeffe3196 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -171,39 +171,80 @@ class zahostModel extends model return common::createChanges($oldHost, $templateInfo); } + /** + * Get image by ID. + * + * @param int $imageID + * @access public + * @return object + */ + public function getImageByID($imageID) + { + return $this->dao->select('*')->from(TABLE_IMAGE)->where('deleted')->eq(0)->andWhere('id')->eq($imageID)->fetch(); + } + /** * Get image files from ZAgent server. * - * @param object $host - * @param int $templateID + * @param object $hostID * @access public * @return array */ - public function getImageList($host, $templateID = 0) + public function getImageList($hostID, $browseType = 'all', $param = 0, $orderBy = 'id', $pager = null) { - $result = json_decode(commonModel::http("http://{$host->publicIP}:8086/api/v1/kvm/listTmpl")); - if(empty($result) || $result->code != 200) - { - $result = new stdclass; - $result->data = array(); - } - - $usedImageList = $this->dao->select('imageName')->from(TABLE_VMTEMPLATE)->where('hostID')->eq($host->hostID)->fetchAll('imageName'); - - $imageList = array(); - foreach($result->data as $image) - { - if(array_key_exists($image->name, $usedImageList)) continue; - - $imageList[] = array('name' => $image->name); - } - - /* Template ID is not empty means editing template. */ - if($templateID) foreach($usedImageList as $usedImage) $imageList[] = array('name' => $usedImage->imageName); + $imageList = $this->dao->select('*')->from(TABLE_IMAGE) + ->where('hostID')->eq($hostID) + ->orderBy($orderBy) + ->page($pager) + ->fetchAll(); return $imageList; } + /** + * create image. + * + * @access public + * @return void + */ + public function createImage() + { + $vmImage = fixer::input('post') + ->get(); + + $this->dao->insert(TABLE_IMAGE)->data($vmImage) + ->batchCheck($this->config->zahost->createimage->requiredFields, 'notempty') + ->autoCheck()->exec(); + if(dao::isError()) return false; + + $imageID = $this->dao->lastInsertID(); + $this->loadModel('action')->create('image', $imageID, 'Created'); + } + + /** + * Send download image command to HOST. + * + * @param object $image + * @access public + * @return bool + */ + public function downloadImage($image) + { + $host = $this->getById($image->hostID); + $downloadApi = 'http://' . $host->address . '/api/v1/download/add'; + + $apiParams['md5'] = $image->md5; + $apiParams['task'] = 1; + $apiParams['url'] = $image->address; + + $response = json_decode(commonModel::http($downloadApi, $apiParams)); + + if($response->code == 200) return true; + + dao::$errors[] = $response->msg; + return false; + } + /** * Get host by id. * diff --git a/module/zahost/view/browseimage.html.php b/module/zahost/view/browseimage.html.php new file mode 100755 index 0000000000..8c6b5265c8 --- /dev/null +++ b/module/zahost/view/browseimage.html.php @@ -0,0 +1,82 @@ + + * @package zahost + * @version $Id$ + * @link http://www.zentao.net + */ +?> + + +
' data-module='vmTemplate'>
+
+ recTotal}&recPerPage={$pager->recPerPage}";?> + +
+

+ zahost->image->imageEmpty;?> + ' . $lang->zahost->image->createImage, '', 'class="btn btn-info"');?> +

+
+ +
zahost->virtualSoftware;?>zahost->softwareList, $host->virtualSoftware, "class='form-control chosen'");?>
zahost->zaHostType;?> zahost->zaHostTypeList, $host->hostType, "class='form-control chosen'");?>
zahost->cpuCores;?>cpuCores, "class='form-control'");?>zahost->cpuCoreList, $host->cpuCores, "class='form-control chosen'");?>
zahost->memory;?>
memory, "class='form-control'");?> - zahost->unitList['GB'];?> + zahost->unitList['GB'];?>
zahost->virtualSoftware;?>zahost->softwareList, $host->virtualSoftware, "class='form-control chosen'");?>
zahost->instanceNum?>instanceNum, "class='form-control'");?>zahost->desc ?>desc, "class='form-control'")?>
diff --git a/module/zahost/view/inithost.html.php b/module/zahost/view/inithost.html.php new file mode 100644 index 0000000000..463db6f503 --- /dev/null +++ b/module/zahost/view/inithost.html.php @@ -0,0 +1,39 @@ + + * @package automation + * @version $Id$ + * @link http://www.zentao.net + */ +?> + + +zahost);?> + +
+
+
+
+

zahost->initHost->title;?>

+
+
+

zahost->initHost->descTitle;?>

+ zahost->initHost->descLi as $key => $li): ?> +
.
+ + +
+
+
+ +
+ + +
+
+
+ From dfa13273c0c061f17d80fabe0a55eb8154ac22de Mon Sep 17 00:00:00 2001 From: zhaoke Date: Thu, 10 Nov 2022 08:24:13 +0000 Subject: [PATCH 03/36] * Add execnode table. --- config/zentaopms.php | 1 + module/executionnode/config.php | 2 +- module/executionnode/model.php | 48 +++++++++++------------ module/executionnode/view/browse.html.php | 2 +- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/config/zentaopms.php b/config/zentaopms.php index af5d41838c..8d903ea646 100644 --- a/config/zentaopms.php +++ b/config/zentaopms.php @@ -255,6 +255,7 @@ define('TABLE_TESTRESULT', '`' . $config->db->prefix . 'testresult`'); define('TABLE_USERTPL', '`' . $config->db->prefix . 'usertpl`'); define('TABLE_ZAHOST', '`' . $config->db->prefix . 'host`'); define('TABLE_EXECUTIONNODE', '`' . $config->db->prefix . 'executionnode`'); +define('TABLE_IMAGE', '`' . $config->db->prefix . 'image`'); if(!defined('TABLE_ASSET')) define('TABLE_ASSET', '`' . $config->db->prefix . 'asset`'); if(!defined('TABLE_VMTEMPLATE')) define('TABLE_VMTEMPLATE', '`' . $config->db->prefix . 'vmtemplate`'); diff --git a/module/executionnode/config.php b/module/executionnode/config.php index 84c36be428..68f779b89f 100755 --- a/module/executionnode/config.php +++ b/module/executionnode/config.php @@ -44,7 +44,7 @@ $config->executionnode->search['fields']['osCpu'] = $lang->executionnode->c $config->executionnode->search['fields']['osMemory'] = $lang->executionnode->osMemory; $config->executionnode->search['fields']['osDisk'] = $lang->executionnode->osDisk; $config->executionnode->search['fields']['macAddress'] = $lang->executionnode->macAddress; -$config->executionnode->search['fields']['publicIP'] = $lang->executionnode->ip; +$config->executionnode->search['fields']['address'] = $lang->executionnode->ip; $config->executionnode->search['params']['name'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); $config->executionnode->search['params']['osType'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $config->executionnode->os->type['windows'] + $config->executionnode->os->type['linux']); $config->executionnode->search['params']['hostID'] = array('operator' => '=', 'control' => 'select', 'values' => ''); diff --git a/module/executionnode/model.php b/module/executionnode/model.php index 641288a976..67db7be9d5 100755 --- a/module/executionnode/model.php +++ b/module/executionnode/model.php @@ -31,7 +31,7 @@ class executionnodemodel extends model * Create an VM. * * @param object $data - * @param int $templateID + * @param int $imageID * @access public * @return void */ @@ -41,7 +41,7 @@ class executionnodemodel extends model /* Batch check fields. */ $this->lang->vm = $this->lang->executionnode; - $this->dao->update(TABLE_VM)->data($data) + $this->dao->update(TABLE_EXECUTIONNODE)->data($data) ->batchCheck($this->config->executionnode->create->requiredFields, 'notempty') ->check('name', 'unique'); if(dao::isError()) return false; @@ -53,7 +53,7 @@ class executionnodemodel extends model } /* Get Vmtemplate. */ - $vmTemplate = $this->getVmTemplateByID($data->templateID); + $vmTemplate = $this->getVmTemplateByID($data->imageID); $data->osCategory = $vmTemplate->osCategory; $data->osType = $vmTemplate->osType; $data->osVersion = $vmTemplate->osVersion; @@ -66,7 +66,7 @@ class executionnodemodel extends model $macAddress = $this->genMacAddress(); /* Prepare create params. */ - $agnetUrl = 'http://' . $host->publicIP . ':' . $this->config->executionnode->defaultPort; + $agnetUrl = 'http://' . $host->address . ':' . $this->config->executionnode->defaultPort; $param = array( 'vmMacAddress' => $macAddress, 'osCategory' => $vmTemplate->osCategory, @@ -94,7 +94,7 @@ class executionnodemodel extends model } /* Prepare create execution node data. */ - $data->templateID = $data->templateID; + $data->imageID = $data->imageID; $data->hostID = $host->id; $data->macAddress = $macAddress; $data->status = static::STATUS_RUNNING; @@ -106,7 +106,7 @@ class executionnodemodel extends model $data->vncPort = (int)$result->data->vncPort; /* Save execution node. */ - $this->dao->insert(TABLE_VM)->data($data)->autoCheck()->exec(); + $this->dao->insert(TABLE_EXECUTIONNODE)->data($data)->autoCheck()->exec(); if(dao::isError()) return false; $nodeID = $this->dao->lastInsertID(); @@ -129,7 +129,7 @@ class executionnodemodel extends model $host = $this->getHostByID($node->hostID); /* Prepare create params. */ - $agnetUrl = 'http://' . $host->publicIP . ':' . $this->config->executionnode->defaultPort; + $agnetUrl = 'http://' . $host->address . ':' . $this->config->executionnode->defaultPort; $path = '/api/v1/kvm/' . $node->name . '/' . $type; $param = array('vmUniqueName' => $node->name); @@ -142,7 +142,7 @@ class executionnodemodel extends model if($type != 'reboot') { $status = $type == 'suspend' ? 'suspend' : 'running'; - $this->dao->update(TABLE_VM)->set('status')->eq($status)->where('id')->eq($id)->exec(); + $this->dao->update(TABLE_EXECUTIONNODE)->set('status')->eq($status)->where('id')->eq($id)->exec(); } $this->loadModel('action')->create('executionnode', $id, ucfirst($type)); @@ -166,7 +166,7 @@ class executionnodemodel extends model /* Prepare create params. */ if($host) { - $agnetUrl = 'http://' . $host->publicIP . ':' . $this->config->executionnode->defaultPort; + $agnetUrl = 'http://' . $host->address . ':' . $this->config->executionnode->defaultPort; $result = commonModel::http($agnetUrl . '/api/v1/kvm/' . $node->name . '/destroy', json_encode($req)); $data = json_decode($result, true); @@ -176,7 +176,7 @@ class executionnodemodel extends model } /* delete execution node. */ - $this->dao->update(TABLE_VM) + $this->dao->update(TABLE_EXECUTIONNODE) ->set('deleted')->eq(1) ->set('destroyAt')->eq(helper::now()) ->where('id')->eq($id) @@ -234,7 +234,7 @@ class executionnodemodel extends model */ public function update($id, $data) { - $this->dao->update(TABLE_VM)->data($data) + $this->dao->update(TABLE_EXECUTIONNODE)->data($data) ->where('id')->eq($id) ->exec(); } @@ -250,7 +250,7 @@ class executionnodemodel extends model public function setVmName($vm, $id) { $name = sprintf('test-%s-%s-%s-%s-%d', $vm['osCategory'], $vm['osType'], $vm['osArch'], $vm['osLang'], $id); - $this->dao->update(TABLE_VM)->data(array('name' => $name)) + $this->dao->update(TABLE_EXECUTIONNODE)->data(array('name' => $name)) ->where('id')->eq($id) ->exec(); $vm['name'] = $name; @@ -300,12 +300,12 @@ class executionnodemodel extends model $orderBy = str_replace('osVersion', 't4.osVersion', $orderBy); - return $this->dao->select('t1.*, t3.name as hostName, t2.publicIP as hostIP,t4.osVersion')->from(TABLE_VM)->alias('t1') + return $this->dao->select('t1.*, t3.name as hostName, t2.address as hostIP,t4.osVersion')->from(TABLE_EXECUTIONNODE)->alias('t1') ->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t1.hostID = t2.id') ->leftJoin(TABLE_ASSET)->alias('t3')->on('t3.id = t2.assetID') - ->leftJoin(TABLE_VMTEMPLATE)->alias('t4')->on('t4.id = t1.templateID') + ->leftJoin(TABLE_IMAGE)->alias('t4')->on('t4.id = t1.imageID') ->where('t1.deleted')->eq(0) - ->andWhere("((t1.public = 1) OR (t1.createdBy = '{$this->app->user->account}'))") + ->andWhere("(t1.createdBy = '{$this->app->user->account}')") ->beginIF($query)->andWhere($query)->fi() ->orderBy($orderBy) ->page($pager) @@ -337,7 +337,7 @@ class executionnodemodel extends model public function getHostByIP($ip) { return $this->dao->select('*')->from(TABLE_ZAHOST) - ->where('publicIP')->eq($ip) + ->where('address')->eq($ip) ->fetch(); } @@ -364,7 +364,7 @@ class executionnodemodel extends model */ public function getVmTemplateByID($id) { - return $this->dao->select('*')->from(TABLE_VMTEMPLATE) + return $this->dao->select('*')->from(TABLE_IMAGE) ->where('id')->eq($id) ->fetch(); } @@ -415,7 +415,7 @@ class executionnodemodel extends model */ public function getVmTemplateList($orderBy = 'id_desc', $pager = null) { - return $this->dao->select('*')->from(TABLE_VMTEMPLATE)->orderBy($orderBy)->page($pager)->fetchAll(); + return $this->dao->select('*')->from(TABLE_IMAGE)->orderBy($orderBy)->page($pager)->fetchAll(); } /** @@ -429,7 +429,7 @@ class executionnodemodel extends model */ public function getVmTemplatePairs($osCategory = '', $osType = '', $osVersion = '') { - return $this->dao->select('id,name')->from(TABLE_VMTEMPLATE) + return $this->dao->select('id,name')->from(TABLE_IMAGE) ->where('osCategory')->eq($osCategory) ->andwhere('osType')->eq($osType) ->andwhere('osVersion')->eq($osVersion) @@ -444,10 +444,10 @@ class executionnodemodel extends model */ public function getVMByID($id) { - return $this->dao->select('t1.*, t3.name as hostName, t2.publicIP as ip,t4.osVersion')->from(TABLE_VM)->alias('t1') + return $this->dao->select('t1.*, t3.name as hostName, t2.address as ip,t4.osVersion')->from(TABLE_EXECUTIONNODE)->alias('t1') ->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t1.hostID = t2.id') ->leftJoin(TABLE_ASSET)->alias('t3')->on('t3.id = t2.assetID') - ->leftJoin(TABLE_VMTEMPLATE)->alias('t4')->on('t4.id = t1.templateID') + ->leftJoin(TABLE_IMAGE)->alias('t4')->on('t4.id = t1.imageID') ->where('t1.id')->eq($id) ->fetch(); } @@ -460,7 +460,7 @@ class executionnodemodel extends model */ public function getVMByMac($mac) { - return $this->dao->select('*')->from(TABLE_VM) + return $this->dao->select('*')->from(TABLE_EXECUTIONNODE) ->where('macAddress')->eq($mac) ->fetch(); } @@ -508,13 +508,13 @@ class executionnodemodel extends model $host = $this->getHostByID($vm->hostID); if(empty($host)) return false; - $agnetUrl = 'http://' . $host->publicIP . ':' . $host->agentPort . static::KVM_TOKEN_PATH; + $agnetUrl = 'http://' . $host->address . ':' . $host->agentPort . static::KVM_TOKEN_PATH; $result = json_decode(commonModel::http("$agnetUrl?port={$vm->vncPort}")); if(empty($result) or $result->code != 1) return false; $returnData = new stdClass(); - $returnData->hostIP = $host->publicIP; + $returnData->hostIP = $host->address; $returnData->agentPort = $host->agentPort; $returnData->vncPort = $vm->vncPort; $returnData->token = $result->data->token; diff --git a/module/executionnode/view/browse.html.php b/module/executionnode/view/browse.html.php index 76db50882f..4167a8dcb1 100755 --- a/module/executionnode/view/browse.html.php +++ b/module/executionnode/view/browse.html.php @@ -49,7 +49,7 @@
idAB);?> executionnode->name);?>executionnode->ip);?>executionnode->ip);?> executionnode->cpu);?> executionnode->osMemory);?> executionnode->osDisk);?>
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
idAB);?>zahost->image->name);?>zahost->image->memory);?>zahost->image->disk);?>zahost->image->osCategory);?>zahost->image->osType);?>zahost->image->osVersion);?>zahost->image->osLang);?>zahost->status;?>actions;?>
id;?>name;?>memory . zget($this->lang->zahost->unitList, 'GB');?>disk . zget($this->lang->zahost->unitList, 'GB');?>zahost->os->list, $image->osCategory);?>zahost->os->type[$image->osCategory], $image->osType);?>zahost->versionList[$image->osType], $image->osVersion);?>zahost->langList, $image->osLang);?>zahost->image->statusList, $image->status, '');?> + id}", $image, 'list', 'download');?> + createLink('zahost', 'downloadImage', "id={$image->id}"), '', 'hiddenwin', "title='{$lang->zahost->image->downloadImage}' class='btn'");?> + id}", $image, 'list', 'edit');?> + createLink('zahost', 'deleteImage', "id={$image->id}"), '', 'hiddenwin', "title='{$lang->zahost->delete}' class='btn'");?> +
+ + +
+getModuleRoot() . 'common/view/footer.html.php';?> diff --git a/module/zahost/view/createimage.html.php b/module/zahost/view/createimage.html.php new file mode 100644 index 0000000000..c78c79f70c --- /dev/null +++ b/module/zahost/view/createimage.html.php @@ -0,0 +1,79 @@ + + * @package zahost + * @version $Id$ + * @link http://www.zentao.net + */ +?> +getModuleRoot() . 'common/view/header.html.php';?> +zahost);?> +zahost);?> +hostID);?> +
+
+

zahost->image->createImage;?>

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
zahost->common;?>name;?>
zahost->image->choseImage;?>
zahost->name;?>
zahost->memory;?> +
+ + MB +
+
zahost->diskSize;?> +
+ + GB +
+
zahost->image->osCategory;?>zahost->os->list, '', "class='form-control chosen'")?>
zahost->image->osType;?>
zahost->image->osVersion;?>
zahost->image->osLang;?>zahost->langList, '', "class='form-control chosen'")?>
+ + + id);?> +
+ +
+getModuleRoot() . 'common/view/footer.html.php';?> diff --git a/module/zahost/view/editimage.html.php b/module/zahost/view/editimage.html.php new file mode 100644 index 0000000000..e7faa05750 --- /dev/null +++ b/module/zahost/view/editimage.html.php @@ -0,0 +1,80 @@ + + * @package zahost + * @version $Id$ + * @link http://www.zentao.net + */ +?> +getModuleRoot() . 'common/view/header.html.php';?> +zahost);?> +zahost);?> + +hostID);?> +
+
+

zahost->createTemplate;?>

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
zahost->name;?>name, "class='form-control'");?>
zahost->cpuCores;?>cpuCoreNum, "class='form-control'");?>
zahost->memory;?> +
+ memorySize, "class='form-control'");?> + MB +
+
zahost->diskSize;?> +
+ diskSize/1024), "class='form-control'");?> + GB +
+
zahost->vmTemplate->osCategory;?>zahost->os->list, $template->osCategory, "class='form-control chosen'")?>
zahost->vmTemplate->osType;?>osType, "class='form-control chosen'")?>
zahost->vmTemplate->osVersion;?>osVersion, "class='form-control chosen'")?>
zahost->vmTemplate->osLang;?>zahost->langList, $template->osLang, "class='form-control chosen'")?>
zahost->vmTemplate->imageName;?>imageName, "class='form-control chosen'")?>
+ + + +
+
+
+getModuleRoot() . 'common/view/footer.html.php';?> From fc921fa9804727a071d837602ad57ec2f99085ce Mon Sep 17 00:00:00 2001 From: wangjianhua Date: Fri, 11 Nov 2022 09:53:41 +0800 Subject: [PATCH 05/36] * Add hostID to image table. --- module/zahost/control.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/zahost/control.php b/module/zahost/control.php index 301bd3be14..d8ce0cebc2 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -197,7 +197,7 @@ class zahost extends control $this->zahost->downloadImage($image); - return $this->send(array('result' => 'success', 'message' => $this->lang->zahost->image->startDowload))); + return $this->send(array('result' => 'success', 'message' => $this->lang->zahost->image->startDowload)); } /** From 0e2c874fed0e076752fb8a510f88d8c70f55c6a3 Mon Sep 17 00:00:00 2001 From: wangjianhua Date: Fri, 11 Nov 2022 09:56:31 +0800 Subject: [PATCH 06/36] * Add hostID to image table. --- db/update18.0.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/update18.0.sql b/db/update18.0.sql index d3d740868c..ec7ab6d81b 100644 --- a/db/update18.0.sql +++ b/db/update18.0.sql @@ -31,6 +31,7 @@ CREATE TABLE `zt_executionnode` ( CREATE TABLE `zt_image` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `hostID` int(11) unsigned NOT NULL DEFAULT 0, `name` varchar(64) NOT NULL DEFAULT '', `address` varchar(64) NOT NULL DEFAULT '', `from` varchar(64) NOT NULL DEFAULT '', From b1545ae32558e442777be1517c22606cbfbeda59 Mon Sep 17 00:00:00 2001 From: wangjianhua Date: Fri, 11 Nov 2022 10:29:03 +0800 Subject: [PATCH 07/36] * Hide some buttons in image list page. --- module/zahost/control.php | 13 +++++++++++++ module/zahost/view/browseimage.html.php | 14 +++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/module/zahost/control.php b/module/zahost/control.php index d8ce0cebc2..2cde051ac1 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -143,6 +143,19 @@ class zahost extends control return print(js::locate($this->createLink('zahost', 'browse'), 'parent')); } + /** + * Show image list page. + * + * @param int $hostID + * @param string $browseType + * @param int $param + * @param string $orderBy + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID + * @access public + * @return void + */ public function browseImage($hostID, $browseType = 'all', $param = 0, $orderBy = 'id', $recTotal = 0, $recPerPage = 20, $pageID = 1) { $this->app->session->set('imageList', $this->app->getURI(true)); diff --git a/module/zahost/view/browseimage.html.php b/module/zahost/view/browseimage.html.php index 8c6b5265c8..8890ab3af6 100755 --- a/module/zahost/view/browseimage.html.php +++ b/module/zahost/view/browseimage.html.php @@ -13,8 +13,8 @@
zahost->image->osVersion);?> zahost->image->osLang);?> zahost->status;?>actions;?>actions;?>
zahost->os->type[$image->osCategory], $image->osType);?> zahost->versionList[$image->osType], $image->osVersion);?> zahost->langList, $image->osLang);?>zahost->image->statusList, $image->status, '');?>zahost->image->statusList, $image->status, '');?> - id}", $image, 'list', 'download');?> - createLink('zahost', 'downloadImage', "id={$image->id}"), '', 'hiddenwin', "title='{$lang->zahost->image->downloadImage}' class='btn'");?> - id}", $image, 'list', 'edit');?> + id}", $image, 'list', 'download');?> + createLink('zahost', 'downloadImage', "id={$image->id}"), '', 'hiddenwin', "title='{$lang->zahost->image->downloadImage}' class='btn'");?> + id}", $image, 'list', 'edit');?> createLink('zahost', 'deleteImage', "id={$image->id}"), '', 'hiddenwin', "title='{$lang->zahost->delete}' class='btn'");?>
zahost->os->type[$image->osCategory], $image->osType);?> zahost->versionList[$image->osType], $image->osVersion);?> zahost->langList, $image->osLang);?>zahost->image->statusList, $image->status, '');?>zahost->image->statusList, $image->status, '');?> id}", $image, 'list', 'download');?> createLink('zahost', 'downloadImage', "id={$image->id}"), '', 'hiddenwin', "title='{$lang->zahost->image->downloadImage}' class='btn'");?> From 42fb46ed5123ed4c8cd9fa6c084561e32c491769 Mon Sep 17 00:00:00 2001 From: wangjianhua Date: Fri, 11 Nov 2022 17:52:32 +0800 Subject: [PATCH 10/36] * Modify api of downloading image status. --- module/zahost/model.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/module/zahost/model.php b/module/zahost/model.php index 46e06ed261..47a3438bf7 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -261,26 +261,25 @@ class zahostModel extends model public function queryDownloadImageStatus($image) { $host = $this->getById($image->hostID); - $apiUrl = 'http://' . $host->publicIP. '/api/v1/task/status'; + $apiUrl = 'http://' . $host->publicIP. '/api/v1/task/getStatus'; - $result = json_decode(commonModel::http($apiUrl, array(), array(CURLOPT_CUSTOMREQUEST => 'GET'), array(), 'json')); + $result = json_decode(commonModel::http($apiUrl, array(), array(CURLOPT_CUSTOMREQUEST => 'POST'), array(), 'json')); if(!$result or $result->code != 'success') return $image->status; foreach($result->data as $status => $group) { - $task = array_filter($group, function($task) + $task = array_filter($group, function($task) use($image) { - $task->id == $image->id; + return $task->task == $image->id; }); if($task) { - $image->status = $status; - break; + $this->dao->update(TABLE_IMAGE)->set('status')->eq($status)->where('id')->eq($image->id)->exec(); + return $status; } } - $this->dao->update(TABLE_IMAGE)->set('status')->eq($status)->where('id')->eq($image->id)->exec(); return $image->status; } From 223c86c6fd8fd7ac0f5e5439e0c9a83d3aed90f3 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Mon, 14 Nov 2022 03:27:17 +0000 Subject: [PATCH 11/36] * Finish task 74993. --- db/update18.0.sql | 20 ++-- db/zentao.sql | 28 +++--- module/executionnode/config.php | 23 +++-- module/executionnode/control.php | 20 ++-- module/executionnode/css/create.css | 4 +- module/executionnode/js/common.js | 19 ++-- module/executionnode/lang/de.php | 15 ++- module/executionnode/lang/en.php | 15 ++- module/executionnode/lang/fr.php | 15 ++- module/executionnode/lang/zh-cn.php | 17 ++-- module/executionnode/model.php | 104 ++++++--------------- module/executionnode/view/browse.html.php | 21 ++--- module/executionnode/view/create.html.php | 34 +++---- module/executionnode/view/view.html.php | 2 +- module/zahost/config.php | 28 +++--- module/zahost/control.php | 4 +- module/zahost/css/create.css | 5 +- module/zahost/css/edit.css | 4 +- module/zahost/css/inithost.css | 2 +- module/zahost/js/create.js | 18 ++-- module/zahost/js/inithost.js | 6 +- module/zahost/lang/de.php | 16 ++-- module/zahost/lang/en.php | 16 ++-- module/zahost/lang/fr.php | 16 ++-- module/zahost/lang/vi.php | 16 ++-- module/zahost/lang/zh-cn.php | 18 ++-- module/zahost/model.php | 44 +++++---- module/zahost/view/browse.html.php | 12 +-- module/zahost/view/browsetemplate.html.php | 2 +- module/zahost/view/create.html.php | 12 +-- module/zahost/view/createimage.html.php | 2 +- module/zahost/view/createtemplate.html.php | 4 +- module/zahost/view/edit.html.php | 12 +-- module/zahost/view/editimage.html.php | 4 +- module/zahost/view/edittemplate.html.php | 4 +- module/zahost/view/inithost.html.php | 3 +- test/data/host.yaml | 2 +- test/data/zt_host.yaml | 6 +- 38 files changed, 261 insertions(+), 332 deletions(-) diff --git a/db/update18.0.sql b/db/update18.0.sql index ec7ab6d81b..21cec74630 100644 --- a/db/update18.0.sql +++ b/db/update18.0.sql @@ -11,21 +11,21 @@ CREATE TABLE `zt_executionnode` ( `hostID` int(11) unsigned NOT NULL DEFAULT 0, `name` varchar(64) NOT NULL DEFAULT '', `imageID` int(11) unsigned NOT NULL DEFAULT 0, - `osCategory` varchar(32) NOT NULL DEFAULT '', - `osType` varchar(32) NOT NULL DEFAULT '', - `osVersion` varchar(32) NOT NULL DEFAULT '', - `osLang` varchar(32) NOT NULL DEFAULT '', + `cpu` int(11) unsigned NOT NULL DEFAULT 0, + `os` varchar(128) NOT NULL DEFAULT '', + `unit` enum('GB','TB') NOT NULL DEFAULT 'GB', `memory` float unsigned NOT NULL, `disk` float unsigned NOT NULL, `status` varchar(20) NOT NULL, `mac` varchar(64) NOT NULL, `vnc` int(11) unsigned NOT NULL DEFAULT 0, + `desc` text NOT NULL, `registerDate` datetime NOT NULL, - `createdBy` datetime NOT NULL, + `createdBy` varchar(30) NOT NULL, `createdDate` datetime NOT NULL, - `editedBy` datetime NOT NULL, + `editedBy` varchar(30) NOT NULL, `editedDate` datetime NOT NULL, - `deleted` datetime NOT NULL, + `deleted` enum('0','1') NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; @@ -46,11 +46,11 @@ CREATE TABLE `zt_image` ( `fileSize` float unsigned NOT NULL, `md5` varchar(64) NOT NULL, `registerDate` datetime NOT NULL, - `createdBy` datetime NOT NULL, + `createdBy` varchar(30) NOT NULL, `createdDate` datetime NOT NULL, - `editedBy` datetime NOT NULL, + `editedBy` varchar(30) NOT NULL, `editedDate` datetime NOT NULL, - `deleted` datetime NOT NULL, + `deleted` enum('0','1') NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; diff --git a/db/zentao.sql b/db/zentao.sql index 48a0d6f860..b98dace20d 100755 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -7281,14 +7281,14 @@ CREATE TABLE IF NOT EXISTS `zt_host` ( `cpuBrand` varchar(128) NOT NULL, `cpuModel` varchar(128) NOT NULL, `cpuNumber` varchar(16) NOT NULL, - `cpuCores` varchar(30) NOT NULL, + `cpu` varchar(30) NOT NULL, `cpuRate` varchar(30) NOT NULL, `memory` varchar(30) NOT NULL, `diskType` varchar(30) NOT NULL, - `diskSize` varchar(30) NOT NULL, + `disk` varchar(30) NOT NULL, `unit` enum('GB','TB') NOT NULL DEFAULT 'GB', `privateIP` varchar(128) NOT NULL, - `publicIP` varchar(128) NOT NULL, + `address` varchar(128) NOT NULL, `nic` varchar(128) NOT NULL, `mac` varchar(128) NOT NULL, `osName` varchar(64) NOT NULL, @@ -7301,7 +7301,7 @@ CREATE TABLE IF NOT EXISTS `zt_host` ( `agentPort` varchar(10) NOT NULL, `instanceNum` tinyint(0) NOT NULL DEFAULT 0, `pri` smallint(5) unsigned NOT NULL DEFAULT 0, - `heartbeatTime` datetime NOT NULL, + `heartbeat` datetime NOT NULL, `tags` varchar(50) NOT NULL DEFAULT '', `provider` varchar(255) NOT NULL DEFAULT '', `bridgeID` varchar(255) NOT NULL DEFAULT '', @@ -7322,27 +7322,27 @@ CREATE TABLE `zt_executionnode` ( `hostID` int(11) unsigned NOT NULL DEFAULT 0, `name` varchar(64) NOT NULL DEFAULT '', `imageID` int(11) unsigned NOT NULL DEFAULT 0, - `osCategory` varchar(32) NOT NULL DEFAULT '', - `osType` varchar(32) NOT NULL DEFAULT '', - `osVersion` varchar(32) NOT NULL DEFAULT '', - `osLang` varchar(32) NOT NULL DEFAULT '', + `cpu` int(11) unsigned NOT NULL DEFAULT 0, + `os` varchar(128) NOT NULL DEFAULT '', `memory` float unsigned NOT NULL, `disk` float unsigned NOT NULL, `status` varchar(20) NOT NULL, `mac` varchar(64) NOT NULL, `vnc` int(11) unsigned NOT NULL DEFAULT 0, + `desc` text NOT NULL, `registerDate` datetime NOT NULL, - `createdBy` datetime NOT NULL, + `createdBy` varchar(30) NOT NULL, `createdDate` datetime NOT NULL, - `editedBy` datetime NOT NULL, + `editedBy` varchar(30) NOT NULL, `editedDate` datetime NOT NULL, - `deleted` datetime NOT NULL, + `deleted` enum('0','1') NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; -- DROP TABLE IF EXISTS `zt_image`; CREATE TABLE `zt_image` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `hostID` int(11) unsigned NOT NULL DEFAULT 0, `name` varchar(64) NOT NULL DEFAULT '', `address` varchar(64) NOT NULL DEFAULT '', `from` varchar(64) NOT NULL DEFAULT '', @@ -7357,11 +7357,11 @@ CREATE TABLE `zt_image` ( `fileSize` float unsigned NOT NULL, `md5` varchar(64) NOT NULL, `registerDate` datetime NOT NULL, - `createdBy` datetime NOT NULL, + `createdBy` varchar(30) NOT NULL, `createdDate` datetime NOT NULL, - `editedBy` datetime NOT NULL, + `editedBy` varchar(30) NOT NULL, `editedDate` datetime NOT NULL, - `deleted` datetime NOT NULL, + `deleted` enum('0','1') NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; diff --git a/module/executionnode/config.php b/module/executionnode/config.php index 68f779b89f..a6b151edb8 100755 --- a/module/executionnode/config.php +++ b/module/executionnode/config.php @@ -1,7 +1,7 @@ executionnode->create = new stdClass(); $config->executionnode->edit = new stdClass(); -$config->executionnode->create->requiredFields = 'name,hostID,templateID,osCpu,osMemory,osDisk'; +$config->executionnode->create->requiredFields = 'name,hostID,imageID,cpu,memory,disk,os'; $config->executionnode->edit->requiredFields = ''; $config->executionnode->defaultPort = '8086'; @@ -36,22 +36,21 @@ $config->executionnode->os->type['linux']['debian'] = 'Debian'; global $lang; $config->executionnode->search['module'] = 'executionnode'; $config->executionnode->search['fields']['name'] = $lang->executionnode->name; -$config->executionnode->search['fields']['osType'] = $lang->executionnode->osType; -$config->executionnode->search['fields']['osVersion'] = $lang->executionnode->osVersion; +$config->executionnode->search['fields']['os'] = $lang->executionnode->os; $config->executionnode->search['fields']['hostID'] = $lang->executionnode->hostName; $config->executionnode->search['fields']['status'] = $lang->executionnode->status; -$config->executionnode->search['fields']['osCpu'] = $lang->executionnode->cpu; -$config->executionnode->search['fields']['osMemory'] = $lang->executionnode->osMemory; -$config->executionnode->search['fields']['osDisk'] = $lang->executionnode->osDisk; -$config->executionnode->search['fields']['macAddress'] = $lang->executionnode->macAddress; -$config->executionnode->search['fields']['address'] = $lang->executionnode->ip; +$config->executionnode->search['fields']['cpu'] = $lang->executionnode->cpu; +$config->executionnode->search['fields']['memory'] = $lang->executionnode->memory; +$config->executionnode->search['fields']['disk'] = $lang->executionnode->disk; +$config->executionnode->search['fields']['mac'] = $lang->executionnode->mac; +$config->executionnode->search['fields']['address'] = $lang->executionnode->ip; $config->executionnode->search['params']['name'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); -$config->executionnode->search['params']['osType'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $config->executionnode->os->type['windows'] + $config->executionnode->os->type['linux']); +$config->executionnode->search['params']['os'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); $config->executionnode->search['params']['hostID'] = array('operator' => '=', 'control' => 'select', 'values' => ''); $config->executionnode->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $lang->executionnode->statusList); -$config->executionnode->search['params']['osCpu'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $config->executionnode->os->cpu); -$config->executionnode->search['params']['osMemory'] = array('operator' => '=', 'control' => 'input', 'values' => ''); -$config->executionnode->search['params']['osDisk'] = array('operator' => '=', 'control' => 'input', 'values' => ''); +$config->executionnode->search['params']['cpu'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $config->executionnode->os->cpu); +$config->executionnode->search['params']['memory'] = array('operator' => '=', 'control' => 'input', 'values' => ''); +$config->executionnode->search['params']['disk'] = array('operator' => '=', 'control' => 'input', 'values' => ''); $config->executionnode->editor = new stdclass(); $config->executionnode->editor->create = array('id' => 'desc', 'tools' => 'simpleTools'); diff --git a/module/executionnode/control.php b/module/executionnode/control.php index 9f117bd1c7..edc7507d68 100755 --- a/module/executionnode/control.php +++ b/module/executionnode/control.php @@ -58,7 +58,7 @@ class executionnode extends control /** * Create node page. * - * @param int $templateID + * @param int $imageID * @access public * @return void */ @@ -179,28 +179,26 @@ class executionnode extends control * @access public * @return void */ - public function ajaxGetTemplates($hostID) + public function ajaxGetImages($hostID) { - $templatePairs = $this->loadModel('zahost')->getTemplatePairs($hostID); - return print(html::select('templateID', $templatePairs, '', "class='form-control chosen'")); + $templatePairs = $this->loadModel('zahost')->getImagePairs($hostID); + + return print(html::select('imageID', $templatePairs, '', "class='form-control chosen'")); } /** * Ajax get template info. * - * @param int $templateID + * @param int $imageID * @access public * @return void */ - public function ajaxGetTemplateInfo($templateID) + public function ajaxGetImage($imageID) { - $template = $this->loadModel('zahost')->getTemplateByID($templateID); + $template = $this->loadModel('zahost')->getImageByID($imageID); if($template) { - $template->osCategoryName = zget($this->config->zahost->os->list, $template->osCategory); - $template->osTypeName = zget($this->config->zahost->os->type[$template->osCategory], $template->osType); - $template->osVersionName = zget($this->lang->zahost->versionList[$template->osType], $template->osVersion); - $template->osLangName = zget($this->lang->zahost->langList, $template->osLang); + $template->os = $template->osCategory; } return print(json_encode($template)); } diff --git a/module/executionnode/css/create.css b/module/executionnode/css/create.css index 662cc09295..f5c8086763 100644 --- a/module/executionnode/css/create.css +++ b/module/executionnode/css/create.css @@ -1,3 +1,3 @@ -#unit {padding: 0px !important; width:0px; border-left: 0px;} +#unit {padding: 0px !important; width:0px; border-left: 0px;width:63px;} .input-group-addon {border: 0px; width: 100px;} -#unit_chosen a {border-left: 0px; border-radius: 0 2px;} +#memory-addon {width:63px;} diff --git a/module/executionnode/js/common.js b/module/executionnode/js/common.js index 912da9a03a..eb1eb29324 100755 --- a/module/executionnode/js/common.js +++ b/module/executionnode/js/common.js @@ -5,29 +5,26 @@ $(function() $('#hostID').change(function() { var hostID = $('#hostID').val(); - var link = createLink('executionnode', 'ajaxGetTemplates', 'hostID=' + hostID); + var link = createLink('executionnode', 'ajaxGetImages', 'hostID=' + hostID); $.get(link, function(data) { $('#template').html('').append(data); - $('#templateID').chosen().trigger("chosen:updated"); - $('#templateID').change(); + $('#imageID').chosen().trigger("chosen:updated"); + $('#imageID').change(); }); }); - $(document).on("change", '#templateID', function() + $(document).on("change", '#imageID', function() { - var templateID = $('#templateID').val(); - var link = createLink('executionnode', 'ajaxGetTemplateInfo', 'templateID=' + templateID); + var imageID = $('#imageID').val(); + var link = createLink('executionnode', 'ajaxGetImage', 'imageID=' + imageID); $.get(link, function(data) { data = JSON.parse(data); console.log(data); - $('#osCategory').val(data.osCategoryName); - $('#osType').val(data.osTypeName); - $('#osVersion').val(data.osVersionName); - $('#osLang').val(data.osLangName); + $('#os').val(data.os); }); }); - if(typeof templateID == 'undefined' || !templateID) $('#osCategory').change(); + if(typeof imageID == 'undefined' || !imageID) $('#os').change(); }) diff --git a/module/executionnode/lang/de.php b/module/executionnode/lang/de.php index 0687a90e7c..58e60d50cf 100755 --- a/module/executionnode/lang/de.php +++ b/module/executionnode/lang/de.php @@ -13,28 +13,25 @@ $lang->executionnode->resume = 'Resume Execution Node'; $lang->executionnode->getVNC = 'Remote management'; $lang->executionnode->all = 'All'; $lang->executionnode->byQuery = 'Search'; -$lang->executionnode->osCategory = 'System'; -$lang->executionnode->osType = 'Os Version'; -$lang->executionnode->osVersion = 'Os Version No'; -$lang->executionnode->vmTemplate = 'VM Template'; +$lang->executionnode->os = 'OS Version'; +$lang->executionnode->image = 'VM Image'; $lang->executionnode->name = 'Name'; $lang->executionnode->start = 'Start After Created'; $lang->executionnode->hostName = 'Host Name'; $lang->executionnode->hostID = $lang->executionnode->hostName; $lang->executionnode->ip = 'IP'; $lang->executionnode->osArch = 'Arch'; -$lang->executionnode->osLang = 'Language'; $lang->executionnode->cpu = 'CPU Cores'; -$lang->executionnode->osMemory = 'Memory Size'; -$lang->executionnode->osDisk = 'Disk Size'; +$lang->executionnode->memory = 'Memory Size'; +$lang->executionnode->disk = 'Disk Size'; $lang->executionnode->status = 'Status'; -$lang->executionnode->macAddress = 'MAC'; +$lang->executionnode->mac = 'MAC'; $lang->executionnode->vnc = 'VNC Port'; $lang->executionnode->destroyAt = 'Destroy Time'; $lang->executionnode->creater = 'Creator'; $lang->executionnode->createdDate = 'Create Date'; $lang->executionnode->template = 'Template'; -$lang->executionnode->templateID = 'VM Template'; +$lang->executionnode->imageID = 'VM Template'; $lang->executionnode->templateList = 'TemplateList'; $lang->executionnode->confirmDelete = "Are you sure about destroying the execution node?"; $lang->executionnode->confirmBoot = "Are you sure to start the execution node?"; diff --git a/module/executionnode/lang/en.php b/module/executionnode/lang/en.php index 0687a90e7c..c47776b32d 100755 --- a/module/executionnode/lang/en.php +++ b/module/executionnode/lang/en.php @@ -13,28 +13,25 @@ $lang->executionnode->resume = 'Resume Execution Node'; $lang->executionnode->getVNC = 'Remote management'; $lang->executionnode->all = 'All'; $lang->executionnode->byQuery = 'Search'; -$lang->executionnode->osCategory = 'System'; -$lang->executionnode->osType = 'Os Version'; -$lang->executionnode->osVersion = 'Os Version No'; -$lang->executionnode->vmTemplate = 'VM Template'; +$lang->executionnode->os = 'Os Version'; +$lang->executionnode->image = 'VM Image'; $lang->executionnode->name = 'Name'; $lang->executionnode->start = 'Start After Created'; $lang->executionnode->hostName = 'Host Name'; $lang->executionnode->hostID = $lang->executionnode->hostName; $lang->executionnode->ip = 'IP'; $lang->executionnode->osArch = 'Arch'; -$lang->executionnode->osLang = 'Language'; $lang->executionnode->cpu = 'CPU Cores'; -$lang->executionnode->osMemory = 'Memory Size'; -$lang->executionnode->osDisk = 'Disk Size'; +$lang->executionnode->memory = 'Memory Size'; +$lang->executionnode->disk = 'Disk Size'; $lang->executionnode->status = 'Status'; -$lang->executionnode->macAddress = 'MAC'; +$lang->executionnode->mac = 'MAC'; $lang->executionnode->vnc = 'VNC Port'; $lang->executionnode->destroyAt = 'Destroy Time'; $lang->executionnode->creater = 'Creator'; $lang->executionnode->createdDate = 'Create Date'; $lang->executionnode->template = 'Template'; -$lang->executionnode->templateID = 'VM Template'; +$lang->executionnode->imageID = 'VM Template'; $lang->executionnode->templateList = 'TemplateList'; $lang->executionnode->confirmDelete = "Are you sure about destroying the execution node?"; $lang->executionnode->confirmBoot = "Are you sure to start the execution node?"; diff --git a/module/executionnode/lang/fr.php b/module/executionnode/lang/fr.php index 2f87c20538..af65d41386 100755 --- a/module/executionnode/lang/fr.php +++ b/module/executionnode/lang/fr.php @@ -13,28 +13,25 @@ $lang->executionnode->resume = 'Resume Execution Node'; $lang->executionnode->getVNC = 'Remote management'; $lang->executionnode->all = 'All'; $lang->executionnode->byQuery = 'Search'; -$lang->executionnode->osCategory = 'System'; -$lang->executionnode->osType = 'Os Version'; -$lang->executionnode->osVersion = 'Os Version No'; -$lang->executionnode->vmTemplate = 'VM Template'; +$lang->executionnode->os = 'Os Version'; +$lang->executionnode->image = 'VM Image'; $lang->executionnode->name = 'Name'; $lang->executionnode->start = 'Start After Created'; $lang->executionnode->hostName = 'Host Name'; $lang->executionnode->hostID = $lang->executionnode->hostName; $lang->executionnode->ip = 'IP'; $lang->executionnode->osArch = 'Arch'; -$lang->executionnode->osLang = 'Language'; $lang->executionnode->cpu = 'CPU Cores'; -$lang->executionnode->osMemory = 'Memory Size'; -$lang->executionnode->osDisk = 'Disk Size'; +$lang->executionnode->memory = 'Memory Size'; +$lang->executionnode->disk = 'Disk Size'; $lang->executionnode->status = 'Status'; -$lang->executionnode->macAddress = 'MAC'; +$lang->executionnode->mac = 'MAC'; $lang->executionnode->vnc = 'VNC Port'; $lang->executionnode->destroyAt = 'Destroy Time'; $lang->executionnode->creater = 'Creator'; $lang->executionnode->createdDate = 'Create Date'; $lang->executionnode->template = 'Template'; -$lang->executionnode->templateID = 'VM Template'; +$lang->executionnode->imageID = 'VM Template'; $lang->executionnode->templateList = 'TemplateList'; $lang->executionnode->createTemplate = 'Create Template'; $lang->executionnode->editTemplate = 'Edit Template'; diff --git a/module/executionnode/lang/zh-cn.php b/module/executionnode/lang/zh-cn.php index c4b8367a35..4ac5794879 100755 --- a/module/executionnode/lang/zh-cn.php +++ b/module/executionnode/lang/zh-cn.php @@ -13,29 +13,26 @@ $lang->executionnode->resume = '恢复执行节点'; $lang->executionnode->getVNC = '远程管理'; $lang->executionnode->all = '全部'; $lang->executionnode->byQuery = '搜索'; -$lang->executionnode->osCategory = '操作系统平台'; -$lang->executionnode->osType = '操作系统版本'; -$lang->executionnode->osVersion = '操作系统版本号'; -$lang->executionnode->vmTemplate = '虚拟机模板'; +$lang->executionnode->os = '操作系统'; +$lang->executionnode->image = '镜像'; $lang->executionnode->name = '执行节点名称'; $lang->executionnode->start = '创建后自动开启'; $lang->executionnode->hostName = '所属宿主机'; $lang->executionnode->hostID = $lang->executionnode->hostName; -$lang->executionnode->ip = 'IP'; +$lang->executionnode->ip = 'IP/域名'; $lang->executionnode->osArch = '架构'; -$lang->executionnode->osLang = '系统语言'; $lang->executionnode->cpu = 'CPU核心数'; -$lang->executionnode->osMemory = '内存'; -$lang->executionnode->osDisk = '硬盘'; +$lang->executionnode->memory = '内存'; +$lang->executionnode->disk = '硬盘'; $lang->executionnode->desc = '描述'; $lang->executionnode->status = '状态'; -$lang->executionnode->macAddress = 'MAC地址'; +$lang->executionnode->mac = 'MAC地址'; $lang->executionnode->vnc = 'VNC端口'; $lang->executionnode->destroyAt = '销毁时间'; $lang->executionnode->creater = '创建人'; $lang->executionnode->createdDate = '创建日期'; $lang->executionnode->template = '模板'; -$lang->executionnode->templateID = '虚拟机模板'; +$lang->executionnode->imageID = '虚拟机模板'; $lang->executionnode->templateList = '模板列表'; $lang->executionnode->confirmDelete = "您确定销毁执行节点吗?"; $lang->executionnode->confirmBoot = "您确定启动执行节点吗?"; diff --git a/module/executionnode/model.php b/module/executionnode/model.php index 67db7be9d5..3ab249cc34 100755 --- a/module/executionnode/model.php +++ b/module/executionnode/model.php @@ -52,32 +52,24 @@ class executionnodemodel extends model return false; } - /* Get Vmtemplate. */ - $vmTemplate = $this->getVmTemplateByID($data->imageID); - $data->osCategory = $vmTemplate->osCategory; - $data->osType = $vmTemplate->osType; - $data->osVersion = $vmTemplate->osVersion; - $data->osLang = $vmTemplate->osLang; + /* Get image. */ + $image = $this->getImageByID($data->imageID); /* Get host info. */ - $host = $this->getHostByID($vmTemplate->hostID); + $host = $this->getHostByID($data->hostID); /* Gen mac address */ - $macAddress = $this->genMacAddress(); + $mac = $this->genmac(); /* Prepare create params. */ $agnetUrl = 'http://' . $host->address . ':' . $this->config->executionnode->defaultPort; $param = array( - 'vmMacAddress' => $macAddress, - 'osCategory' => $vmTemplate->osCategory, - 'osType' => $vmTemplate->osType, - 'osLang' => $data->osLang, - 'osVersion' => $vmTemplate->osVersion, - 'vmTemplate' => $vmTemplate->imageName, - 'vmUniqueName' => $data->name, - 'vmCpu' => (int)$data->osCpu, - 'vmDiskSize' => (int)$data->osDisk, - 'vmMemorySize' => (int)$data->osMemory, + 'os' => $image->osCategory, + 'path' => $image->path, + 'name' => $data->name, + 'cpu' => (int)$data->cpu, + 'disk' => (int)$data->disk, + 'memory' => (int)$data->memory, ); $result = json_decode(commonModel::http($agnetUrl . static::KVM_CREATE_PATH, json_encode($param), null)); @@ -87,23 +79,20 @@ class executionnodemodel extends model dao::$errors[] = $this->lang->executionnode->notFoundAgent; return false; } - if($result->code != 1) + if($result->code != 'success') { dao::$errors[] = $this->lang->executionnode->createVmFail; return false; } /* Prepare create execution node data. */ - $data->imageID = $data->imageID; + $data->imageID = $data->imageID; $data->hostID = $host->id; - $data->macAddress = $macAddress; + $data->mac = $mac; $data->status = static::STATUS_RUNNING; $data->createdBy = $this->app->user->account; $data->createdDate = helper::now(); - $data->osCategory = $vmTemplate->osCategory; - $data->osType = $vmTemplate->osType; - $data->osArch = $vmTemplate->osArch; - $data->vncPort = (int)$result->data->vncPort; + $data->vnc = (int)$result->data->vnc; /* Save execution node. */ $this->dao->insert(TABLE_EXECUTIONNODE)->data($data)->autoCheck()->exec(); @@ -137,7 +126,7 @@ class executionnodemodel extends model $data = json_decode($result, true); if(empty($data)) return $this->lang->executionnode->notFoundAgent; - if($data['code'] != 1) return zget($this->lang->executionnode->apiError, $data['code'], $data['msg']); + if($data['code'] != 'success') return zget($this->lang->executionnode->apiError, $data['code'], $data['msg']); if($type != 'reboot') { @@ -161,24 +150,23 @@ class executionnodemodel extends model $node = $this->getVMByID($id); $host = $this->getHostByID($node->hostID); - $req = array( 'vmUniqueName' => $node->name ); + $req = array( 'name' => $node->name ); /* Prepare create params. */ if($host) { $agnetUrl = 'http://' . $host->address . ':' . $this->config->executionnode->defaultPort; - $result = commonModel::http($agnetUrl . '/api/v1/kvm/' . $node->name . '/destroy', json_encode($req)); + $result = commonModel::http($agnetUrl . '/api/v1/kvm/remove', json_encode($req)); $data = json_decode($result, true); if(empty($data)) return $this->lang->executionnode->notFoundAgent; - if($data['code'] != 1) return zget($this->lang->executionnode->apiError, $data['code'], $data['msg']); + if($data['code'] != 'success') return zget($this->lang->executionnode->apiError, $data['code'], $data['msg']); } /* delete execution node. */ $this->dao->update(TABLE_EXECUTIONNODE) ->set('deleted')->eq(1) - ->set('destroyAt')->eq(helper::now()) ->where('id')->eq($id) ->exec(); $this->loadModel('action')->create('executionnode', $id, 'destroy'); @@ -286,9 +274,9 @@ class executionnodemodel extends model } else { - if($this->session->vmQuery == false) $this->session->set('vmQuery', ' 1 = 1'); + if($this->session->executionnodeQuery == false) $this->session->set('executionnodeQuery', ' 1 = 1'); } - $query = $this->session->vmQuery; + $query = $this->session->executionnodeQuery; $query = str_replace('`id`', 't1.`id`', $query); $query = str_replace('`name`', 't1.`name`', $query); $query = str_replace('`status`', 't1.`status`', $query); @@ -342,27 +330,13 @@ class executionnodemodel extends model } /** - * Get BaseImage by name. + * Get Image. * * @param int $id * @access public * @return object */ - public function getBaseImageByID($id) - { - return $this->dao->select('*')->from(TABLE_BASEIMAGE) - ->where('id')->eq($id) - ->fetch(); - } - - /** - * Get VM template. - * - * @param int $id - * @access public - * @return object - */ - public function getVmTemplateByID($id) + public function getImageByID($id) { return $this->dao->select('*')->from(TABLE_IMAGE) ->where('id')->eq($id) @@ -389,22 +363,6 @@ class executionnodemodel extends model return $list; } - /** - * Get baseImage list by params. - * - * @param string $osCategory - * @param string $osType - * @access public - * @return array - */ - public function getBaseImageList($osCategory = '', $osType = '') - { - return $this->dao->select('*')->from(TABLE_BASEIMAGE) - ->where('osCategory')->eq($osCategory) - ->andwhere('osType')->eq($osType) - ->fetchAll('id'); - } - /** * Get VM template list. * @@ -413,7 +371,7 @@ class executionnodemodel extends model * @access public * @return array */ - public function getVmTemplateList($orderBy = 'id_desc', $pager = null) + public function getimageList($orderBy = 'id_desc', $pager = null) { return $this->dao->select('*')->from(TABLE_IMAGE)->orderBy($orderBy)->page($pager)->fetchAll(); } @@ -427,7 +385,7 @@ class executionnodemodel extends model * @access public * @return array */ - public function getVmTemplatePairs($osCategory = '', $osType = '', $osVersion = '') + public function getimagePairs($osCategory = '', $osType = '', $osVersion = '') { return $this->dao->select('id,name')->from(TABLE_IMAGE) ->where('osCategory')->eq($osCategory) @@ -461,7 +419,7 @@ class executionnodemodel extends model public function getVMByMac($mac) { return $this->dao->select('*')->from(TABLE_EXECUTIONNODE) - ->where('macAddress')->eq($mac) + ->where('mac')->eq($mac) ->fetch(); } @@ -470,7 +428,7 @@ class executionnodemodel extends model * * @return void */ - private function genMacAddress() + private function genmac() { $buf = array( 0x1C, @@ -490,7 +448,7 @@ class executionnodemodel extends model { return $mac; } - $this->genMacAddress(); + $this->genmac(); } /** @@ -503,20 +461,20 @@ class executionnodemodel extends model public function getVncUrl($vmID) { $vm = $this->getVMByID($vmID); - if(empty($vm) or empty($vm->hostID) or empty($vm->vncPort)) return false; + if(empty($vm) or empty($vm->hostID) or empty($vm->vnc)) return false; $host = $this->getHostByID($vm->hostID); if(empty($host)) return false; $agnetUrl = 'http://' . $host->address . ':' . $host->agentPort . static::KVM_TOKEN_PATH; - $result = json_decode(commonModel::http("$agnetUrl?port={$vm->vncPort}")); + $result = json_decode(commonModel::http("$agnetUrl?port={$vm->vnc}")); - if(empty($result) or $result->code != 1) return false; + if(empty($result) or $result->code != 'success') return false; $returnData = new stdClass(); $returnData->hostIP = $host->address; $returnData->agentPort = $host->agentPort; - $returnData->vncPort = $vm->vncPort; + $returnData->vnc = $vm->vnc; $returnData->token = $result->data->token; return $returnData; } diff --git a/module/executionnode/view/browse.html.php b/module/executionnode/view/browse.html.php index 4167a8dcb1..31feb8ffff 100755 --- a/module/executionnode/view/browse.html.php +++ b/module/executionnode/view/browse.html.php @@ -50,12 +50,10 @@ idAB);?> executionnode->name);?> executionnode->ip);?>executionnode->cpu);?>executionnode->osMemory);?>executionnode->osDisk);?>executionnode->osCategory);?>executionnode->osType);?>executionnode->osVersion);?>executionnode->cpu);?>executionnode->memory);?>executionnode->disk);?>executionnode->os);?> executionnode->status);?> executionnode->hostName);?> actions?>id;?> name;?> hostIP;?>executionnode->os->cpu, $node->osCpu);?>osMemory . $this->lang->zahost->unitList['GB'];?>osDisk . zget($this->lang->zahost->unitList, $node->unit);?>executionnode->os->list, $node->osCategory);?>executionnode->os->type[$node->osCategory], $node->osType);?>executionnode->versionList[$node->osType], $node->osVersion);?>executionnode->os->cpu, $node->cpu);?>memory . $this->lang->zahost->unitList['GB'];?>disk . zget($this->lang->zahost->unitList, $node->unit);?>executionnode->os->list, $node->os);?> executionnode->statusList, $node->status);?> hostName;?> diff --git a/module/executionnode/view/create.html.php b/module/executionnode/view/create.html.php index a4306f0d5a..be3466cbb6 100755 --- a/module/executionnode/view/create.html.php +++ b/module/executionnode/view/create.html.php @@ -30,48 +30,36 @@
executionnode->vmTemplate;?>executionnode->image;?>
executionnode->cpu;?>executionnode->os->cpu, '', "class='form-control chosen'")?>executionnode->os->cpu, '', "class='form-control chosen'")?>
executionnode->osMemory;?>executionnode->memory;?>
- - zahost->unitList['GB'];?> + + zahost->unitList['GB'];?>
executionnode->osDisk;?>executionnode->disk;?>
- + - zahost->unitList, 'GB', "class='form-control chosen w-50px'");?> + zahost->unitList['GB'];?>
executionnode->osCategory;?>
executionnode->osType;?>
executionnode->osVersion;?>
executionnode->osLang;?>executionnode->os;?>
executionnode->desc ?>
vm->vnc;?>vncPort;?>vnc;?> vm->status;?> vm->statusList, $vm->status);?>
idAB);?> zahost->name);?> zahost->type);?> zahost->IP);?> zahost->cpuCores);?> zahost->IP);?> zahost->cpu );?> zahost->memory);?> zahost->diskSize);?> zahost->disk);?> zahost->virtualSoftware);?> zahost->status);?> zahost->registerDate);?>hostID);?> inlink('browsetemplate', "id=$host->hostID"), $host->name) : $host->name;?> zahost->zaHostTypeList, $host->hostType);?>publicIP;?>cpuCores;?>address;?>cpu;?> memory . $lang->zahost->unitList['GB'];?>diskSize . zget($lang->zahost->unitList, $host->unit);?>disk . zget($lang->zahost->unitList, $host->unit);?> virtualSoftware;?> host->statusList, $host->status);?> registerDate) ? '' : $host->registerDate;?>zahost->name);?> zahost->cpuCoreNum);?> zahost->memory);?>zahost->diskSize);?>zahost->disk);?> zahost->osCategory);?> zahost->osType);?> zahost->osVersion);?>
zahost->IP;?>
zahost->cpuCores;?>zahost->cpuCoreList, '2', "class='form-control chosen'");?>zahost->cpu;?>zahost->cpuCoreList, '2', "class='form-control chosen'");?>
zahost->memory;?>
zahost->diskSize;?>zahost->disk;?>
- + - zahost->unitList, 'GB', "class='form-control chosen w-50px'");?> + zahost->unitList['GB'];?>
zahost->diskSize;?>zahost->disk;?>
diff --git a/module/zahost/view/createtemplate.html.php b/module/zahost/view/createtemplate.html.php index 5148a42785..813cdd89df 100644 --- a/module/zahost/view/createtemplate.html.php +++ b/module/zahost/view/createtemplate.html.php @@ -26,7 +26,7 @@
zahost->cpuCores;?>zahost->cpu ;?>
zahost->diskSize;?>zahost->disk;?>
diff --git a/module/zahost/view/edit.html.php b/module/zahost/view/edit.html.php index 6e2d4ac43d..e3a855dbe6 100644 --- a/module/zahost/view/edit.html.php +++ b/module/zahost/view/edit.html.php @@ -35,11 +35,11 @@
zahost->IP;?>publicIP, "class='form-control' disabled");?>address, "class='form-control' disabled");?>
zahost->cpuCores;?>zahost->cpuCoreList, $host->cpuCores, "class='form-control chosen'");?>zahost->cpu ;?>zahost->cpuCoreList, $host->cpu, "class='form-control chosen'");?>
zahost->memory;?>
zahost->diskSize;?>zahost->disk;?>
- diskSize, "class='form-control'");?> + disk, "class='form-control'");?> - zahost->unitList, $host->unit, "class='form-control chosen w-50px'");?> + zahost->unitList['GB'];?>
zahost->cpuCores;?>zahost->cpu ;?> cpuCoreNum, "class='form-control'");?>
zahost->diskSize;?>zahost->disk;?>
diskSize/1024), "class='form-control'");?> diff --git a/module/zahost/view/edittemplate.html.php b/module/zahost/view/edittemplate.html.php index e7faa05750..ac53dce825 100644 --- a/module/zahost/view/edittemplate.html.php +++ b/module/zahost/view/edittemplate.html.php @@ -27,7 +27,7 @@
zahost->cpuCores;?>zahost->cpu ;?> cpuCoreNum, "class='form-control'");?>
zahost->diskSize;?>zahost->disk;?>
diskSize/1024), "class='form-control'");?> diff --git a/module/zahost/view/inithost.html.php b/module/zahost/view/inithost.html.php index 463db6f503..faed1209e1 100644 --- a/module/zahost/view/inithost.html.php +++ b/module/zahost/view/inithost.html.php @@ -32,7 +32,8 @@
- + + createLink('zahost', 'browseImage', "hostID={$hostID}"), $lang->zahost->initHost->next, '', "title='{$lang->zahost->initHost->next}' class='btn btn-primary margin-top-18'");?>
diff --git a/test/data/host.yaml b/test/data/host.yaml index 2c1cf31bee..bd0eb33f1c 100644 --- a/test/data/host.yaml +++ b/test/data/host.yaml @@ -14,7 +14,7 @@ fields: range: GB - field: privateIP range: 192.168.1.215 - - field: publicIP + - field: address range: 192.168.1.215 - field: osName range: linux diff --git a/test/data/zt_host.yaml b/test/data/zt_host.yaml index a72bb69713..bf6e12dcb3 100644 --- a/test/data/zt_host.yaml +++ b/test/data/zt_host.yaml @@ -73,7 +73,7 @@ fields: loop: 0 loopfix: "" format: "" - - field: cpuCores + - field: cpu note: "" prefix: "" postfix: "" @@ -101,7 +101,7 @@ fields: loop: 0 loopfix: "" format: "" - - field: diskSize + - field: disk note: "" prefix: "" postfix: "" @@ -115,7 +115,7 @@ fields: loop: 0 loopfix: "" format: "" - - field: publicIP + - field: address note: "" prefix: "" postfix: "" From bc1421d7b5a8bca9f3edf8608df46a5e6b0ed67e Mon Sep 17 00:00:00 2001 From: zhaoke Date: Mon, 14 Nov 2022 08:55:33 +0000 Subject: [PATCH 12/36] * Fix bug --- module/executionnode/js/common.js | 8 +++++++- module/zahost/js/common.js | 2 +- module/zahost/js/inithost.js | 6 +++++- module/zahost/lang/de.php | 3 ++- module/zahost/lang/en.php | 3 ++- module/zahost/lang/fr.php | 3 ++- module/zahost/lang/vi.php | 3 ++- module/zahost/lang/zh-cn.php | 3 ++- module/zahost/view/inithost.html.php | 3 +-- 9 files changed, 24 insertions(+), 10 deletions(-) diff --git a/module/executionnode/js/common.js b/module/executionnode/js/common.js index eb1eb29324..8b2ac8d3c8 100755 --- a/module/executionnode/js/common.js +++ b/module/executionnode/js/common.js @@ -17,12 +17,18 @@ $(function() $(document).on("change", '#imageID', function() { var imageID = $('#imageID').val(); - var link = createLink('executionnode', 'ajaxGetImage', 'imageID=' + imageID); + var link = createLink('executionnode', 'ajaxGetImage', 'imageID=' + imageID); $.get(link, function(data) { data = JSON.parse(data); console.log(data); $('#os').val(data.os); + if(data.memory != 0){ + $('#memory').val(data.memory); + } + if(data.memory != 0){ + $('#disk').val(data.disk); + } }); }); diff --git a/module/zahost/js/common.js b/module/zahost/js/common.js index 3cecfab163..c0d1bbac83 100755 --- a/module/zahost/js/common.js +++ b/module/zahost/js/common.js @@ -8,7 +8,7 @@ $(function() { var resultData = JSON.parse(response); var options = ''; - if(resultData.result == 'success') + if(resultData.result == 'success' && typeof resultData.data == 'object') { resultData.data.forEach(function(item) { diff --git a/module/zahost/js/inithost.js b/module/zahost/js/inithost.js index b84f68bb0d..5b4ca1d12d 100644 --- a/module/zahost/js/inithost.js +++ b/module/zahost/js/inithost.js @@ -16,8 +16,12 @@ $('#checkServiceStatus').click(function(){ if(isSuccess){ html += '

' + zahostLang.initHost.initSuccessNotice + '

' + $('#jumpToImageList').removeAttr('disabled'); + $('#jumpToImageList').attr('href', createLink('zahost', 'browseImage', 'hostID=' + hostID)); }else{ - html += '

' + zahostLang.initHost.initFailNotice + '
https://github.com/easysoft/zenagent/

' + html += '

' + zahostLang.initHost.initFailNoticeTitle + '

'; + html += '
' + zahostLang.initHost.initFailNoticeDesc + 'https://github.com/easysoft/zenagent/
' + $('#jumpToImageList').attr('disabled', 'disabled') } $('#statusContainer').html(html) }); diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index 0169323d48..1997efa9f6 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -46,7 +46,8 @@ $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->initFailNotice = "Initialization failed, check the init script execution log and try the following two solutions:
1. Re-execute the script
2. Review the initialization FAQ"; +$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
2. Review the initialization FAQ"; $lang->zahost->initHost->serviceStatus = [ "kvm" => 'not_install', "novnc" => 'not_install', diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index b5cdf59e26..87599dc15f 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -46,7 +46,8 @@ $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->initFailNotice = "Initialization failed, check the init script execution log and try the following two solutions:
1. Re-execute the script
2. Review the initialization FAQ"; +$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
2. Review the initialization FAQ"; $lang->zahost->initHost->serviceStatus = [ "kvm" => 'not_install', "novnc" => 'not_install', diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index f721628840..f06e087fe3 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -46,7 +46,8 @@ $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->initFailNotice = "Initialization failed, check the init script execution log and try the following two solutions:
1. Re-execute the script
2. Review the initialization FAQ"; +$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
2. Review the initialization FAQ"; $lang->zahost->initHost->serviceStatus = [ "kvm" => 'not_install', "novnc" => 'not_install', diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php index 0f642697fb..6813ef67cf 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -46,7 +46,8 @@ $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->initFailNotice = "Initialization failed, check the init script execution log and try the following two solutions:
1. Re-execute the script
2. Review the initialization FAQ"; +$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
2. Review the initialization FAQ"; $lang->zahost->initHost->serviceStatus = [ "kvm" => 'not_install', "novnc" => 'not_install', diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index f8532c3336..8c2b2ae9d4 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -48,7 +48,8 @@ $lang->zahost->initHost->ready = "已就绪"; $lang->zahost->initHost->next = "下一步"; $lang->zahost->initHost->initSuccessNotice = "初始化成功,请点击下一步完成后续操作。"; -$lang->zahost->initHost->initFailNotice = "初始化失败,请查看初始化脚本执行日志并尝试以下两种解决方案:
1. 重新执行脚本
2. 查看初始化常见问题"; +$lang->zahost->initHost->initFailNoticeTitle = "初始化失败,请查看初始化脚本执行日志并尝试以下两种解决方案:"; +$lang->zahost->initHost->initFailNoticeDesc = "1. 重新执行脚本
2. 查看初始化常见问题"; $lang->zahost->initHost->serviceStatus = [ "kvm" => 'not_install', "novnc" => 'not_install', diff --git a/module/zahost/view/inithost.html.php b/module/zahost/view/inithost.html.php index faed1209e1..932323b5c0 100644 --- a/module/zahost/view/inithost.html.php +++ b/module/zahost/view/inithost.html.php @@ -32,8 +32,7 @@
- - createLink('zahost', 'browseImage', "hostID={$hostID}"), $lang->zahost->initHost->next, '', "title='{$lang->zahost->initHost->next}' class='btn btn-primary margin-top-18'");?> + createLink('zahost', 'browseImage', "hostID={$hostID}"), $lang->zahost->initHost->next, '', "title='{$lang->zahost->initHost->next}' class='btn btn-primary margin-top-18' disabled='disabled' id='jumpToImageList'");?>
From d4e8c3cfd36b5bb3ba7bf035054a43b0e882c9c8 Mon Sep 17 00:00:00 2001 From: wangjianhua Date: Mon, 14 Nov 2022 17:42:42 +0800 Subject: [PATCH 13/36] * Modify image list page. --- module/zahost/config.php | 2 + module/zahost/control.php | 11 +++-- module/zahost/js/browseimage.js | 1 - module/zahost/model.php | 56 +++++++++++++++++++++---- module/zahost/view/browseimage.html.php | 14 +------ 5 files changed, 59 insertions(+), 25 deletions(-) diff --git a/module/zahost/config.php b/module/zahost/config.php index 89527d1e7c..954ffe592a 100644 --- a/module/zahost/config.php +++ b/module/zahost/config.php @@ -6,6 +6,8 @@ $config->zahost->create->ipFields = 'publicIP'; $config->zahost->edit = new stdclass(); $config->zahost->edit->requiredFields = 'name,hostType,cpuCores,memory,diskSize,virtualSoftware,instanceNum'; +$config->zahost->imageListUrl = 'https://pkg.qucheng.com/zenagent/list.json'; + $config->zahost->createtemplate = new stdclass(); $config->zahost->createtemplate->requiredFields = 'name,cpuCoreNum,memorySize,diskSize,osCategory,osType,osVersion,osLang,imageName'; diff --git a/module/zahost/control.php b/module/zahost/control.php index 7f04b881b0..ba395c433b 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -200,13 +200,18 @@ class zahost extends control /** * Sent download image request to Host. * - * @param int $imageID + * @param int $hostID + * @param string $imageName * @access public * @return object */ - public function ajaxDownloadImage($imageID) + public function ajaxDownloadImage($hostID, $imageName) { - $image = $this->zahost->getImageByID($imageID); + $image = $this->zahost->getImageByName($imageName); + if(empty($image)) + { + $image = $this->zahost->createImage($hostID, $imageName); + } $this->zahost->downloadImage($image); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => $this->lang->zahost->image->downloadImageFail)); diff --git a/module/zahost/js/browseimage.js b/module/zahost/js/browseimage.js index a481773274..23df5e5f0a 100644 --- a/module/zahost/js/browseimage.js +++ b/module/zahost/js/browseimage.js @@ -12,7 +12,6 @@ $(function() { $('.image-status-' + imageID).text(statusList[imageID].statusName); } - }); }, 5000); }); diff --git a/module/zahost/model.php b/module/zahost/model.php index 47a3438bf7..0226dfef35 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -183,6 +183,18 @@ class zahostModel extends model return $this->dao->select('*')->from(TABLE_IMAGE)->where('deleted')->eq(0)->andWhere('id')->eq($imageID)->fetch(); } + /** + * Get image by name. + * + * @param string $imageName + * @access public + * @return object + */ + public function getImageByName($imageName) + { + return $this->dao->select('*')->from(TABLE_IMAGE)->where('deleted')->eq(0)->andWhere('name')->eq($imageName)->fetch(); + } + /** * Get image files from ZAgent server. * @@ -192,11 +204,30 @@ class zahostModel extends model */ public function getImageList($hostID, $browseType = 'all', $param = 0, $orderBy = 'id', $pager = null) { - $imageList = $this->dao->select('*')->from(TABLE_IMAGE) + $imageList = json_decode(file_get_contents($this->config->zahost->imageListUrl)); + + $downloadedImageList = $this->dao->select('*')->from(TABLE_IMAGE) ->where('hostID')->eq($hostID) ->orderBy($orderBy) ->page($pager) - ->fetchAll(); + ->fetchAll('name'); + + foreach($imageList as &$image) + { + $downloadedImage = zget($downloadedImageList, $image->name, ''); + if(empty($downloadedImage)) + { + $image->id = 0; + $image->status = ''; + } + else + { + $image->id = $downloadedImage->id; + $image->status = $downloadedImage->status; + } + + $image->hostID = $hostID; + } return $imageList; } @@ -204,21 +235,28 @@ class zahostModel extends model /** * create image. * + * @param int $hostID + * @param string $imageName * @access public - * @return void + * @return object */ - public function createImage() + public function createImage($hostID, $imageName) { - $vmImage = fixer::input('post') - ->get(); + $imageList = json_decode(file_get_contents($this->config->zahost->imageListUrl)); - $this->dao->insert(TABLE_IMAGE)->data($vmImage) - ->batchCheck($this->config->zahost->createimage->requiredFields, 'notempty') - ->autoCheck()->exec(); + $imageData = new stdclass; + foreach($imageList as $item) if($item->name == $imageName) $imageData = $item; + + $imageData->hostID = $hostID; + $imageData->status = 'created'; + + $this->dao->insert(TABLE_IMAGE)->data($imageData)->autoCheck()->exec(); if(dao::isError()) return false; $imageID = $this->dao->lastInsertID(); $this->loadModel('action')->create('image', $imageID, 'Created'); + + return $this->getImageByID($imageID); } /** diff --git a/module/zahost/view/browseimage.html.php b/module/zahost/view/browseimage.html.php index a2c0bfd4f3..1b29b23b88 100755 --- a/module/zahost/view/browseimage.html.php +++ b/module/zahost/view/browseimage.html.php @@ -41,14 +41,9 @@ - - - - - @@ -56,17 +51,12 @@ - - - - - - + recTotal}&recPerPage={$pager->recPerPage}";?> - + - - - + + + - - + + @@ -64,8 +64,8 @@ - - + + + @@ -84,7 +84,8 @@ common::printLink('zanode', 'suspend', "zanodeID={$node->id}", " ", '', $suspendAttr); common::printLink('zanode', 'resume', "zanodeID={$node->id}", " ", '', $resumeAttr); common::printLink('zanode', 'reboot', "zanodeID={$node->id}", " ", '', $rebootAttr); - common::printLink('zanode', 'destroy', "zanodeID={$node->id}", " ", '', "title='{$lang->zanode->destroy}' class='btn btn-primary' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmDelete}\")==false) return false;'"); + common::printIcon('zanode', 'edit', "id={$node->id}", $node, 'list'); + common::printLink('zanode', 'delete', "zanodeID={$node->id}", " ", '', "title='{$lang->zanode->destroy}' class='btn btn-primary' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmDelete}\")==false) return false;'"); ?> diff --git a/module/zanode/view/edit.html.php b/module/zanode/view/edit.html.php new file mode 100644 index 0000000000..d3f27e65c7 --- /dev/null +++ b/module/zanode/view/edit.html.php @@ -0,0 +1,81 @@ + + * @package host + * @version $Id$ + * @link http://www.zentao.net + */ +?> + +getModuleRoot() . 'common/view/kindeditor.html.php';?> +
+
+
+
+

zanode->editAction;?>

+
+ +
idAB);?> zahost->image->name);?> zahost->image->memory);?> zahost->image->disk);?>zahost->image->osCategory);?>zahost->image->osType);?>zahost->image->osVersion);?>zahost->image->osLang);?> zahost->status;?> actions;?>
id;?> name;?> memory . zget($this->lang->zahost->unitList, 'GB');?> disk . zget($this->lang->zahost->unitList, 'GB');?>zahost->os->list, $image->osCategory);?>zahost->os->type[$image->osCategory], $image->osType);?>zahost->versionList[$image->osType], $image->osVersion);?>zahost->langList, $image->osLang);?>zahost->image->statusList, $image->status, '');?>'>zahost->image->statusList, $image->status, '');?> - id}", $image, 'list', 'download');?> + name}&imageID={$image->id}", $image, 'list', 'download');?> createLink('zahost', 'downloadImage', "id={$image->id}"), '', 'hiddenwin', "title='{$lang->zahost->image->downloadImage}' class='btn'");?> id}", $image, 'list', 'edit');?> createLink('zahost', 'deleteImage', "id={$image->id}"), '', 'hiddenwin', "title='{$lang->zahost->delete}' class='btn'");?> From 737d2a3d2063e6b6b2770a1863681e7b52b23aaa Mon Sep 17 00:00:00 2001 From: wangjianhua Date: Mon, 14 Nov 2022 17:45:29 +0800 Subject: [PATCH 14/36] - Remove create image button. --- module/zahost/view/browseimage.html.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/module/zahost/view/browseimage.html.php b/module/zahost/view/browseimage.html.php index 1b29b23b88..77786bd3f9 100755 --- a/module/zahost/view/browseimage.html.php +++ b/module/zahost/view/browseimage.html.php @@ -15,17 +15,7 @@
' data-module='vmTemplate'>
@@ -34,7 +24,6 @@

zahost->image->imageEmpty;?> - ' . $lang->zahost->image->createImage, '', 'class="btn btn-info"');?>

From 5f575c16f5dfd6b2723875636972426892320270 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Tue, 15 Nov 2022 00:39:23 +0000 Subject: [PATCH 15/36] * Add real url --- module/zahost/lang/de.php | 2 +- module/zahost/lang/en.php | 2 +- module/zahost/lang/fr.php | 2 +- module/zahost/lang/vi.php | 2 +- module/zahost/lang/zh-cn.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index 1997efa9f6..92ba54c168 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -56,7 +56,7 @@ $lang->zahost->initHost->serviceStatus = [ $lang->zahost->initHost->title = "Initialize Host"; $lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; $lang->zahost->initHost->descLi = [ - "Download the init script to the host:wget https://pkg-1308438674.cos.ap-shanghai.myqcloud.com/zenagent/zagentenv", + "Download the init script to the host:wget https://pkg.qucheng.com/zenagent/zagentenv", "Execute the init script on the host and execute the command example under Ubuntu:./zagentenv" ]; $lang->zahost->initHost->statusTitle = "Service Status"; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index 87599dc15f..17cf6e8576 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -56,7 +56,7 @@ $lang->zahost->initHost->serviceStatus = [ $lang->zahost->initHost->title = "Initialize Host"; $lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; $lang->zahost->initHost->descLi = [ - "Download the init script to the host:wget https://pkg-1308438674.cos.ap-shanghai.myqcloud.com/zenagent/zagentenv", + "Download the init script to the host:wget https://pkg.qucheng.com/zenagent/zagentenv", "Execute the init script on the host and execute the command example under Ubuntu:./zagentenv" ]; $lang->zahost->initHost->statusTitle = "Service Status"; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index f06e087fe3..9150f8dca2 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -56,7 +56,7 @@ $lang->zahost->initHost->serviceStatus = [ $lang->zahost->initHost->title = "Initialize Host"; $lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; $lang->zahost->initHost->descLi = [ - "Download the init script to the host:wget https://pkg-1308438674.cos.ap-shanghai.myqcloud.com/zenagent/zagentenv", + "Download the init script to the host:wget https://pkg.qucheng.com/zenagent/zagentenv", "Execute the init script on the host and execute the command example under Ubuntu:./zagentenv" ]; $lang->zahost->initHost->statusTitle = "Service Status"; diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php index 6813ef67cf..916cc6a903 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -56,7 +56,7 @@ $lang->zahost->initHost->serviceStatus = [ $lang->zahost->initHost->title = "Initialize Host"; $lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; $lang->zahost->initHost->descLi = [ - "Download the init script to the host:wget https://pkg-1308438674.cos.ap-shanghai.myqcloud.com/zenagent/zagentenv", + "Download the init script to the host:wget https://pkg.qucheng.com/zenagent/zagentenv", "Execute the init script on the host and execute the command example under Ubuntu:./zagentenv" ]; $lang->zahost->initHost->statusTitle = "Service Status"; diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index 8c2b2ae9d4..66f757eb81 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -58,7 +58,7 @@ $lang->zahost->initHost->serviceStatus = [ $lang->zahost->initHost->title = "初始化宿主机"; $lang->zahost->initHost->descTitle = "请按照以下步骤在宿主机上完成初始化:"; $lang->zahost->initHost->descLi = [ - "下载初始化脚本至宿主机:wget https://pkg-1308438674.cos.ap-shanghai.myqcloud.com/zenagent/zagentenv", + "下载初始化脚本至宿主机:wget https://pkg.qucheng.com/zenagent/zagentenv", "在宿主机上执行初始化脚本,Ubuntu下执行命令示例:./zagentenv" ]; From 063075302940a0fa90daac060f687f83b37c005a Mon Sep 17 00:00:00 2001 From: zhaoke Date: Tue, 15 Nov 2022 01:39:44 +0000 Subject: [PATCH 16/36] * Add default port --- db/update18.0.sql | 1 + db/zentao.sql | 1 + module/zahost/config.php | 2 ++ module/zahost/model.php | 6 +++--- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/db/update18.0.sql b/db/update18.0.sql index b772eebc71..6b47fc1794 100644 --- a/db/update18.0.sql +++ b/db/update18.0.sql @@ -45,6 +45,7 @@ CREATE TABLE `zt_image` ( `disk` float unsigned NOT NULL, `fileSize` float unsigned NOT NULL, `md5` varchar(64) NOT NULL, + `desc` text NOT NULL, `registerDate` datetime NOT NULL, `createdBy` varchar(30) NOT NULL, `createdDate` datetime NOT NULL, diff --git a/db/zentao.sql b/db/zentao.sql index 546fff215a..ccaa6e2d55 100755 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -7356,6 +7356,7 @@ CREATE TABLE `zt_image` ( `disk` float unsigned NOT NULL, `fileSize` float unsigned NOT NULL, `md5` varchar(64) NOT NULL, + `desc` text NOT NULL, `registerDate` datetime NOT NULL, `createdBy` varchar(30) NOT NULL, `createdDate` datetime NOT NULL, diff --git a/module/zahost/config.php b/module/zahost/config.php index 749c713fb1..1df953214f 100644 --- a/module/zahost/config.php +++ b/module/zahost/config.php @@ -3,6 +3,8 @@ $config->zahost->create = new stdclass(); $config->zahost->create->requiredFields = 'name,hostType,address,cpu,memory,disk,virtualSoftware'; $config->zahost->create->ipFields = 'address'; +$config->zahost->defaultPort = '8086'; + $config->zahost->edit = new stdclass(); $config->zahost->edit->requiredFields = 'name,hostType,cpu,memory,disk,virtualSoftware'; diff --git a/module/zahost/model.php b/module/zahost/model.php index 4c3d297d13..fe4c634af2 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -263,7 +263,7 @@ class zahostModel extends model public function downloadImage($image) { $host = $this->getById($image->hostID); - $apiUrl = 'http://' . $host->publicIP. '/api/v1/download/add'; + $apiUrl = 'http://' . $host->address. ':' . $this->config->zahost->defaultPort . '/api/v1/download/add'; $apiParams['md5'] = $image->md5; $apiParams['url'] = $image->address; @@ -293,7 +293,7 @@ class zahostModel extends model public function queryDownloadImageStatus($image) { $host = $this->getById($image->hostID); - $apiUrl = 'http://' . $host->publicIP. '/api/v1/task/getStatus'; + $apiUrl = 'http://' . $host->address . ':' . $this->config->zahost->defaultPort . '/api/v1/task/getStatus'; $result = json_decode(commonModel::http($apiUrl, array(), array(CURLOPT_CUSTOMREQUEST => 'POST'), array(), 'json')); if(!$result or $result->code != 'success') return $image->status; @@ -483,7 +483,7 @@ class zahostModel extends model */ public function getImagePairs($hostID) { - return $this->dao->select('id,name')->from(TABLE_IMAGE)->where('hostID')->eq($hostID)->fetchPairs(); + return $this->dao->select('id,name')->from(TABLE_IMAGE)->where('hostID')->eq($hostID)->andWhere('status')->eq('completed')->fetchPairs(); } /** From 032641a0858748b6a11f2e9a523202b53d245734 Mon Sep 17 00:00:00 2001 From: wangjianhua Date: Tue, 15 Nov 2022 10:23:56 +0800 Subject: [PATCH 17/36] * Add progress of downloading image. --- module/zahost/control.php | 6 ++--- module/zahost/js/browseimage.js | 5 ++++- module/zahost/lang/zh-cn.php | 3 ++- module/zahost/model.php | 30 +++++++++++++++++-------- module/zahost/view/browseimage.html.php | 4 +++- 5 files changed, 33 insertions(+), 15 deletions(-) diff --git a/module/zahost/control.php b/module/zahost/control.php index 2793efc5df..42b0490272 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -233,10 +233,10 @@ class zahost extends control $imageList = $this->zahost->getImageList($hostID); foreach($imageList as $image) { - $statusCode = $this->zahost->queryDownloadImageStatus($image); - $statusName = zget($this->lang->zahost->image->statusList, $statusCode,''); + $image = $this->zahost->queryDownloadImageStatus($image); + $statusName = zget($this->lang->zahost->image->statusList, $image->status,''); - $statusList[$image->id] = array('statusCode' => $statusCode, 'statusName' => $statusName); + $statusList[$image->id] = array('statusCode' => $image->status, 'status' => $statusName . '(' . $image->rate * 100 . '%)', 'rate' => $image->rate); } return $this->send(array('result' => 'success', 'message' => '', 'data' => $statusList)); diff --git a/module/zahost/js/browseimage.js b/module/zahost/js/browseimage.js index 23df5e5f0a..4d74829772 100644 --- a/module/zahost/js/browseimage.js +++ b/module/zahost/js/browseimage.js @@ -10,7 +10,10 @@ $(function() console.log(statusList); for(var imageID in statusList) { - $('.image-status-' + imageID).text(statusList[imageID].statusName); + if(statusList[imageID].statusCode) + { + $('.image-status-' + imageID).text(statusList[imageID].status); + } } }); }, 5000); diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index b7bbbfeabd..ec842c4153 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -70,8 +70,9 @@ $lang->zahost->image->choseImage = '选择镜像'; $lang->zahost->image->downloadImage = '下载镜像'; $lang->zahost->image->startDowload = '开始下载'; -$lang->zahost->image->name = '名称'; $lang->zahost->image->common = '镜像'; +$lang->zahost->image->name = '名称'; +$lang->zahost->image->desc = '说明'; $lang->zahost->image->memory = $lang->zahost->memory; $lang->zahost->image->disk = $lang->zahost->disk; $lang->zahost->image->osType = $lang->zahost->osType; diff --git a/module/zahost/model.php b/module/zahost/model.php index fe4c634af2..620a510b30 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -244,7 +244,7 @@ class zahostModel extends model $imageData->hostID = $hostID; $imageData->status = 'created'; - $this->dao->insert(TABLE_IMAGE)->data($imageData)->autoCheck()->exec(); + $this->dao->insert(TABLE_IMAGE)->data($imageData, 'desc')->autoCheck()->exec(); if(dao::isError()) return false; $imageID = $this->dao->lastInsertID(); @@ -263,7 +263,7 @@ class zahostModel extends model public function downloadImage($image) { $host = $this->getById($image->hostID); - $apiUrl = 'http://' . $host->address. ':' . $this->config->zahost->defaultPort . '/api/v1/download/add'; + $apiUrl = 'http://' . $host->address . ':' . $this->config->zahost->defaultPort . '/api/v1/download/add'; $apiParams['md5'] = $image->md5; $apiParams['url'] = $image->address; @@ -300,19 +300,31 @@ class zahostModel extends model foreach($result->data as $status => $group) { - $task = array_filter($group, function($task) use($image) + $currentTask = null; + foreach($group as $task) { - return $task->task == $image->id; - }); + if($task->task == $image->id ) + { + $currentTask = $task; + break; + } + } - if($task) + if($currentTask) { - $this->dao->update(TABLE_IMAGE)->set('status')->eq($status)->where('id')->eq($image->id)->exec(); - return $status; + $image->rate = $currentTask->rate; + $image->status = $status; + + $this->dao->update(TABLE_IMAGE) + ->set('status')->eq($status) + ->set('path')->eq($currentTask->path) + ->where('id')->eq($image->id)->exec(); + + break; } } - return $image->status; + return $image; } /** diff --git a/module/zahost/view/browseimage.html.php b/module/zahost/view/browseimage.html.php index 77786bd3f9..014136ecab 100755 --- a/module/zahost/view/browseimage.html.php +++ b/module/zahost/view/browseimage.html.php @@ -27,10 +27,11 @@

- +
+ @@ -41,6 +42,7 @@ + From 4141110e743e7a597154eac9dcc9abbd629ba38e Mon Sep 17 00:00:00 2001 From: wangjianhua Date: Tue, 15 Nov 2022 10:50:12 +0800 Subject: [PATCH 18/36] * Modify function name. --- module/zahost/control.php | 2 +- module/zahost/model.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/module/zahost/control.php b/module/zahost/control.php index 42b0490272..8c44946990 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -207,7 +207,7 @@ class zahost extends control */ public function ajaxDownloadImage($hostID, $imageName) { - $image = $this->zahost->getImageByName($imageName); + $image = $this->zahost->getImageByNameAndHostID($imageName, $hostID); if(empty($image)) { $image = $this->zahost->createImage($hostID, $imageName); diff --git a/module/zahost/model.php b/module/zahost/model.php index 620a510b30..4897059bd2 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -181,12 +181,16 @@ class zahostModel extends model * Get image by name. * * @param string $imageName + * @param int $hostID * @access public * @return object */ - public function getImageByName($imageName) + public function getImageByNameAndHostID($imageName, $hostID) { - return $this->dao->select('*')->from(TABLE_IMAGE)->where('deleted')->eq(0)->andWhere('name')->eq($imageName)->fetch(); + return $this->dao->select('*')->from(TABLE_IMAGE) + ->where('deleted')->eq(0) + ->andWhere('hostID')->eq($hostID) + ->andWhere('name')->eq($imageName)->fetch(); } /** From bbaa550c05a54ea86723f4364a42f8d6724de665 Mon Sep 17 00:00:00 2001 From: wangjianhua Date: Tue, 15 Nov 2022 11:03:21 +0800 Subject: [PATCH 19/36] + Add language items for VM Image. --- module/zahost/lang/de.php | 25 +++++++++++++++++++++++++ module/zahost/lang/en.php | 25 +++++++++++++++++++++++++ module/zahost/lang/fr.php | 25 +++++++++++++++++++++++++ module/zahost/lang/vi.php | 25 +++++++++++++++++++++++++ 4 files changed, 100 insertions(+) diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index 92ba54c168..a98de16488 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -61,6 +61,31 @@ $lang->zahost->initHost->descLi = [ ]; $lang->zahost->initHost->statusTitle = "Service Status"; +$lang->zahost->image = new stdclass; +$lang->zahost->image->list = 'Image List'; +$lang->zahost->image->browseImage = 'Image List'; +$lang->zahost->image->createImage = 'Create Image'; +$lang->zahost->image->choseImage = 'Select Image'; +$lang->zahost->image->downloadImage = 'Download Image'; +$lang->zahost->image->startDowload = 'Start Download'; + +$lang->zahost->image->common = 'Image'; +$lang->zahost->image->name = 'Name'; +$lang->zahost->image->desc = 'Description'; +$lang->zahost->image->memory = $lang->zahost->memory; +$lang->zahost->image->disk = $lang->zahost->disk; +$lang->zahost->image->osType = $lang->zahost->osType; +$lang->zahost->image->osCategory = $lang->zahost->osCategory; +$lang->zahost->image->osVersion = $lang->zahost->osVersion; +$lang->zahost->image->osLang = $lang->zahost->osLang; +$lang->zahost->image->imageName = $lang->zahost->imageName; + +$lang->zahost->image->statusList['created'] = 'Created'; +$lang->zahost->image->statusList['canceled'] = 'Canceled'; +$lang->zahost->image->statusList['inprogress'] = 'Inprogress'; +$lang->zahost->image->statusList['completed'] = 'Completed'; +$lang->zahost->image->statusList['failed'] = 'Failed'; + $lang->zahost->vmTemplate = new stdclass; $lang->zahost->vmTemplate->name = 'Name'; $lang->zahost->vmTemplate->common = 'VM Template'; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index 17cf6e8576..49bbcf3655 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -61,6 +61,31 @@ $lang->zahost->initHost->descLi = [ ]; $lang->zahost->initHost->statusTitle = "Service Status"; +$lang->zahost->image = new stdclass; +$lang->zahost->image->list = 'Image List'; +$lang->zahost->image->browseImage = 'Image List'; +$lang->zahost->image->createImage = 'Create Image'; +$lang->zahost->image->choseImage = 'Select Image'; +$lang->zahost->image->downloadImage = 'Download Image'; +$lang->zahost->image->startDowload = 'Start Download'; + +$lang->zahost->image->common = 'Image'; +$lang->zahost->image->name = 'Name'; +$lang->zahost->image->desc = 'Description'; +$lang->zahost->image->memory = $lang->zahost->memory; +$lang->zahost->image->disk = $lang->zahost->disk; +$lang->zahost->image->osType = $lang->zahost->osType; +$lang->zahost->image->osCategory = $lang->zahost->osCategory; +$lang->zahost->image->osVersion = $lang->zahost->osVersion; +$lang->zahost->image->osLang = $lang->zahost->osLang; +$lang->zahost->image->imageName = $lang->zahost->imageName; + +$lang->zahost->image->statusList['created'] = 'Created'; +$lang->zahost->image->statusList['canceled'] = 'Canceled'; +$lang->zahost->image->statusList['inprogress'] = 'Inprogress'; +$lang->zahost->image->statusList['completed'] = 'Completed'; +$lang->zahost->image->statusList['failed'] = 'Failed'; + $lang->zahost->vmTemplate = new stdclass; $lang->zahost->vmTemplate->name = 'Name'; $lang->zahost->vmTemplate->common = 'VM Template'; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index 9150f8dca2..9fed42b274 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -61,6 +61,31 @@ $lang->zahost->initHost->descLi = [ ]; $lang->zahost->initHost->statusTitle = "Service Status"; +$lang->zahost->image = new stdclass; +$lang->zahost->image->list = 'Image List'; +$lang->zahost->image->browseImage = 'Image List'; +$lang->zahost->image->createImage = 'Create Image'; +$lang->zahost->image->choseImage = 'Select Image'; +$lang->zahost->image->downloadImage = 'Download Image'; +$lang->zahost->image->startDowload = 'Start Download'; + +$lang->zahost->image->common = 'Image'; +$lang->zahost->image->name = 'Name'; +$lang->zahost->image->desc = 'Description'; +$lang->zahost->image->memory = $lang->zahost->memory; +$lang->zahost->image->disk = $lang->zahost->disk; +$lang->zahost->image->osType = $lang->zahost->osType; +$lang->zahost->image->osCategory = $lang->zahost->osCategory; +$lang->zahost->image->osVersion = $lang->zahost->osVersion; +$lang->zahost->image->osLang = $lang->zahost->osLang; +$lang->zahost->image->imageName = $lang->zahost->imageName; + +$lang->zahost->image->statusList['created'] = 'Created'; +$lang->zahost->image->statusList['canceled'] = 'Canceled'; +$lang->zahost->image->statusList['inprogress'] = 'Inprogress'; +$lang->zahost->image->statusList['completed'] = 'Completed'; +$lang->zahost->image->statusList['failed'] = 'Failed'; + $lang->zahost->vmTemplate = new stdclass; $lang->zahost->vmTemplate->name = 'Nom'; $lang->zahost->vmTemplate->common = 'VM Template'; diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php index 916cc6a903..a6977cd1d8 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -61,6 +61,31 @@ $lang->zahost->initHost->descLi = [ ]; $lang->zahost->initHost->statusTitle = "Service Status"; +$lang->zahost->image = new stdclass; +$lang->zahost->image->list = 'Image List'; +$lang->zahost->image->browseImage = 'Image List'; +$lang->zahost->image->createImage = 'Create Image'; +$lang->zahost->image->choseImage = 'Select Image'; +$lang->zahost->image->downloadImage = 'Download Image'; +$lang->zahost->image->startDowload = 'Start Download'; + +$lang->zahost->image->common = 'Image'; +$lang->zahost->image->name = 'Name'; +$lang->zahost->image->desc = 'Description'; +$lang->zahost->image->memory = $lang->zahost->memory; +$lang->zahost->image->disk = $lang->zahost->disk; +$lang->zahost->image->osType = $lang->zahost->osType; +$lang->zahost->image->osCategory = $lang->zahost->osCategory; +$lang->zahost->image->osVersion = $lang->zahost->osVersion; +$lang->zahost->image->osLang = $lang->zahost->osLang; +$lang->zahost->image->imageName = $lang->zahost->imageName; + +$lang->zahost->image->statusList['created'] = 'Created'; +$lang->zahost->image->statusList['canceled'] = 'Canceled'; +$lang->zahost->image->statusList['inprogress'] = 'Inprogress'; +$lang->zahost->image->statusList['completed'] = 'Completed'; +$lang->zahost->image->statusList['failed'] = 'Failed'; + $lang->zahost->vmTemplate = new stdclass; $lang->zahost->vmTemplate->name = 'Name'; $lang->zahost->vmTemplate->common = 'VM Template'; From a154be14e9fb429e874ec451ccb7ec32acc27e29 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Tue, 15 Nov 2022 03:19:42 +0000 Subject: [PATCH 20/36] * Update lang --- module/zahost/lang/en.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index 17cf6e8576..2b2d809c67 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -17,7 +17,7 @@ $lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Name'; $lang->zahost->IP = 'IP/Domain'; -$lang->zahost->address = 'IP'; +$lang->zahost->address = 'IP/Domain'; $lang->zahost->cpu = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; $lang->zahost->disk = 'Disk Size'; From 78e89ded468f0bdd70974fd43d2020508f609906 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Tue, 15 Nov 2022 03:32:20 +0000 Subject: [PATCH 21/36] * Add desc lang --- module/executionnode/lang/de.php | 1 + module/executionnode/lang/en.php | 1 + module/executionnode/lang/fr.php | 1 + 3 files changed, 3 insertions(+) diff --git a/module/executionnode/lang/de.php b/module/executionnode/lang/de.php index 58e60d50cf..43513d1985 100755 --- a/module/executionnode/lang/de.php +++ b/module/executionnode/lang/de.php @@ -23,6 +23,7 @@ $lang->executionnode->ip = 'IP'; $lang->executionnode->osArch = 'Arch'; $lang->executionnode->cpu = 'CPU Cores'; $lang->executionnode->memory = 'Memory Size'; +$lang->executionnode->desc = 'Description'; $lang->executionnode->disk = 'Disk Size'; $lang->executionnode->status = 'Status'; $lang->executionnode->mac = 'MAC'; diff --git a/module/executionnode/lang/en.php b/module/executionnode/lang/en.php index c47776b32d..4a7327993c 100755 --- a/module/executionnode/lang/en.php +++ b/module/executionnode/lang/en.php @@ -23,6 +23,7 @@ $lang->executionnode->ip = 'IP'; $lang->executionnode->osArch = 'Arch'; $lang->executionnode->cpu = 'CPU Cores'; $lang->executionnode->memory = 'Memory Size'; +$lang->executionnode->desc = 'Description'; $lang->executionnode->disk = 'Disk Size'; $lang->executionnode->status = 'Status'; $lang->executionnode->mac = 'MAC'; diff --git a/module/executionnode/lang/fr.php b/module/executionnode/lang/fr.php index af65d41386..babd1366ce 100755 --- a/module/executionnode/lang/fr.php +++ b/module/executionnode/lang/fr.php @@ -23,6 +23,7 @@ $lang->executionnode->ip = 'IP'; $lang->executionnode->osArch = 'Arch'; $lang->executionnode->cpu = 'CPU Cores'; $lang->executionnode->memory = 'Memory Size'; +$lang->executionnode->desc = 'Description'; $lang->executionnode->disk = 'Disk Size'; $lang->executionnode->status = 'Status'; $lang->executionnode->mac = 'MAC'; From fdf3e3cb16d29c6ce7c2495bd3d10e6f5b308909 Mon Sep 17 00:00:00 2001 From: wangjianhua Date: Tue, 15 Nov 2022 13:07:57 +0800 Subject: [PATCH 22/36] + Add os info for VM image. --- module/zahost/model.php | 1 + 1 file changed, 1 insertion(+) diff --git a/module/zahost/model.php b/module/zahost/model.php index 4897059bd2..9672791760 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -320,6 +320,7 @@ class zahostModel extends model $image->status = $status; $this->dao->update(TABLE_IMAGE) + ->set('osCategory')->eq($image->os) ->set('status')->eq($status) ->set('path')->eq($currentTask->path) ->where('id')->eq($image->id)->exec(); From 45e1c4dc20ce45bdadeb4c3af890573e4b5cf073 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Fri, 18 Nov 2022 01:43:33 +0000 Subject: [PATCH 23/36] * Add view zahost. --- module/common/lang/de.php | 2 +- module/common/lang/en.php | 2 +- module/common/lang/fr.php | 2 +- module/common/lang/menu.php | 2 +- module/common/lang/zh-cn.php | 2 +- module/executionnode/model.php | 18 ++++ module/zahost/control.php | 22 ++++- module/zahost/css/create.css | 2 +- module/zahost/css/view.css | 5 ++ module/zahost/lang/de.php | 1 + module/zahost/lang/en.php | 3 +- module/zahost/lang/fr.php | 3 +- module/zahost/lang/vi.php | 1 + module/zahost/lang/zh-cn.php | 8 +- module/zahost/model.php | 44 +++++++++- module/zahost/view/browse.html.php | 2 +- module/zahost/view/view.html.php | 135 +++++++++++++++++++++++++++++ 17 files changed, 238 insertions(+), 16 deletions(-) create mode 100644 module/zahost/css/view.css create mode 100644 module/zahost/view/view.html.php diff --git a/module/common/lang/de.php b/module/common/lang/de.php index 31f39799aa..44eb1b433f 100644 --- a/module/common/lang/de.php +++ b/module/common/lang/de.php @@ -179,7 +179,7 @@ $lang->testtask->common = 'Request'; $lang->score->common = 'Score'; $lang->build->common = 'Build'; $lang->testreport->common = 'Report'; -$lang->automation->common = 'Automation'; +$lang->automation->common = 'Automation:'; $lang->zahost->common = 'ZAhost'; $lang->executionnode->common = 'Execution Node'; $lang->team->common = 'Team'; diff --git a/module/common/lang/en.php b/module/common/lang/en.php index 6c2eb5bf0e..14694c011a 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.php @@ -179,7 +179,7 @@ $lang->testtask->common = 'Request'; $lang->score->common = 'Score'; $lang->build->common = 'Build'; $lang->testreport->common = 'Report'; -$lang->automation->common = 'Automation'; +$lang->automation->common = 'Automation:'; $lang->zahost->common = 'ZAhost'; $lang->executionnode->common = 'Execution Node'; $lang->team->common = 'Team'; diff --git a/module/common/lang/fr.php b/module/common/lang/fr.php index a738784ee8..54ea15507f 100644 --- a/module/common/lang/fr.php +++ b/module/common/lang/fr.php @@ -179,7 +179,7 @@ $lang->testtask->common = 'Request'; $lang->score->common = 'Score'; $lang->build->common = 'Build'; $lang->testreport->common = 'Report'; -$lang->automation->common = 'Automation'; +$lang->automation->common = 'Automation:'; $lang->zahost->common = 'ZAhost'; $lang->executionnode->common = 'Execution Node'; $lang->team->common = 'Team'; diff --git a/module/common/lang/menu.php b/module/common/lang/menu.php index adffa35d69..abbdf14037 100644 --- a/module/common/lang/menu.php +++ b/module/common/lang/menu.php @@ -450,7 +450,7 @@ $lang->qa->menu->testsuite = array('link' => "{$lang->testcase->testsuite}|t $lang->qa->menu->testtask = array('link' => "{$lang->testtask->common}|testtask|browse|productID=%s", 'subModule' => 'testtask', 'alias' => 'view,edit,linkcase,cases,start,close,batchrun,groupcase,report,importunitresult'); $lang->qa->menu->report = array('link' => "{$lang->testreport->common}|testreport|browse|productID=%s", 'subModule' => 'testreport'); $lang->qa->menu->caselib = array('link' => "{$lang->testcase->caselib}|caselib|browse|libID=0", 'subModule' => 'caselib'); -$lang->qa->menu->automation = array('link' => "{$lang->automation->common}|automation|browse|productID=%s", 'subModule' => 'automation', 'alias' => ''); +$lang->qa->menu->automation = array('link' => "{$lang->automation->common}|project|other|productID=%s", 'subModule' => 'automation', 'alias' => '', 'class' => "qa-automation-menu"); $lang->qa->menu->zahost = array('link' => "{$lang->zahost->common}|zahost|browse", 'subModule' => 'zahost'); $lang->qa->menu->executionnode = array('link' => "{$lang->executionnode->common}|executionnode|browse", 'subModule' => 'executionnode'); diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index c42b93e921..15453a6bf8 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -179,7 +179,7 @@ $lang->testtask->common = '测试单'; $lang->score->common = '我的积分'; $lang->build->common = '版本'; $lang->testreport->common = '测试报告'; -$lang->automation->common = '自动化'; +$lang->automation->common = '自动化:'; $lang->zahost->common = '宿主机'; $lang->executionnode->common = '执行节点'; $lang->team->common = '团队'; diff --git a/module/executionnode/model.php b/module/executionnode/model.php index 3ab249cc34..71edfb6cd0 100755 --- a/module/executionnode/model.php +++ b/module/executionnode/model.php @@ -300,6 +300,24 @@ class executionnodemodel extends model ->fetchAll(); } + /** + * Get node list by hostid. + * + * @param string $browseType + * @param int $param + * @param string $orderBy + * @param object $pager + * @return void + */ + public function getListByHost($hostID, $orderBy = 'id_desc') + { + return $this->dao->select('id, name, vnc, cpu, memory, disk, os, status')->from(TABLE_EXECUTIONNODE) + ->where('deleted')->eq(0) + ->andWhere("hostID")->eq($hostID) + ->orderBy($orderBy) + ->fetchAll(); + } + /** * Get Host by id. diff --git a/module/zahost/control.php b/module/zahost/control.php index 8c44946990..309d8d7b43 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -12,7 +12,7 @@ class zahost extends control { /** - * View host. + * View host list. * * @param string $browseType * @param string $param @@ -52,6 +52,26 @@ class zahost extends control $this->display(); } + /** + * View host. + * + * @param int $id + * @access public + * @return void + */ + public function view($id, $orderBy = 'id_desc') + { + $this->view->title = $this->lang->zahost->view; + $this->view->position[] = html::a($this->createLink('host', 'browse'), $this->lang->zahost->common); + $this->view->position[] = $this->lang->zahost->view; + + $this->view->zahost = $this->zahost->getById($id); + $this->view->orderBy = $orderBy; + $this->view->nodeList = $this->loadModel("executionnode")->getListByHost($this->view->zahost->hostID, $orderBy); + $this->view->actions = $this->loadModel('action')->getList('zahost', $id); + $this->display(); + } + /** * Create host. * diff --git a/module/zahost/css/create.css b/module/zahost/css/create.css index 6affb4df70..20d6b74309 100644 --- a/module/zahost/css/create.css +++ b/module/zahost/css/create.css @@ -1,3 +1,3 @@ #unit {padding: 0px !important; width:0px; border-left: 0px;width: 63px;} .input-group-addon {border: 0px; width: 100px;} -#memory-addon{padding-left: 30px;text-align: left;width: 63px;} \ No newline at end of file +#memory-addon{text-align: center;width: 63px;} \ No newline at end of file diff --git a/module/zahost/css/view.css b/module/zahost/css/view.css new file mode 100644 index 0000000000..734631374a --- /dev/null +++ b/module/zahost/css/view.css @@ -0,0 +1,5 @@ +.zahost-detail .text-right{text-align: right;} +.zahost-detail .col-8{padding-left: 10px;} +.zahost-detail .detail-content{color: #838a9d;} +.table.has-sort-head thead tr th a:after{line-height: 22px;} +.table.has-sort-head thead tr th a:before{line-height: 22px;} \ No newline at end of file diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index a98de16488..3678f9d7fa 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -10,6 +10,7 @@ $lang->zahost->delete = 'Delete'; $lang->zahost->deleteAction = 'Delete Host'; $lang->zahost->byQuery = 'Search'; $lang->zahost->all = 'All'; +$lang->zahost->browseNode = 'ExecutionNode Browse'; $lang->zahost->browseTemplate = 'Template Browse'; $lang->zahost->createTemplate = 'Create Template'; $lang->zahost->editTemplate = 'Edit Template'; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index 9670b431a5..b54a05a3f1 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -10,6 +10,7 @@ $lang->zahost->delete = 'Delete'; $lang->zahost->deleteAction = 'Delete Host'; $lang->zahost->byQuery = 'Search'; $lang->zahost->all = 'All'; +$lang->zahost->browseNode = 'ExecutionNode Browse'; $lang->zahost->browseTemplate = 'Template Browse'; $lang->zahost->createTemplate = 'Create Template'; $lang->zahost->editTemplate = 'Edit Template'; @@ -20,7 +21,7 @@ $lang->zahost->IP = 'IP/Domain'; $lang->zahost->address = 'IP/Domain'; $lang->zahost->cpu = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; -$lang->zahost->disk = 'Disk Size'; +$lang->zahost->disk = 'Disk Size'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index 9fed42b274..7a7a6f2134 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -10,6 +10,7 @@ $lang->zahost->delete = 'Supprimer'; $lang->zahost->deleteAction = 'Supprimer Hôte'; $lang->zahost->byQuery = 'Recherche'; $lang->zahost->all = 'Tous les hôtes'; +$lang->zahost->browseNode = 'ExecutionNode Browse'; $lang->zahost->browseTemplate = 'Template Browse'; $lang->zahost->createTemplate = 'Create Template'; $lang->zahost->editTemplate = 'Edit Template'; @@ -20,7 +21,7 @@ $lang->zahost->IP = 'IP/Domain'; $lang->zahost->address = 'IP'; $lang->zahost->cpu = 'CPU Cores'; $lang->zahost->memory = 'Mémoire Espace'; -$lang->zahost->disk = 'Disque Espace'; +$lang->zahost->disk = 'Disque Espace'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php index a6977cd1d8..86674d4f0c 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -10,6 +10,7 @@ $lang->zahost->delete = 'Delete'; $lang->zahost->deleteAction = 'Delete Host'; $lang->zahost->byQuery = 'Search'; $lang->zahost->all = 'All'; +$lang->zahost->browseNode = 'ExecutionNode Browse'; $lang->zahost->browseTemplate = 'Template Browse'; $lang->zahost->createTemplate = 'Create Template'; $lang->zahost->editTemplate = 'Edit Template'; diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index ec842c4153..d33729a7fd 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -1,15 +1,17 @@ zahost->id = 'ID'; $lang->zahost->common = '宿主机'; -$lang->zahost->browse = '主机列表'; +$lang->zahost->common = '宿主机'; +$lang->zahost->browse = '宿主机列表'; $lang->zahost->create = '添加宿主机'; -$lang->zahost->view = '主机详情'; +$lang->zahost->view = '宿主机详情'; $lang->zahost->edit = '编辑'; $lang->zahost->editAction = '编辑宿主机'; $lang->zahost->delete = '删除'; $lang->zahost->deleteAction = '删除宿主机'; $lang->zahost->byQuery = '搜索'; $lang->zahost->all = '全部主机'; +$lang->zahost->browseNode = '执行节点列表'; $lang->zahost->browseTemplate = '虚拟机模板列表'; $lang->zahost->createTemplate = '创建虚拟机模板'; $lang->zahost->editTemplate = '编辑虚拟机模板'; @@ -108,7 +110,7 @@ $lang->zahost->langList['zh_cn'] = '简体中文'; $lang->zahost->langList['zh_tw'] = '繁体中文'; $lang->zahost->langList['en_us'] = '美式英语'; -$lang->zahost->empty = '暂时没有主机'; +$lang->zahost->empty = '暂时没有宿主机'; $lang->zahost->templateEmpty = '暂时没有模板'; $lang->zahost->statusList['ready'] = '准备中'; diff --git a/module/zahost/model.php b/module/zahost/model.php index 9672791760..cbce05d9d4 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -247,6 +247,8 @@ class zahostModel extends model $imageData->hostID = $hostID; $imageData->status = 'created'; + $imageData->osCategory = $imageData->os; + unset($imageData->os); $this->dao->insert(TABLE_IMAGE)->data($imageData, 'desc')->autoCheck()->exec(); if(dao::isError()) return false; @@ -305,11 +307,11 @@ class zahostModel extends model foreach($result->data as $status => $group) { $currentTask = null; - foreach($group as $task) + foreach($group as $host) { - if($task->task == $image->id ) + if($host->task == $image->id ) { - $currentTask = $task; + $currentTask = $host; break; } } @@ -435,6 +437,42 @@ class zahostModel extends model ->fetchAll(); } + /** + * Build test task menu. + * + * @param object $host + * @param string $type + * @access public + * @return string + */ + public function buildOperateMenu($host, $type = 'view') + { + $function = 'buildOperate' . ucfirst($type) . 'Menu'; + return $this->$function($host); + } + + /** + * Build test task view menu. + * + * @param object $host + * @access public + * @return string + */ + public function buildOperateViewMenu($host) + { + if($host->deleted) return ''; + + $menu = ''; + $params = "hostID=$host->hostID"; + + $menu .= $this->buildMenu('zahost', 'edit', $params, $host, 'view'); + + $params = "hostID=$host->assetID"; + $menu .= $this->buildMenu('zahost', 'delete', $params, $host, 'view', 'trash', 'hiddenwin'); + + return $menu; + } + /** * Get VM template list. * diff --git a/module/zahost/view/browse.html.php b/module/zahost/view/browse.html.php index 671b951583..49e6900eab 100644 --- a/module/zahost/view/browse.html.php +++ b/module/zahost/view/browse.html.php @@ -59,7 +59,7 @@ - + diff --git a/module/zahost/view/view.html.php b/module/zahost/view/view.html.php new file mode 100644 index 0000000000..2e120bec51 --- /dev/null +++ b/module/zahost/view/view.html.php @@ -0,0 +1,135 @@ + + * @package zahost + * @version $Id: view.html.php $ + * @link http://www.zentao.net + */ +?> + + +session->zahostList ? $this->session->zahostList : $this->createLink('zahost', 'browse', "");?> +hostID}&orderBy=%s";?> + +
+
+
+
+
zahost->view;?>
+
+
+
+
+
zahost->zaHostType;?>:
+
zahost->zaHostTypeList[$zahost->hostType];?>
+
+
+
+
+
zahost->address;?>:
+
address;?>
+
+
+
+
+
zahost->memory;?>:
+
memory;?>
+
+
+
+
+
+
+
zahost->virtualSoftware;?>:
+
virtualSoftware;?>
+
+
+
+
+
zahost->cpu;?>:
+
cpu;?>
+
+
+
+
+
zahost->disk;?>:
+
disk;?>
+
+
+
+
+
+
+
zahost->desc;?>
+
desc) ? $zahost->desc : $lang->noData;?>
+
+ +
+
zahost->browseNode;?>
+
+
zahost->image->name);?>zahost->image->desc;?> zahost->image->memory);?> zahost->image->disk);?> zahost->status;?>
name;?>desc;?> memory . zget($this->lang->zahost->unitList, 'GB');?> disk . zget($this->lang->zahost->unitList, 'GB');?> '>zahost->image->statusList, $image->status, '');?>
hostID);?>inlink('browsetemplate', "id=$host->hostID"), $host->name) : $host->name;?>inlink('view', "id=$host->hostID"), $host->name, '', "");?> zahost->zaHostTypeList, $host->hostType);?> address;?> cpu;?>
+ + + + + + + + + + + + + + + + + + + + + + +
zahost->name);?>executionnode->cpu);?>executionnode->memory);?>executionnode->disk);?>executionnode->os);?>executionnode->status);?>
name;?>executionnode->os->cpu, $node->cpu);?>memory . $this->lang->zahost->unitList['GB'];?>disk . zget($this->lang->zahost->unitList, $node->unit);?>executionnode->os->list, $node->os);?>executionnode->statusList, $node->status);?>
+ + + + createLink('action', 'comment', "objectType=zahost&objectID=$zahost->hostID"); + ?> + + printExtendFields($zahost, 'div', "position=left&inForm=0&inCell=1");?> +
+
+ ' . $lang->goback, '', 'btn btn-secondary');?> +
+ zahost->buildOperateMenu($zahost, 'view');?> +
+
+ +
+
+
+ + +
+ +
+ From b8e0e3f8be6d652057708bc1f84307393dd560ed Mon Sep 17 00:00:00 2001 From: zhaoke Date: Fri, 18 Nov 2022 06:49:10 +0000 Subject: [PATCH 24/36] * Update sql. --- db/update18.0.sql | 107 +++++++++++++++-------- db/zentao.sql | 218 ++++++++-------------------------------------- 2 files changed, 107 insertions(+), 218 deletions(-) diff --git a/db/update18.0.sql b/db/update18.0.sql index 6b47fc1794..d2ab5f5ea9 100644 --- a/db/update18.0.sql +++ b/db/update18.0.sql @@ -3,57 +3,92 @@ ALTER TABLE `zt_project` ADD `hasProduct` tinyint(1) unsigned NOT NULL DEFAULT 1 ALTER table `zt_project` ADD `multiple` enum('0', '1') NOT NULL DEFAULT '1'; ALTER TABLE `zt_repo` ADD `projects` varchar(255) NOT NULL AFTER `product`; -ALTER TABLE `zt_host` ADD `desc` text NOT NULL AFTER `token`; -ALTER TABLE `zt_host` CHANGE COLUMN `publicIP` `address` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,CHANGE COLUMN `cpuCores` `cpu` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,CHANGE COLUMN `diskSize` `disk` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,CHANGE COLUMN `heartbeatTime` `heartbeat` datetime NOT NULL; +ALTER TABLE `zt_host` +DROP COLUMN `cabinet`, +DROP COLUMN `cpuRate`, +DROP COLUMN `diskType`, +DROP COLUMN `unit`, +DROP COLUMN `nic`, +DROP COLUMN `webserver`, +DROP COLUMN `database`, +DROP COLUMN `language`, +DROP COLUMN `instanceNum`, +DROP COLUMN `pri`, +DROP COLUMN `tags`, +DROP COLUMN `bridgeID`, +DROP COLUMN `cloudKey`, +DROP COLUMN `cloudSecret`, +DROP COLUMN `cloudRegion`, +DROP COLUMN `cloudNamespace`, +DROP COLUMN `cloudUser`, +DROP COLUMN `cloudAccount`, +DROP COLUMN `cloudPassword`, +DROP COLUMN `couldVPC`, +ADD COLUMN `name` varchar(255) NOT NULL DEFAULT '' AFTER `id`, +MODIFY COLUMN `type` varchar(30) NOT NULL DEFAULT 'normal' AFTER `name`, +MODIFY COLUMN `hostType` varchar(30) NOT NULL DEFAULT '' AFTER `type`, +MODIFY COLUMN `mac` varchar(128) NOT NULL AFTER `hostType`, +MODIFY COLUMN `memory` varchar(30) NOT NULL AFTER `mac`, +MODIFY COLUMN `diskSize` varchar(30) NOT NULL AFTER `memory`, +MODIFY COLUMN `status` varchar(50) NOT NULL AFTER `diskSize`, +MODIFY COLUMN `secret` varchar(50) NOT NULL DEFAULT '' AFTER `status`, +ADD COLUMN `desc` text NOT NULL AFTER `secret`, +CHANGE COLUMN `token` `tokenSN` varchar(50) NOT NULL DEFAULT '' AFTER `desc`, +CHANGE COLUMN `expiredDate` `tokenTime` datetime NOT NULL AFTER `tokenSN`, +CHANGE COLUMN `virtualSoftware` `vsoft` varchar(30) NOT NULL DEFAULT '' AFTER `tokenTime`, +CHANGE COLUMN `heartbeatTime` `heartbeat` datetime NOT NULL AFTER `vsoft`, +CHANGE COLUMN `agentPort` `zap` varchar(10) NOT NULL AFTER `heartbeat`, +MODIFY COLUMN `provider` varchar(255) NOT NULL DEFAULT '' AFTER `zap`, +ADD COLUMN `vnc` int(11) NOT NULL AFTER `provider`, +ADD COLUMN `parent` int(11) unsigned NOT NULL DEFAULT '0' AFTER `vnc`, +ADD COLUMN `image` int(11) unsigned NOT NULL DEFAULT '0' AFTER `parent`, +ADD COLUMN `group` varchar(128) NOT NULL DEFAULT '' AFTER `osVersion`, +ADD COLUMN `createdBy` varchar(30) NOT NULL, +ADD COLUMN `createdDate` datetime NOT NULL, +ADD COLUMN `editedBy` varchar(30) NOT NULL, +ADD COLUMN `editedDate` datetime NOT NULL, +ADD COLUMN `deleted` enum('0','1') NOT NULL DEFAULT '0', +CHANGE COLUMN `privateIP` `intranet` varchar(128) NOT NULL AFTER `cpuCores`, +CHANGE COLUMN `publicIP` `extranet` varchar(128) NOT NULL AFTER `intranet`; -CREATE TABLE `zt_executionnode` ( - `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `hostID` int(11) unsigned NOT NULL DEFAULT 0, - `name` varchar(64) NOT NULL DEFAULT '', - `imageID` int(11) unsigned NOT NULL DEFAULT 0, - `cpu` int(11) unsigned NOT NULL DEFAULT 0, - `os` varchar(128) NOT NULL DEFAULT '', - `unit` enum('GB','TB') NOT NULL DEFAULT 'GB', - `memory` float unsigned NOT NULL, - `disk` float unsigned NOT NULL, - `status` varchar(20) NOT NULL, - `mac` varchar(64) NOT NULL, - `vnc` int(11) unsigned NOT NULL DEFAULT 0, - `desc` text NOT NULL, - `registerDate` datetime NOT NULL, - `createdBy` varchar(30) NOT NULL, - `createdDate` datetime NOT NULL, - `editedBy` varchar(30) NOT NULL, - `editedDate` datetime NOT NULL, - `deleted` enum('0','1') NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; +UPDATE zt_host h, +zt_asset a +SET h.`name` = a.`name`, +h.`createdBy` = a.`createdBy`, +h.`createdDate` = a.`createdDate`, +h.`editedBy` = a.`editedBy`, +h.`editedDate` = a.`editedDate`, +h.`group` = a.`group`, +h.`type` = a.`type`, +h.`deleted` = a.`deleted` +WHERE + h.`assetID` = a.`id`; + +ALTER TABLE `zt_host` DROP COLUMN `assetID`, + +DROP TABLE IF EXISTS `zt_asset`; +DROP TABLE IF EXISTS `zt_baseimagebrowser`; +DROP TABLE IF EXISTS `zt_browser`; +DROP TABLE IF EXISTS `zt_baseimage`; +DROP TABLE IF EXISTS `zt_vmtemplate`; +DROP TABLE IF EXISTS `zt_vm`; CREATE TABLE `zt_image` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `hostID` int(11) unsigned NOT NULL DEFAULT 0, + `host` int(11) unsigned NOT NULL DEFAULT 0, `name` varchar(64) NOT NULL DEFAULT '', - `address` varchar(500) NOT NULL DEFAULT '', - `from` varchar(64) NOT NULL DEFAULT '', `path` varchar(64) NOT NULL DEFAULT '', `status` varchar(20) NOT NULL DEFAULT '', - `osCategory` varchar(32) NOT NULL DEFAULT '', - `osType` varchar(32) NOT NULL DEFAULT '', - `osVersion` varchar(32) NOT NULL DEFAULT '', - `osLang` varchar(32) NOT NULL DEFAULT '', + `os` varchar(32) NOT NULL DEFAULT '', `memory` float unsigned NOT NULL, `disk` float unsigned NOT NULL, `fileSize` float unsigned NOT NULL, `md5` varchar(64) NOT NULL, `desc` text NOT NULL, - `registerDate` datetime NOT NULL, `createdBy` varchar(30) NOT NULL, `createdDate` datetime NOT NULL, - `editedBy` varchar(30) NOT NULL, - `editedDate` datetime NOT NULL, - `deleted` enum('0','1') NOT NULL DEFAULT '0', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE OR REPLACE VIEW `ztv_normalproduct` AS SELECT * FROM `zt_product` WHERE `shadow` = 0; diff --git a/db/zentao.sql b/db/zentao.sql index ccaa6e2d55..6e9027feab 100755 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -7247,124 +7247,66 @@ CREATE TABLE IF NOT EXISTS `zt_account` ( key `status` (`status`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- DROP TABLE IF EXISTS `zt_asset`; -CREATE TABLE IF NOT EXISTS `zt_asset` ( - `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `status` varchar(30) NOT NULL, - `type` varchar(30) NOT NULL, - `group` varchar(128) NOT NULL, - `createdBy` char(30) NOT NULL, - `createdDate` datetime NOT NULL, - `editedBy` char(30) NOT NULL, - `editedDate` datetime NOT NULL, - `registerDate` datetime NOT NULL, - `deleted` enum('0','1') NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -- DROP TABLE IF EXISTS `zt_host`; -CREATE TABLE IF NOT EXISTS `zt_host` ( - `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `assetID` mediumint(8) UNSIGNED NOT NULL, - `admin` smallint(5) UNSIGNED NOT NULL DEFAULT 0, - `type` varchar(30) NOT NULL DEFAULT 'normal', - `secret` varchar(50) NOT NULL DEFAULT '', - `token` varchar(50) NOT NULL DEFAULT '', - `desc` text NOT NULL, - `expiredDate` datetime NOT NULL, - `serverRoom` mediumint(8) UNSIGNED NOT NULL, - `cabinet` varchar(128) NOT NULL, - `serverModel` varchar(256) NOT NULL, - `hardwareType` varchar(64) NOT NULL, - `hostType` enum('physical','virtual') NOT NULL, - `cpuBrand` varchar(128) NOT NULL, - `cpuModel` varchar(128) NOT NULL, - `cpuNumber` varchar(16) NOT NULL, - `cpu` varchar(30) NOT NULL, - `cpuRate` varchar(30) NOT NULL, - `memory` varchar(30) NOT NULL, - `diskType` varchar(30) NOT NULL, - `disk` varchar(30) NOT NULL, - `unit` enum('GB','TB') NOT NULL DEFAULT 'GB', - `privateIP` varchar(128) NOT NULL, - `address` varchar(128) NOT NULL, - `nic` varchar(128) NOT NULL, - `mac` varchar(128) NOT NULL, - `osName` varchar(64) NOT NULL, - `osVersion` varchar(64) NOT NULL, - `webserver` varchar(128) NOT NULL, - `database` varchar(128) NOT NULL, - `language` varchar(16) NOT NULL, - `status` varchar(50) NOT NULL, - `virtualSoftware` varchar(30) NOT NULL DEFAULT '', - `agentPort` varchar(10) NOT NULL, - `instanceNum` tinyint(0) NOT NULL DEFAULT 0, - `pri` smallint(5) unsigned NOT NULL DEFAULT 0, - `heartbeat` datetime NOT NULL, - `tags` varchar(50) NOT NULL DEFAULT '', - `provider` varchar(255) NOT NULL DEFAULT '', - `bridgeID` varchar(255) NOT NULL DEFAULT '', - `cloudKey` varchar(255) NOT NULL DEFAULT '', - `cloudSecret` varchar(255) NOT NULL DEFAULT '', - `cloudRegion` varchar(255) NOT NULL DEFAULT '', - `cloudNamespace` varchar(255) NOT NULL DEFAULT '', - `cloudUser` varchar(255) NOT NULL DEFAULT '', - `cloudAccount` varchar(255) NOT NULL DEFAULT '', - `cloudPassword` varchar(255) NOT NULL DEFAULT '', - `couldVPC` varchar(255) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- DROP TABLE IF EXISTS `zt_executionnode`; -CREATE TABLE `zt_executionnode` ( +CREATE TABLE `zt_host` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `hostID` int(11) unsigned NOT NULL DEFAULT 0, - `name` varchar(64) NOT NULL DEFAULT '', - `imageID` int(11) unsigned NOT NULL DEFAULT 0, - `cpu` int(11) unsigned NOT NULL DEFAULT 0, - `os` varchar(128) NOT NULL DEFAULT '', - `memory` float unsigned NOT NULL, - `disk` float unsigned NOT NULL, - `status` varchar(20) NOT NULL, - `mac` varchar(64) NOT NULL, - `vnc` int(11) unsigned NOT NULL DEFAULT 0, + `name` varchar(255) NOT NULL DEFAULT '', + `type` varchar(30) NOT NULL DEFAULT 'normal', + `hostType` varchar(30) NOT NULL DEFAULT '', + `mac` varchar(128) NOT NULL, + `memory` varchar(30) NOT NULL, + `diskSize` varchar(30) NOT NULL, + `status` varchar(50) NOT NULL, + `secret` varchar(50) NOT NULL DEFAULT '', `desc` text NOT NULL, - `registerDate` datetime NOT NULL, + `tokenSN` varchar(50) NOT NULL DEFAULT '', + `tokenTime` datetime NOT NULL, + `vsoft` varchar(30) NOT NULL DEFAULT '', + `heartbeat` datetime NOT NULL, + `zap` varchar(10) NOT NULL, + `provider` varchar(255) NOT NULL DEFAULT '', + `vnc` int(11) NOT NULL, + `parent` int(11) unsigned NOT NULL DEFAULT '0', + `image` int(11) unsigned NOT NULL DEFAULT '0', + `assetID` mediumint(8) unsigned NOT NULL, + `admin` smallint(5) unsigned NOT NULL DEFAULT '0', + `serverRoom` mediumint(8) unsigned NOT NULL, + `serverModel` varchar(256) NOT NULL, + `hardwareType` varchar(64) NOT NULL, + `cpuBrand` varchar(128) NOT NULL, + `cpuModel` varchar(128) NOT NULL, + `cpuNumber` varchar(16) NOT NULL, + `cpuCores` varchar(30) NOT NULL, + `intranet` varchar(128) NOT NULL, + `extranet` varchar(128) NOT NULL, + `osName` varchar(64) NOT NULL, + `osVersion` varchar(64) NOT NULL, + `group` varchar(128) NOT NULL DEFAULT '', `createdBy` varchar(30) NOT NULL, `createdDate` datetime NOT NULL, `editedBy` varchar(30) NOT NULL, `editedDate` datetime NOT NULL, `deleted` enum('0','1') NOT NULL DEFAULT '0', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 -- DROP TABLE IF EXISTS `zt_image`; CREATE TABLE `zt_image` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `hostID` int(11) unsigned NOT NULL DEFAULT 0, + `host` int(11) unsigned NOT NULL DEFAULT 0, `name` varchar(64) NOT NULL DEFAULT '', - `address` varchar(500) NOT NULL DEFAULT '', - `from` varchar(64) NOT NULL DEFAULT '', `path` varchar(64) NOT NULL DEFAULT '', `status` varchar(20) NOT NULL DEFAULT '', - `osCategory` varchar(32) NOT NULL DEFAULT '', - `osType` varchar(32) NOT NULL DEFAULT '', - `osVersion` varchar(32) NOT NULL DEFAULT '', - `osLang` varchar(32) NOT NULL DEFAULT '', + `os` varchar(32) NOT NULL DEFAULT '', `memory` float unsigned NOT NULL, `disk` float unsigned NOT NULL, `fileSize` float unsigned NOT NULL, `md5` varchar(64) NOT NULL, `desc` text NOT NULL, - `registerDate` datetime NOT NULL, `createdBy` varchar(30) NOT NULL, `createdDate` datetime NOT NULL, - `editedBy` varchar(30) NOT NULL, - `editedDate` datetime NOT NULL, - `deleted` enum('0','1') NOT NULL DEFAULT '0', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- DROP TABLE IF EXISTS `zt_service`; CREATE TABLE IF NOT EXISTS `zt_service` ( @@ -7609,94 +7551,6 @@ CREATE TABLE IF NOT EXISTS `zt_deployscope` ( `remove` text NOT NULL, `add` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- DROP TABLE IF EXISTS `zt_vm`; -CREATE TABLE IF NOT EXISTS `zt_vm` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `hostID` int(10) unsigned NOT NULL DEFAULT 0, - `name` varchar(255) NOT NULL DEFAULT '', - `osCategory` varchar(50) NOT NULL DEFAULT '', - `osVersion` varchar(50) NOT NULL DEFAULT '', - `osType` varchar(50) NOT NULL DEFAULT '', - `osArch` varchar(50) NOT NULL DEFAULT '', - `osLang` varchar(50) NOT NULL DEFAULT '', - `osCpu` tinyint(2) NOT NULL DEFAULT 0, - `osMemory` smallint(6) NOT NULL DEFAULT 0, - `osDisk` smallint(6) NOT NULL DEFAULT 0, - `unit` enum('GB','TB') NOT NULL DEFAULT 'GB', - `status` varchar(50) NOT NULL DEFAULT '', - `destroyAt` datetime NULL, - `macAddress` varchar(255) NOT NULL DEFAULT '', - `workspace` varchar(255) NOT NULL DEFAULT '', - `templateID` int(10) unsigned NOT NULL DEFAULT 0, - `baseImageID` int(10) unsigned NOT NULL DEFAULT 0, - `baseImagePath` varchar(255) NOT NULL DEFAULT '', - `desc` varchar(255) NOT NULL DEFAULT '', - `heatbeat` datetime NULL, - `vncPort` int(10) NOT NULL DEFAULT 0, - `instance` varchar(255) NOT NULL DEFAULT '', - `eip` varchar(255) NOT NULL DEFAULT '', - `createdBy` varchar(30) NOT NULL, - `createdDate` datetime NOT NULL, - `editedBy` varchar(30) NOT NULL, - `editedDate` datetime NOT NULL, - `deleted` enum('0','1') NOT NULL DEFAULT '0', - `public` varchar(50) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- DROP TABLE IF EXISTS `zt_baseimage`; -CREATE TABLE IF NOT EXISTS `zt_baseimage` ( - `id` SMALLINT(7) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL DEFAULT '', - `path` varchar(255) NOT NULL DEFAULT '', - `osType` varchar(50) NOT NULL DEFAULT '', - `os` varchar(50) NOT NULL DEFAULT '', - `osCategory` varchar(50) NOT NULL DEFAULT '', - `osArch` varchar(50) NOT NULL DEFAULT '', - `osLang` varchar(50) NOT NULL DEFAULT '', - `suggestCore` tinyint(1) unsigned NOT NULL DEFAULT 0, - `suggestMemory` mediumint(6) unsigned NOT NULL DEFAULT 0, - `suggestVolume` mediumint(6) unsigned NOT NULL DEFAULT 0, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- DROP TABLE IF EXISTS `zt_vmtemplate`; -CREATE TABLE IF NOT EXISTS `zt_vmtemplate` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `hostID` int(10) unsigned NOT NULL DEFAULT 0, - `type` varchar(30) NOT NULL DEFAULT 'normal', - `templateName` varchar(255) NOT NULL DEFAULT '', - `osType` varchar(50) NOT NULL DEFAULT '', - `osCategory` varchar(50) NOT NULL DEFAULT '', - `osVersion` varchar(50) NOT NULL DEFAULT '', - `osLang` varchar(50) NOT NULL, - `cpuCoreNum` smallint(4) NOT NULL DEFAULT 0, - `memorySize` int NOT NULL DEFAULT 0, - `diskSize` int NOT NULL DEFAULT 0, - `osArch` varchar(50) NOT NULL, - `imageName` varchar(50) NOT NULL, - `createdBy` varchar(30) NOT NULL, - `createdDate` datetime NOT NULL, - `editedBy` varchar(30) NOT NULL, - `editedDate` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- DROP TABLE IF EXISTS `zt_browser`; -CREATE TABLE IF NOT EXISTS `zt_browser` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL DEFAULT '', - `type` varchar(255) NOT NULL DEFAULT '', - `version` varchar(255) NOT NULL DEFAULT '', - `lang` varchar(255) NOT NULL DEFAULT '', - `createdBy` varchar(30) NOT NULL, - `createdDate` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- DROP TABLE IF EXISTS `zt_baseimagebrowser`; -CREATE TABLE IF NOT EXISTS `zt_baseimagebrowser` ( - `vmBackingID` int(10) NOT NULL, - `browserID` int(10) NOT NULL, - PRIMARY KEY (`vmBackingID`, `browserID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- DROP TABLE IF EXISTS `zt_traincourse`; CREATE TABLE IF NOT EXISTS `zt_traincourse` ( From 65adccbff9f87cbe1e4da89235319da90592556d Mon Sep 17 00:00:00 2001 From: zhaoke Date: Mon, 21 Nov 2022 00:56:54 +0000 Subject: [PATCH 25/36] * Update for sql change. --- api/v1/entries/hostheartbeat.php | 8 +- config/zentaopms.php | 6 - module/executionnode/model.php | 51 ++--- module/zahost/config.php | 101 ++-------- module/zahost/control.php | 140 +------------ module/zahost/css/browse.css | 2 +- module/zahost/lang/de.php | 16 +- module/zahost/lang/en.php | 52 +---- module/zahost/lang/fr.php | 8 +- module/zahost/lang/vi.php | 8 +- module/zahost/lang/zh-cn.php | 8 +- module/zahost/model.php | 220 +++------------------ module/zahost/view/browse.html.php | 16 +- module/zahost/view/browsetemplate.html.php | 80 -------- module/zahost/view/create.html.php | 8 +- module/zahost/view/createtemplate.html.php | 79 -------- module/zahost/view/edit.html.php | 10 +- module/zahost/view/edittemplate.html.php | 80 -------- module/zahost/view/view.html.php | 12 +- 19 files changed, 121 insertions(+), 784 deletions(-) delete mode 100755 module/zahost/view/browsetemplate.html.php delete mode 100644 module/zahost/view/createtemplate.html.php delete mode 100644 module/zahost/view/edittemplate.html.php diff --git a/api/v1/entries/hostheartbeat.php b/api/v1/entries/hostheartbeat.php index 01cfaf2d41..f7258ab09b 100644 --- a/api/v1/entries/hostheartbeat.php +++ b/api/v1/entries/hostheartbeat.php @@ -42,15 +42,15 @@ class hostHeartbeatEntry extends baseEntry } $this->dao = $this->loadModel('common')->dao; - $assetID = $this->dao->select('assetID')->from(TABLE_HOST) + $assetID = $this->dao->select('id')->from(TABLE_HOST) ->beginIF($secret)->where('secret')->eq($secret)->fi() - ->beginIF(!$secret)->where('token')->eq($token) - ->andWhere('expiredDate')->gt($now)->fi() + ->beginIF(!$secret)->where('tokenSN')->eq($token) + ->andWhere('tokenTime')->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->dao->update(TABLE_HOST)->set('heartbeat')->eq($now)->where('id')->eq($assetID)->exec(); if(!$secret) return $this->sendSuccess(200, 'success'); diff --git a/config/zentaopms.php b/config/zentaopms.php index 8632a4bcec..deb6da1498 100644 --- a/config/zentaopms.php +++ b/config/zentaopms.php @@ -254,13 +254,8 @@ 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`'); -define('TABLE_EXECUTIONNODE', '`' . $config->db->prefix . 'executionnode`'); define('TABLE_IMAGE', '`' . $config->db->prefix . 'image`'); -if(!defined('TABLE_ASSET')) define('TABLE_ASSET', '`' . $config->db->prefix . 'asset`'); -if(!defined('TABLE_VMTEMPLATE')) define('TABLE_VMTEMPLATE', '`' . $config->db->prefix . 'vmtemplate`'); -if(!defined('TABLE_VM')) define('TABLE_VM', '`' . $config->db->prefix . 'vm`'); - define('TABLE_PRODUCT', '`' . $config->db->prefix . 'product`'); define('TABLE_BRANCH', '`' . $config->db->prefix . 'branch`'); define('TABLE_EXPECT', '`' . $config->db->prefix . 'expect`'); @@ -402,7 +397,6 @@ $config->objectTables['stage'] = TABLE_STAGE; $config->objectTables['apistruct'] = TABLE_APISTRUCT; $config->objectTables['repo'] = TABLE_REPO; $config->objectTables['zahost'] = TABLE_ZAHOST; -$config->objectTables['executionnode'] = TABLE_EXECUTIONNODE; $config->newFeatures = array('introduction', 'tutorial', 'youngBlueTheme', 'visions'); $config->disabledFeatures = ''; diff --git a/module/executionnode/model.php b/module/executionnode/model.php index 71edfb6cd0..39c0c18cb0 100755 --- a/module/executionnode/model.php +++ b/module/executionnode/model.php @@ -41,7 +41,8 @@ class executionnodemodel extends model /* Batch check fields. */ $this->lang->vm = $this->lang->executionnode; - $this->dao->update(TABLE_EXECUTIONNODE)->data($data) + $data->type = 'node'; + $this->dao->update(TABLE_ZAHOST)->data($data) ->batchCheck($this->config->executionnode->create->requiredFields, 'notempty') ->check('name', 'unique'); if(dao::isError()) return false; @@ -56,7 +57,7 @@ class executionnodemodel extends model $image = $this->getImageByID($data->imageID); /* Get host info. */ - $host = $this->getHostByID($data->hostID); + $host = $this->getHostByID($data->parent); /* Gen mac address */ $mac = $this->genmac(); @@ -87,7 +88,7 @@ class executionnodemodel extends model /* Prepare create execution node data. */ $data->imageID = $data->imageID; - $data->hostID = $host->id; + $data->parent = $host->id; $data->mac = $mac; $data->status = static::STATUS_RUNNING; $data->createdBy = $this->app->user->account; @@ -95,7 +96,7 @@ class executionnodemodel extends model $data->vnc = (int)$result->data->vnc; /* Save execution node. */ - $this->dao->insert(TABLE_EXECUTIONNODE)->data($data)->autoCheck()->exec(); + $this->dao->insert(TABLE_ZAHOST)->data($data)->autoCheck()->exec(); if(dao::isError()) return false; $nodeID = $this->dao->lastInsertID(); @@ -115,7 +116,7 @@ class executionnodemodel extends model public function handleVM($id, $type) { $node = $this->getVMByID($id); - $host = $this->getHostByID($node->hostID); + $host = $this->getHostByID($node->parent); /* Prepare create params. */ $agnetUrl = 'http://' . $host->address . ':' . $this->config->executionnode->defaultPort; @@ -131,7 +132,7 @@ class executionnodemodel extends model if($type != 'reboot') { $status = $type == 'suspend' ? 'suspend' : 'running'; - $this->dao->update(TABLE_EXECUTIONNODE)->set('status')->eq($status)->where('id')->eq($id)->exec(); + $this->dao->update(TABLE_ZAHOST)->set('status')->eq($status)->where('id')->eq($id)->exec(); } $this->loadModel('action')->create('executionnode', $id, ucfirst($type)); @@ -148,7 +149,7 @@ class executionnodemodel extends model public function destroy($id) { $node = $this->getVMByID($id); - $host = $this->getHostByID($node->hostID); + $host = $this->getHostByID($node->parent); $req = array( 'name' => $node->name ); @@ -165,7 +166,7 @@ class executionnodemodel extends model } /* delete execution node. */ - $this->dao->update(TABLE_EXECUTIONNODE) + $this->dao->update(TABLE_ZAHOST) ->set('deleted')->eq(1) ->where('id')->eq($id) ->exec(); @@ -222,7 +223,7 @@ class executionnodemodel extends model */ public function update($id, $data) { - $this->dao->update(TABLE_EXECUTIONNODE)->data($data) + $this->dao->update(TABLE_ZAHOST)->data($data) ->where('id')->eq($id) ->exec(); } @@ -238,7 +239,7 @@ class executionnodemodel extends model public function setVmName($vm, $id) { $name = sprintf('test-%s-%s-%s-%s-%d', $vm['osCategory'], $vm['osType'], $vm['osArch'], $vm['osLang'], $id); - $this->dao->update(TABLE_EXECUTIONNODE)->data(array('name' => $name)) + $this->dao->update(TABLE_ZAHOST)->data(array('name' => $name)) ->where('id')->eq($id) ->exec(); $vm['name'] = $name; @@ -282,17 +283,17 @@ class executionnodemodel extends model $query = str_replace('`status`', 't1.`status`', $query); $query = str_replace('`osCategory`', 't1.`osCategory`', $query); $query = str_replace('`osType`', 't1.`osType`', $query); - $query = str_replace('`hostID`', 't1.`hostID`', $query); + $query = str_replace('`parent`', 't1.`parent`', $query); $query = str_replace('`osVersion`', 't4.`osVersion`', $query); } $orderBy = str_replace('osVersion', 't4.osVersion', $orderBy); - return $this->dao->select('t1.*, t3.name as hostName, t2.address as hostIP,t4.osVersion')->from(TABLE_EXECUTIONNODE)->alias('t1') - ->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t1.hostID = t2.id') - ->leftJoin(TABLE_ASSET)->alias('t3')->on('t3.id = t2.assetID') - ->leftJoin(TABLE_IMAGE)->alias('t4')->on('t4.id = t1.imageID') + return $this->dao->select('t1.*, t1.name as hostName, t2.extranet as hostIP,t3.osVersion')->from(TABLE_ZAHOST)->alias('t1') + ->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t1.parent = t2.id') + ->leftJoin(TABLE_IMAGE)->alias('t3')->on('t3.id = t1.imageID') ->where('t1.deleted')->eq(0) + ->andWhere("t1.type")->eq("node") ->andWhere("(t1.createdBy = '{$this->app->user->account}')") ->beginIF($query)->andWhere($query)->fi() ->orderBy($orderBy) @@ -301,7 +302,7 @@ class executionnodemodel extends model } /** - * Get node list by hostid. + * Get node list by hostID. * * @param string $browseType * @param int $param @@ -311,9 +312,9 @@ class executionnodemodel extends model */ public function getListByHost($hostID, $orderBy = 'id_desc') { - return $this->dao->select('id, name, vnc, cpu, memory, disk, os, status')->from(TABLE_EXECUTIONNODE) + return $this->dao->select('id, name, vnc, cpu, memory, disk, os, status')->from(TABLE_ZAHOST) ->where('deleted')->eq(0) - ->andWhere("hostID")->eq($hostID) + ->andWhere("parent")->eq($hostID) ->orderBy($orderBy) ->fetchAll(); } @@ -420,10 +421,9 @@ class executionnodemodel extends model */ public function getVMByID($id) { - return $this->dao->select('t1.*, t3.name as hostName, t2.address as ip,t4.osVersion')->from(TABLE_EXECUTIONNODE)->alias('t1') - ->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t1.hostID = t2.id') - ->leftJoin(TABLE_ASSET)->alias('t3')->on('t3.id = t2.assetID') - ->leftJoin(TABLE_IMAGE)->alias('t4')->on('t4.id = t1.imageID') + return $this->dao->select('t1.*, t1.name as hostName, t2.extranet as ip,t3.osVersion')->from(TABLE_ZAHOST)->alias('t1') + ->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t1.parent = t2.id') + ->leftJoin(TABLE_IMAGE)->alias('t3')->on('t3.id = t1.imageID') ->where('t1.id')->eq($id) ->fetch(); } @@ -436,8 +436,9 @@ class executionnodemodel extends model */ public function getVMByMac($mac) { - return $this->dao->select('*')->from(TABLE_EXECUTIONNODE) + return $this->dao->select('*')->from(TABLE_ZAHOST) ->where('mac')->eq($mac) + ->andWhere("type")->eq('node') ->fetch(); } @@ -479,9 +480,9 @@ class executionnodemodel extends model public function getVncUrl($vmID) { $vm = $this->getVMByID($vmID); - if(empty($vm) or empty($vm->hostID) or empty($vm->vnc)) return false; + if(empty($vm) or empty($vm->parent) or empty($vm->vnc)) return false; - $host = $this->getHostByID($vm->hostID); + $host = $this->getHostByID($vm->parent); if(empty($host)) return false; $agnetUrl = 'http://' . $host->address . ':' . $host->agentPort . static::KVM_TOKEN_PATH; diff --git a/module/zahost/config.php b/module/zahost/config.php index 1df953214f..2b612315c3 100644 --- a/module/zahost/config.php +++ b/module/zahost/config.php @@ -1,35 +1,15 @@ zahost->create = new stdclass(); -$config->zahost->create->requiredFields = 'name,hostType,address,cpu,memory,disk,virtualSoftware'; -$config->zahost->create->ipFields = 'address'; +$config->zahost->create->requiredFields = 'name,hostType,extranet,cpuCores,memory,diskSize,vsoft'; +$config->zahost->create->ipFields = 'extranet'; $config->zahost->defaultPort = '8086'; $config->zahost->edit = new stdclass(); -$config->zahost->edit->requiredFields = 'name,hostType,cpu,memory,disk,virtualSoftware'; +$config->zahost->edit->requiredFields = 'name,hostType,cpuCores,memory,diskSize,vsoft'; $config->zahost->imageListUrl = 'https://pkg.qucheng.com/zenagent/list.json'; -$config->zahost->createtemplate = new stdclass(); -$config->zahost->createtemplate->requiredFields = 'name,cpuCoreNum,memorySize,disk,osCategory,osType,osVersion,osLang,imageName'; - -$config->zahost->edittemplate = new stdclass(); -$config->zahost->edittemplate->requiredFields = 'name,cpuCoreNum,memorySize,disk,osCategory,osType,osVersion,osLang,imageName'; - -$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'; $config->zahost->cpuCoreList = [1 => 1, 2 => 2, 4 => 4, 6 => 6, 8 => 8, 10 => 10, 12 => 12, 16 => 16, 24 => 24, 32 => 32, 64 => 64]; global $lang; @@ -37,11 +17,11 @@ $config->zahost->search['module'] = 'zahost'; $config->zahost->search['fields']['name'] = $lang->zahost->name; $config->zahost->search['fields']['id'] = $lang->zahost->id; $config->zahost->search['fields']['type'] = $lang->zahost->type; -$config->zahost->search['fields']['address'] = $lang->zahost->IP; -$config->zahost->search['fields']['cpu'] = $lang->zahost->cpu; +$config->zahost->search['fields']['extranet'] = $lang->zahost->IP; +$config->zahost->search['fields']['cpuCores'] = $lang->zahost->cpuCores; $config->zahost->search['fields']['memory'] = $lang->zahost->memory; -$config->zahost->search['fields']['disk'] = $lang->zahost->disk; -$config->zahost->search['fields']['virtualSoftware'] = $lang->zahost->virtualSoftware; +$config->zahost->search['fields']['diskSize'] = $lang->zahost->diskSize; +$config->zahost->search['fields']['vsoft'] = $lang->zahost->vsoft; $config->zahost->search['fields']['status'] = $lang->zahost->status; $config->zahost->search['fields']['createdBy'] = $lang->zahost->createdBy; $config->zahost->search['fields']['createdDate'] = $lang->zahost->createdDate; @@ -52,11 +32,11 @@ $config->zahost->search['fields']['editedDate'] = $lang->zahost->editedDate $config->zahost->search['params']['name'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); $config->zahost->search['params']['id'] = array('operator' => '=', 'control' => 'input', 'values' => ''); $config->zahost->search['params']['type'] = array('operator' => '=', 'control' => 'input', 'values' => $lang->zahost->zaHostType); -$config->zahost->search['params']['address'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); -$config->zahost->search['params']['cpu'] = array('operator' => '=', 'control' => 'input', 'values' => ''); +$config->zahost->search['params']['extranet'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); +$config->zahost->search['params']['cpuCores'] = array('operator' => '=', 'control' => 'input', 'values' => ''); $config->zahost->search['params']['memory'] = array('operator' => '=', 'control' => 'input', 'values' => ''); -$config->zahost->search['params']['disk'] = array('operator' => '=', 'control' => 'input', 'values' => ''); -$config->zahost->search['params']['virtualSoftware'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); +$config->zahost->search['params']['diskSize'] = array('operator' => '=', 'control' => 'input', 'values' => ''); +$config->zahost->search['params']['vsoft'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); $config->zahost->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => $lang->zahost->statusList); $config->zahost->search['params']['instanceNum'] = array('operator' => '=', 'control' => 'input', 'values' => ''); $config->zahost->search['params']['createdBy'] = array('operator' => '=', 'control' => 'select', 'values' => 'users'); @@ -68,62 +48,3 @@ $config->zahost->search['params']['editedDate'] = array('operator' => '=', $config->zahost->editor = new stdclass(); $config->zahost->editor->create = array('id' => 'desc', 'tools' => 'simpleTools'); $config->zahost->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools'); - -$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->cpu; -$config->vmTemplate->search['fields']['memorySize'] = $lang->zahost->memory; -$config->vmTemplate->search['fields']['disk'] = $lang->zahost->disk; -$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']['disk'] = 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); diff --git a/module/zahost/control.php b/module/zahost/control.php index 309d8d7b43..cc5f1df70d 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -23,7 +23,7 @@ class zahost extends control * @access public * @return void */ - public function browse($browseType = 'all', $param = 0, $orderBy = 't1.id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function browse($browseType = 'all', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { $browseType = strtolower($browseType); $param = (int)$param; @@ -67,7 +67,7 @@ class zahost extends control $this->view->zahost = $this->zahost->getById($id); $this->view->orderBy = $orderBy; - $this->view->nodeList = $this->loadModel("executionnode")->getListByHost($this->view->zahost->hostID, $orderBy); + $this->view->nodeList = $this->loadModel("executionnode")->getListByHost($this->view->zahost->parent, $orderBy); $this->view->actions = $this->loadModel('action')->getList('zahost', $id); $this->display(); } @@ -140,7 +140,7 @@ class zahost extends control return print(js::confirm($this->lang->zahost->confirmDelete, inlink('delete', "assetID=$assetID&confirm=yes"))); } - $this->dao->update(TABLE_ASSET)->set('deleted')->eq(1)->where('id')->eq($assetID)->exec(); + $this->dao->update(TABLE_ZAHOST)->set('deleted')->eq(1)->where('id')->eq($assetID)->exec(); $this->loadModel('action')->create('zahost', $assetID, 'deleted'); /* if ajax request, send result. */ @@ -262,140 +262,6 @@ class zahost extends control return $this->send(array('result' => 'success', 'message' => '', 'data' => $statusList)); } - /** - * Create template. - * - * @access public - * @return void - */ - public function createTemplate($hostID) - { - $host = $this->zahost->getById($hostID); - if($_POST) - { - $this->zahost->createTemplate($host); - if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inLink('browseTemplate', "id={$hostID}"))); - } - - $this->view->imageOptions = array('' => $this->lang->zahost->notice->loading); - $this->view->host = $host; - $this->display(); - } - - /** - * Edit template - * - * @param int $templateID - * @access public - * @return void - */ - public function editTemplate($templateID) - { - $template = $this->zahost->getTemplateById($templateID); - if($_POST) - { - $changes = $this->zahost->updateTemplate($templateID); - if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - - if($changes) - { - $actionID = $this->loadModel('action')->create('vmtemplate', $templateID, 'Edited'); - if(!empty($changes)) $this->action->logHistory($actionID, $changes); - } - - if(isonlybody()) $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent')); - - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browsetemplate', "hostID={$template->hostID}"))); - } - - $this->view->title = $this->lang->zahost->edit; - $this->view->template = $template; - $this->view->imageOptions = array('' => $this->lang->zahost->notice->loading); - $this->display(); - } - - /** - * Delete host. - * - * @param int $templateID - * @param string $confirm - * @access public - * @return void - */ - public function deleteTemplate($templateID, $confirm = 'no') - { - if($confirm == 'no') - { - return print(js::confirm($this->lang->zahost->confirmDeleteVMTemplate, inlink('deleteTemplate', "templateID=$templateID&confirm=yes"))); - } - - $template = $this->zahost->getTemplateById($templateID); - $this->dao->delete()->from(TABLE_VMTEMPLATE)->where('id')->eq($templateID)->exec(); - $this->loadModel('action')->create('vmtemplate', $templateID, 'deleted'); - - /* if ajax request, send result. */ - if($this->server->ajax) - { - if(dao::isError()) - { - $response['result'] = 'fail'; - $response['message'] = dao::getError(); - } - else - { - $response['result'] = 'success'; - $response['message'] = ''; - } - $this->send($response); - } - - if(isonlybody()) return print(js::reload('parent.parent')); - return print(js::locate($this->createLink('zahost', 'browsetemplate', "hostID={$template->hostID}"), 'parent')); - } - - /* - * Browse VM template. - * - * @param int $hostID - * @param string $browseType - * @param string $param - * @param string $orderBy - * @param int $recTotal - * @param int $recPerPage - * @param int $pageID - * @access public - * @return void - */ - public function browseTemplate($hostID, $browseType = 'all', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) - { - $browseType = strtolower($browseType); - $this->app->loadClass('pager', true); - - $queryID = ($browseType == 'bysearch') ? (int)$param : 0; - $pager = pager::init($recTotal, $recPerPage, $pageID); - $templateList = $this->zahost->getVMTemplateList($hostID, $browseType, $queryID, $orderBy, $pager); - - /* Build the search form. */ - $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'); - $this->view->templateList = $templateList; - $this->view->hostID = $hostID; - $this->view->pager = $pager; - $this->view->param = $param; - $this->view->orderBy = $orderBy; - $this->view->browseType = $browseType; - - $this->display(); - } - /** * Check IP format and generate secret. * diff --git a/module/zahost/css/browse.css b/module/zahost/css/browse.css index 829d9f09ca..f1eb7f176d 100644 --- a/module/zahost/css/browse.css +++ b/module/zahost/css/browse.css @@ -1,3 +1,3 @@ .c-ip {width: 100px;} -.c-memory, .c-disk, .c-status, .c-cpu, .c-software, .c-instanceNum {width: 90px;} +.c-memory, .c-diskSize, .c-status, .c-cpuCores, .c-software, .c-instanceNum {width: 90px;} .c-datetime {width: 150px;} diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index 3678f9d7fa..b0dea50896 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -18,10 +18,10 @@ $lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Name'; $lang->zahost->IP = 'IP/Domain'; -$lang->zahost->address = 'IP'; -$lang->zahost->cpu = 'CPU Cores'; +$lang->zahost->extranet = 'IP'; +$lang->zahost->cpuCores = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; -$lang->zahost->disk = 'Disk Size'; +$lang->zahost->diskSize = 'diskSize Size'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -33,7 +33,7 @@ $lang->zahost->editedDate = 'EditedDate'; $lang->zahost->registerDate = 'RegisterDate'; $lang->zahost->memorySize = $lang->zahost->memory; -$lang->zahost->cpuCoreNum = $lang->zahost->cpu; +$lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; $lang->zahost->osType = 'Os Version'; $lang->zahost->osCategory = 'System'; $lang->zahost->osVersion = 'Os Version No'; @@ -74,7 +74,7 @@ $lang->zahost->image->common = 'Image'; $lang->zahost->image->name = 'Name'; $lang->zahost->image->desc = 'Description'; $lang->zahost->image->memory = $lang->zahost->memory; -$lang->zahost->image->disk = $lang->zahost->disk; +$lang->zahost->image->diskSize = $lang->zahost->diskSize; $lang->zahost->image->osType = $lang->zahost->osType; $lang->zahost->image->osCategory = $lang->zahost->osCategory; $lang->zahost->image->osVersion = $lang->zahost->osVersion; @@ -90,9 +90,9 @@ $lang->zahost->image->statusList['failed'] = 'Failed'; $lang->zahost->vmTemplate = new stdclass; $lang->zahost->vmTemplate->name = 'Name'; $lang->zahost->vmTemplate->common = 'VM Template'; -$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpu; +$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpuCores; $lang->zahost->vmTemplate->memorySize = $lang->zahost->memory; -$lang->zahost->vmTemplate->diskSize = $lang->zahost->disk; +$lang->zahost->vmTemplate->diskSizeSize = $lang->zahost->diskSize; $lang->zahost->vmTemplate->osType = $lang->zahost->osType; $lang->zahost->vmTemplate->osCategory = $lang->zahost->osCategory; $lang->zahost->vmTemplate->osVersion = $lang->zahost->osVersion; @@ -110,7 +110,7 @@ $lang->zahost->templateEmpty = 'No Template'; $lang->zahost->statusList['ready'] = 'Ready'; $lang->zahost->statusList['online'] = 'Online'; -$lang->zahost->virtualSoftware = 'VM Software'; +$lang->zahost->vsoft = 'VM Software'; $lang->zahost->softwareList['kvm'] = 'KVM'; $lang->zahost->unitList['GB'] = 'GB'; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index b54a05a3f1..62bd1f78ff 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -17,11 +17,11 @@ $lang->zahost->editTemplate = 'Edit Template'; $lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Name'; -$lang->zahost->IP = 'IP/Domain'; -$lang->zahost->address = 'IP/Domain'; -$lang->zahost->cpu = 'CPU Cores'; +$lang->zahost->IP = 'Extranet Address'; +$lang->zahost->extranet = 'Extranet Address'; +$lang->zahost->cpuCores = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; -$lang->zahost->disk = 'Disk Size'; +$lang->zahost->diskSize = 'diskSize Size'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -74,7 +74,7 @@ $lang->zahost->image->common = 'Image'; $lang->zahost->image->name = 'Name'; $lang->zahost->image->desc = 'Description'; $lang->zahost->image->memory = $lang->zahost->memory; -$lang->zahost->image->disk = $lang->zahost->disk; +$lang->zahost->image->diskSize = $lang->zahost->diskSize; $lang->zahost->image->osType = $lang->zahost->osType; $lang->zahost->image->osCategory = $lang->zahost->osCategory; $lang->zahost->image->osVersion = $lang->zahost->osVersion; @@ -87,18 +87,6 @@ $lang->zahost->image->statusList['inprogress'] = 'Inprogress'; $lang->zahost->image->statusList['completed'] = 'Completed'; $lang->zahost->image->statusList['failed'] = 'Failed'; -$lang->zahost->vmTemplate = new stdclass; -$lang->zahost->vmTemplate->name = 'Name'; -$lang->zahost->vmTemplate->common = 'VM Template'; -$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpu ; -$lang->zahost->vmTemplate->memorySize = $lang->zahost->memory; -$lang->zahost->vmTemplate->diskSize = $lang->zahost->disk; -$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->imageName = $lang->zahost->imageName; - $lang->zahost->langList = array(); $lang->zahost->langList['zh_cn'] = 'Simplified Chinese'; $lang->zahost->langList['zh_tw'] = 'Traditional Chinese'; @@ -110,7 +98,7 @@ $lang->zahost->templateEmpty = 'No Template'; $lang->zahost->statusList['ready'] = 'Ready'; $lang->zahost->statusList['online'] = 'Online'; -$lang->zahost->virtualSoftware = 'VM Software'; +$lang->zahost->vsoft = 'VM Software'; $lang->zahost->softwareList['kvm'] = 'KVM'; $lang->zahost->unitList['GB'] = 'GB'; @@ -122,34 +110,6 @@ $lang->zahost->zaHostTypeList['physical'] = 'Physical'; $lang->zahost->confirmDelete = 'Do you want to delete this host?'; $lang->zahost->confirmDeleteVMTemplate = 'Do you want to delete this VM template?'; -$lang->zahost->versionList = array(); -$lang->zahost->versionList['winxp']['all'] = 'Windows XP'; -$lang->zahost->versionList['win7']['home'] = 'Home Basic'; -$lang->zahost->versionList['win7']['professional'] = 'Professional'; -$lang->zahost->versionList['win7']['enterprise'] = 'Enterprise'; -$lang->zahost->versionList['win7']['ultimate'] = 'Ultimate'; -$lang->zahost->versionList['win10']['home'] = 'Home Basic'; -$lang->zahost->versionList['win10']['professional'] = 'Professional'; -$lang->zahost->versionList['win10']['enterprise'] = 'Enterprise'; -$lang->zahost->versionList['win10']['ultimate'] = 'Ultimate'; -$lang->zahost->versionList['win11']['home'] = 'Home Basic'; -$lang->zahost->versionList['win11']['professional'] = 'Professional'; -$lang->zahost->versionList['win11']['enterprise'] = 'Enterprise'; -$lang->zahost->versionList['win11']['ultimate'] = '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』incorrect format!'; $lang->zahost->notice->registerCommand = 'Register command: ./zagent-host -t host -s http://%s:%s -i %s -p 8086 -secret %s'; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index 7a7a6f2134..02ed9f299d 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -21,7 +21,7 @@ $lang->zahost->IP = 'IP/Domain'; $lang->zahost->address = 'IP'; $lang->zahost->cpu = 'CPU Cores'; $lang->zahost->memory = 'Mémoire Espace'; -$lang->zahost->disk = 'Disque Espace'; +$lang->zahost->diskSize = 'Disque Espace'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -74,7 +74,7 @@ $lang->zahost->image->common = 'Image'; $lang->zahost->image->name = 'Name'; $lang->zahost->image->desc = 'Description'; $lang->zahost->image->memory = $lang->zahost->memory; -$lang->zahost->image->disk = $lang->zahost->disk; +$lang->zahost->image->diskSize = $lang->zahost->diskSize; $lang->zahost->image->osType = $lang->zahost->osType; $lang->zahost->image->osCategory = $lang->zahost->osCategory; $lang->zahost->image->osVersion = $lang->zahost->osVersion; @@ -92,7 +92,7 @@ $lang->zahost->vmTemplate->name = 'Nom'; $lang->zahost->vmTemplate->common = 'VM Template'; $lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpu ; $lang->zahost->vmTemplate->memorySize = $lang->zahost->memory; -$lang->zahost->vmTemplate->diskSize = $lang->zahost->disk; +$lang->zahost->vmTemplate->diskSizeSize = $lang->zahost->diskSize; $lang->zahost->vmTemplate->osType = $lang->zahost->osType; $lang->zahost->vmTemplate->osCategory = $lang->zahost->osCategory; $lang->zahost->vmTemplate->osVersion = $lang->zahost->osVersion; @@ -110,7 +110,7 @@ $lang->zahost->templateEmpty = 'No Template'; $lang->zahost->statusList['ready'] = 'Ready'; $lang->zahost->statusList['online'] = 'Online'; -$lang->zahost->virtualSoftware = 'VM Software'; +$lang->zahost->vsoft = 'VM Software'; $lang->zahost->softwareList['kvm'] = 'KVM'; $lang->zahost->unitList['GB'] = 'GB'; diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php index 86674d4f0c..d6f82c1199 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -21,7 +21,7 @@ $lang->zahost->IP = 'IP/Domain'; $lang->zahost->address = 'IP'; $lang->zahost->cpu = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; -$lang->zahost->disk = 'Disk Size'; +$lang->zahost->diskSize = 'diskSize Size'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -74,7 +74,7 @@ $lang->zahost->image->common = 'Image'; $lang->zahost->image->name = 'Name'; $lang->zahost->image->desc = 'Description'; $lang->zahost->image->memory = $lang->zahost->memory; -$lang->zahost->image->disk = $lang->zahost->disk; +$lang->zahost->image->diskSize = $lang->zahost->diskSize; $lang->zahost->image->osType = $lang->zahost->osType; $lang->zahost->image->osCategory = $lang->zahost->osCategory; $lang->zahost->image->osVersion = $lang->zahost->osVersion; @@ -92,7 +92,7 @@ $lang->zahost->vmTemplate->name = 'Name'; $lang->zahost->vmTemplate->common = 'VM Template'; $lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpu ; $lang->zahost->vmTemplate->memorySize = $lang->zahost->memory; -$lang->zahost->vmTemplate->diskSize = $lang->zahost->disk; +$lang->zahost->vmTemplate->diskSizeSize = $lang->zahost->diskSize; $lang->zahost->vmTemplate->osType = $lang->zahost->osType; $lang->zahost->vmTemplate->osCategory = $lang->zahost->osCategory; $lang->zahost->vmTemplate->osVersion = $lang->zahost->osVersion; @@ -110,7 +110,7 @@ $lang->zahost->langList['en_us'] = 'American English'; $lang->zahost->statusList['ready'] = 'Ready'; $lang->zahost->statusList['online'] = 'Online'; -$lang->zahost->virtualSoftware = 'VM Software'; +$lang->zahost->vsoft = 'VM Software'; $lang->zahost->softwareList['kvm'] = 'KVM'; $lang->zahost->unitList['GB'] = 'GB'; diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index d33729a7fd..0089b90df8 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -22,7 +22,7 @@ $lang->zahost->IP = 'IP/域名'; $lang->zahost->address = 'IP/域名'; $lang->zahost->memory = '内存'; $lang->zahost->cpu = 'CPU核心数'; -$lang->zahost->disk = '硬盘容量'; +$lang->zahost->diskSize = '硬盘容量'; $lang->zahost->desc = '描述'; $lang->zahost->type = '类型'; $lang->zahost->status = '状态'; @@ -76,7 +76,7 @@ $lang->zahost->image->common = '镜像'; $lang->zahost->image->name = '名称'; $lang->zahost->image->desc = '说明'; $lang->zahost->image->memory = $lang->zahost->memory; -$lang->zahost->image->disk = $lang->zahost->disk; +$lang->zahost->image->diskSize = $lang->zahost->diskSize; $lang->zahost->image->osType = $lang->zahost->osType; $lang->zahost->image->osCategory = $lang->zahost->osCategory; $lang->zahost->image->osVersion = $lang->zahost->osVersion; @@ -98,7 +98,7 @@ $lang->zahost->vmTemplate->name = '名称'; $lang->zahost->vmTemplate->common = '虚拟机模板'; $lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpu ; $lang->zahost->vmTemplate->memorySize = $lang->zahost->memory; -$lang->zahost->vmTemplate->diskSize = $lang->zahost->disk; +$lang->zahost->vmTemplate->diskSizeSize = $lang->zahost->diskSize; $lang->zahost->vmTemplate->osType = $lang->zahost->osType; $lang->zahost->vmTemplate->osCategory = $lang->zahost->osCategory; $lang->zahost->vmTemplate->osVersion = $lang->zahost->osVersion; @@ -116,7 +116,7 @@ $lang->zahost->templateEmpty = '暂时没有模板'; $lang->zahost->statusList['ready'] = '准备中'; $lang->zahost->statusList['online'] = '已上架'; -$lang->zahost->virtualSoftware = '虚拟化软件'; +$lang->zahost->vsoft = '虚拟化软件'; $lang->zahost->softwareList['kvm'] = 'KVM'; $lang->zahost->unitList['GB'] = 'GB'; diff --git a/module/zahost/model.php b/module/zahost/model.php index cbce05d9d4..b63471ff0e 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -21,7 +21,6 @@ class zahostModel extends model { parent::__construct(); $this->app->lang->host = $this->lang->zahost; - $this->app->lang->vmtemplate = $this->lang->zahost; } /** @@ -33,32 +32,23 @@ class zahostModel extends model public function create() { $hostInfo = fixer::input('post') - ->setDefault('cpuNumber,cpu,disk,memory', 0) + ->setDefault('cpuNumber,cpuCores,diskSize,memory', 0) ->get(); - $this->dao->table = 'zahost'; + $this->dao->table = 'zahost'; + $hostInfo->type = 'zahost'; + $hostInfo->createdBy = $this->app->user->account; + $hostInfo->createdDate = helper::now(); + $this->dao->update(TABLE_ZAHOST)->data($hostInfo) ->batchCheck($this->config->zahost->create->requiredFields, 'notempty') - ->batchCheck('cpu,disk', 'gt', 0) - ->batchCheck('disk,memory', 'float') + ->batchCheck('cpuCores,diskSize', 'gt', 0) + ->batchCheck('diskSize,memory', 'float') + ->check('name', 'unique') ->autoCheck(); if(dao::isError()) 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(); + $this->dao->insert(TABLE_ZAHOST)->data($hostInfo)->autoCheck()->exec(); $hostID = $this->dao->lastInsertID(); if(!dao::isError()) { @@ -78,93 +68,23 @@ class zahostModel extends model */ public function update($hostID) { - $oldHost = $this->getById($hostID); - $hostInfo = fixer::input('post')->get(); + $oldHost = $this->getById($hostID); + $hostInfo = fixer::input('post')->get(); + $hostInfo->editedBy = $this->app->user->account; + $hostInfo->editedDate = helper::now(); $this->dao->update(TABLE_ZAHOST)->data($hostInfo) ->batchCheck($this->config->zahost->create->requiredFields, 'notempty') - ->batchCheck('disk,memory', 'float'); - if(dao::isError()) return false; - - $assetInfo['name'] = $hostInfo->name; - $assetInfo['editedBy'] = $this->app->user->account; - $assetInfo['editedDate'] = helper::now(); - - $this->dao->update(TABLE_ASSET)->data($assetInfo)->autoCheck() - ->batchCheck($this->config->zahost->edit->requiredFields, 'notempty') - ->where('id')->eq($oldHost->id) - ->exec(); + ->batchCheck('diskSize,memory', 'float'); if(dao::isError()) return false; $this->dao->update(TABLE_ZAHOST)->data($hostInfo, 'name')->autoCheck() - ->batchCheck('cpu,disk', 'gt', 0) - ->batchCheck('disk,memory', 'float') + ->batchCheck('cpuCores,diskSize', 'gt', 0) + ->batchCheck('diskSize,memory', 'float') ->where('id')->eq($hostID)->exec(); return common::createChanges($oldHost, $hostInfo); } - /** - * Create vm template. - * - * @param object $host - * @access public - * @return void - */ - public function createTemplate($host) - { - $template = fixer::input('post') - ->setIF($this->post->disk > 0, 'disk', $this->post->disk * 1024) - ->setDefault('imageName', '') - ->get(); - - $this->dao->insert(TABLE_VMTEMPLATE)->data($template) - ->batchCheck($this->config->zahost->createtemplate->requiredFields, 'notempty') - ->batchCheck('cpuCoreNum,disk,memorySize', 'gt', 0) - ->autoCheck(); - if(dao::isError()) return false; - - $template->hostID = $host->hostID; - $template->createdBy = $this->app->user->account; - $template->createdDate = helper::now(); - - $this->dao->insert(TABLE_VMTEMPLATE)->data($template) ->autoCheck()->exec(); - if(dao::isError()) return false; - - $templateID = $this->dao->lastInsertID(); - $this->loadModel('action')->create('vmtemplate', $templateID, 'Created'); - } - - /** - * Edit template - * - * @param int $templateID - * @access public - * @return bool|object - */ - public function updateTemplate($templateID) - { - $oldHost = $this->getTemplateById($templateID); - $templateInfo = fixer::input('post') - ->setIF($this->post->disk > 0, 'disk', $this->post->disk * 1024) - ->get(); - - $this->dao->update(TABLE_VMTEMPLATE)->data($templateInfo) - ->batchCheck($this->config->zahost->edittemplate->requiredFields, 'notempty') - ->batchCheck('cpuCoreNum,disk,memorySize', 'gt', 0) - ->autoCheck(); - if(dao::isError()) return false; - - $templateInfo->editedBy = $this->app->user->account; - $templateInfo->editedDate = helper::now(); - - $this->dao->update(TABLE_VMTEMPLATE)->data($templateInfo)->autoCheck() - ->where('id')->eq($oldHost->id) - ->exec(); - if(dao::isError()) return false; - - return common::createChanges($oldHost, $templateInfo); - } - /** * Get image by ID. * @@ -365,9 +285,8 @@ class zahostModel extends model */ public function getById($hostID) { - return $this->dao->select('*,t1.id as hostID,t2.id as id')->from(TABLE_ZAHOST)->alias('t1') - ->leftJoin(TABLE_ASSET)->alias('t2')->on('t1.assetID = t2.id') - ->where('t1.id')->eq($hostID) + return $this->dao->select('*,id as hostID')->from(TABLE_ZAHOST) + ->where('id')->eq($hostID) ->fetch(); } @@ -378,12 +297,11 @@ class zahostModel extends model * @access public * @return array */ - public function getPairs($idForm = 'asset') + public function getPairs() { - $field = $idForm == 'asset' ? 't1.id' : 't2.id'; - return $this->dao->select("$field,t1.name")->from(TABLE_ASSET)->alias('t1') - ->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t1.id = t2.assetID') - ->where('t1.deleted')->eq('0') + return $this->dao->select("id,name")->from(TABLE_ZAHOST) + ->where('deleted')->eq('0') + ->andWhere('type')->eq('zahost') ->orderBy('`group`') ->fetchPairs('id', 'name'); } @@ -398,7 +316,7 @@ class zahostModel extends model * @access public * @return array */ - public function getList($browseType = 'all', $param = 0, $orderBy = 't1.id_desc', $pager = null) + public function getList($browseType = 'all', $param = 0, $orderBy = 'id_desc', $pager = null) { $query = ''; if($browseType == 'bysearch') @@ -422,15 +340,11 @@ class zahostModel extends model if($this->session->zahostQuery == false) $this->session->set('zahostQuery', ' 1 = 1'); } $query = $this->session->zahostQuery; - $query = str_replace('`id`', 't1.`id`', $query); - $query = str_replace('`status`', 't2.`status`', $query); - $query = str_replace('`type`', 't2.`type`', $query); } - return $this->dao->select('*,t2.id as hostID,t1.id as id')->from(TABLE_ASSET)->alias('t1') - ->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t1.id = t2.assetID') - ->where('t1.deleted')->eq('0') - ->andWhere('t1.type')->eq('zahost') + return $this->dao->select('*,id as hostID')->from(TABLE_ZAHOST) + ->where('deleted')->eq('0') + ->andWhere('type')->eq('zahost') ->beginIF($query)->andWhere($query)->fi() ->orderBy($orderBy) ->page($pager) @@ -473,62 +387,6 @@ class zahostModel extends model return $menu; } - /** - * Get VM template list. - * - * @param int $hostID - * @param string $browseType - * @param int $param - * @param string $orderBy - * @param int $pager - * @access public - * @return array - */ - public function getVmTemplateList($hostID, $browseType = 'all', $param = 0, $orderBy = 'id_desc', $pager = null) - { - $query = ''; - if($browseType == 'bysearch') - { - /* Concatenate the conditions for the query. */ - if($param) - { - $query = $this->loadModel('search')->getQuery($param); - if($query) - { - $this->session->set('vmTemplateQuery', $query->sql); - $this->session->set('vmTemplateForm', $query->form); - } - else - { - $this->session->set('vmTemplateQuery', ' 1 = 1'); - } - } - else - { - if($this->session->vmTemplateQuery == false) $this->session->set('vmTemplateQuery', ' 1 = 1'); - } - $query = $this->session->vmTemplateQuery; - } - - $templateList = $this->dao->select('*')->from(TABLE_VMTEMPLATE) - ->where('hostID')->eq($hostID) - ->beginIF($query)->andWhere($query)->fi() - ->orderBy($orderBy) - ->page($pager) - ->fetchAll(); - - foreach($templateList as $template) - { - $template->unit = zget($this->lang->zahost->unitList, 'MB'); - if($template->disk > 1024) - { - $template->disk = round($template->disk / 1024); - $template->unit = zget($this->lang->zahost->unitList, 'GB'); - } - } - return $templateList; - } - /** * Get image pairs by host. * @@ -541,30 +399,6 @@ class zahostModel extends model return $this->dao->select('id,name')->from(TABLE_IMAGE)->where('hostID')->eq($hostID)->andWhere('status')->eq('completed')->fetchPairs(); } - /** - * Get template pairs by host. - * - * @param int $hostID - * @access public - * @return array - */ - public function getTemplatePairs($hostID) - { - return $this->dao->select('id,name')->from(TABLE_VMTEMPLATE)->where('hostID')->eq($hostID)->fetchPairs(); - } - - /** - * Get template by id. - * - * @param int $templateID - * @access public - * @return object - */ - public function getTemplateByID($templateID) - { - return $this->dao->select('*')->from(TABLE_VMTEMPLATE)->where('id')->eq($templateID)->fetch(); - } - /** * Get service status from ZAgent server. * diff --git a/module/zahost/view/browse.html.php b/module/zahost/view/browse.html.php index 49e6900eab..e39c342071 100644 --- a/module/zahost/view/browse.html.php +++ b/module/zahost/view/browse.html.php @@ -42,14 +42,14 @@
idAB);?> idAB);?> zahost->name);?> zahost->type);?> zahost->IP);?> zahost->cpu );?> zahost->type);?> zahost->IP);?> zahost->cpu );?> zahost->memory);?> zahost->disk);?> zahost->virtualSoftware);?> zahost->diskSize);?> zahost->vsoft);?> zahost->status);?> zahost->registerDate);?> actions;?>address;?> cpu;?> memory . $lang->zahost->unitList['GB'];?>disk . zget($lang->zahost->unitList, $host->unit);?>virtualSoftware;?>diskSize . zget($lang->zahost->unitList, $host->unit);?>vsoft;?> host->statusList, $host->status);?> registerDate) ? '' : $host->registerDate;?> diff --git a/module/zahost/view/browsetemplate.html.php b/module/zahost/view/browsetemplate.html.php deleted file mode 100755 index 33410c8553..0000000000 --- a/module/zahost/view/browsetemplate.html.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @package zahost - * @version $Id$ - * @link http://www.zentao.net - */ -?> - - -
' data-module='vmTemplate'>
-
- recTotal}&recPerPage={$pager->recPerPage}";?> - -
-

- zahost->templateEmpty;?> - ' . $lang->zahost->createTemplate, '', 'class="btn btn-info"');?> -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
idAB);?>zahost->name);?>zahost->cpuCoreNum);?>zahost->memory);?>zahost->disk);?>zahost->osCategory);?>zahost->osType);?>zahost->osVersion);?>zahost->osLang);?>actions;?>
id;?>name;?>cpuCoreNum;?>memorySize . zget($this->lang->zahost->unitList, 'GB');?>diskSize . $template->unit;?>zahost->os->list, $template->osCategory);?>zahost->os->type[$template->osCategory], $template->osType);?>zahost->versionList[$template->osType], $template->osVersion);?>zahost->langList, $template->osLang);?> - id}", $template, 'list', 'edit');?> - createLink('zahost', 'deleteTemplate', "id={$template->id}"), '', 'hiddenwin', "title='{$lang->zahost->delete}' class='btn'");?> -
- - -
-getModuleRoot() . 'common/view/footer.html.php';?> diff --git a/module/zahost/view/create.html.php b/module/zahost/view/create.html.php index e52016eded..926c6f6169 100644 --- a/module/zahost/view/create.html.php +++ b/module/zahost/view/create.html.php @@ -21,8 +21,8 @@
- - + + @@ -51,10 +51,10 @@ - + - - + + - + @@ -61,13 +61,13 @@ - - + + - + - - - - - + + + + + - + - - - + + + diff --git a/module/zanode/config.php b/module/zanode/config.php new file mode 100644 index 0000000000..9c66a2b533 --- /dev/null +++ b/module/zanode/config.php @@ -0,0 +1,44 @@ +zanode->create = new stdClass(); +$config->zanode->edit = new stdClass(); +$config->zanode->create->requiredFields = 'name,host,image,cpu,memory,disk,os'; +$config->zanode->edit->requiredFields = ''; + +$config->zanode->defaultPort = '8086'; + +$config->zanode->os = new stdClass(); + +$config->zanode->os->cpuCores = array(); +$config->zanode->os->cpuCores['1'] = '1'; +$config->zanode->os->cpuCores['2'] = '2'; +$config->zanode->os->cpuCores['4'] = '4'; +$config->zanode->os->cpuCores['6'] = '6'; +$config->zanode->os->cpuCores['8'] = '8'; +$config->zanode->os->cpuCores['12'] = '12'; +$config->zanode->os->cpuCores['16'] = '16'; +$config->zanode->os->cpuCores['24'] = '24'; +$config->zanode->os->cpuCores['32'] = '32'; +$config->zanode->os->cpuCores['64'] = '64'; + +global $lang; +$config->zanode->search['module'] = 'zanode'; +$config->zanode->search['fields']['name'] = $lang->zanode->name; +$config->zanode->search['fields']['osName'] = $lang->zanode->osName; +$config->zanode->search['fields']['host'] = $lang->zanode->hostName; +$config->zanode->search['fields']['status'] = $lang->zanode->status; +$config->zanode->search['fields']['cpuCores'] = $lang->zanode->cpuCores; +$config->zanode->search['fields']['memory'] = $lang->zanode->memory; +$config->zanode->search['fields']['diskSize'] = $lang->zanode->diskSize; +$config->zanode->search['fields']['mac'] = $lang->zanode->mac; +$config->zanode->search['fields']['address'] = $lang->zanode->ip; +$config->zanode->search['params']['name'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); +$config->zanode->search['params']['osName'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); +$config->zanode->search['params']['host'] = array('operator' => '=', 'control' => 'select', 'values' => ''); +$config->zanode->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $lang->zanode->statusList); +$config->zanode->search['params']['cpuCores'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $config->zanode->os->cpuCores); +$config->zanode->search['params']['memory'] = array('operator' => '=', 'control' => 'input', 'values' => ''); +$config->zanode->search['params']['diskSize'] = array('operator' => '=', 'control' => 'input', 'values' => ''); + +$config->zanode->editor = new stdclass(); +$config->zanode->editor->create = array('id' => 'desc', 'tools' => 'simpleTools'); +$config->zanode->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools'); diff --git a/module/executionnode/control.php b/module/zanode/control.php old mode 100755 new mode 100644 similarity index 77% rename from module/executionnode/control.php rename to module/zanode/control.php index a11e7f451d..a041089afe --- a/module/executionnode/control.php +++ b/module/zanode/control.php @@ -9,7 +9,7 @@ * @version $Id$ * @link http://www.zentao.net */ -class executionnode extends control +class zanode extends control { /** @@ -33,18 +33,18 @@ class executionnode extends control $queryID = ($browseType == 'bysearch') ? (int)$param : 0; $pager = pager::init($recTotal, $recPerPage, $pageID); - $nodeList = $this->executionnode->getListByQuery($browseType, $queryID, $orderBy, $pager); + $nodeList = $this->zanode->getListByQuery($browseType, $queryID, $orderBy, $pager); $hosts = $this->loadModel('zahost')->getPairs('host'); /* Build the search form. */ - $actionURL = $this->createLink('executionnode', 'browse', "browseType=bySearch&queryID=myQueryID"); - $this->config->executionnode->search['actionURL'] = $actionURL; - $this->config->executionnode->search['queryID'] = $queryID; - $this->config->executionnode->search['onMenuBar'] = 'no'; - $this->config->executionnode->search['params']['hostID']['values'] = array('' => '') + $hosts; - $this->loadModel('search')->setSearchParams($this->config->executionnode->search); + $actionURL = $this->createLink('zanode', 'browse', "browseType=bySearch&queryID=myQueryID"); + $this->config->zanode->search['actionURL'] = $actionURL; + $this->config->zanode->search['queryID'] = $queryID; + $this->config->zanode->search['onMenuBar'] = 'no'; + $this->config->zanode->search['params']['hostID']['values'] = array('' => '') + $hosts; + $this->loadModel('search')->setSearchParams($this->config->zanode->search); - $this->view->title = $this->lang->executionnode->common; + $this->view->title = $this->lang->zanode->common; $this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted'); $this->view->nodeList = $nodeList; $this->view->pager = $pager; @@ -66,12 +66,12 @@ class executionnode extends control { if(!empty($_POST)) { - $this->executionnode->create(); + $this->zanode->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->executionnode->create; + $this->view->title = $this->lang->zanode->create; $this->view->hostPairs = array('' => '') + $this->loadModel('zahost')->getPairs('host'); return $this->display(); @@ -86,9 +86,9 @@ class executionnode extends control */ public function view($id) { - $this->view->title = $this->lang->executionnode->view; - $this->view->node = $this->executionnode->getVMByID($id); - $this->view->actions = $this->loadModel('action')->getList('executionnode', $id); + $this->view->title = $this->lang->zanode->view; + $this->view->node = $this->zanode->getVMByID($id); + $this->view->actions = $this->loadModel('action')->getList('zanode', $id); $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->display(); @@ -139,7 +139,7 @@ class executionnode extends control */ public function handleVM($nodeID, $type) { - $error = $this->executionnode->handleVM($nodeID, $type); + $error = $this->zanode->handleVM($nodeID, $type); if($error) { @@ -147,7 +147,7 @@ class executionnode extends control } else { - return print(js::alert($this->lang->executionnode->actionSuccess) . js::reload('parent')); + return print(js::alert($this->lang->zanode->actionSuccess) . js::reload('parent')); } } @@ -159,7 +159,7 @@ class executionnode extends control */ public function destroy($nodeID) { - $error = $this->executionnode->destroy($nodeID); + $error = $this->zanode->destroy($nodeID); if($error) { @@ -167,8 +167,8 @@ class executionnode extends control } else { - if(isonlybody()) return print(js::alert($this->lang->executionnode->actionSuccess) . js::reload('parent.parent')); - return print(js::alert($this->lang->executionnode->actionSuccess) . js::reload('parent')); + if(isonlybody()) return print(js::alert($this->lang->zanode->actionSuccess) . js::reload('parent.parent')); + return print(js::alert($this->lang->zanode->actionSuccess) . js::reload('parent')); } } diff --git a/module/executionnode/css/browse.css b/module/zanode/css/browse.css similarity index 100% rename from module/executionnode/css/browse.css rename to module/zanode/css/browse.css diff --git a/module/executionnode/css/create.css b/module/zanode/css/create.css similarity index 100% rename from module/executionnode/css/create.css rename to module/zanode/css/create.css diff --git a/module/executionnode/js/browse.js b/module/zanode/js/browse.js old mode 100755 new mode 100644 similarity index 100% rename from module/executionnode/js/browse.js rename to module/zanode/js/browse.js diff --git a/module/executionnode/js/common.js b/module/zanode/js/common.js old mode 100755 new mode 100644 similarity index 83% rename from module/executionnode/js/common.js rename to module/zanode/js/common.js index 7491451e9a..5b47861cd4 --- a/module/executionnode/js/common.js +++ b/module/zanode/js/common.js @@ -5,7 +5,7 @@ $(function() $('#parent').change(function() { var hostID = $('#parent').val(); - var link = createLink('executionnode', 'ajaxGetImages', 'hostID=' + hostID); + var link = createLink('zanode', 'ajaxGetImages', 'hostID=' + hostID); $.get(link, function(data) { $('#template').html('').append(data); @@ -17,7 +17,7 @@ $(function() $(document).on("change", '#image', function() { var image = $('#image').val(); - var link = createLink('executionnode', 'ajaxGetImage', 'image=' + image); + var link = createLink('zanode', 'ajaxGetImage', 'image=' + image); $.get(link, function(data) { data = JSON.parse(data); diff --git a/module/zanode/lang/de.php b/module/zanode/lang/de.php new file mode 100644 index 0000000000..fc1e77afdb --- /dev/null +++ b/module/zanode/lang/de.php @@ -0,0 +1,60 @@ +zanode->common = 'Execution Node'; +$lang->zanode->browse = 'Execution Node List'; +$lang->zanode->create = 'Create Execution Node'; +$lang->zanode->view = 'View Execution Node'; +$lang->zanode->suspend = 'Suspend Execution Node'; +$lang->zanode->destroy = 'Destroy Execution Node'; +$lang->zanode->handleVM = 'Restart Execution Node'; +$lang->zanode->boot = 'Start Execution Node'; +$lang->zanode->reboot = 'Restart Execution Node'; +$lang->zanode->shutdown = 'Shutdown Execution Node'; +$lang->zanode->resume = 'Resume Execution Node'; +$lang->zanode->getVNC = 'Remote management'; +$lang->zanode->all = 'All'; +$lang->zanode->byQuery = 'Search'; +$lang->zanode->osName = 'System'; +$lang->zanode->image = 'VM Image'; +$lang->zanode->name = 'Name'; +$lang->zanode->start = 'Start After Created'; +$lang->zanode->hostName = 'Host Name'; +$lang->zanode->host = $lang->zanode->hostName; +$lang->zanode->ip = 'IP'; +$lang->zanode->osArch = 'Arch'; +$lang->zanode->cpuCores = 'CPU Cores'; +$lang->zanode->memory = 'Memory Size'; +$lang->zanode->desc = 'Description'; +$lang->zanode->diskSize = 'Disk Size'; +$lang->zanode->status = 'Status'; +$lang->zanode->mac = 'MAC'; +$lang->zanode->vnc = 'VNC Port'; +$lang->zanode->destroyAt = 'Destroy Time'; +$lang->zanode->creater = 'Creator'; +$lang->zanode->createdDate = 'Create Date'; +$lang->zanode->confirmDelete = "Are you sure about destroying the execution node?"; +$lang->zanode->confirmBoot = "Are you sure to start the execution node?"; +$lang->zanode->confirmReboot = "Are you sure to restart the execution node?"; +$lang->zanode->confirmShutdown = "Are you sure to shutdown the execution node?"; +$lang->zanode->confirmSuspend = "Are you sure to suspend the execution node?"; +$lang->zanode->confirmResume = "Are you sure to resume the execution node?"; +$lang->zanode->actionSuccess = 'Success'; + +$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 Execution Node'; + +$lang->zanode->apiError['-10100'] = 'Execution node not found.'; + +$lang->zanode->publicList[0] = 'Private'; +$lang->zanode->publicList[1] = 'Public'; + +$lang->zanode->statusList['created'] = 'Created'; +$lang->zanode->statusList['launch'] = 'Launch'; +$lang->zanode->statusList['ready'] = 'Ready'; +$lang->zanode->statusList['running'] = 'Running'; +$lang->zanode->statusList['suspend'] = 'Suspend'; +$lang->zanode->statusList['destroy'] = 'Destroyed'; +$lang->zanode->statusList['destroy_fail'] = 'Destroy Fail'; diff --git a/module/zanode/lang/en.php b/module/zanode/lang/en.php new file mode 100644 index 0000000000..9dad90038c --- /dev/null +++ b/module/zanode/lang/en.php @@ -0,0 +1,60 @@ +zanode->common = 'Execution Node'; +$lang->zanode->browse = 'Execution Node List'; +$lang->zanode->create = 'Create Execution Node'; +$lang->zanode->view = 'View Execution Node'; +$lang->zanode->suspend = 'Suspend Execution Node'; +$lang->zanode->destroy = 'Destroy Execution Node'; +$lang->zanode->handleVM = 'Restart Execution Node'; +$lang->zanode->boot = 'Start Execution Node'; +$lang->zanode->reboot = 'Restart Execution Node'; +$lang->zanode->shutdown = 'Shutdown Execution Node'; +$lang->zanode->resume = 'Resume Execution Node'; +$lang->zanode->getVNC = 'Remote management'; +$lang->zanode->all = 'All'; +$lang->zanode->byQuery = 'Search'; +$lang->zanode->osName = 'System'; +$lang->zanode->image = 'VM Image'; +$lang->zanode->name = 'Name'; +$lang->zanode->start = 'Start After Created'; +$lang->zanode->hostName = 'Host Name'; +$lang->zanode->host = $lang->zanode->hostName; +$lang->zanode->ip = 'IP'; +$lang->zanode->osArch = 'Arch'; +$lang->zanode->cpuCores = 'CPU Cores'; +$lang->zanode->memory = 'Memory Size'; +$lang->zanode->desc = 'Description'; +$lang->zanode->diskSize = 'Disk Size'; +$lang->zanode->status = 'Status'; +$lang->zanode->mac = 'MAC'; +$lang->zanode->vnc = 'VNC Port'; +$lang->zanode->destroyAt = 'Destroy Time'; +$lang->zanode->creater = 'Creator'; +$lang->zanode->createdDate = 'Create Date'; +$lang->zanode->confirmDelete = "Are you sure about destroying the execution node?"; +$lang->zanode->confirmBoot = "Are you sure to start the execution node?"; +$lang->zanode->confirmReboot = "Are you sure to restart the execution node?"; +$lang->zanode->confirmShutdown = "Are you sure to shutdown the execution node?"; +$lang->zanode->confirmSuspend = "Are you sure to suspend the execution node?"; +$lang->zanode->confirmResume = "Are you sure to resume the execution node?"; +$lang->zanode->actionSuccess = 'Success'; + +$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 Execution Node'; + +$lang->zanode->apiError['-10100'] = 'Execution node not found.'; + +$lang->zanode->publicList[0] = 'Private'; +$lang->zanode->publicList[1] = 'Public'; + +$lang->zanode->statusList['created'] = 'Created'; +$lang->zanode->statusList['launch'] = 'Launch'; +$lang->zanode->statusList['ready'] = 'Ready'; +$lang->zanode->statusList['running'] = 'Running'; +$lang->zanode->statusList['suspend'] = 'Suspend'; +$lang->zanode->statusList['destroy'] = 'Destroyed'; +$lang->zanode->statusList['destroy_fail'] = 'Destroy Fail'; diff --git a/module/zanode/lang/fr.php b/module/zanode/lang/fr.php new file mode 100644 index 0000000000..fc1e77afdb --- /dev/null +++ b/module/zanode/lang/fr.php @@ -0,0 +1,60 @@ +zanode->common = 'Execution Node'; +$lang->zanode->browse = 'Execution Node List'; +$lang->zanode->create = 'Create Execution Node'; +$lang->zanode->view = 'View Execution Node'; +$lang->zanode->suspend = 'Suspend Execution Node'; +$lang->zanode->destroy = 'Destroy Execution Node'; +$lang->zanode->handleVM = 'Restart Execution Node'; +$lang->zanode->boot = 'Start Execution Node'; +$lang->zanode->reboot = 'Restart Execution Node'; +$lang->zanode->shutdown = 'Shutdown Execution Node'; +$lang->zanode->resume = 'Resume Execution Node'; +$lang->zanode->getVNC = 'Remote management'; +$lang->zanode->all = 'All'; +$lang->zanode->byQuery = 'Search'; +$lang->zanode->osName = 'System'; +$lang->zanode->image = 'VM Image'; +$lang->zanode->name = 'Name'; +$lang->zanode->start = 'Start After Created'; +$lang->zanode->hostName = 'Host Name'; +$lang->zanode->host = $lang->zanode->hostName; +$lang->zanode->ip = 'IP'; +$lang->zanode->osArch = 'Arch'; +$lang->zanode->cpuCores = 'CPU Cores'; +$lang->zanode->memory = 'Memory Size'; +$lang->zanode->desc = 'Description'; +$lang->zanode->diskSize = 'Disk Size'; +$lang->zanode->status = 'Status'; +$lang->zanode->mac = 'MAC'; +$lang->zanode->vnc = 'VNC Port'; +$lang->zanode->destroyAt = 'Destroy Time'; +$lang->zanode->creater = 'Creator'; +$lang->zanode->createdDate = 'Create Date'; +$lang->zanode->confirmDelete = "Are you sure about destroying the execution node?"; +$lang->zanode->confirmBoot = "Are you sure to start the execution node?"; +$lang->zanode->confirmReboot = "Are you sure to restart the execution node?"; +$lang->zanode->confirmShutdown = "Are you sure to shutdown the execution node?"; +$lang->zanode->confirmSuspend = "Are you sure to suspend the execution node?"; +$lang->zanode->confirmResume = "Are you sure to resume the execution node?"; +$lang->zanode->actionSuccess = 'Success'; + +$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 Execution Node'; + +$lang->zanode->apiError['-10100'] = 'Execution node not found.'; + +$lang->zanode->publicList[0] = 'Private'; +$lang->zanode->publicList[1] = 'Public'; + +$lang->zanode->statusList['created'] = 'Created'; +$lang->zanode->statusList['launch'] = 'Launch'; +$lang->zanode->statusList['ready'] = 'Ready'; +$lang->zanode->statusList['running'] = 'Running'; +$lang->zanode->statusList['suspend'] = 'Suspend'; +$lang->zanode->statusList['destroy'] = 'Destroyed'; +$lang->zanode->statusList['destroy_fail'] = 'Destroy Fail'; diff --git a/module/zanode/lang/zh-cn.php b/module/zanode/lang/zh-cn.php new file mode 100644 index 0000000000..3a628171d0 --- /dev/null +++ b/module/zanode/lang/zh-cn.php @@ -0,0 +1,62 @@ +zanode->common = '执行节点'; +$lang->zanode->browse = '执行节点列表'; +$lang->zanode->create = '创建执行节点'; +$lang->zanode->view = '执行节点详情'; +$lang->zanode->suspend = '暂停执行节点'; +$lang->zanode->destroy = '销毁执行节点'; +$lang->zanode->handleVM = '重启执行节点'; +$lang->zanode->boot = '启动执行节点'; +$lang->zanode->reboot = '重启执行节点'; +$lang->zanode->shutdown = '关闭执行节点'; +$lang->zanode->resume = '恢复执行节点'; +$lang->zanode->getVNC = '远程管理'; +$lang->zanode->all = '全部'; +$lang->zanode->byQuery = '搜索'; +$lang->zanode->osName = '操作系统'; +$lang->zanode->image = '镜像'; +$lang->zanode->name = '执行节点名称'; +$lang->zanode->start = '创建后自动开启'; +$lang->zanode->hostName = '所属宿主机'; +$lang->zanode->host = $lang->zanode->hostName; +$lang->zanode->ip = 'IP/域名'; +$lang->zanode->osArch = '架构'; +$lang->zanode->cpuCores = 'CPU核心数'; +$lang->zanode->memory = '内存'; +$lang->zanode->diskSize = '硬盘'; +$lang->zanode->desc = '描述'; +$lang->zanode->status = '状态'; +$lang->zanode->mac = 'MAC地址'; +$lang->zanode->vnc = 'VNC端口'; +$lang->zanode->destroyAt = '销毁时间'; +$lang->zanode->creater = '创建人'; +$lang->zanode->createdDate = '创建日期'; +$lang->zanode->confirmDelete = "您确定销毁执行节点吗?"; +$lang->zanode->confirmBoot = "您确定启动执行节点吗?"; +$lang->zanode->confirmReboot = "您确定重启执行节点吗?"; +$lang->zanode->confirmShutdown = "您确定关闭执行节点吗?"; +$lang->zanode->confirmSuspend = "您确定暂停执行节点吗?"; +$lang->zanode->confirmResume = "您确定恢复执行节点吗?"; +$lang->zanode->actionSuccess = '操作成功'; + +$lang->zanode->notFoundAgent = '没有发现Agent服务'; +$lang->zanode->createVmFail = '创建执行节点失败'; +$lang->zanode->noVncPort = '无法获取执行节点端口'; +$lang->zanode->nameValid = "名称只能是字母、数字,'-','_','.',且不能以符号开头"; + +$lang->zanode->empty = '暂时没有执行节点'; + +$lang->zanode->apiError['-10100'] = '执行节点不存在'; + +$lang->zanode->publicList[0] = '不共享'; +$lang->zanode->publicList[1] = '共享'; + +$lang->zanode->statusList['created'] = '已创建'; +$lang->zanode->statusList['launch'] = '启动中'; +$lang->zanode->statusList['ready'] = '运行中'; +$lang->zanode->statusList['running'] = '运行中'; +$lang->zanode->statusList['suspend'] = '暂停'; +$lang->zanode->statusList['offline'] = '下线'; +$lang->zanode->statusList['destroy'] = '已销毁'; +$lang->zanode->statusList['destroy_fail'] = '销毁失败'; + diff --git a/module/executionnode/lang/zh-tw.php b/module/zanode/lang/zh-tw.php similarity index 100% rename from module/executionnode/lang/zh-tw.php rename to module/zanode/lang/zh-tw.php diff --git a/module/executionnode/model.php b/module/zanode/model.php old mode 100755 new mode 100644 similarity index 88% rename from module/executionnode/model.php rename to module/zanode/model.php index 6854bfb648..046cd07d91 --- a/module/executionnode/model.php +++ b/module/zanode/model.php @@ -9,7 +9,7 @@ * @version $Id$ * @link http://www.zentao.net */ -class executionnodemodel extends model +class zanodemodel extends model { const STATUS_CREATED = 'created'; @@ -39,16 +39,16 @@ class executionnodemodel extends model $data = fixer::input('post')->get(); /* Batch check fields. */ - $this->lang->vm = $this->lang->executionnode; + $this->lang->vm = $this->lang->zanode; $data->type = 'node'; $this->dao->update(TABLE_ZAHOST)->data($data) - ->batchCheck($this->config->executionnode->create->requiredFields, 'notempty') + ->batchCheck($this->config->zanode->create->requiredFields, 'notempty') ->check('name', 'unique'); if(dao::isError()) return false; if(!preg_match("/^(?!_)(?!-)(?!\.)[a-zA-Z0-9\_\.\-]+$/", $data->name)) { - dao::$errors[] = $this->lang->executionnode->nameValid; + dao::$errors[] = $this->lang->zanode->nameValid; return false; } @@ -62,7 +62,7 @@ class executionnodemodel extends model $mac = $this->genmac(); /* Prepare create params. */ - $agnetUrl = 'http://' . $host->extranet . ':' . $this->config->executionnode->defaultPort; + $agnetUrl = 'http://' . $host->extranet . ':' . $this->config->zanode->defaultPort; $param = array( 'os' => $image->os, 'path' => $image->path, @@ -76,12 +76,12 @@ class executionnodemodel extends model if(empty($result)) { - dao::$errors[] = $this->lang->executionnode->notFoundAgent; + dao::$errors[] = $this->lang->zanode->notFoundAgent; return false; } if($result->code != 'success') { - dao::$errors[] = $this->lang->executionnode->createVmFail; + dao::$errors[] = $this->lang->zanode->createVmFail; return false; } @@ -101,7 +101,7 @@ class executionnodemodel extends model $nodeID = $this->dao->lastInsertID(); /* update action log. */ - $this->loadModel('action')->create('executionnode', $nodeID, 'Created'); + $this->loadModel('action')->create('zanode', $nodeID, 'Created'); return true; } @@ -118,15 +118,15 @@ class executionnodemodel extends model $host = $this->getHostByID($node->parent); /* Prepare create params. */ - $agnetUrl = 'http://' . $host->extranet . ':' . $this->config->executionnode->defaultPort; + $agnetUrl = 'http://' . $host->extranet . ':' . $this->config->zanode->defaultPort; $path = '/api/v1/kvm/' . $node->name . '/' . $type; $param = array('vmUniqueName' => $node->name); $result = commonModel::http($agnetUrl . $path, $param); $data = json_decode($result, true); - if(empty($data)) return $this->lang->executionnode->notFoundAgent; + if(empty($data)) return $this->lang->zanode->notFoundAgent; - if($data['code'] != 'success') return zget($this->lang->executionnode->apiError, $data['code'], $data['msg']); + if($data['code'] != 'success') return zget($this->lang->zanode->apiError, $data['code'], $data['msg']); if($type != 'reboot') { @@ -134,7 +134,7 @@ class executionnodemodel extends model $this->dao->update(TABLE_ZAHOST)->set('status')->eq($status)->where('id')->eq($id)->exec(); } - $this->loadModel('action')->create('executionnode', $id, ucfirst($type)); + $this->loadModel('action')->create('zanode', $id, ucfirst($type)); return; } @@ -155,13 +155,13 @@ class executionnodemodel extends model /* Prepare create params. */ if($host) { - $agnetUrl = 'http://' . $host->extranet . ':' . $this->config->executionnode->defaultPort; + $agnetUrl = 'http://' . $host->extranet . ':' . $this->config->zanode->defaultPort; $result = commonModel::http($agnetUrl . '/api/v1/kvm/remove', json_encode($req)); $data = json_decode($result, true); - if(empty($data)) return $this->lang->executionnode->notFoundAgent; + if(empty($data)) return $this->lang->zanode->notFoundAgent; - if($data['code'] != 'success') return zget($this->lang->executionnode->apiError, $data['code'], $data['msg']); + if($data['code'] != 'success') return zget($this->lang->zanode->apiError, $data['code'], $data['msg']); } /* delete execution node. */ @@ -169,7 +169,7 @@ class executionnodemodel extends model ->set('deleted')->eq(1) ->where('id')->eq($id) ->exec(); - $this->loadModel('action')->create('executionnode', $id, 'destroy'); + $this->loadModel('action')->create('zanode', $id, 'destroy'); return; } @@ -183,7 +183,7 @@ class executionnodemodel extends model public function getNodeCreateActionByID($id) { return $this->dao->select('*')->from(TABLE_ACTION) - ->where('objectType')->eq('executionnode') + ->where('objectType')->eq('zanode') ->andWhere('objectID')->eq($id) ->andWhere('action')->eq('created') ->fetch(); @@ -256,9 +256,9 @@ class executionnodemodel extends model } else { - if($this->session->executionnodeQuery == false) $this->session->set('executionnodeQuery', ' 1 = 1'); + if($this->session->zanodeQuery == false) $this->session->set('zanodeQuery', ' 1 = 1'); } - $query = $this->session->executionnodeQuery; + $query = $this->session->zanodeQuery; $query = str_replace('`id`', 't1.`id`', $query); $query = str_replace('`name`', 't1.`name`', $query); $query = str_replace('`status`', 't1.`status`', $query); @@ -266,7 +266,7 @@ class executionnodemodel extends model $query = str_replace('`parent`', 't1.`parent`', $query); } - return $this->dao->select('t1.*, t1.name as hostName, t2.extranet as hostIP,t3.os')->from(TABLE_ZAHOST)->alias('t1') + return $this->dao->select('t1.*, t1.name as hostName, t2.extranet as hostIP,t3.osName')->from(TABLE_ZAHOST)->alias('t1') ->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t1.parent = t2.id') ->leftJoin(TABLE_IMAGE)->alias('t3')->on('t3.id = t1.image') ->where('t1.deleted')->eq(0) @@ -289,7 +289,7 @@ class executionnodemodel extends model */ public function getListByHost($hostID, $orderBy = 'id_desc') { - return $this->dao->select('id, name, vnc, cpu, memory, disk, os, status')->from(TABLE_ZAHOST) + return $this->dao->select('id, name, vnc, cpuCores, memory, diskSize, osName, status')->from(TABLE_ZAHOST) ->where('deleted')->eq(0) ->andWhere("parent")->eq($hostID) ->orderBy($orderBy) @@ -360,7 +360,7 @@ class executionnodemodel extends model */ public function getNodeByID($id) { - return $this->dao->select('t1.*, t1.name as hostName, t2.extranet as ip,t3.os')->from(TABLE_ZAHOST)->alias('t1') + return $this->dao->select('t1.*, t1.name as hostName, t2.extranet as ip,t3.osName')->from(TABLE_ZAHOST)->alias('t1') ->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t1.parent = t2.id') ->leftJoin(TABLE_IMAGE)->alias('t3')->on('t3.id = t1.image') ->where('t1.id')->eq($id) diff --git a/module/zanode/view/browse.html.php b/module/zanode/view/browse.html.php new file mode 100644 index 0000000000..e8f81e4137 --- /dev/null +++ b/module/zanode/view/browse.html.php @@ -0,0 +1,100 @@ + + * @package zanode + * @version $Id$ + * @link http://www.zentao.net + */ +?> +getModuleRoot() . 'common/view/header.html.php';?> +zanode->confirmDelete)?> +zanode->confirmBoot)?> +zanode->confirmReboot)?> +zanode->confirmShutdown)?> +zanode->actionSuccess)?> + +
' data-module='zanode'>
+
+recTotal}&recPerPage={$pager->recPerPage}";?> +
+ +
+

+ zanode->empty;?> + ' . $lang->zanode->create, '', 'class="btn btn-info"');?> +

+
+ +
zahost->virtualSoftware;?>zahost->softwareList, '', "class='form-control chosen'");?>zahost->vsoft;?>zahost->softwareList, '', "class='form-control chosen'");?>
zahost->zaHostType;?>
zahost->disk;?>zahost->diskSize;?>
- + zahost->unitList['GB'];?> diff --git a/module/zahost/view/createtemplate.html.php b/module/zahost/view/createtemplate.html.php deleted file mode 100644 index 813cdd89df..0000000000 --- a/module/zahost/view/createtemplate.html.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @package zahost - * @version $Id$ - * @link http://www.zentao.net - */ -?> -getModuleRoot() . 'common/view/header.html.php';?> -zahost);?> -zahost);?> -hostID);?> -
-
-

zahost->createTemplate;?>

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
zahost->name;?>
zahost->cpu ;?>
zahost->memory;?> -
- - MB -
-
zahost->disk;?> -
- - GB -
-
zahost->vmTemplate->osCategory;?>zahost->os->list, '', "class='form-control chosen'")?>
zahost->vmTemplate->osType;?>
zahost->vmTemplate->osVersion;?>
zahost->vmTemplate->osLang;?>zahost->langList, '', "class='form-control chosen'")?>
zahost->vmTemplate->imageName;?>
- - - -
- -
-getModuleRoot() . 'common/view/footer.html.php';?> diff --git a/module/zahost/view/edit.html.php b/module/zahost/view/edit.html.php index e3a855dbe6..2117b17a4f 100644 --- a/module/zahost/view/edit.html.php +++ b/module/zahost/view/edit.html.php @@ -21,8 +21,8 @@
- - + + @@ -38,7 +38,7 @@ - + @@ -51,10 +51,10 @@ - + - + @@ -100,7 +100,7 @@ - + From ba428eaf4952de7977f444bbe969fc811f1ef70a Mon Sep 17 00:00:00 2001 From: zhaoke Date: Mon, 21 Nov 2022 06:27:41 +0000 Subject: [PATCH 26/36] * Update execnode code for sql change --- db/update18.0.sql | 3 +- db/zentao.sql | 3 +- module/executionnode/config.php | 53 ++++------ module/executionnode/control.php | 6 +- module/executionnode/js/common.js | 22 ++-- module/executionnode/lang/de.php | 45 +------- module/executionnode/lang/en.php | 45 +------- module/executionnode/lang/fr.php | 47 +-------- module/executionnode/lang/zh-cn.php | 44 +------- module/executionnode/model.php | 121 ++++++---------------- module/executionnode/view/create.html.php | 16 +-- module/zahost/control.php | 19 +--- module/zahost/lang/de.php | 64 +----------- module/zahost/lang/en.php | 17 +-- module/zahost/lang/fr.php | 69 ++---------- module/zahost/lang/vi.php | 61 ++--------- module/zahost/lang/zh-cn.php | 70 ++----------- module/zahost/model.php | 35 +++---- module/zahost/view/create.html.php | 8 +- module/zahost/view/edit.html.php | 6 +- module/zahost/view/view.html.php | 2 +- 21 files changed, 144 insertions(+), 612 deletions(-) diff --git a/db/update18.0.sql b/db/update18.0.sql index d2ab5f5ea9..f8b86beaee 100644 --- a/db/update18.0.sql +++ b/db/update18.0.sql @@ -77,9 +77,10 @@ CREATE TABLE `zt_image` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `host` int(11) unsigned NOT NULL DEFAULT 0, `name` varchar(64) NOT NULL DEFAULT '', + `address` varchar(64) NOT NULL DEFAULT '', `path` varchar(64) NOT NULL DEFAULT '', `status` varchar(20) NOT NULL DEFAULT '', - `os` varchar(32) NOT NULL DEFAULT '', + `osName` varchar(32) NOT NULL DEFAULT '', `memory` float unsigned NOT NULL, `disk` float unsigned NOT NULL, `fileSize` float unsigned NOT NULL, diff --git a/db/zentao.sql b/db/zentao.sql index 6e9027feab..344ceb8e63 100755 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -7295,9 +7295,10 @@ CREATE TABLE `zt_image` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `host` int(11) unsigned NOT NULL DEFAULT 0, `name` varchar(64) NOT NULL DEFAULT '', + `address` varchar(64) NOT NULL DEFAULT '', `path` varchar(64) NOT NULL DEFAULT '', `status` varchar(20) NOT NULL DEFAULT '', - `os` varchar(32) NOT NULL DEFAULT '', + `osName` varchar(32) NOT NULL DEFAULT '', `memory` float unsigned NOT NULL, `disk` float unsigned NOT NULL, `fileSize` float unsigned NOT NULL, diff --git a/module/executionnode/config.php b/module/executionnode/config.php index a6b151edb8..64c8897be6 100755 --- a/module/executionnode/config.php +++ b/module/executionnode/config.php @@ -1,56 +1,43 @@ executionnode->create = new stdClass(); $config->executionnode->edit = new stdClass(); -$config->executionnode->create->requiredFields = 'name,hostID,imageID,cpu,memory,disk,os'; +$config->executionnode->create->requiredFields = 'name,host,image,cpu,memory,disk,os'; $config->executionnode->edit->requiredFields = ''; $config->executionnode->defaultPort = '8086'; $config->executionnode->os = new stdClass(); -$config->executionnode->os->list = array(); -$config->executionnode->os->list['windows'] = 'Windows'; -$config->executionnode->os->list['linux'] = 'Linux'; -$config->executionnode->os->cpu = array(); -$config->executionnode->os->cpu['1'] = '1'; -$config->executionnode->os->cpu['2'] = '2'; -$config->executionnode->os->cpu['4'] = '4'; -$config->executionnode->os->cpu['6'] = '6'; -$config->executionnode->os->cpu['8'] = '8'; -$config->executionnode->os->cpu['12'] = '12'; -$config->executionnode->os->cpu['16'] = '16'; -$config->executionnode->os->cpu['24'] = '24'; -$config->executionnode->os->cpu['32'] = '32'; -$config->executionnode->os->cpu['64'] = '64'; - -$config->executionnode->os->type = array(); -$config->executionnode->os->type['windows']['winServer'] = 'Windows Server'; -$config->executionnode->os->type['windows']['win11'] = 'Windows 11'; -$config->executionnode->os->type['windows']['win10'] = 'Windows 10'; -$config->executionnode->os->type['windows']['win7'] = 'Windows 7'; -$config->executionnode->os->type['windows']['winxp'] = 'Windows XP'; -$config->executionnode->os->type['linux']['ubuntu'] = 'Ubuntu'; -$config->executionnode->os->type['linux']['centos'] = 'CentOS'; -$config->executionnode->os->type['linux']['debian'] = 'Debian'; +$config->executionnode->os->cpuCores = array(); +$config->executionnode->os->cpuCores['1'] = '1'; +$config->executionnode->os->cpuCores['2'] = '2'; +$config->executionnode->os->cpuCores['4'] = '4'; +$config->executionnode->os->cpuCores['6'] = '6'; +$config->executionnode->os->cpuCores['8'] = '8'; +$config->executionnode->os->cpuCores['12'] = '12'; +$config->executionnode->os->cpuCores['16'] = '16'; +$config->executionnode->os->cpuCores['24'] = '24'; +$config->executionnode->os->cpuCores['32'] = '32'; +$config->executionnode->os->cpuCores['64'] = '64'; global $lang; $config->executionnode->search['module'] = 'executionnode'; $config->executionnode->search['fields']['name'] = $lang->executionnode->name; -$config->executionnode->search['fields']['os'] = $lang->executionnode->os; -$config->executionnode->search['fields']['hostID'] = $lang->executionnode->hostName; +$config->executionnode->search['fields']['osName'] = $lang->executionnode->osName; +$config->executionnode->search['fields']['host'] = $lang->executionnode->hostName; $config->executionnode->search['fields']['status'] = $lang->executionnode->status; -$config->executionnode->search['fields']['cpu'] = $lang->executionnode->cpu; +$config->executionnode->search['fields']['cpuCores'] = $lang->executionnode->cpuCores; $config->executionnode->search['fields']['memory'] = $lang->executionnode->memory; -$config->executionnode->search['fields']['disk'] = $lang->executionnode->disk; +$config->executionnode->search['fields']['diskSize'] = $lang->executionnode->diskSize; $config->executionnode->search['fields']['mac'] = $lang->executionnode->mac; $config->executionnode->search['fields']['address'] = $lang->executionnode->ip; $config->executionnode->search['params']['name'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); -$config->executionnode->search['params']['os'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); -$config->executionnode->search['params']['hostID'] = array('operator' => '=', 'control' => 'select', 'values' => ''); +$config->executionnode->search['params']['osName'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); +$config->executionnode->search['params']['host'] = array('operator' => '=', 'control' => 'select', 'values' => ''); $config->executionnode->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $lang->executionnode->statusList); -$config->executionnode->search['params']['cpu'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $config->executionnode->os->cpu); +$config->executionnode->search['params']['cpuCores'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $config->executionnode->os->cpuCores); $config->executionnode->search['params']['memory'] = array('operator' => '=', 'control' => 'input', 'values' => ''); -$config->executionnode->search['params']['disk'] = array('operator' => '=', 'control' => 'input', 'values' => ''); +$config->executionnode->search['params']['diskSize'] = array('operator' => '=', 'control' => 'input', 'values' => ''); $config->executionnode->editor = new stdclass(); $config->executionnode->editor->create = array('id' => 'desc', 'tools' => 'simpleTools'); diff --git a/module/executionnode/control.php b/module/executionnode/control.php index edc7507d68..a11e7f451d 100755 --- a/module/executionnode/control.php +++ b/module/executionnode/control.php @@ -183,7 +183,7 @@ class executionnode extends control { $templatePairs = $this->loadModel('zahost')->getImagePairs($hostID); - return print(html::select('imageID', $templatePairs, '', "class='form-control chosen'")); + return print(html::select('image', $templatePairs, '', "class='form-control chosen'")); } /** @@ -196,10 +196,6 @@ class executionnode extends control public function ajaxGetImage($imageID) { $template = $this->loadModel('zahost')->getImageByID($imageID); - if($template) - { - $template->os = $template->osCategory; - } return print(json_encode($template)); } } diff --git a/module/executionnode/js/common.js b/module/executionnode/js/common.js index 8b2ac8d3c8..7491451e9a 100755 --- a/module/executionnode/js/common.js +++ b/module/executionnode/js/common.js @@ -1,36 +1,36 @@ $(function() { - if(config.currentMethod == 'create') $('#hostID').change(); + if(config.currentMethod == 'create') $('#parent').change(); - $('#hostID').change(function() + $('#parent').change(function() { - var hostID = $('#hostID').val(); + var hostID = $('#parent').val(); var link = createLink('executionnode', 'ajaxGetImages', 'hostID=' + hostID); $.get(link, function(data) { $('#template').html('').append(data); - $('#imageID').chosen().trigger("chosen:updated"); - $('#imageID').change(); + $('#image').chosen().trigger("chosen:updated"); + $('#image').change(); }); }); - $(document).on("change", '#imageID', function() + $(document).on("change", '#image', function() { - var imageID = $('#imageID').val(); - var link = createLink('executionnode', 'ajaxGetImage', 'imageID=' + imageID); + var image = $('#image').val(); + var link = createLink('executionnode', 'ajaxGetImage', 'image=' + image); $.get(link, function(data) { data = JSON.parse(data); console.log(data); - $('#os').val(data.os); + $('#osName').val(data.osName); if(data.memory != 0){ $('#memory').val(data.memory); } if(data.memory != 0){ - $('#disk').val(data.disk); + $('#diskSize').val(data.disk); } }); }); - if(typeof imageID == 'undefined' || !imageID) $('#os').change(); + if(typeof image == 'undefined' || !image) $('#os').change(); }) diff --git a/module/executionnode/lang/de.php b/module/executionnode/lang/de.php index 43513d1985..ac85338a56 100755 --- a/module/executionnode/lang/de.php +++ b/module/executionnode/lang/de.php @@ -13,27 +13,24 @@ $lang->executionnode->resume = 'Resume Execution Node'; $lang->executionnode->getVNC = 'Remote management'; $lang->executionnode->all = 'All'; $lang->executionnode->byQuery = 'Search'; -$lang->executionnode->os = 'OS Version'; +$lang->executionnode->osName = 'System'; $lang->executionnode->image = 'VM Image'; $lang->executionnode->name = 'Name'; $lang->executionnode->start = 'Start After Created'; $lang->executionnode->hostName = 'Host Name'; -$lang->executionnode->hostID = $lang->executionnode->hostName; +$lang->executionnode->host = $lang->executionnode->hostName; $lang->executionnode->ip = 'IP'; $lang->executionnode->osArch = 'Arch'; -$lang->executionnode->cpu = 'CPU Cores'; +$lang->executionnode->cpuCores = 'CPU Cores'; $lang->executionnode->memory = 'Memory Size'; $lang->executionnode->desc = 'Description'; -$lang->executionnode->disk = 'Disk Size'; +$lang->executionnode->diskSize = 'Disk Size'; $lang->executionnode->status = 'Status'; $lang->executionnode->mac = 'MAC'; $lang->executionnode->vnc = 'VNC Port'; $lang->executionnode->destroyAt = 'Destroy Time'; $lang->executionnode->creater = 'Creator'; $lang->executionnode->createdDate = 'Create Date'; -$lang->executionnode->template = 'Template'; -$lang->executionnode->imageID = 'VM Template'; -$lang->executionnode->templateList = 'TemplateList'; $lang->executionnode->confirmDelete = "Are you sure about destroying the execution node?"; $lang->executionnode->confirmBoot = "Are you sure to start the execution node?"; $lang->executionnode->confirmReboot = "Are you sure to restart the execution node?"; @@ -48,7 +45,6 @@ $lang->executionnode->noVncPort = 'Failed to get vnc port'; $lang->executionnode->nameValid = "The name can only be letters, numbers, '-', '_', '.', and cannot start with a symbol"; $lang->executionnode->empty = 'No Execution Node'; -$lang->executionnode->templateEmpty = 'No Template'; $lang->executionnode->apiError['-10100'] = 'Execution node not found.'; @@ -62,36 +58,3 @@ $lang->executionnode->statusList['running'] = 'Running'; $lang->executionnode->statusList['suspend'] = 'Suspend'; $lang->executionnode->statusList['destroy'] = 'Destroyed'; $lang->executionnode->statusList['destroy_fail'] = 'Destroy Fail'; - -$lang->executionnode->versionList = array(); -$lang->executionnode->versionList['winxp']['all'] = 'Windows XP'; -$lang->executionnode->versionList['win7']['home'] = 'Home Basic'; -$lang->executionnode->versionList['win7']['professional'] = 'Professional'; -$lang->executionnode->versionList['win7']['enterprise'] = 'Enterprise'; -$lang->executionnode->versionList['win7']['ultimate'] = 'Ultimate'; -$lang->executionnode->versionList['win10']['home'] = 'Home Basic'; -$lang->executionnode->versionList['win10']['professional'] = 'Professional'; -$lang->executionnode->versionList['win10']['enterprise'] = 'Enterprise'; -$lang->executionnode->versionList['win10']['ultimate'] = 'Ultimate'; -$lang->executionnode->versionList['win11']['home'] = 'Home Basic'; -$lang->executionnode->versionList['win11']['professional'] = 'Professional'; -$lang->executionnode->versionList['win11']['enterprise'] = 'Enterprise'; -$lang->executionnode->versionList['win11']['ultimate'] = 'Ultimate'; -$lang->executionnode->versionList['winServer']['2008'] = '2008'; -$lang->executionnode->versionList['winServer']['2012'] = '2012'; -$lang->executionnode->versionList['winServer']['2016'] = '2016'; -$lang->executionnode->versionList['winServer']['2019'] = '2019'; -$lang->executionnode->versionList['debian']['9'] = '9'; -$lang->executionnode->versionList['debian']['10'] = '10'; -$lang->executionnode->versionList['debian']['11'] = '11'; -$lang->executionnode->versionList['ubuntu']['16'] = '16'; -$lang->executionnode->versionList['ubuntu']['18'] = '18'; -$lang->executionnode->versionList['ubuntu']['20'] = '20'; -$lang->executionnode->versionList['centos']['6'] = '6'; -$lang->executionnode->versionList['centos']['7'] = '7'; -$lang->executionnode->versionList['centos']['8'] = '8'; - -$lang->executionnode->langList = array(); -$lang->executionnode->langList['zh_cn'] = 'Simplified Chinese'; -$lang->executionnode->langList['zh_tw'] = 'Traditional Chinese'; -$lang->executionnode->langList['en_us'] = 'American English'; diff --git a/module/executionnode/lang/en.php b/module/executionnode/lang/en.php index 4a7327993c..36db2575a7 100755 --- a/module/executionnode/lang/en.php +++ b/module/executionnode/lang/en.php @@ -13,27 +13,24 @@ $lang->executionnode->resume = 'Resume Execution Node'; $lang->executionnode->getVNC = 'Remote management'; $lang->executionnode->all = 'All'; $lang->executionnode->byQuery = 'Search'; -$lang->executionnode->os = 'Os Version'; +$lang->executionnode->osName = 'System'; $lang->executionnode->image = 'VM Image'; $lang->executionnode->name = 'Name'; $lang->executionnode->start = 'Start After Created'; $lang->executionnode->hostName = 'Host Name'; -$lang->executionnode->hostID = $lang->executionnode->hostName; +$lang->executionnode->host = $lang->executionnode->hostName; $lang->executionnode->ip = 'IP'; $lang->executionnode->osArch = 'Arch'; -$lang->executionnode->cpu = 'CPU Cores'; +$lang->executionnode->cpuCores = 'CPU Cores'; $lang->executionnode->memory = 'Memory Size'; $lang->executionnode->desc = 'Description'; -$lang->executionnode->disk = 'Disk Size'; +$lang->executionnode->diskSize = 'Disk Size'; $lang->executionnode->status = 'Status'; $lang->executionnode->mac = 'MAC'; $lang->executionnode->vnc = 'VNC Port'; $lang->executionnode->destroyAt = 'Destroy Time'; $lang->executionnode->creater = 'Creator'; $lang->executionnode->createdDate = 'Create Date'; -$lang->executionnode->template = 'Template'; -$lang->executionnode->imageID = 'VM Template'; -$lang->executionnode->templateList = 'TemplateList'; $lang->executionnode->confirmDelete = "Are you sure about destroying the execution node?"; $lang->executionnode->confirmBoot = "Are you sure to start the execution node?"; $lang->executionnode->confirmReboot = "Are you sure to restart the execution node?"; @@ -48,7 +45,6 @@ $lang->executionnode->noVncPort = 'Failed to get vnc port'; $lang->executionnode->nameValid = "The name can only be letters, numbers, '-', '_', '.', and cannot start with a symbol"; $lang->executionnode->empty = 'No Execution Node'; -$lang->executionnode->templateEmpty = 'No Template'; $lang->executionnode->apiError['-10100'] = 'Execution node not found.'; @@ -62,36 +58,3 @@ $lang->executionnode->statusList['running'] = 'Running'; $lang->executionnode->statusList['suspend'] = 'Suspend'; $lang->executionnode->statusList['destroy'] = 'Destroyed'; $lang->executionnode->statusList['destroy_fail'] = 'Destroy Fail'; - -$lang->executionnode->versionList = array(); -$lang->executionnode->versionList['winxp']['all'] = 'Windows XP'; -$lang->executionnode->versionList['win7']['home'] = 'Home Basic'; -$lang->executionnode->versionList['win7']['professional'] = 'Professional'; -$lang->executionnode->versionList['win7']['enterprise'] = 'Enterprise'; -$lang->executionnode->versionList['win7']['ultimate'] = 'Ultimate'; -$lang->executionnode->versionList['win10']['home'] = 'Home Basic'; -$lang->executionnode->versionList['win10']['professional'] = 'Professional'; -$lang->executionnode->versionList['win10']['enterprise'] = 'Enterprise'; -$lang->executionnode->versionList['win10']['ultimate'] = 'Ultimate'; -$lang->executionnode->versionList['win11']['home'] = 'Home Basic'; -$lang->executionnode->versionList['win11']['professional'] = 'Professional'; -$lang->executionnode->versionList['win11']['enterprise'] = 'Enterprise'; -$lang->executionnode->versionList['win11']['ultimate'] = 'Ultimate'; -$lang->executionnode->versionList['winServer']['2008'] = '2008'; -$lang->executionnode->versionList['winServer']['2012'] = '2012'; -$lang->executionnode->versionList['winServer']['2016'] = '2016'; -$lang->executionnode->versionList['winServer']['2019'] = '2019'; -$lang->executionnode->versionList['debian']['9'] = '9'; -$lang->executionnode->versionList['debian']['10'] = '10'; -$lang->executionnode->versionList['debian']['11'] = '11'; -$lang->executionnode->versionList['ubuntu']['16'] = '16'; -$lang->executionnode->versionList['ubuntu']['18'] = '18'; -$lang->executionnode->versionList['ubuntu']['20'] = '20'; -$lang->executionnode->versionList['centos']['6'] = '6'; -$lang->executionnode->versionList['centos']['7'] = '7'; -$lang->executionnode->versionList['centos']['8'] = '8'; - -$lang->executionnode->langList = array(); -$lang->executionnode->langList['zh_cn'] = 'Simplified Chinese'; -$lang->executionnode->langList['zh_tw'] = 'Traditional Chinese'; -$lang->executionnode->langList['en_us'] = 'American English'; diff --git a/module/executionnode/lang/fr.php b/module/executionnode/lang/fr.php index babd1366ce..ac85338a56 100755 --- a/module/executionnode/lang/fr.php +++ b/module/executionnode/lang/fr.php @@ -13,29 +13,24 @@ $lang->executionnode->resume = 'Resume Execution Node'; $lang->executionnode->getVNC = 'Remote management'; $lang->executionnode->all = 'All'; $lang->executionnode->byQuery = 'Search'; -$lang->executionnode->os = 'Os Version'; +$lang->executionnode->osName = 'System'; $lang->executionnode->image = 'VM Image'; $lang->executionnode->name = 'Name'; $lang->executionnode->start = 'Start After Created'; $lang->executionnode->hostName = 'Host Name'; -$lang->executionnode->hostID = $lang->executionnode->hostName; +$lang->executionnode->host = $lang->executionnode->hostName; $lang->executionnode->ip = 'IP'; $lang->executionnode->osArch = 'Arch'; -$lang->executionnode->cpu = 'CPU Cores'; +$lang->executionnode->cpuCores = 'CPU Cores'; $lang->executionnode->memory = 'Memory Size'; $lang->executionnode->desc = 'Description'; -$lang->executionnode->disk = 'Disk Size'; +$lang->executionnode->diskSize = 'Disk Size'; $lang->executionnode->status = 'Status'; $lang->executionnode->mac = 'MAC'; $lang->executionnode->vnc = 'VNC Port'; $lang->executionnode->destroyAt = 'Destroy Time'; $lang->executionnode->creater = 'Creator'; $lang->executionnode->createdDate = 'Create Date'; -$lang->executionnode->template = 'Template'; -$lang->executionnode->imageID = 'VM Template'; -$lang->executionnode->templateList = 'TemplateList'; -$lang->executionnode->createTemplate = 'Create Template'; -$lang->executionnode->editTemplate = 'Edit Template'; $lang->executionnode->confirmDelete = "Are you sure about destroying the execution node?"; $lang->executionnode->confirmBoot = "Are you sure to start the execution node?"; $lang->executionnode->confirmReboot = "Are you sure to restart the execution node?"; @@ -50,7 +45,6 @@ $lang->executionnode->noVncPort = 'Failed to get vnc port'; $lang->executionnode->nameValid = "The name can only be letters, numbers, '-', '_', '.', and cannot start with a symbol"; $lang->executionnode->empty = 'No Execution Node'; -$lang->executionnode->templateEmpty = 'No Template'; $lang->executionnode->apiError['-10100'] = 'Execution node not found.'; @@ -64,36 +58,3 @@ $lang->executionnode->statusList['running'] = 'Running'; $lang->executionnode->statusList['suspend'] = 'Suspend'; $lang->executionnode->statusList['destroy'] = 'Destroyed'; $lang->executionnode->statusList['destroy_fail'] = 'Destroy Fail'; - -$lang->executionnode->versionList = array(); -$lang->executionnode->versionList['winxp']['all'] = 'Windows XP'; -$lang->executionnode->versionList['win7']['home'] = 'Home Basic'; -$lang->executionnode->versionList['win7']['professional'] = 'Professional'; -$lang->executionnode->versionList['win7']['enterprise'] = 'Enterprise'; -$lang->executionnode->versionList['win7']['ultimate'] = 'Ultimate'; -$lang->executionnode->versionList['win10']['home'] = 'Home Basic'; -$lang->executionnode->versionList['win10']['professional'] = 'Professional'; -$lang->executionnode->versionList['win10']['enterprise'] = 'Enterprise'; -$lang->executionnode->versionList['win10']['ultimate'] = 'Ultimate'; -$lang->executionnode->versionList['win11']['home'] = 'Home Basic'; -$lang->executionnode->versionList['win11']['professional'] = 'Professional'; -$lang->executionnode->versionList['win11']['enterprise'] = 'Enterprise'; -$lang->executionnode->versionList['win11']['ultimate'] = 'Ultimate'; -$lang->executionnode->versionList['winServer']['2008'] = '2008'; -$lang->executionnode->versionList['winServer']['2012'] = '2012'; -$lang->executionnode->versionList['winServer']['2016'] = '2016'; -$lang->executionnode->versionList['winServer']['2019'] = '2019'; -$lang->executionnode->versionList['debian']['9'] = '9'; -$lang->executionnode->versionList['debian']['10'] = '10'; -$lang->executionnode->versionList['debian']['11'] = '11'; -$lang->executionnode->versionList['ubuntu']['16'] = '16'; -$lang->executionnode->versionList['ubuntu']['18'] = '18'; -$lang->executionnode->versionList['ubuntu']['20'] = '20'; -$lang->executionnode->versionList['centos']['6'] = '6'; -$lang->executionnode->versionList['centos']['7'] = '7'; -$lang->executionnode->versionList['centos']['8'] = '8'; - -$lang->executionnode->langList = array(); -$lang->executionnode->langList['zh_cn'] = 'Simplified Chinese'; -$lang->executionnode->langList['zh_tw'] = 'Traditional Chinese'; -$lang->executionnode->langList['en_us'] = 'American English'; diff --git a/module/executionnode/lang/zh-cn.php b/module/executionnode/lang/zh-cn.php index 4ac5794879..d8a0e77bf0 100755 --- a/module/executionnode/lang/zh-cn.php +++ b/module/executionnode/lang/zh-cn.php @@ -13,17 +13,17 @@ $lang->executionnode->resume = '恢复执行节点'; $lang->executionnode->getVNC = '远程管理'; $lang->executionnode->all = '全部'; $lang->executionnode->byQuery = '搜索'; -$lang->executionnode->os = '操作系统'; +$lang->executionnode->osName = '操作系统'; $lang->executionnode->image = '镜像'; $lang->executionnode->name = '执行节点名称'; $lang->executionnode->start = '创建后自动开启'; $lang->executionnode->hostName = '所属宿主机'; -$lang->executionnode->hostID = $lang->executionnode->hostName; +$lang->executionnode->host = $lang->executionnode->hostName; $lang->executionnode->ip = 'IP/域名'; $lang->executionnode->osArch = '架构'; -$lang->executionnode->cpu = 'CPU核心数'; +$lang->executionnode->cpuCores = 'CPU核心数'; $lang->executionnode->memory = '内存'; -$lang->executionnode->disk = '硬盘'; +$lang->executionnode->diskSize = '硬盘'; $lang->executionnode->desc = '描述'; $lang->executionnode->status = '状态'; $lang->executionnode->mac = 'MAC地址'; @@ -31,9 +31,6 @@ $lang->executionnode->vnc = 'VNC端口'; $lang->executionnode->destroyAt = '销毁时间'; $lang->executionnode->creater = '创建人'; $lang->executionnode->createdDate = '创建日期'; -$lang->executionnode->template = '模板'; -$lang->executionnode->imageID = '虚拟机模板'; -$lang->executionnode->templateList = '模板列表'; $lang->executionnode->confirmDelete = "您确定销毁执行节点吗?"; $lang->executionnode->confirmBoot = "您确定启动执行节点吗?"; $lang->executionnode->confirmReboot = "您确定重启执行节点吗?"; @@ -48,7 +45,6 @@ $lang->executionnode->noVncPort = '无法获取执行节点端口'; $lang->executionnode->nameValid = "名称只能是字母、数字,'-','_','.',且不能以符号开头"; $lang->executionnode->empty = '暂时没有执行节点'; -$lang->executionnode->templateEmpty = '暂时没有模板'; $lang->executionnode->apiError['-10100'] = '执行节点不存在'; @@ -64,35 +60,3 @@ $lang->executionnode->statusList['offline'] = '下线'; $lang->executionnode->statusList['destroy'] = '已销毁'; $lang->executionnode->statusList['destroy_fail'] = '销毁失败'; -$lang->executionnode->versionList = array(); -$lang->executionnode->versionList['winxp']['all'] = 'Windows XP'; -$lang->executionnode->versionList['win7']['home'] = '家庭版'; -$lang->executionnode->versionList['win7']['professional'] = '专业版'; -$lang->executionnode->versionList['win7']['enterprise'] = '企业版'; -$lang->executionnode->versionList['win7']['ultimate'] = '旗舰版'; -$lang->executionnode->versionList['win10']['home'] = '家庭版'; -$lang->executionnode->versionList['win10']['professional'] = '专业版'; -$lang->executionnode->versionList['win10']['enterprise'] = '企业版'; -$lang->executionnode->versionList['win10']['ultimate'] = '旗舰版'; -$lang->executionnode->versionList['win11']['home'] = '家庭版'; -$lang->executionnode->versionList['win11']['professional'] = '专业版'; -$lang->executionnode->versionList['win11']['enterprise'] = '企业版'; -$lang->executionnode->versionList['win11']['ultimate'] = '旗舰版'; -$lang->executionnode->versionList['winServer']['2008'] = '2008'; -$lang->executionnode->versionList['winServer']['2012'] = '2012'; -$lang->executionnode->versionList['winServer']['2016'] = '2016'; -$lang->executionnode->versionList['winServer']['2019'] = '2019'; -$lang->executionnode->versionList['debian']['9'] = '9'; -$lang->executionnode->versionList['debian']['10'] = '10'; -$lang->executionnode->versionList['debian']['11'] = '11'; -$lang->executionnode->versionList['ubuntu']['16'] = '16'; -$lang->executionnode->versionList['ubuntu']['18'] = '18'; -$lang->executionnode->versionList['ubuntu']['20'] = '20'; -$lang->executionnode->versionList['centos']['6'] = '6'; -$lang->executionnode->versionList['centos']['7'] = '7'; -$lang->executionnode->versionList['centos']['8'] = '8'; - -$lang->executionnode->langList = array(); -$lang->executionnode->langList['zh_cn'] = '简体中文'; -$lang->executionnode->langList['zh_tw'] = '繁体中文'; -$lang->executionnode->langList['en_us'] = '美式英语'; diff --git a/module/executionnode/model.php b/module/executionnode/model.php index 39c0c18cb0..6854bfb648 100755 --- a/module/executionnode/model.php +++ b/module/executionnode/model.php @@ -28,10 +28,9 @@ class executionnodemodel extends model /** - * Create an VM. + * Create an Node. * * @param object $data - * @param int $imageID * @access public * @return void */ @@ -54,7 +53,7 @@ class executionnodemodel extends model } /* Get image. */ - $image = $this->getImageByID($data->imageID); + $image = $this->getImageByID($data->image); /* Get host info. */ $host = $this->getHostByID($data->parent); @@ -63,9 +62,9 @@ class executionnodemodel extends model $mac = $this->genmac(); /* Prepare create params. */ - $agnetUrl = 'http://' . $host->address . ':' . $this->config->executionnode->defaultPort; + $agnetUrl = 'http://' . $host->extranet . ':' . $this->config->executionnode->defaultPort; $param = array( - 'os' => $image->osCategory, + 'os' => $image->os, 'path' => $image->path, 'name' => $data->name, 'cpu' => (int)$data->cpu, @@ -87,13 +86,13 @@ class executionnodemodel extends model } /* Prepare create execution node data. */ - $data->imageID = $data->imageID; + $data->image = $data->image; $data->parent = $host->id; $data->mac = $mac; $data->status = static::STATUS_RUNNING; $data->createdBy = $this->app->user->account; $data->createdDate = helper::now(); - $data->vnc = (int)$result->data->vnc; + $data->vnc = (int)$result->data->vnc; /* Save execution node. */ $this->dao->insert(TABLE_ZAHOST)->data($data)->autoCheck()->exec(); @@ -107,19 +106,19 @@ class executionnodemodel extends model } /** - * Action VM. + * Action Node. * * @param int $id * @param string $type * @return string */ - public function handleVM($id, $type) + public function handleNode($id, $type) { - $node = $this->getVMByID($id); + $node = $this->getNodeByID($id); $host = $this->getHostByID($node->parent); /* Prepare create params. */ - $agnetUrl = 'http://' . $host->address . ':' . $this->config->executionnode->defaultPort; + $agnetUrl = 'http://' . $host->extranet . ':' . $this->config->executionnode->defaultPort; $path = '/api/v1/kvm/' . $node->name . '/' . $type; $param = array('vmUniqueName' => $node->name); @@ -140,7 +139,7 @@ class executionnodemodel extends model } /** - * Destroy VM. + * Destroy Node. * * @param int $id * @access public @@ -148,7 +147,7 @@ class executionnodemodel extends model */ public function destroy($id) { - $node = $this->getVMByID($id); + $node = $this->getNodeByID($id); $host = $this->getHostByID($node->parent); $req = array( 'name' => $node->name ); @@ -156,7 +155,7 @@ class executionnodemodel extends model /* Prepare create params. */ if($host) { - $agnetUrl = 'http://' . $host->address . ':' . $this->config->executionnode->defaultPort; + $agnetUrl = 'http://' . $host->extranet . ':' . $this->config->executionnode->defaultPort; $result = commonModel::http($agnetUrl . '/api/v1/kvm/remove', json_encode($req)); $data = json_decode($result, true); @@ -215,7 +214,7 @@ class executionnodemodel extends model } /** - * Update VM attribute. + * Update Node attribute. * * @param int $id * @param array $data @@ -228,24 +227,6 @@ class executionnodemodel extends model ->exec(); } - /** - * Set vm name. - * - * @param array $vm - * @param int $id - * @access public - * @return array - */ - public function setVmName($vm, $id) - { - $name = sprintf('test-%s-%s-%s-%s-%d', $vm['osCategory'], $vm['osType'], $vm['osArch'], $vm['osLang'], $id); - $this->dao->update(TABLE_ZAHOST)->data(array('name' => $name)) - ->where('id')->eq($id) - ->exec(); - $vm['name'] = $name; - return $vm; - } - /** * Get vm list. * @@ -281,17 +262,13 @@ class executionnodemodel extends model $query = str_replace('`id`', 't1.`id`', $query); $query = str_replace('`name`', 't1.`name`', $query); $query = str_replace('`status`', 't1.`status`', $query); - $query = str_replace('`osCategory`', 't1.`osCategory`', $query); - $query = str_replace('`osType`', 't1.`osType`', $query); + $query = str_replace('`os`', 't1.`os`', $query); $query = str_replace('`parent`', 't1.`parent`', $query); - $query = str_replace('`osVersion`', 't4.`osVersion`', $query); } - $orderBy = str_replace('osVersion', 't4.osVersion', $orderBy); - - return $this->dao->select('t1.*, t1.name as hostName, t2.extranet as hostIP,t3.osVersion')->from(TABLE_ZAHOST)->alias('t1') + return $this->dao->select('t1.*, t1.name as hostName, t2.extranet as hostIP,t3.os')->from(TABLE_ZAHOST)->alias('t1') ->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t1.parent = t2.id') - ->leftJoin(TABLE_IMAGE)->alias('t3')->on('t3.id = t1.imageID') + ->leftJoin(TABLE_IMAGE)->alias('t3')->on('t3.id = t1.image') ->where('t1.deleted')->eq(0) ->andWhere("t1.type")->eq("node") ->andWhere("(t1.createdBy = '{$this->app->user->account}')") @@ -344,7 +321,7 @@ class executionnodemodel extends model public function getHostByIP($ip) { return $this->dao->select('*')->from(TABLE_ZAHOST) - ->where('address')->eq($ip) + ->where('extranet')->eq($ip) ->fetch(); } @@ -363,27 +340,7 @@ class executionnodemodel extends model } /** - * Get os list by osCategory. - * - * @param stirng $osCategory - * @access public - * @return void - */ - public function getOsByOsType($osCategory) - { - $list = array(); - foreach($this->lang->vm->osTypeList as $item) - { - if($osCategory == $item['osType']) - { - $list[$item['value']] = $item['label']; - } - } - return $list; - } - - /** - * Get VM template list. + * Get Node image list. * * @param string $orderBy * @param int $pager @@ -396,45 +353,27 @@ class executionnodemodel extends model } /** - * Get Vm Templaete pairs. - * - * @param string $osCategory - * @param string $osType - * @param string $osVersion - * @access public - * @return array - */ - public function getimagePairs($osCategory = '', $osType = '', $osVersion = '') - { - return $this->dao->select('id,name')->from(TABLE_IMAGE) - ->where('osCategory')->eq($osCategory) - ->andwhere('osType')->eq($osType) - ->andwhere('osVersion')->eq($osVersion) - ->fetchPairs(); - } - - /** - * Get VM by id. + * Get Node by id. * * @param int $id * @return object */ - public function getVMByID($id) + public function getNodeByID($id) { - return $this->dao->select('t1.*, t1.name as hostName, t2.extranet as ip,t3.osVersion')->from(TABLE_ZAHOST)->alias('t1') + return $this->dao->select('t1.*, t1.name as hostName, t2.extranet as ip,t3.os')->from(TABLE_ZAHOST)->alias('t1') ->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t1.parent = t2.id') - ->leftJoin(TABLE_IMAGE)->alias('t3')->on('t3.id = t1.imageID') + ->leftJoin(TABLE_IMAGE)->alias('t3')->on('t3.id = t1.image') ->where('t1.id')->eq($id) ->fetch(); } /** - * Get VM by mac address. + * Get Node by mac address. * * @param string $mac * @return object */ - public function getVMByMac($mac) + public function getNodeByMac($mac) { return $this->dao->select('*')->from(TABLE_ZAHOST) ->where('mac')->eq($mac) @@ -462,8 +401,8 @@ class executionnodemodel extends model return sprintf("%02X",$v); },$buf)); - $VM = $this->getVMByMac($mac); - if(empty($VM)) + $Node = $this->getNodeByMac($mac); + if(empty($Node)) { return $mac; } @@ -479,19 +418,19 @@ class executionnodemodel extends model */ public function getVncUrl($vmID) { - $vm = $this->getVMByID($vmID); + $vm = $this->getNodeByID($vmID); if(empty($vm) or empty($vm->parent) or empty($vm->vnc)) return false; $host = $this->getHostByID($vm->parent); if(empty($host)) return false; - $agnetUrl = 'http://' . $host->address . ':' . $host->agentPort . static::KVM_TOKEN_PATH; + $agnetUrl = 'http://' . $host->extranet . ':' . $host->agentPort . static::KVM_TOKEN_PATH; $result = json_decode(commonModel::http("$agnetUrl?port={$vm->vnc}")); if(empty($result) or $result->code != 'success') return false; $returnData = new stdClass(); - $returnData->hostIP = $host->address; + $returnData->hostIP = $host->extranet; $returnData->agentPort = $host->agentPort; $returnData->vnc = $vm->vnc; $returnData->token = $result->data->token; diff --git a/module/executionnode/view/create.html.php b/module/executionnode/view/create.html.php index be3466cbb6..084a22cc5a 100755 --- a/module/executionnode/view/create.html.php +++ b/module/executionnode/view/create.html.php @@ -22,7 +22,7 @@
zahost->virtualSoftware;?>zahost->softwareList, $host->virtualSoftware, "class='form-control chosen'");?>zahost->vsoft;?>zahost->softwareList, $host->vsoft, "class='form-control chosen'");?>
zahost->zaHostType;?>address, "class='form-control' disabled");?>
zahost->cpu ;?>zahost->cpu;?> zahost->cpuCoreList, $host->cpu, "class='form-control chosen'");?>
zahost->disk;?>zahost->diskSize;?>
- disk, "class='form-control'");?> + diskSize, "class='form-control'");?> zahost->unitList['GB'];?> diff --git a/module/zahost/view/edittemplate.html.php b/module/zahost/view/edittemplate.html.php deleted file mode 100644 index ac53dce825..0000000000 --- a/module/zahost/view/edittemplate.html.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @package zahost - * @version $Id$ - * @link http://www.zentao.net - */ -?> -getModuleRoot() . 'common/view/header.html.php';?> -zahost);?> -zahost);?> - -hostID);?> -
-
-

zahost->createTemplate;?>

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
zahost->name;?>name, "class='form-control'");?>
zahost->cpu ;?>cpuCoreNum, "class='form-control'");?>
zahost->memory;?> -
- memorySize, "class='form-control'");?> - MB -
-
zahost->disk;?> -
- diskSize/1024), "class='form-control'");?> - GB -
-
zahost->vmTemplate->osCategory;?>zahost->os->list, $template->osCategory, "class='form-control chosen'")?>
zahost->vmTemplate->osType;?>osType, "class='form-control chosen'")?>
zahost->vmTemplate->osVersion;?>osVersion, "class='form-control chosen'")?>
zahost->vmTemplate->osLang;?>zahost->langList, $template->osLang, "class='form-control chosen'")?>
zahost->vmTemplate->imageName;?>imageName, "class='form-control chosen'")?>
- - - -
- -
-getModuleRoot() . 'common/view/footer.html.php';?> diff --git a/module/zahost/view/view.html.php b/module/zahost/view/view.html.php index 2e120bec51..e42739d8fd 100644 --- a/module/zahost/view/view.html.php +++ b/module/zahost/view/view.html.php @@ -56,8 +56,8 @@
-
zahost->virtualSoftware;?>:
-
virtualSoftware;?>
+
zahost->vsoft;?>:
+
vsoft;?>
@@ -68,8 +68,8 @@
-
zahost->disk;?>:
-
disk;?>
+
zahost->diskSize;?>:
+
diskSize;?>
@@ -89,7 +89,7 @@
zahost->name);?> executionnode->cpu);?> executionnode->memory);?>executionnode->disk);?>executionnode->diskSize);?> executionnode->os);?> executionnode->status);?>
name;?> executionnode->os->cpu, $node->cpu);?> memory . $this->lang->zahost->unitList['GB'];?>disk . zget($this->lang->zahost->unitList, $node->unit);?>diskSize . zget($this->lang->zahost->unitList, $node->unit);?> executionnode->os->list, $node->os);?> executionnode->statusList, $node->status);?>
- + @@ -31,11 +31,11 @@ - + - - + + @@ -47,10 +47,10 @@ - + - - + + diff --git a/module/zahost/control.php b/module/zahost/control.php index cc5f1df70d..eb875fdbda 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -262,23 +262,6 @@ class zahost extends control return $this->send(array('result' => 'success', 'message' => '', 'data' => $statusList)); } - /** - * Check IP format and generate secret. - * - * @param string $IP - * @access public - * @return void - */ - public function ajaxCheckaddress($IP) - { - if(!validater::checkIP($IP)) return $this->send(array('result' => 'fail', 'message' => array('address' => array(sprintf($this->lang->zahost->notice->ip, $this->lang->zahost->address))))); - - $secret = md5(time()); - $registerCommand = sprintf($this->lang->zahost->notice->registerCommand, $this->server->server_addr, $this->server->server_port, $IP, $secret); - - return $this->send(array('result' => 'success', 'message' => '', 'data' => array('registerCommand' => $registerCommand, 'secret' => $secret))); - } - /** * Get image list by ajax. * @@ -320,7 +303,7 @@ class zahost extends control */ public function ajaxGetServiceStatus($hostID) { - $host = $this->zahost->getById($hostID); + $host = $this->zahost->getById($hostID); $serviceStatus = $this->zahost->getServiceStatus($host); return $this->send(array('result' => 'success', 'message' => '', 'data' => $serviceStatus)); diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index b0dea50896..cd1a2e5d00 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -11,17 +11,13 @@ $lang->zahost->deleteAction = 'Delete Host'; $lang->zahost->byQuery = 'Search'; $lang->zahost->all = 'All'; $lang->zahost->browseNode = 'ExecutionNode Browse'; -$lang->zahost->browseTemplate = 'Template Browse'; -$lang->zahost->createTemplate = 'Create Template'; -$lang->zahost->editTemplate = 'Edit Template'; -$lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Name'; $lang->zahost->IP = 'IP/Domain'; $lang->zahost->extranet = 'IP'; $lang->zahost->cpuCores = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; -$lang->zahost->diskSize = 'diskSize Size'; +$lang->zahost->diskSize = 'diskSize Size'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -34,9 +30,7 @@ $lang->zahost->registerDate = 'RegisterDate'; $lang->zahost->memorySize = $lang->zahost->memory; $lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; -$lang->zahost->osType = 'Os Version'; -$lang->zahost->osCategory = 'System'; -$lang->zahost->osVersion = 'Os Version No'; +$lang->zahost->os = 'System'; $lang->zahost->osLang = 'Language'; $lang->zahost->imageName = 'Image File'; @@ -74,11 +68,8 @@ $lang->zahost->image->common = 'Image'; $lang->zahost->image->name = 'Name'; $lang->zahost->image->desc = 'Description'; $lang->zahost->image->memory = $lang->zahost->memory; -$lang->zahost->image->diskSize = $lang->zahost->diskSize; -$lang->zahost->image->osType = $lang->zahost->osType; -$lang->zahost->image->osCategory = $lang->zahost->osCategory; -$lang->zahost->image->osVersion = $lang->zahost->osVersion; -$lang->zahost->image->osLang = $lang->zahost->osLang; +$lang->zahost->image->disk = $lang->zahost->diskSize; +$lang->zahost->image->os = $lang->zahost->osCategory; $lang->zahost->image->imageName = $lang->zahost->imageName; $lang->zahost->image->statusList['created'] = 'Created'; @@ -87,25 +78,7 @@ $lang->zahost->image->statusList['inprogress'] = 'Inprogress'; $lang->zahost->image->statusList['completed'] = 'Completed'; $lang->zahost->image->statusList['failed'] = 'Failed'; -$lang->zahost->vmTemplate = new stdclass; -$lang->zahost->vmTemplate->name = 'Name'; -$lang->zahost->vmTemplate->common = 'VM Template'; -$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpuCores; -$lang->zahost->vmTemplate->memorySize = $lang->zahost->memory; -$lang->zahost->vmTemplate->diskSizeSize = $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->imageName = $lang->zahost->imageName; - -$lang->zahost->langList = array(); -$lang->zahost->langList['zh_cn'] = 'Simplified Chinese'; -$lang->zahost->langList['zh_tw'] = 'Traditional Chinese'; -$lang->zahost->langList['en_us'] = 'American English'; - $lang->zahost->empty = 'No Host'; -$lang->zahost->templateEmpty = 'No Template'; $lang->zahost->statusList['ready'] = 'Ready'; $lang->zahost->statusList['online'] = 'Online'; @@ -120,35 +93,6 @@ $lang->zahost->zaHostType = 'Type'; $lang->zahost->zaHostTypeList['physical'] = 'Physical'; $lang->zahost->confirmDelete = 'Do you want to delete this host?'; -$lang->zahost->confirmDeleteVMTemplate = 'Do you want to delete this VM template?'; - -$lang->zahost->versionList = array(); -$lang->zahost->versionList['winxp']['all'] = 'Windows XP'; -$lang->zahost->versionList['win7']['home'] = 'Home Basic'; -$lang->zahost->versionList['win7']['professional'] = 'Professional'; -$lang->zahost->versionList['win7']['enterprise'] = 'Enterprise'; -$lang->zahost->versionList['win7']['ultimate'] = 'Ultimate'; -$lang->zahost->versionList['win10']['home'] = 'Home Basic'; -$lang->zahost->versionList['win10']['professional'] = 'Professional'; -$lang->zahost->versionList['win10']['enterprise'] = 'Enterprise'; -$lang->zahost->versionList['win10']['ultimate'] = 'Ultimate'; -$lang->zahost->versionList['win11']['home'] = 'Home Basic'; -$lang->zahost->versionList['win11']['professional'] = 'Professional'; -$lang->zahost->versionList['win11']['enterprise'] = 'Enterprise'; -$lang->zahost->versionList['win11']['ultimate'] = '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』incorrect format!'; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index 62bd1f78ff..0ee5b2aa18 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -11,10 +11,6 @@ $lang->zahost->deleteAction = 'Delete Host'; $lang->zahost->byQuery = 'Search'; $lang->zahost->all = 'All'; $lang->zahost->browseNode = 'ExecutionNode Browse'; -$lang->zahost->browseTemplate = 'Template Browse'; -$lang->zahost->createTemplate = 'Create Template'; -$lang->zahost->editTemplate = 'Edit Template'; -$lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Name'; $lang->zahost->IP = 'Extranet Address'; @@ -33,9 +29,9 @@ $lang->zahost->editedDate = 'EditedDate'; $lang->zahost->registerDate = 'RegisterDate'; $lang->zahost->memorySize = $lang->zahost->memory; -$lang->zahost->cpuCoreNum = $lang->zahost->cpu ; +$lang->zahost->cpuCoreNum = $lang->zahost->cpuCores ; $lang->zahost->osType = 'Os Version'; -$lang->zahost->osCategory = 'System'; +$lang->zahost->os = 'System'; $lang->zahost->osVersion = 'Os Version No'; $lang->zahost->osLang = 'Language'; $lang->zahost->imageName = 'Image File'; @@ -74,11 +70,8 @@ $lang->zahost->image->common = 'Image'; $lang->zahost->image->name = 'Name'; $lang->zahost->image->desc = 'Description'; $lang->zahost->image->memory = $lang->zahost->memory; -$lang->zahost->image->diskSize = $lang->zahost->diskSize; -$lang->zahost->image->osType = $lang->zahost->osType; -$lang->zahost->image->osCategory = $lang->zahost->osCategory; -$lang->zahost->image->osVersion = $lang->zahost->osVersion; -$lang->zahost->image->osLang = $lang->zahost->osLang; +$lang->zahost->image->disk = $lang->zahost->diskSize; +$lang->zahost->image->os = $lang->zahost->os; $lang->zahost->image->imageName = $lang->zahost->imageName; $lang->zahost->image->statusList['created'] = 'Created'; @@ -93,7 +86,6 @@ $lang->zahost->langList['zh_tw'] = 'Traditional Chinese'; $lang->zahost->langList['en_us'] = 'American English'; $lang->zahost->empty = 'No Host'; -$lang->zahost->templateEmpty = 'No Template'; $lang->zahost->statusList['ready'] = 'Ready'; $lang->zahost->statusList['online'] = 'Online'; @@ -108,7 +100,6 @@ $lang->zahost->zaHostType = 'Type'; $lang->zahost->zaHostTypeList['physical'] = 'Physical'; $lang->zahost->confirmDelete = 'Do you want to delete this host?'; -$lang->zahost->confirmDeleteVMTemplate = 'Do you want to delete this VM template?'; $lang->zahost->notice = new stdclass(); $lang->zahost->notice->ip = '『%s』incorrect format!'; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index 02ed9f299d..d96817e989 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -11,17 +11,13 @@ $lang->zahost->deleteAction = 'Supprimer Hôte'; $lang->zahost->byQuery = 'Recherche'; $lang->zahost->all = 'Tous les hôtes'; $lang->zahost->browseNode = 'ExecutionNode Browse'; -$lang->zahost->browseTemplate = 'Template Browse'; -$lang->zahost->createTemplate = 'Create Template'; -$lang->zahost->editTemplate = 'Edit Template'; -$lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Nom'; $lang->zahost->IP = 'IP/Domain'; -$lang->zahost->address = 'IP'; -$lang->zahost->cpu = 'CPU Cores'; +$lang->zahost->extranet = 'IP'; +$lang->zahost->cpuCore = 'CPU Cores'; $lang->zahost->memory = 'Mémoire Espace'; -$lang->zahost->diskSize = 'Disque Espace'; +$lang->zahost->diskSize = 'Disque Espace'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -33,11 +29,8 @@ $lang->zahost->editedDate = "Date d'édition"; $lang->zahost->registerDate = "RegisterDate"; $lang->zahost->memorySize = $lang->zahost->memory; -$lang->zahost->cpuCoreNum = $lang->zahost->cpu ; -$lang->zahost->osType = 'Os Version'; -$lang->zahost->osCategory = 'System'; -$lang->zahost->osVersion = 'Os Version No'; -$lang->zahost->osLang = 'Language'; +$lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; +$lang->zahost->os = 'System'; $lang->zahost->imageName = 'Image File'; $lang->zahost->initHost = new stdclass; @@ -74,9 +67,8 @@ $lang->zahost->image->common = 'Image'; $lang->zahost->image->name = 'Name'; $lang->zahost->image->desc = 'Description'; $lang->zahost->image->memory = $lang->zahost->memory; -$lang->zahost->image->diskSize = $lang->zahost->diskSize; -$lang->zahost->image->osType = $lang->zahost->osType; -$lang->zahost->image->osCategory = $lang->zahost->osCategory; +$lang->zahost->image->disk = $lang->zahost->diskSize; +$lang->zahost->image->os = $lang->zahost->os; $lang->zahost->image->osVersion = $lang->zahost->osVersion; $lang->zahost->image->osLang = $lang->zahost->osLang; $lang->zahost->image->imageName = $lang->zahost->imageName; @@ -87,25 +79,7 @@ $lang->zahost->image->statusList['inprogress'] = 'Inprogress'; $lang->zahost->image->statusList['completed'] = 'Completed'; $lang->zahost->image->statusList['failed'] = 'Failed'; -$lang->zahost->vmTemplate = new stdclass; -$lang->zahost->vmTemplate->name = 'Nom'; -$lang->zahost->vmTemplate->common = 'VM Template'; -$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpu ; -$lang->zahost->vmTemplate->memorySize = $lang->zahost->memory; -$lang->zahost->vmTemplate->diskSizeSize = $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->imageName = $lang->zahost->imageName; - -$lang->zahost->langList = array(); -$lang->zahost->langList['zh_cn'] = 'Simplified Chinese'; -$lang->zahost->langList['zh_tw'] = 'Traditional Chinese'; -$lang->zahost->langList['en_us'] = 'American English'; - $lang->zahost->empty = 'No Host'; -$lang->zahost->templateEmpty = 'No Template'; $lang->zahost->statusList['ready'] = 'Ready'; $lang->zahost->statusList['online'] = 'Online'; @@ -120,35 +94,6 @@ $lang->zahost->zaHostType = 'Type Hôte'; $lang->zahost->zaHostTypeList['physical'] = 'Physique'; $lang->zahost->confirmDelete = 'Voulez-vous supprimer cet hôte?'; -$lang->zahost->confirmDeleteVMTemplate = 'Do you want to delete this VM template?'; - -$lang->zahost->versionList = array(); -$lang->zahost->versionList['winxp']['all'] = 'Windows XP'; -$lang->zahost->versionList['win7']['home'] = 'Home Basic'; -$lang->zahost->versionList['win7']['professional'] = 'Professional'; -$lang->zahost->versionList['win7']['enterprise'] = 'Enterprise'; -$lang->zahost->versionList['win7']['ultimate'] = 'Ultimate'; -$lang->zahost->versionList['win10']['home'] = 'Home Basic'; -$lang->zahost->versionList['win10']['professional'] = 'Professional'; -$lang->zahost->versionList['win10']['enterprise'] = 'Enterprise'; -$lang->zahost->versionList['win10']['ultimate'] = 'Ultimate'; -$lang->zahost->versionList['win11']['home'] = 'Home Basic'; -$lang->zahost->versionList['win11']['professional'] = 'Professional'; -$lang->zahost->versionList['win11']['enterprise'] = 'Enterprise'; -$lang->zahost->versionList['win11']['ultimate'] = '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』format incorrect!'; diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php index d6f82c1199..1d8f4564a9 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -18,10 +18,10 @@ $lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Name'; $lang->zahost->IP = 'IP/Domain'; -$lang->zahost->address = 'IP'; -$lang->zahost->cpu = 'CPU Cores'; +$lang->zahost->extranet = 'IP'; +$lang->zahost->cpuCores = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; -$lang->zahost->diskSize = 'diskSize Size'; +$lang->zahost->diskSize = 'diskSize Size'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -33,9 +33,9 @@ $lang->zahost->editedDate = 'EditedDate'; $lang->zahost->registerDate = 'RegisterDate'; $lang->zahost->memorySize = $lang->zahost->memory; -$lang->zahost->cpuCoreNum = $lang->zahost->cpu ; +$lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; $lang->zahost->osType = 'Os Version'; -$lang->zahost->osCategory = 'System'; +$lang->zahost->os = 'System'; $lang->zahost->osVersion = 'Os Version No'; $lang->zahost->osLang = 'Language'; $lang->zahost->imageName = 'Image File'; @@ -74,9 +74,9 @@ $lang->zahost->image->common = 'Image'; $lang->zahost->image->name = 'Name'; $lang->zahost->image->desc = 'Description'; $lang->zahost->image->memory = $lang->zahost->memory; -$lang->zahost->image->diskSize = $lang->zahost->diskSize; +$lang->zahost->image->disk = $lang->zahost->diskSize; $lang->zahost->image->osType = $lang->zahost->osType; -$lang->zahost->image->osCategory = $lang->zahost->osCategory; +$lang->zahost->image->os = $lang->zahost->os; $lang->zahost->image->osVersion = $lang->zahost->osVersion; $lang->zahost->image->osLang = $lang->zahost->osLang; $lang->zahost->image->imageName = $lang->zahost->imageName; @@ -87,25 +87,7 @@ $lang->zahost->image->statusList['inprogress'] = 'Inprogress'; $lang->zahost->image->statusList['completed'] = 'Completed'; $lang->zahost->image->statusList['failed'] = 'Failed'; -$lang->zahost->vmTemplate = new stdclass; -$lang->zahost->vmTemplate->name = 'Name'; -$lang->zahost->vmTemplate->common = 'VM Template'; -$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpu ; -$lang->zahost->vmTemplate->memorySize = $lang->zahost->memory; -$lang->zahost->vmTemplate->diskSizeSize = $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->imageName = $lang->zahost->imageName; - $lang->zahost->empty = 'No Host'; -$lang->zahost->templateEmpty = 'No Template'; - -$lang->zahost->langList = array(); -$lang->zahost->langList['zh_cn'] = 'Simplified Chinese'; -$lang->zahost->langList['zh_tw'] = 'Traditional Chinese'; -$lang->zahost->langList['en_us'] = 'American English'; $lang->zahost->statusList['ready'] = 'Ready'; $lang->zahost->statusList['online'] = 'Online'; @@ -120,35 +102,6 @@ $lang->zahost->zaHostType = 'Type'; $lang->zahost->zaHostTypeList['physical'] = 'Physical'; $lang->zahost->confirmDelete = 'Do you want to delete this host?'; -$lang->zahost->confirmDeleteVMTemplate = 'Do you want to delete this VM template?'; - -$lang->zahost->versionList = array(); -$lang->zahost->versionList['winxp']['all'] = 'Windows XP'; -$lang->zahost->versionList['win7']['home'] = 'Home Basic'; -$lang->zahost->versionList['win7']['professional'] = 'Professional'; -$lang->zahost->versionList['win7']['enterprise'] = 'Enterprise'; -$lang->zahost->versionList['win7']['ultimate'] = 'Ultimate'; -$lang->zahost->versionList['win10']['home'] = 'Home Basic'; -$lang->zahost->versionList['win10']['professional'] = 'Professional'; -$lang->zahost->versionList['win10']['enterprise'] = 'Enterprise'; -$lang->zahost->versionList['win10']['ultimate'] = 'Ultimate'; -$lang->zahost->versionList['win11']['home'] = 'Home Basic'; -$lang->zahost->versionList['win11']['professional'] = 'Professional'; -$lang->zahost->versionList['win11']['enterprise'] = 'Enterprise'; -$lang->zahost->versionList['win11']['ultimate'] = '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』incorrect format!'; diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index 0089b90df8..723b45d945 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -12,17 +12,13 @@ $lang->zahost->deleteAction = '删除宿主机'; $lang->zahost->byQuery = '搜索'; $lang->zahost->all = '全部主机'; $lang->zahost->browseNode = '执行节点列表'; -$lang->zahost->browseTemplate = '虚拟机模板列表'; -$lang->zahost->createTemplate = '创建虚拟机模板'; -$lang->zahost->editTemplate = '编辑虚拟机模板'; -$lang->zahost->deleteTemplate = '删除虚拟机模板'; $lang->zahost->name = '名称'; $lang->zahost->IP = 'IP/域名'; -$lang->zahost->address = 'IP/域名'; +$lang->zahost->extranet = 'IP/域名'; $lang->zahost->memory = '内存'; -$lang->zahost->cpu = 'CPU核心数'; -$lang->zahost->diskSize = '硬盘容量'; +$lang->zahost->cpuCores = 'CPU核心数'; +$lang->zahost->diskSize = '硬盘容量'; $lang->zahost->desc = '描述'; $lang->zahost->type = '类型'; $lang->zahost->status = '状态'; @@ -34,11 +30,8 @@ $lang->zahost->editedDate = '最后修改时间'; $lang->zahost->registerDate = '最后注册时间'; $lang->zahost->memorySize = $lang->zahost->memory; -$lang->zahost->cpuCoreNum = $lang->zahost->cpu ; -$lang->zahost->osType = '操作系统版本'; -$lang->zahost->osCategory = '操作系统平台'; -$lang->zahost->osVersion = '操作系统版本号'; -$lang->zahost->osLang = '系统语言'; +$lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; +$lang->zahost->os = '操作系统平台'; $lang->zahost->imageName = '镜像文件'; $lang->zahost->initHost = new stdclass; @@ -76,11 +69,8 @@ $lang->zahost->image->common = '镜像'; $lang->zahost->image->name = '名称'; $lang->zahost->image->desc = '说明'; $lang->zahost->image->memory = $lang->zahost->memory; -$lang->zahost->image->diskSize = $lang->zahost->diskSize; -$lang->zahost->image->osType = $lang->zahost->osType; -$lang->zahost->image->osCategory = $lang->zahost->osCategory; -$lang->zahost->image->osVersion = $lang->zahost->osVersion; -$lang->zahost->image->osLang = $lang->zahost->osLang; +$lang->zahost->image->disk = $lang->zahost->diskSize; +$lang->zahost->image->os = $lang->zahost->os; $lang->zahost->image->imageName = $lang->zahost->imageName; $lang->zahost->image->statusList['created'] = '已创建'; @@ -93,25 +83,8 @@ $lang->zahost->image->imageEmpty = '无镜像'; $lang->zahost->image->downloadImageFail = '创建下载镜像任务失败'; $lang->zahost->image->downloadImageSuccess = '创建下载镜像任务成功'; -$lang->zahost->vmTemplate = new stdclass; -$lang->zahost->vmTemplate->name = '名称'; -$lang->zahost->vmTemplate->common = '虚拟机模板'; -$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpu ; -$lang->zahost->vmTemplate->memorySize = $lang->zahost->memory; -$lang->zahost->vmTemplate->diskSizeSize = $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->imageName = $lang->zahost->imageName; - -$lang->zahost->langList = array(); -$lang->zahost->langList['zh_cn'] = '简体中文'; -$lang->zahost->langList['zh_tw'] = '繁体中文'; -$lang->zahost->langList['en_us'] = '美式英语'; $lang->zahost->empty = '暂时没有宿主机'; -$lang->zahost->templateEmpty = '暂时没有模板'; $lang->zahost->statusList['ready'] = '准备中'; $lang->zahost->statusList['online'] = '已上架'; @@ -126,35 +99,6 @@ $lang->zahost->zaHostType = '主机类型'; $lang->zahost->zaHostTypeList['physical'] = '实体主机'; $lang->zahost->confirmDelete = '是否删除该主机记录?'; -$lang->zahost->confirmDeleteVMTemplate = '是否删除该虚拟机模板?'; - -$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』格式不正确!'; diff --git a/module/zahost/model.php b/module/zahost/model.php index b63471ff0e..f0609f85e8 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -94,7 +94,7 @@ class zahostModel extends model */ public function getImageByID($imageID) { - return $this->dao->select('*')->from(TABLE_IMAGE)->where('deleted')->eq(0)->andWhere('id')->eq($imageID)->fetch(); + return $this->dao->select('*')->from(TABLE_IMAGE)->where('id')->eq($imageID)->fetch(); } /** @@ -108,8 +108,7 @@ class zahostModel extends model public function getImageByNameAndHostID($imageName, $hostID) { return $this->dao->select('*')->from(TABLE_IMAGE) - ->where('deleted')->eq(0) - ->andWhere('hostID')->eq($hostID) + ->where('host')->eq($hostID) ->andWhere('name')->eq($imageName)->fetch(); } @@ -125,7 +124,7 @@ class zahostModel extends model $imageList = json_decode(file_get_contents($this->config->zahost->imageListUrl)); $downloadedImageList = $this->dao->select('*')->from(TABLE_IMAGE) - ->where('hostID')->eq($hostID) + ->where('host')->eq($hostID) ->orderBy($orderBy) ->page($pager) ->fetchAll('name'); @@ -144,7 +143,7 @@ class zahostModel extends model $image->status = $downloadedImage->status; } - $image->hostID = $hostID; + $image->host = $hostID; } return $imageList; @@ -165,10 +164,9 @@ class zahostModel extends model $imageData = new stdclass; foreach($imageList as $item) if($item->name == $imageName) $imageData = $item; - $imageData->hostID = $hostID; + $imageData->host = $hostID; $imageData->status = 'created'; - $imageData->osCategory = $imageData->os; - unset($imageData->os); + $imageData->os = $imageData->os; $this->dao->insert(TABLE_IMAGE)->data($imageData, 'desc')->autoCheck()->exec(); if(dao::isError()) return false; @@ -188,8 +186,8 @@ class zahostModel extends model */ public function downloadImage($image) { - $host = $this->getById($image->hostID); - $apiUrl = 'http://' . $host->address . ':' . $this->config->zahost->defaultPort . '/api/v1/download/add'; + $host = $this->getById($image->host); + $apiUrl = 'http://' . $host->extranet . ':' . $this->config->zahost->defaultPort . '/api/v1/download/add'; $apiParams['md5'] = $image->md5; $apiParams['url'] = $image->address; @@ -218,8 +216,8 @@ class zahostModel extends model */ public function queryDownloadImageStatus($image) { - $host = $this->getById($image->hostID); - $apiUrl = 'http://' . $host->address . ':' . $this->config->zahost->defaultPort . '/api/v1/task/getStatus'; + $host = $this->getById($image->host); + $apiUrl = 'http://' . $host->extranet . ':' . $this->config->zahost->defaultPort . '/api/v1/task/getStatus'; $result = json_decode(commonModel::http($apiUrl, array(), array(CURLOPT_CUSTOMREQUEST => 'POST'), array(), 'json')); if(!$result or $result->code != 'success') return $image->status; @@ -242,7 +240,6 @@ class zahostModel extends model $image->status = $status; $this->dao->update(TABLE_IMAGE) - ->set('osCategory')->eq($image->os) ->set('status')->eq($status) ->set('path')->eq($currentTask->path) ->where('id')->eq($image->id)->exec(); @@ -263,8 +260,8 @@ class zahostModel extends model */ public function downloadImageStatus($image) { - $host = $this->getById($image->hostID); - $statusApi = 'http://' . $host->address . '/api/v1/task/status'; + $host = $this->getById($image->host); + $statusApi = 'http://' . $host->extranet . '/api/v1/task/status'; $response = json_decode(commonModel::http($statusApi, array(), array(CURLOPT_CUSTOMREQUEST => 'GET'), array(), 'json')); @@ -377,11 +374,11 @@ class zahostModel extends model if($host->deleted) return ''; $menu = ''; - $params = "hostID=$host->hostID"; + $params = "hostID=$host->id"; $menu .= $this->buildMenu('zahost', 'edit', $params, $host, 'view'); - $params = "hostID=$host->assetID"; + $params = "hostID=$host->id"; $menu .= $this->buildMenu('zahost', 'delete', $params, $host, 'view', 'trash', 'hiddenwin'); return $menu; @@ -396,7 +393,7 @@ class zahostModel extends model */ public function getImagePairs($hostID) { - return $this->dao->select('id,name')->from(TABLE_IMAGE)->where('hostID')->eq($hostID)->andWhere('status')->eq('completed')->fetchPairs(); + return $this->dao->select('id,name')->from(TABLE_IMAGE)->where('host')->eq($hostID)->andWhere('status')->eq('completed')->fetchPairs(); } /** @@ -408,7 +405,7 @@ class zahostModel extends model */ public function getServiceStatus($host) { - $result = json_decode(commonModel::http("http://{$host->address}:8086/api/v1/service/check", json_encode(array("services" => "all")))); + $result = json_decode(commonModel::http("http://{$host->extranet}:8086/api/v1/service/check", json_encode(array("services" => "all")))); if(empty($result) || $result->code != 'success') { $result = new stdclass; diff --git a/module/zahost/view/create.html.php b/module/zahost/view/create.html.php index 926c6f6169..5bcb7c257a 100644 --- a/module/zahost/view/create.html.php +++ b/module/zahost/view/create.html.php @@ -34,12 +34,12 @@ - - + + - - + + diff --git a/module/zahost/view/edit.html.php b/module/zahost/view/edit.html.php index 2117b17a4f..a1879cffa9 100644 --- a/module/zahost/view/edit.html.php +++ b/module/zahost/view/edit.html.php @@ -35,11 +35,11 @@ - + - - + + diff --git a/module/zahost/view/view.html.php b/module/zahost/view/view.html.php index e42739d8fd..2068941f1a 100644 --- a/module/zahost/view/view.html.php +++ b/module/zahost/view/view.html.php @@ -42,7 +42,7 @@
-
zahost->address;?>:
+
zahost->extranet;?>:
address;?>
From c2b0f0a656ed20a9ada9a9b1dd3c315c1f8e5252 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Wed, 23 Nov 2022 02:44:27 +0000 Subject: [PATCH 27/36] * Update zanode name --- api/v1/entries/executionnodeheartbeat.php | 31 +++--- config/routes.php | 2 +- module/action/config.php | 2 +- module/action/lang/de.php | 13 ++- module/action/lang/en.php | 13 ++- module/action/lang/fr.php | 12 +-- module/action/lang/vi.php | 12 +-- module/action/lang/zh-cn.php | 13 ++- module/common/lang/common.php | 2 +- module/common/lang/de.php | 2 +- module/common/lang/en.php | 2 +- module/common/lang/fr.php | 2 +- module/common/lang/menu.php | 4 +- module/common/lang/zh-cn.php | 2 +- module/executionnode/config.php | 44 -------- module/executionnode/lang/de.php | 60 ----------- module/executionnode/lang/en.php | 60 ----------- module/executionnode/lang/fr.php | 60 ----------- module/executionnode/lang/zh-cn.php | 62 ----------- module/executionnode/view/browse.html.php | 100 ------------------ module/group/lang/resource.php | 32 +++--- module/upgrade/config.php | 2 +- module/zahost/control.php | 2 +- module/zahost/lang/de.php | 2 +- module/zahost/lang/en.php | 2 +- module/zahost/lang/fr.php | 2 +- module/zahost/lang/vi.php | 6 +- module/zahost/view/browse.html.php | 12 +-- module/zahost/view/view.html.php | 24 ++--- module/zanode/config.php | 44 ++++++++ module/{executionnode => zanode}/control.php | 38 +++---- .../{executionnode => zanode}/css/browse.css | 0 .../{executionnode => zanode}/css/create.css | 0 module/{executionnode => zanode}/js/browse.js | 0 module/{executionnode => zanode}/js/common.js | 4 +- module/zanode/lang/de.php | 60 +++++++++++ module/zanode/lang/en.php | 60 +++++++++++ module/zanode/lang/fr.php | 60 +++++++++++ module/zanode/lang/zh-cn.php | 62 +++++++++++ .../{executionnode => zanode}/lang/zh-tw.php | 0 module/{executionnode => zanode}/model.php | 44 ++++---- module/zanode/view/browse.html.php | 100 ++++++++++++++++++ .../view/create.html.php | 22 ++-- .../view/getvnc.html.php | 0 .../view/view.html.php | 0 45 files changed, 535 insertions(+), 541 deletions(-) delete mode 100755 module/executionnode/config.php delete mode 100755 module/executionnode/lang/de.php delete mode 100755 module/executionnode/lang/en.php delete mode 100755 module/executionnode/lang/fr.php delete mode 100755 module/executionnode/lang/zh-cn.php delete mode 100755 module/executionnode/view/browse.html.php create mode 100644 module/zanode/config.php rename module/{executionnode => zanode}/control.php (77%) mode change 100755 => 100644 rename module/{executionnode => zanode}/css/browse.css (100%) rename module/{executionnode => zanode}/css/create.css (100%) rename module/{executionnode => zanode}/js/browse.js (100%) mode change 100755 => 100644 rename module/{executionnode => zanode}/js/common.js (83%) mode change 100755 => 100644 create mode 100644 module/zanode/lang/de.php create mode 100644 module/zanode/lang/en.php create mode 100644 module/zanode/lang/fr.php create mode 100644 module/zanode/lang/zh-cn.php rename module/{executionnode => zanode}/lang/zh-tw.php (100%) rename module/{executionnode => zanode}/model.php (88%) mode change 100755 => 100644 create mode 100644 module/zanode/view/browse.html.php rename module/{executionnode => zanode}/view/create.html.php (77%) mode change 100755 => 100644 rename module/{executionnode => zanode}/view/getvnc.html.php (100%) rename module/{executionnode => zanode}/view/view.html.php (100%) diff --git a/api/v1/entries/executionnodeheartbeat.php b/api/v1/entries/executionnodeheartbeat.php index 8a2d30dc34..5923d0fc10 100644 --- a/api/v1/entries/executionnodeheartbeat.php +++ b/api/v1/entries/executionnodeheartbeat.php @@ -1,6 +1,6 @@ sendError(400, 'Params error.'); $this->dao = $this->loadModel('common')->dao; - $assetID = $this->dao->select('assetID')->from(TABLE_HOST) + $id = $this->dao->select('id')->from(TABLE_ZAHOST) ->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.'); + ->beginIF(!$secret)->where('tokenSN')->eq($token) + ->andWhere('tokenTime')->gt($now)->fi() + ->fetch('id'); + if(!$id) return $this->sendError(400, 'Secret error.'); - $conditionField = $secret ? 'secret' : 'token'; + $conditionField = $secret ? 'secret' : 'tokenSN'; $conditionValue = $secret ? $secret : $token; if($secret) { $host = new stdclass(); - $host->token = md5($secret . $now); - $host->expiredDate = date('Y-m-d H:i:s', time() + 7200); - $this->dao->update(TABLE_HOST)->data($host)->where($conditionField)->eq($conditionValue)->exec(); + $host->tokenSN = md5($secret . $now); + $host->tokenTime = date('Y-m-d H:i:s', time() + 7200); + $this->dao->update(TABLE_ZAHOST)->data($host)->where($conditionField)->eq($conditionValue)->exec(); } $node = new stdclass(); - $node->vmIP = $this->requestBody->ip; - $node->agentPort = $this->requestBody->agentPortOnHost; + $node->zap = $this->requestBody->agentPortOnHost; $node->status = $this->requestBody->status; - $this->dao->update(TABLE_VM)->data($node)->where('macAddress')->eq($this->requestBody->macAddress)->exec(); + $this->dao->update(TABLE_ZAHOST)->data($node)->where('mac')->eq($this->requestBody->macAddress)->exec(); if(!$secret) return $this->sendSuccess(200, 'success'); $host->expiredTimeUnix = strtotime($host->expiredDate); + $host->token = $host->tokenSN; + unset($host->status); - unset($host->expiredDate); + unset($host->tokenSN); return $this->send(200, $host); } } diff --git a/config/routes.php b/config/routes.php index 3b35290ee7..18a55e1ec6 100644 --- a/config/routes.php +++ b/config/routes.php @@ -163,7 +163,7 @@ $routes['/reports'] = 'reports'; $routes['/host/heartbeat'] = 'hostHeartbeat'; -$routes['/executionnode/heartbeat'] = 'executionnodeHeartbeat'; +$routes['/zanode/heartbeat'] = 'zanodeHeartbeat'; $routes['/z/folders'] = 'zfolders'; $routes['/z/folders/:id'] = 'zfolder'; diff --git a/module/action/config.php b/module/action/config.php index 5229e6b93d..62052e47b1 100755 --- a/module/action/config.php +++ b/module/action/config.php @@ -48,7 +48,7 @@ $config->action->objectNameFields['gogs'] = 'name'; $config->action->objectNameFields['stage'] = 'name'; $config->action->objectNameFields['apistruct'] = 'name'; $config->action->objectNameFields['repo'] = 'name'; -$config->action->objectNameFields['executionnode'] = 'name'; +$config->action->objectNameFields['zanode'] = 'name'; $config->action->commonImgSize = 870; diff --git a/module/action/lang/de.php b/module/action/lang/de.php index bb547129d4..397a6a56ed 100644 --- a/module/action/lang/de.php +++ b/module/action/lang/de.php @@ -112,8 +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['executionnode'] = 'Execution Node'; +$lang->action->objectTypes['zanode'] = 'ZA Node'; $lang->action->objectTypes['doc'] = 'Dok'; $lang->action->objectTypes['api'] = 'Interface'; $lang->action->objectTypes['doclib'] = 'Dok Bibliothek'; @@ -643,11 +642,11 @@ $lang->action->dynamicAction->zahost['created'] = 'Create Host'; $lang->action->dynamicAction->vmtemplate['created'] = 'Create Virtual Host Template'; -$lang->action->dynamicAction->executionnode['created'] = 'Create Execution Node'; -$lang->action->dynamicAction->executionnode['suspend'] = 'Suspend Execution Node'; -$lang->action->dynamicAction->executionnode['resume'] = 'Resume Execution Node'; -$lang->action->dynamicAction->executionnode['reboot'] = 'Reboot Execution Node'; -$lang->action->dynamicAction->executionnode['destroy'] = 'Destory Execution Node'; +$lang->action->dynamicAction->zanode['created'] = 'Create Zagent Node'; +$lang->action->dynamicAction->zanode['suspend'] = 'Suspend Zagent Node'; +$lang->action->dynamicAction->zanode['resume'] = 'Resume Zagent Node'; +$lang->action->dynamicAction->zanode['reboot'] = 'Reboot Zagent Node'; +$lang->action->dynamicAction->zanode['destroy'] = 'Destory Zagent Node'; $lang->action->dynamicAction->doclib['created'] = 'Create Doc Library'; $lang->action->dynamicAction->doclib['edited'] = 'Edit Doc Library'; diff --git a/module/action/lang/en.php b/module/action/lang/en.php index 38619800bd..e0dd127398 100755 --- a/module/action/lang/en.php +++ b/module/action/lang/en.php @@ -112,8 +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['executionnode'] = 'Execution Node'; +$lang->action->objectTypes['zanode'] = 'ZA Node'; $lang->action->objectTypes['doc'] = 'Document'; $lang->action->objectTypes['api'] = 'Interface'; $lang->action->objectTypes['doclib'] = 'Document Library'; @@ -644,11 +643,11 @@ $lang->action->dynamicAction->zahost['created'] = 'Create Host'; $lang->action->dynamicAction->vmtemplate['created'] = 'Create Virtual Host Template'; -$lang->action->dynamicAction->executionnode['created'] = 'Create Execution Node'; -$lang->action->dynamicAction->executionnode['suspend'] = 'Suspend Execution Node'; -$lang->action->dynamicAction->executionnode['resume'] = 'Resume Execution Node'; -$lang->action->dynamicAction->executionnode['reboot'] = 'Reboot Execution Node'; -$lang->action->dynamicAction->executionnode['destroy'] = 'Destory Execution Node'; +$lang->action->dynamicAction->zanode['created'] = 'Create Zagent Node'; +$lang->action->dynamicAction->zanode['suspend'] = 'Suspend Zagent Node'; +$lang->action->dynamicAction->zanode['resume'] = 'Resume Zagent Node'; +$lang->action->dynamicAction->zanode['reboot'] = 'Reboot Zagent Node'; +$lang->action->dynamicAction->zanode['destroy'] = 'Destory Zagent Node'; $lang->action->dynamicAction->doclib['created'] = 'Create Doc Library'; $lang->action->dynamicAction->doclib['edited'] = 'Edit Doc Library'; diff --git a/module/action/lang/fr.php b/module/action/lang/fr.php index 47a856b1c9..c8c4f9d82b 100644 --- a/module/action/lang/fr.php +++ b/module/action/lang/fr.php @@ -112,7 +112,7 @@ $lang->action->objectTypes['testsuite'] = 'Cahier recette'; $lang->action->objectTypes['testtask'] = 'Recette'; $lang->action->objectTypes['testreport'] = 'Edition'; $lang->action->objectTypes['zahost'] = 'Host'; -$lang->action->objectTypes['executionnode'] = 'Execution Node'; +$lang->action->objectTypes['zanode'] = 'ZA Node'; $lang->action->objectTypes['doc'] = 'Document'; $lang->action->objectTypes['api'] = 'Interface'; $lang->action->objectTypes['doclib'] = 'Répertoire Documents'; @@ -642,11 +642,11 @@ $lang->action->dynamicAction->zahost['created'] = 'Create Host'; $lang->action->dynamicAction->vmtemplate['created'] = 'Create Virtual Host Template'; -$lang->action->dynamicAction->executionnode['created'] = 'Create Execution Node'; -$lang->action->dynamicAction->executionnode['suspend'] = 'Suspend Execution Node'; -$lang->action->dynamicAction->executionnode['resume'] = 'Resume Execution Node'; -$lang->action->dynamicAction->executionnode['reboot'] = 'Reboot Execution Node'; -$lang->action->dynamicAction->executionnode['destroy'] = 'Destory Execution Node'; +$lang->action->dynamicAction->zanode['created'] = 'Create Zagent Node'; +$lang->action->dynamicAction->zanode['suspend'] = 'Suspend Zagent Node'; +$lang->action->dynamicAction->zanode['resume'] = 'Resume Zagent Node'; +$lang->action->dynamicAction->zanode['reboot'] = 'Reboot Zagent Node'; +$lang->action->dynamicAction->zanode['destroy'] = 'Destory Zagent Node'; $lang->action->dynamicAction->doclib['created'] = 'Créer Doc Library'; $lang->action->dynamicAction->doclib['edited'] = 'Editer Doc Library'; diff --git a/module/action/lang/vi.php b/module/action/lang/vi.php index 4e0ef83620..822da8e48d 100644 --- a/module/action/lang/vi.php +++ b/module/action/lang/vi.php @@ -90,7 +90,7 @@ $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['executionnode'] = 'Execution Node'; +$lang->action->objectTypes['zanode'] = 'ZA Node'; $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'; @@ -498,11 +498,11 @@ $lang->action->dynamicAction->zahost['created'] = 'Create Host'; $lang->action->dynamicAction->vmtemplate['created'] = 'Create Virtual Host Template'; -$lang->action->dynamicAction->executionnode['created'] = 'Create Execution Node'; -$lang->action->dynamicAction->executionnode['suspend'] = 'Suspend Execution Node'; -$lang->action->dynamicAction->executionnode['resume'] = 'Resume Execution Node'; -$lang->action->dynamicAction->executionnode['reboot'] = 'Reboot Execution Node'; -$lang->action->dynamicAction->executionnode['destroy'] = 'Destory Execution Node'; +$lang->action->dynamicAction->zanode['created'] = 'Create Zagent Node'; +$lang->action->dynamicAction->zanode['suspend'] = 'Suspend Zagent Node'; +$lang->action->dynamicAction->zanode['resume'] = 'Resume Zagent Node'; +$lang->action->dynamicAction->zanode['reboot'] = 'Reboot Zagent Node'; +$lang->action->dynamicAction->zanode['destroy'] = 'Destory Zagent Node'; $lang->action->dynamicAction->doclib['created'] = 'Tạo Doc thư viện'; $lang->action->dynamicAction->doclib['edited'] = 'Sửa Doc thư viện'; diff --git a/module/action/lang/zh-cn.php b/module/action/lang/zh-cn.php index 1d1d61002d..fa8a8ac6fb 100755 --- a/module/action/lang/zh-cn.php +++ b/module/action/lang/zh-cn.php @@ -112,8 +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['executionnode'] = '执行节点'; +$lang->action->objectTypes['zanode'] = '执行节点'; $lang->action->objectTypes['doc'] = '文档'; $lang->action->objectTypes['api'] = '接口'; $lang->action->objectTypes['doclib'] = '文档库'; @@ -643,11 +642,11 @@ $lang->action->dynamicAction->zahost['created'] = '创建宿主机'; $lang->action->dynamicAction->vmtemplate['created'] = '创建虚拟机模板'; -$lang->action->dynamicAction->executionnode['created'] = '创建执行节点'; -$lang->action->dynamicAction->executionnode['suspend'] = '暂停执行节点'; -$lang->action->dynamicAction->executionnode['resume'] = '恢复执行节点'; -$lang->action->dynamicAction->executionnode['reboot'] = '重启执行节点'; -$lang->action->dynamicAction->executionnode['destroy'] = '销毁执行节点'; +$lang->action->dynamicAction->zanode['created'] = '创建执行节点'; +$lang->action->dynamicAction->zanode['suspend'] = '暂停执行节点'; +$lang->action->dynamicAction->zanode['resume'] = '恢复执行节点'; +$lang->action->dynamicAction->zanode['reboot'] = '重启执行节点'; +$lang->action->dynamicAction->zanode['destroy'] = '销毁执行节点'; $lang->action->dynamicAction->doclib['created'] = '创建文档库'; $lang->action->dynamicAction->doclib['edited'] = '编辑文档库'; diff --git a/module/common/lang/common.php b/module/common/lang/common.php index 10f99d1ade..2e16cc6e68 100644 --- a/module/common/lang/common.php +++ b/module/common/lang/common.php @@ -71,7 +71,7 @@ $lang->devops = new stdclass(); $lang->team = new stdclass(); $lang->automation = new stdclass(); $lang->zahost = new stdclass(); -$lang->executionnode = new stdclass(); +$lang->zanode = new stdclass(); $lang->personnel = new stdclass(); $lang->mail = new stdclass(); $lang->testsuite = new stdclass(); diff --git a/module/common/lang/de.php b/module/common/lang/de.php index 44eb1b433f..a2ab6d6170 100644 --- a/module/common/lang/de.php +++ b/module/common/lang/de.php @@ -181,7 +181,7 @@ $lang->build->common = 'Build'; $lang->testreport->common = 'Report'; $lang->automation->common = 'Automation:'; $lang->zahost->common = 'ZAhost'; -$lang->executionnode->common = 'Execution Node'; +$lang->zanode->common = 'ZAnode'; $lang->team->common = 'Team'; $lang->user->common = 'User'; $lang->custom->common = 'Custom'; diff --git a/module/common/lang/en.php b/module/common/lang/en.php index 14694c011a..dafebaebdb 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.php @@ -181,7 +181,7 @@ $lang->build->common = 'Build'; $lang->testreport->common = 'Report'; $lang->automation->common = 'Automation:'; $lang->zahost->common = 'ZAhost'; -$lang->executionnode->common = 'Execution Node'; +$lang->zanode->common = 'ZAnode'; $lang->team->common = 'Team'; $lang->user->common = 'User'; $lang->custom->common = 'Custom'; diff --git a/module/common/lang/fr.php b/module/common/lang/fr.php index 54ea15507f..cd438844fb 100644 --- a/module/common/lang/fr.php +++ b/module/common/lang/fr.php @@ -181,7 +181,7 @@ $lang->build->common = 'Build'; $lang->testreport->common = 'Report'; $lang->automation->common = 'Automation:'; $lang->zahost->common = 'ZAhost'; -$lang->executionnode->common = 'Execution Node'; +$lang->zanode->common = 'ZAnode'; $lang->team->common = 'Team'; $lang->user->common = 'User'; $lang->custom->common = 'Custom'; diff --git a/module/common/lang/menu.php b/module/common/lang/menu.php index abbdf14037..7bba96b5df 100644 --- a/module/common/lang/menu.php +++ b/module/common/lang/menu.php @@ -452,7 +452,7 @@ $lang->qa->menu->report = array('link' => "{$lang->testreport->common}|te $lang->qa->menu->caselib = array('link' => "{$lang->testcase->caselib}|caselib|browse|libID=0", 'subModule' => 'caselib'); $lang->qa->menu->automation = array('link' => "{$lang->automation->common}|project|other|productID=%s", 'subModule' => 'automation', 'alias' => '', 'class' => "qa-automation-menu"); $lang->qa->menu->zahost = array('link' => "{$lang->zahost->common}|zahost|browse", 'subModule' => 'zahost'); -$lang->qa->menu->executionnode = array('link' => "{$lang->executionnode->common}|executionnode|browse", 'subModule' => 'executionnode'); +$lang->qa->menu->zanode = array('link' => "{$lang->zanode->common}|zanode|browse", 'subModule' => 'zanode'); /* QA menu order. */ $lang->qa->menuOrder[5] = 'product'; @@ -724,7 +724,7 @@ $lang->navGroup->bug = 'qa'; $lang->navGroup->testcase = 'qa'; $lang->navGroup->testtask = 'qa'; $lang->navGroup->zahost = 'qa'; -$lang->navGroup->executionnode = 'qa'; +$lang->navGroup->zanode = 'qa'; $lang->navGroup->testreport = 'qa'; $lang->navGroup->testcase = 'qa'; $lang->navGroup->testtask = 'qa'; diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index 15453a6bf8..572c809939 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -181,7 +181,7 @@ $lang->build->common = '版本'; $lang->testreport->common = '测试报告'; $lang->automation->common = '自动化:'; $lang->zahost->common = '宿主机'; -$lang->executionnode->common = '执行节点'; +$lang->zanode->common = '执行节点'; $lang->team->common = '团队'; $lang->user->common = '用户'; $lang->custom->common = '自定义'; diff --git a/module/executionnode/config.php b/module/executionnode/config.php deleted file mode 100755 index 64c8897be6..0000000000 --- a/module/executionnode/config.php +++ /dev/null @@ -1,44 +0,0 @@ -executionnode->create = new stdClass(); -$config->executionnode->edit = new stdClass(); -$config->executionnode->create->requiredFields = 'name,host,image,cpu,memory,disk,os'; -$config->executionnode->edit->requiredFields = ''; - -$config->executionnode->defaultPort = '8086'; - -$config->executionnode->os = new stdClass(); - -$config->executionnode->os->cpuCores = array(); -$config->executionnode->os->cpuCores['1'] = '1'; -$config->executionnode->os->cpuCores['2'] = '2'; -$config->executionnode->os->cpuCores['4'] = '4'; -$config->executionnode->os->cpuCores['6'] = '6'; -$config->executionnode->os->cpuCores['8'] = '8'; -$config->executionnode->os->cpuCores['12'] = '12'; -$config->executionnode->os->cpuCores['16'] = '16'; -$config->executionnode->os->cpuCores['24'] = '24'; -$config->executionnode->os->cpuCores['32'] = '32'; -$config->executionnode->os->cpuCores['64'] = '64'; - -global $lang; -$config->executionnode->search['module'] = 'executionnode'; -$config->executionnode->search['fields']['name'] = $lang->executionnode->name; -$config->executionnode->search['fields']['osName'] = $lang->executionnode->osName; -$config->executionnode->search['fields']['host'] = $lang->executionnode->hostName; -$config->executionnode->search['fields']['status'] = $lang->executionnode->status; -$config->executionnode->search['fields']['cpuCores'] = $lang->executionnode->cpuCores; -$config->executionnode->search['fields']['memory'] = $lang->executionnode->memory; -$config->executionnode->search['fields']['diskSize'] = $lang->executionnode->diskSize; -$config->executionnode->search['fields']['mac'] = $lang->executionnode->mac; -$config->executionnode->search['fields']['address'] = $lang->executionnode->ip; -$config->executionnode->search['params']['name'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); -$config->executionnode->search['params']['osName'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); -$config->executionnode->search['params']['host'] = array('operator' => '=', 'control' => 'select', 'values' => ''); -$config->executionnode->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $lang->executionnode->statusList); -$config->executionnode->search['params']['cpuCores'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $config->executionnode->os->cpuCores); -$config->executionnode->search['params']['memory'] = array('operator' => '=', 'control' => 'input', 'values' => ''); -$config->executionnode->search['params']['diskSize'] = array('operator' => '=', 'control' => 'input', 'values' => ''); - -$config->executionnode->editor = new stdclass(); -$config->executionnode->editor->create = array('id' => 'desc', 'tools' => 'simpleTools'); -$config->executionnode->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools'); diff --git a/module/executionnode/lang/de.php b/module/executionnode/lang/de.php deleted file mode 100755 index ac85338a56..0000000000 --- a/module/executionnode/lang/de.php +++ /dev/null @@ -1,60 +0,0 @@ -executionnode->common = 'Execution Node'; -$lang->executionnode->browse = 'Execution Node List'; -$lang->executionnode->create = 'Create Execution Node'; -$lang->executionnode->view = 'View Execution Node'; -$lang->executionnode->suspend = 'Suspend Execution Node'; -$lang->executionnode->destroy = 'Destroy Execution Node'; -$lang->executionnode->handleVM = 'Restart Execution Node'; -$lang->executionnode->boot = 'Start Execution Node'; -$lang->executionnode->reboot = 'Restart Execution Node'; -$lang->executionnode->shutdown = 'Shutdown Execution Node'; -$lang->executionnode->resume = 'Resume Execution Node'; -$lang->executionnode->getVNC = 'Remote management'; -$lang->executionnode->all = 'All'; -$lang->executionnode->byQuery = 'Search'; -$lang->executionnode->osName = 'System'; -$lang->executionnode->image = 'VM Image'; -$lang->executionnode->name = 'Name'; -$lang->executionnode->start = 'Start After Created'; -$lang->executionnode->hostName = 'Host Name'; -$lang->executionnode->host = $lang->executionnode->hostName; -$lang->executionnode->ip = 'IP'; -$lang->executionnode->osArch = 'Arch'; -$lang->executionnode->cpuCores = 'CPU Cores'; -$lang->executionnode->memory = 'Memory Size'; -$lang->executionnode->desc = 'Description'; -$lang->executionnode->diskSize = 'Disk Size'; -$lang->executionnode->status = 'Status'; -$lang->executionnode->mac = 'MAC'; -$lang->executionnode->vnc = 'VNC Port'; -$lang->executionnode->destroyAt = 'Destroy Time'; -$lang->executionnode->creater = 'Creator'; -$lang->executionnode->createdDate = 'Create Date'; -$lang->executionnode->confirmDelete = "Are you sure about destroying the execution node?"; -$lang->executionnode->confirmBoot = "Are you sure to start the execution node?"; -$lang->executionnode->confirmReboot = "Are you sure to restart the execution node?"; -$lang->executionnode->confirmShutdown = "Are you sure to shutdown the execution node?"; -$lang->executionnode->confirmSuspend = "Are you sure to suspend the execution node?"; -$lang->executionnode->confirmResume = "Are you sure to resume the execution node?"; -$lang->executionnode->actionSuccess = 'Success'; - -$lang->executionnode->notFoundAgent = 'No Agent service is found'; -$lang->executionnode->createVmFail = 'Failed to create a execution node'; -$lang->executionnode->noVncPort = 'Failed to get vnc port'; -$lang->executionnode->nameValid = "The name can only be letters, numbers, '-', '_', '.', and cannot start with a symbol"; - -$lang->executionnode->empty = 'No Execution Node'; - -$lang->executionnode->apiError['-10100'] = 'Execution node not found.'; - -$lang->executionnode->publicList[0] = 'Private'; -$lang->executionnode->publicList[1] = 'Public'; - -$lang->executionnode->statusList['created'] = 'Created'; -$lang->executionnode->statusList['launch'] = 'Launch'; -$lang->executionnode->statusList['ready'] = 'Ready'; -$lang->executionnode->statusList['running'] = 'Running'; -$lang->executionnode->statusList['suspend'] = 'Suspend'; -$lang->executionnode->statusList['destroy'] = 'Destroyed'; -$lang->executionnode->statusList['destroy_fail'] = 'Destroy Fail'; diff --git a/module/executionnode/lang/en.php b/module/executionnode/lang/en.php deleted file mode 100755 index 36db2575a7..0000000000 --- a/module/executionnode/lang/en.php +++ /dev/null @@ -1,60 +0,0 @@ -executionnode->common = 'Execution Node'; -$lang->executionnode->browse = 'Execution Node List'; -$lang->executionnode->create = 'Create Execution Node'; -$lang->executionnode->view = 'View Execution Node'; -$lang->executionnode->suspend = 'Suspend Execution Node'; -$lang->executionnode->destroy = 'Destroy Execution Node'; -$lang->executionnode->handleVM = 'Restart Execution Node'; -$lang->executionnode->boot = 'Start Execution Node'; -$lang->executionnode->reboot = 'Restart Execution Node'; -$lang->executionnode->shutdown = 'Shutdown Execution Node'; -$lang->executionnode->resume = 'Resume Execution Node'; -$lang->executionnode->getVNC = 'Remote management'; -$lang->executionnode->all = 'All'; -$lang->executionnode->byQuery = 'Search'; -$lang->executionnode->osName = 'System'; -$lang->executionnode->image = 'VM Image'; -$lang->executionnode->name = 'Name'; -$lang->executionnode->start = 'Start After Created'; -$lang->executionnode->hostName = 'Host Name'; -$lang->executionnode->host = $lang->executionnode->hostName; -$lang->executionnode->ip = 'IP'; -$lang->executionnode->osArch = 'Arch'; -$lang->executionnode->cpuCores = 'CPU Cores'; -$lang->executionnode->memory = 'Memory Size'; -$lang->executionnode->desc = 'Description'; -$lang->executionnode->diskSize = 'Disk Size'; -$lang->executionnode->status = 'Status'; -$lang->executionnode->mac = 'MAC'; -$lang->executionnode->vnc = 'VNC Port'; -$lang->executionnode->destroyAt = 'Destroy Time'; -$lang->executionnode->creater = 'Creator'; -$lang->executionnode->createdDate = 'Create Date'; -$lang->executionnode->confirmDelete = "Are you sure about destroying the execution node?"; -$lang->executionnode->confirmBoot = "Are you sure to start the execution node?"; -$lang->executionnode->confirmReboot = "Are you sure to restart the execution node?"; -$lang->executionnode->confirmShutdown = "Are you sure to shutdown the execution node?"; -$lang->executionnode->confirmSuspend = "Are you sure to suspend the execution node?"; -$lang->executionnode->confirmResume = "Are you sure to resume the execution node?"; -$lang->executionnode->actionSuccess = 'Success'; - -$lang->executionnode->notFoundAgent = 'No Agent service is found'; -$lang->executionnode->createVmFail = 'Failed to create a execution node'; -$lang->executionnode->noVncPort = 'Failed to get vnc port'; -$lang->executionnode->nameValid = "The name can only be letters, numbers, '-', '_', '.', and cannot start with a symbol"; - -$lang->executionnode->empty = 'No Execution Node'; - -$lang->executionnode->apiError['-10100'] = 'Execution node not found.'; - -$lang->executionnode->publicList[0] = 'Private'; -$lang->executionnode->publicList[1] = 'Public'; - -$lang->executionnode->statusList['created'] = 'Created'; -$lang->executionnode->statusList['launch'] = 'Launch'; -$lang->executionnode->statusList['ready'] = 'Ready'; -$lang->executionnode->statusList['running'] = 'Running'; -$lang->executionnode->statusList['suspend'] = 'Suspend'; -$lang->executionnode->statusList['destroy'] = 'Destroyed'; -$lang->executionnode->statusList['destroy_fail'] = 'Destroy Fail'; diff --git a/module/executionnode/lang/fr.php b/module/executionnode/lang/fr.php deleted file mode 100755 index ac85338a56..0000000000 --- a/module/executionnode/lang/fr.php +++ /dev/null @@ -1,60 +0,0 @@ -executionnode->common = 'Execution Node'; -$lang->executionnode->browse = 'Execution Node List'; -$lang->executionnode->create = 'Create Execution Node'; -$lang->executionnode->view = 'View Execution Node'; -$lang->executionnode->suspend = 'Suspend Execution Node'; -$lang->executionnode->destroy = 'Destroy Execution Node'; -$lang->executionnode->handleVM = 'Restart Execution Node'; -$lang->executionnode->boot = 'Start Execution Node'; -$lang->executionnode->reboot = 'Restart Execution Node'; -$lang->executionnode->shutdown = 'Shutdown Execution Node'; -$lang->executionnode->resume = 'Resume Execution Node'; -$lang->executionnode->getVNC = 'Remote management'; -$lang->executionnode->all = 'All'; -$lang->executionnode->byQuery = 'Search'; -$lang->executionnode->osName = 'System'; -$lang->executionnode->image = 'VM Image'; -$lang->executionnode->name = 'Name'; -$lang->executionnode->start = 'Start After Created'; -$lang->executionnode->hostName = 'Host Name'; -$lang->executionnode->host = $lang->executionnode->hostName; -$lang->executionnode->ip = 'IP'; -$lang->executionnode->osArch = 'Arch'; -$lang->executionnode->cpuCores = 'CPU Cores'; -$lang->executionnode->memory = 'Memory Size'; -$lang->executionnode->desc = 'Description'; -$lang->executionnode->diskSize = 'Disk Size'; -$lang->executionnode->status = 'Status'; -$lang->executionnode->mac = 'MAC'; -$lang->executionnode->vnc = 'VNC Port'; -$lang->executionnode->destroyAt = 'Destroy Time'; -$lang->executionnode->creater = 'Creator'; -$lang->executionnode->createdDate = 'Create Date'; -$lang->executionnode->confirmDelete = "Are you sure about destroying the execution node?"; -$lang->executionnode->confirmBoot = "Are you sure to start the execution node?"; -$lang->executionnode->confirmReboot = "Are you sure to restart the execution node?"; -$lang->executionnode->confirmShutdown = "Are you sure to shutdown the execution node?"; -$lang->executionnode->confirmSuspend = "Are you sure to suspend the execution node?"; -$lang->executionnode->confirmResume = "Are you sure to resume the execution node?"; -$lang->executionnode->actionSuccess = 'Success'; - -$lang->executionnode->notFoundAgent = 'No Agent service is found'; -$lang->executionnode->createVmFail = 'Failed to create a execution node'; -$lang->executionnode->noVncPort = 'Failed to get vnc port'; -$lang->executionnode->nameValid = "The name can only be letters, numbers, '-', '_', '.', and cannot start with a symbol"; - -$lang->executionnode->empty = 'No Execution Node'; - -$lang->executionnode->apiError['-10100'] = 'Execution node not found.'; - -$lang->executionnode->publicList[0] = 'Private'; -$lang->executionnode->publicList[1] = 'Public'; - -$lang->executionnode->statusList['created'] = 'Created'; -$lang->executionnode->statusList['launch'] = 'Launch'; -$lang->executionnode->statusList['ready'] = 'Ready'; -$lang->executionnode->statusList['running'] = 'Running'; -$lang->executionnode->statusList['suspend'] = 'Suspend'; -$lang->executionnode->statusList['destroy'] = 'Destroyed'; -$lang->executionnode->statusList['destroy_fail'] = 'Destroy Fail'; diff --git a/module/executionnode/lang/zh-cn.php b/module/executionnode/lang/zh-cn.php deleted file mode 100755 index d8a0e77bf0..0000000000 --- a/module/executionnode/lang/zh-cn.php +++ /dev/null @@ -1,62 +0,0 @@ -executionnode->common = '执行节点'; -$lang->executionnode->browse = '执行节点列表'; -$lang->executionnode->create = '创建执行节点'; -$lang->executionnode->view = '执行节点详情'; -$lang->executionnode->suspend = '暂停执行节点'; -$lang->executionnode->destroy = '销毁执行节点'; -$lang->executionnode->handleVM = '重启执行节点'; -$lang->executionnode->boot = '启动执行节点'; -$lang->executionnode->reboot = '重启执行节点'; -$lang->executionnode->shutdown = '关闭执行节点'; -$lang->executionnode->resume = '恢复执行节点'; -$lang->executionnode->getVNC = '远程管理'; -$lang->executionnode->all = '全部'; -$lang->executionnode->byQuery = '搜索'; -$lang->executionnode->osName = '操作系统'; -$lang->executionnode->image = '镜像'; -$lang->executionnode->name = '执行节点名称'; -$lang->executionnode->start = '创建后自动开启'; -$lang->executionnode->hostName = '所属宿主机'; -$lang->executionnode->host = $lang->executionnode->hostName; -$lang->executionnode->ip = 'IP/域名'; -$lang->executionnode->osArch = '架构'; -$lang->executionnode->cpuCores = 'CPU核心数'; -$lang->executionnode->memory = '内存'; -$lang->executionnode->diskSize = '硬盘'; -$lang->executionnode->desc = '描述'; -$lang->executionnode->status = '状态'; -$lang->executionnode->mac = 'MAC地址'; -$lang->executionnode->vnc = 'VNC端口'; -$lang->executionnode->destroyAt = '销毁时间'; -$lang->executionnode->creater = '创建人'; -$lang->executionnode->createdDate = '创建日期'; -$lang->executionnode->confirmDelete = "您确定销毁执行节点吗?"; -$lang->executionnode->confirmBoot = "您确定启动执行节点吗?"; -$lang->executionnode->confirmReboot = "您确定重启执行节点吗?"; -$lang->executionnode->confirmShutdown = "您确定关闭执行节点吗?"; -$lang->executionnode->confirmSuspend = "您确定暂停执行节点吗?"; -$lang->executionnode->confirmResume = "您确定恢复执行节点吗?"; -$lang->executionnode->actionSuccess = '操作成功'; - -$lang->executionnode->notFoundAgent = '没有发现Agent服务'; -$lang->executionnode->createVmFail = '创建执行节点失败'; -$lang->executionnode->noVncPort = '无法获取执行节点端口'; -$lang->executionnode->nameValid = "名称只能是字母、数字,'-','_','.',且不能以符号开头"; - -$lang->executionnode->empty = '暂时没有执行节点'; - -$lang->executionnode->apiError['-10100'] = '执行节点不存在'; - -$lang->executionnode->publicList[0] = '不共享'; -$lang->executionnode->publicList[1] = '共享'; - -$lang->executionnode->statusList['created'] = '已创建'; -$lang->executionnode->statusList['launch'] = '启动中'; -$lang->executionnode->statusList['ready'] = '运行中'; -$lang->executionnode->statusList['running'] = '运行中'; -$lang->executionnode->statusList['suspend'] = '暂停'; -$lang->executionnode->statusList['offline'] = '下线'; -$lang->executionnode->statusList['destroy'] = '已销毁'; -$lang->executionnode->statusList['destroy_fail'] = '销毁失败'; - diff --git a/module/executionnode/view/browse.html.php b/module/executionnode/view/browse.html.php deleted file mode 100755 index 31feb8ffff..0000000000 --- a/module/executionnode/view/browse.html.php +++ /dev/null @@ -1,100 +0,0 @@ - - * @package executionnode - * @version $Id$ - * @link http://www.zentao.net - */ -?> -getModuleRoot() . 'common/view/header.html.php';?> -executionnode->confirmDelete)?> -executionnode->confirmBoot)?> -executionnode->confirmReboot)?> -executionnode->confirmShutdown)?> -executionnode->actionSuccess)?> - -
' data-module='executionnode'>
-
-recTotal}&recPerPage={$pager->recPerPage}";?> -
- -
-

- executionnode->empty;?> - ' . $lang->executionnode->create, '', 'class="btn btn-info"');?> -

-
- -
executionnode->hostName;?>
executionnode->name;?>
executionnode->image;?>
executionnode->cpu;?>executionnode->os->cpu, '', "class='form-control chosen'")?>executionnode->cpuCores;?>executionnode->os->cpuCores, '', "class='form-control chosen'")?>
executionnode->memory;?>
executionnode->disk;?>executionnode->diskSize;?>
- + zahost->unitList['GB'];?> @@ -58,8 +58,8 @@
executionnode->os;?>executionnode->osName;?>
executionnode->desc ?>
zahost->IP;?>zahost->extranet;?>
zahost->cpu;?>zahost->cpuCoreList, '2', "class='form-control chosen'");?>zahost->cpuCores;?>zahost->cpuCoreList, '2', "class='form-control chosen'");?>
zahost->memory;?>
zahost->IP;?>address, "class='form-control' disabled");?>extranet, "class='form-control' disabled");?>
zahost->cpu;?>zahost->cpuCoreList, $host->cpu, "class='form-control chosen'");?>zahost->cpuCores;?>zahost->cpuCoreList, $host->cpuCores, "class='form-control chosen'");?>
zahost->memory;?>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
idAB);?>executionnode->name);?>executionnode->ip);?>executionnode->cpu);?>executionnode->memory);?>executionnode->disk);?>executionnode->os);?>executionnode->status);?>executionnode->hostName);?> - actions?>
id;?>name;?>hostIP;?>executionnode->os->cpu, $node->cpu);?>memory . $this->lang->zahost->unitList['GB'];?>disk . zget($this->lang->zahost->unitList, $node->unit);?>executionnode->os->list, $node->os);?>executionnode->statusList, $node->status);?>hostName;?> - executionnode->suspend}' class='btn btn-primary' target='hiddenwin'"; - $suspendAttr .= $node->status == 'suspend' ? ' disabled' : " target='hiddenwin' onclick='if(confirm(\"{$lang->executionnode->confirmSuspend}\")==false) return false;'"; - - $resumeAttr = "title='{$lang->executionnode->resume}' class='btn btn-primary' target='hiddenwin'"; - $resumeAttr .= $node->status == 'running' ? 'disabled' : " target='hiddenwin' onclick='if(confirm(\"{$lang->executionnode->confirmResume}\")==false) return false;'"; - $rebootAttr = "title='{$lang->executionnode->reboot}' class='btn btn-primary' target='hiddenwin'"; - $rebootAttr .= $node->status == 'suspend' ? ' disabled' : " target='hiddenwin' onclick='if(confirm(\"{$lang->executionnode->confirmReboot}\")==false) return false;'"; - common::printLink('executionnode', 'suspend', "executionnodeID={$node->id}", " ", '', $suspendAttr); - common::printLink('executionnode', 'resume', "executionnodeID={$node->id}", " ", '', $resumeAttr); - common::printLink('executionnode', 'reboot', "executionnodeID={$node->id}", " ", '', $rebootAttr); - common::printLink('executionnode', 'destroy', "executionnodeID={$node->id}", " ", '', "title='{$lang->executionnode->destroy}' class='btn btn-primary' target='hiddenwin' onclick='if(confirm(\"{$lang->executionnode->confirmDelete}\")==false) return false;'"); - ?> -
-
- - - - -getModuleRoot() . 'common/view/footer.html.php';?> diff --git a/module/group/lang/resource.php b/module/group/lang/resource.php index 278cd6f6ee..1335d5c04d 100644 --- a/module/group/lang/resource.php +++ b/module/group/lang/resource.php @@ -41,7 +41,7 @@ $lang->moduleOrder[90] = 'testsuite'; $lang->moduleOrder[95] = 'testreport'; $lang->moduleOrder[100] = 'caselib'; $lang->moduleOrder[105] = 'zahost'; -$lang->moduleOrder[108] = 'executionnode'; +$lang->moduleOrder[108] = 'zanode'; $lang->moduleOrder[110] = 'doc'; $lang->moduleOrder[115] = 'report'; @@ -1216,22 +1216,22 @@ $lang->zahost->methodOrder[25] = 'createTemplate'; $lang->zahost->methodOrder[30] = 'editTemplate'; $lang->zahost->methodOrder[35] = 'deleteTemplate'; -$lang->resource->executionnode = new stdclass(); -$lang->resource->executionnode->browse = 'browse'; -$lang->resource->executionnode->create = 'create'; -$lang->resource->executionnode->destroy = 'destroy'; -$lang->resource->executionnode->reboot = 'reboot'; -$lang->resource->executionnode->suspend = 'suspend'; -$lang->resource->executionnode->resume = 'resume'; -$lang->resource->executionnode->getVNC = 'getVNC'; +$lang->resource->zanode = new stdclass(); +$lang->resource->zanode->browse = 'browse'; +$lang->resource->zanode->create = 'create'; +$lang->resource->zanode->destroy = 'destroy'; +$lang->resource->zanode->reboot = 'reboot'; +$lang->resource->zanode->suspend = 'suspend'; +$lang->resource->zanode->resume = 'resume'; +$lang->resource->zanode->getVNC = 'getVNC'; -$lang->executionnode->methodOrder[5] = 'browse'; -$lang->executionnode->methodOrder[10] = 'create'; -$lang->executionnode->methodOrder[15] = 'destroy'; -$lang->executionnode->methodOrder[20] = 'reboot'; -$lang->executionnode->methodOrder[35] = 'suspend'; -$lang->executionnode->methodOrder[30] = 'resume'; -$lang->executionnode->methodOrder[35] = 'getVNC'; +$lang->zanode->methodOrder[5] = 'browse'; +$lang->zanode->methodOrder[10] = 'create'; +$lang->zanode->methodOrder[15] = 'destroy'; +$lang->zanode->methodOrder[20] = 'reboot'; +$lang->zanode->methodOrder[35] = 'suspend'; +$lang->zanode->methodOrder[30] = 'resume'; +$lang->zanode->methodOrder[35] = 'getVNC'; $lang->resource->repo = new stdclass(); $lang->resource->repo->browse = 'browseAction'; diff --git a/module/upgrade/config.php b/module/upgrade/config.php index fde27fd524..4319c32c81 100644 --- a/module/upgrade/config.php +++ b/module/upgrade/config.php @@ -394,7 +394,7 @@ $config->delete['18_0'][] = 'extension/max/my/ext/view/audit.html.php'; $config->upgrade->openModules = array('action', 'admin', 'api', 'automation', 'backup', 'block', 'branch', 'budget', 'bug', 'build', 'caselib', 'ci', 'client', 'common', 'company', 'compile', 'convert', 'cron', 'custom', 'datatable', 'dept', 'design', 'dev', 'doc', 'durationestimation', 'entry', 'execution', 'extension', 'file', 'git', 'gitlab', 'group', 'holiday', 'im', 'index', 'index.html', 'install', 'issue', 'jenkins', 'job', 'kanban', 'license', 'mail', 'message', 'misc', 'mr', 'my', 'personnel', 'pipeline', 'product', 'productplan', 'productset', 'program', 'programplan', 'project', 'projectbuild', 'projectplan', 'projectrelease', 'projectstory', 'qa', 'release', 'repo', 'report', 'risk', 'score', 'search', 'setting', 'sonarqube', 'sso', 'stage', 'stakeholder', 'story', 'subject', 'svn', 'task', 'testcase', 'testreport', 'testsuite', 'testtask', 'todo', 'tree', 'tutorial', 'upgrade', 'user', 'webhook', 'weekly', 'workestimation', 'gitea', 'gogs', 'port', 'zahost'); -$config->upgrade->unsetModules = array('design', 'program', 'programplan', 'projectbuild', 'projectrelease', 'stage', 'stakeholder', 'product', 'branch', 'productplan', 'release', 'build', 'qa', 'bug', 'testcase', 'testtask', 'testreport', 'testsuite', 'caselib', 'automation', 'repo', 'ci', 'compile', 'jenkins', 'job', 'svn', 'gitlab', 'sonarqube', 'mr', 'git', 'report', 'sqlbuilder', 'feedback', 'faq', 'attend', 'holiday', 'leave', 'makeup', 'overtime', 'lieu', 'ops', 'host', 'serverroom', 'account', 'domain', 'service', 'deploy', 'conference', 'traincourse', 'pssp', 'baseline', 'classify', 'cm', 'cmcl', 'auditcl', 'reviewcl', 'process', 'activity', 'zoutput', 'auditplan', 'nc', 'subject', 'weekly', 'workestimation', 'issue', 'durationestimation', 'risk', 'opportunity', 'trainplan', 'gapanalysis', 'researchplan', 'researchreport', 'meeting', 'meetingroom', 'budget', 'reviewissue', 'reviewsetting', 'review', 'milestone', 'measurement', 'measrecord', 'assetlib', 'setting', 'im', 'client', 'ldap', 'dev', 'api', 'gitea', 'gogs', 'executionnode', 'zahost'); +$config->upgrade->unsetModules = array('design', 'program', 'programplan', 'projectbuild', 'projectrelease', 'stage', 'stakeholder', 'product', 'branch', 'productplan', 'release', 'build', 'qa', 'bug', 'testcase', 'testtask', 'testreport', 'testsuite', 'caselib', 'automation', 'repo', 'ci', 'compile', 'jenkins', 'job', 'svn', 'gitlab', 'sonarqube', 'mr', 'git', 'report', 'sqlbuilder', 'feedback', 'faq', 'attend', 'holiday', 'leave', 'makeup', 'overtime', 'lieu', 'ops', 'host', 'serverroom', 'account', 'domain', 'service', 'deploy', 'conference', 'traincourse', 'pssp', 'baseline', 'classify', 'cm', 'cmcl', 'auditcl', 'reviewcl', 'process', 'activity', 'zoutput', 'auditplan', 'nc', 'subject', 'weekly', 'workestimation', 'issue', 'durationestimation', 'risk', 'opportunity', 'trainplan', 'gapanalysis', 'researchplan', 'researchreport', 'meeting', 'meetingroom', 'budget', 'reviewissue', 'reviewsetting', 'review', 'milestone', 'measurement', 'measrecord', 'assetlib', 'setting', 'im', 'client', 'ldap', 'dev', 'api', 'gitea', 'gogs', 'zanode', 'zahost'); global $lang; $config->upgrade->defaultActions = array(); diff --git a/module/zahost/control.php b/module/zahost/control.php index eb875fdbda..e0fdcc5777 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -67,7 +67,7 @@ class zahost extends control $this->view->zahost = $this->zahost->getById($id); $this->view->orderBy = $orderBy; - $this->view->nodeList = $this->loadModel("executionnode")->getListByHost($this->view->zahost->parent, $orderBy); + $this->view->nodeList = $this->loadModel("zanode")->getListByHost($this->view->zahost->parent, $orderBy); $this->view->actions = $this->loadModel('action')->getList('zahost', $id); $this->display(); } diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index cd1a2e5d00..9f8dbd0db6 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -10,7 +10,7 @@ $lang->zahost->delete = 'Delete'; $lang->zahost->deleteAction = 'Delete Host'; $lang->zahost->byQuery = 'Search'; $lang->zahost->all = 'All'; -$lang->zahost->browseNode = 'ExecutionNode Browse'; +$lang->zahost->browseNode = 'ZAnode Browse'; $lang->zahost->name = 'Name'; $lang->zahost->IP = 'IP/Domain'; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index 0ee5b2aa18..6d4be82372 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -10,7 +10,7 @@ $lang->zahost->delete = 'Delete'; $lang->zahost->deleteAction = 'Delete Host'; $lang->zahost->byQuery = 'Search'; $lang->zahost->all = 'All'; -$lang->zahost->browseNode = 'ExecutionNode Browse'; +$lang->zahost->browseNode = 'ZAnode Browse'; $lang->zahost->name = 'Name'; $lang->zahost->IP = 'Extranet Address'; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index d96817e989..ee7458fd37 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -10,7 +10,7 @@ $lang->zahost->delete = 'Supprimer'; $lang->zahost->deleteAction = 'Supprimer Hôte'; $lang->zahost->byQuery = 'Recherche'; $lang->zahost->all = 'Tous les hôtes'; -$lang->zahost->browseNode = 'ExecutionNode Browse'; +$lang->zahost->browseNode = 'ZAnode Browse'; $lang->zahost->name = 'Nom'; $lang->zahost->IP = 'IP/Domain'; diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php index 1d8f4564a9..96797f4e76 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -10,11 +10,7 @@ $lang->zahost->delete = 'Delete'; $lang->zahost->deleteAction = 'Delete Host'; $lang->zahost->byQuery = 'Search'; $lang->zahost->all = 'All'; -$lang->zahost->browseNode = 'ExecutionNode Browse'; -$lang->zahost->browseTemplate = 'Template Browse'; -$lang->zahost->createTemplate = 'Create Template'; -$lang->zahost->editTemplate = 'Edit Template'; -$lang->zahost->deleteTemplate = 'Delete Template'; +$lang->zahost->browseNode = 'ZAnode Browse'; $lang->zahost->name = 'Name'; $lang->zahost->IP = 'IP/Domain'; diff --git a/module/zahost/view/browse.html.php b/module/zahost/view/browse.html.php index e39c342071..651cb9e15a 100644 --- a/module/zahost/view/browse.html.php +++ b/module/zahost/view/browse.html.php @@ -45,10 +45,10 @@
idAB);?> zahost->name);?> zahost->type);?> zahost->IP);?> zahost->cpu );?> zahost->extranet);?> zahost->cpuCores);?> zahost->memory);?> zahost->diskSize);?> zahost->diskSize);?> zahost->vsoft);?> zahost->status);?> zahost->registerDate);?>hostID);?> inlink('view', "id=$host->hostID"), $host->name, '', "");?> zahost->zaHostTypeList, $host->hostType);?>address;?>cpu;?>extranet;?>cpuCores;?> memory . $lang->zahost->unitList['GB'];?> diskSize . zget($lang->zahost->unitList, $host->unit);?> vsoft;?> host->statusList, $host->status);?>registerDate) ? '' : $host->registerDate;?>heartbeat) ? '' : $host->heartbeat;?> hostID}", $host, 'list');?> createLink('zahost', 'delete', "hostID={$host->id}"), '', 'hiddenwin', "title='{$lang->zahost->delete}' class='btn'");;?> diff --git a/module/zahost/view/view.html.php b/module/zahost/view/view.html.php index 2068941f1a..404bcef6d8 100644 --- a/module/zahost/view/view.html.php +++ b/module/zahost/view/view.html.php @@ -43,7 +43,7 @@
zahost->extranet;?>:
-
address;?>
+
extranet;?>
@@ -62,8 +62,8 @@
-
zahost->cpu;?>:
-
cpu;?>
+
zahost->cpuCores;?>:
+
cpuCores;?>
@@ -87,22 +87,22 @@
zahost->name);?>executionnode->cpu);?>executionnode->memory);?>executionnode->diskSize);?>executionnode->os);?>executionnode->status);?>zanode->cpuCores);?>zanode->memory);?>zanode->diskSize);?>zanode->osName);?>zanode->status);?>
name;?>executionnode->os->cpu, $node->cpu);?>zanode->os->cpuCores, $node->cpuCores);?> memory . $this->lang->zahost->unitList['GB'];?>diskSize . zget($this->lang->zahost->unitList, $node->unit);?>executionnode->os->list, $node->os);?>executionnode->statusList, $node->status);?>diskSize . $this->lang->zahost->unitList['GB'];?>osName;?>zanode->statusList, $node->status);?>
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
idAB);?>zanode->name);?>zanode->extranet);?>zanode->cpuCores);?>zanode->memory);?>zanode->diskSize);?>zanode->osName);?>zanode->status);?>zanode->hostName);?> + actions?>
id;?>name;?>hostIP;?>zanode->os->cpu, $node->cpu);?>memory . $this->lang->zahost->unitList['GB'];?>disk . zget($this->lang->zahost->unitList, $node->unit);?>zanode->os->list, $node->os);?>zanode->statusList, $node->status);?>hostName;?> + zanode->suspend}' class='btn btn-primary' target='hiddenwin'"; + $suspendAttr .= $node->status == 'suspend' ? ' disabled' : " target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmSuspend}\")==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}", " ", '', $suspendAttr); + common::printLink('zanode', 'resume', "zanodeID={$node->id}", " ", '', $resumeAttr); + common::printLink('zanode', 'reboot', "zanodeID={$node->id}", " ", '', $rebootAttr); + common::printLink('zanode', 'destroy', "zanodeID={$node->id}", " ", '', "title='{$lang->zanode->destroy}' class='btn btn-primary' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmDelete}\")==false) return false;'"); + ?> +
+ + + + + +getModuleRoot() . 'common/view/footer.html.php';?> diff --git a/module/executionnode/view/create.html.php b/module/zanode/view/create.html.php old mode 100755 new mode 100644 similarity index 77% rename from module/executionnode/view/create.html.php rename to module/zanode/view/create.html.php index 084a22cc5a..a5c4b957e3 --- a/module/executionnode/view/create.html.php +++ b/module/zanode/view/create.html.php @@ -16,29 +16,29 @@
-

executionnode->create;?>

+

zanode->create;?>

- + - - + + - + - - + + - + - + - + - + diff --git a/module/executionnode/view/getvnc.html.php b/module/zanode/view/getvnc.html.php similarity index 100% rename from module/executionnode/view/getvnc.html.php rename to module/zanode/view/getvnc.html.php diff --git a/module/executionnode/view/view.html.php b/module/zanode/view/view.html.php similarity index 100% rename from module/executionnode/view/view.html.php rename to module/zanode/view/view.html.php From b48be4763b225bdebb9a1eccabfa143f771a3c67 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Wed, 23 Nov 2022 08:21:19 +0000 Subject: [PATCH 28/36] * Add view host. --- module/zahost/css/browsetemplate.css | 3 - module/zahost/view/view.html.php | 6 +- module/zanode/config.php | 2 +- module/zanode/control.php | 24 ++-- module/zanode/css/view.css | 5 + module/zanode/lang/de.php | 2 +- module/zanode/lang/en.php | 2 +- module/zanode/lang/fr.php | 2 +- module/zanode/lang/zh-cn.php | 2 +- module/zanode/model.php | 26 +++- module/zanode/view/browse.html.php | 155 +++++++++++------------ module/zanode/view/view.html.php | 176 ++++++++++++++++----------- 12 files changed, 232 insertions(+), 173 deletions(-) delete mode 100644 module/zahost/css/browsetemplate.css create mode 100644 module/zanode/css/view.css diff --git a/module/zahost/css/browsetemplate.css b/module/zahost/css/browsetemplate.css deleted file mode 100644 index 273d944493..0000000000 --- a/module/zahost/css/browsetemplate.css +++ /dev/null @@ -1,3 +0,0 @@ -.c-number {width: 100px;} -.c-os {width: 130px;} -.c-lang {width: 150px;} diff --git a/module/zahost/view/view.html.php b/module/zahost/view/view.html.php index 404bcef6d8..47d2887808 100644 --- a/module/zahost/view/view.html.php +++ b/module/zahost/view/view.html.php @@ -10,8 +10,8 @@ * @link http://www.zentao.net */ ?> - - +getModuleRoot() . 'common/view/header.html.php';?> +getModuleRoot() . 'common/view/kindeditor.html.php'; ?> session->zahostList ? $this->session->zahostList : $this->createLink('zahost', 'browse', "");?> hostID}&orderBy=%s";?>
executionnode->hostName;?>zanode->hostName;?>
executionnode->name;?>executionnode->nameValid}\"");?>zanode->name;?>zanode->nameValid}\"");?>
executionnode->image;?>zanode->image;?>
executionnode->cpuCores;?>executionnode->os->cpuCores, '', "class='form-control chosen'")?>zanode->cpuCores;?>zanode->os->cpuCores, '', "class='form-control chosen'")?>
executionnode->memory;?>zanode->memory;?>
@@ -47,7 +47,7 @@
executionnode->diskSize;?>zanode->diskSize;?>
@@ -58,11 +58,11 @@
executionnode->osName;?>zanode->osName;?>
executionnode->desc ?>zanode->desc ?>
- - - - - - - - - - - - - - - - - - - - - - - - - - + + + +
idAB);?>zanode->name);?>zanode->extranet);?>zanode->cpuCores);?>zanode->memory);?>zanode->diskSize);?>zanode->osName);?>zanode->status);?>zanode->hostName);?> - actions?>
id;?>name;?>hostIP;?>zanode->os->cpu, $node->cpu);?>memory . $this->lang->zahost->unitList['GB'];?>disk . zget($this->lang->zahost->unitList, $node->unit);?>zanode->os->list, $node->os);?>zanode->statusList, $node->status);?>hostName;?> - zanode->suspend}' class='btn btn-primary' target='hiddenwin'"; - $suspendAttr .= $node->status == 'suspend' ? ' disabled' : " target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmSuspend}\")==false) return false;'"; + + +
' data-module='zanode'>
+
+ recTotal}&recPerPage={$pager->recPerPage}"; ?> +
+ +
+

+ zanode->empty; ?> + ' . $lang->zanode->create, '', 'class="btn btn-info"'); ?> +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - -
idAB); ?>zanode->name); ?>zanode->extranet); ?>zanode->cpuCores); ?>zanode->memory); ?>zanode->diskSize); ?>zanode->osName); ?>zanode->status); ?>zanode->hostName); ?> + actions ?>
id; ?>inlink('view', "id=$node->id"), $node->name, '', ""); ?>extranet; ?>zanode->os->cpuCores, $node->cpuCores); ?>memory . $this->lang->zahost->unitList['GB']; ?>diskSize . $this->lang->zahost->unitList['GB']; ?>osName; ?>zanode->statusList, $node->status); ?>hostName; ?> + zanode->suspend}' class='btn btn-primary' target='hiddenwin'"; + $suspendAttr .= $node->status == 'suspend' ? ' disabled' : " target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmSuspend}\")==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}", " ", '', $suspendAttr); - common::printLink('zanode', 'resume', "zanodeID={$node->id}", " ", '', $resumeAttr); - common::printLink('zanode', 'reboot', "zanodeID={$node->id}", " ", '', $rebootAttr); - common::printLink('zanode', 'destroy', "zanodeID={$node->id}", " ", '', "title='{$lang->zanode->destroy}' class='btn btn-primary' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmDelete}\")==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}", " ", '', $suspendAttr); + common::printLink('zanode', 'resume', "zanodeID={$node->id}", " ", '', $resumeAttr); + common::printLink('zanode', 'reboot', "zanodeID={$node->id}", " ", '', $rebootAttr); + common::printLink('zanode', 'destroy', "zanodeID={$node->id}", " ", '', "title='{$lang->zanode->destroy}' class='btn btn-primary' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmDelete}\")==false) return false;'"); + ?> +
- +
-getModuleRoot() . 'common/view/footer.html.php';?> +getModuleRoot() . 'common/view/footer.html.php'; ?> \ No newline at end of file diff --git a/module/zanode/view/view.html.php b/module/zanode/view/view.html.php index 366af00a58..52a6c292ac 100644 --- a/module/zanode/view/view.html.php +++ b/module/zanode/view/view.html.php @@ -1,79 +1,119 @@ - * @package host - * @version $Id$ + * @author Ke Zhao + * @package zanode + * @version $Id: view.html.php $ * @link http://www.zentao.net */ ?> -getModuleRoot() . 'common/view/header.html.php';?> -vm->confirmDelete)?> -vm->confirmBoot)?> -vm->confirmReboot)?> -vm->confirmShutdown)?> -vm->actionSuccess)?> -
-
-

vm->view;?>

-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
vm->name;?>name;?>
vm->osType;?>vm->os->type[$vm->osCategory][$vm->osType];?>vm->osCategory;?>vm->os->list[$vm->osCategory];?>
vm->osVersion;?>vm->versionList[$vm->osType][$vm->osVersion];?>vm->osLang;?>vm->langList[$vm->osLang];?>
vm->ip;?>ip;?>vm->macAddress;?>macAddress;?>
vm->vnc;?>vnc;?>vm->status;?>vm->statusList, $vm->status);?>
vm->createdDate;?>createdDate;?>vm->destroyAt;?>destroyAt;?>
-
- getModuleRoot() . 'common/view/action.html.php'?> -
-
- -
- destroyAt)) - { - common::printLink('vm', 'reboot', "vmID={$vm->id}", " ". $lang->vm->reboot, '', "title='{$lang->vm->reboot}' class='btn' target='hiddenwin' onclick='if(confirm(\"{$lang->vm->confirmReboot}\")==false) return false;'"); - common::printLink('vm', 'destroy', "vmID={$vm->id}", " " . $lang->vm->destroy, '', "title='{$lang->vm->destroy}' class='btn' target='hiddenwin' onclick='if(confirm(\"{$lang->vm->confirmDelete}\")==false) return false;'"); - } - if(!isonlybody()) common::printLink('vm', 'browse', "", " " . $lang->goback, '', "class='btn'"); - ?> +getModuleRoot() . 'common/view/header.html.php'; ?> +getModuleRoot() . 'common/view/kindeditor.html.php'; ?> +zanode->confirmDelete) ?> +zanode->confirmBoot) ?> +zanode->confirmReboot) ?> +zanode->confirmShutdown) ?> +zanode->actionSuccess) ?> +session->zanodeList ? $this->session->zanodeList : $this->createLink('zanode', 'browse', ""); ?> +id}&orderBy=%s"; ?> + -getModuleRoot() . 'common/view/footer.html.php';?> +
+
+
+
+
zanode->view; ?>
+
+
+
+
+
zanode->status; ?>:
+
zanode->statusList, $zanode->status); ?>
+
+
+
+
+
zanode->osName; ?>:
+
osName; ?>
+
+
+
+
+
zanode->memory; ?>:
+
memory; ?>
+
+
+
+
+
+
+
zanode->hostName; ?>:
+
hostName; ?>
+
+
+
+
+
zanode->cpuCores; ?>:
+
cpuCores; ?>
+
+
+
+
+
zanode->diskSize; ?>:
+
diskSize; ?>
+
+
+
+
+
+
+
zanode->desc; ?>
+
desc) ? $zanode->desc : $lang->noData; ?>
+
+ createLink('action', 'comment', "objectType=zanode&objectID=$zanode->id"); + ?> +
+ printExtendFields($zanode, 'div', "position=left&inForm=0&inCell=1"); ?> +
+
+ ' . $lang->goback, '', 'btn btn-secondary'); ?> +
+ deleted)) { + if(in_array($zanode->status, array("suspend", ""))) + common::printLink('zanode', 'suspend', "id={$zanode->id}", " " . $lang->zanode->suspend, '', "title='{$lang->zanode->suspend}' class='btn' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmSuspend}\")==false) return false;'"); + common::printLink('zanode', 'resume', "id={$zanode->id}", " " . $lang->zanode->resume, '', "title='{$lang->zanode->resume}' class='btn' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmResume}\")==false) return false;'"); + common::printLink('zanode', 'getVNC', "id={$zanode->id}", " " . $lang->zanode->getVNC, '', "title='{$lang->zanode->getVNC}' class='btn' target='hiddenwin'"); + } + ?> +
+ zanode->buildOperateMenu($zanode, 'view'); ?> +
+
+
+
+
+
+
+ +
+ +
+ \ No newline at end of file From 0eb5f89999bcda673b1ae91ca3820b5cc78e69db Mon Sep 17 00:00:00 2001 From: zhaoke Date: Thu, 24 Nov 2022 08:13:33 +0000 Subject: [PATCH 29/36] * Add edit node. --- ...nnodeheartbeat.php => zanodeheartbeat.php} | 0 module/zahost/control.php | 2 +- module/zahost/lang/de.php | 10 ++- module/zahost/lang/en.php | 2 + module/zahost/lang/fr.php | 1 + module/zahost/lang/vi.php | 9 +-- module/zahost/lang/zh-cn.php | 2 + module/zanode/config.php | 2 +- module/zanode/control.php | 55 ++++++++++--- module/zanode/js/common.js | 18 +++-- module/zanode/lang/de.php | 4 +- module/zanode/lang/en.php | 2 + module/zanode/lang/fr.php | 4 +- module/zanode/lang/zh-cn.php | 2 + module/zanode/model.php | 22 +++-- module/zanode/view/browse.html.php | 5 +- module/zanode/view/edit.html.php | 81 +++++++++++++++++++ module/zanode/view/view.html.php | 13 ++- 18 files changed, 192 insertions(+), 42 deletions(-) rename api/v1/entries/{executionnodeheartbeat.php => zanodeheartbeat.php} (100%) create mode 100644 module/zanode/view/edit.html.php diff --git a/api/v1/entries/executionnodeheartbeat.php b/api/v1/entries/zanodeheartbeat.php similarity index 100% rename from api/v1/entries/executionnodeheartbeat.php rename to api/v1/entries/zanodeheartbeat.php diff --git a/module/zahost/control.php b/module/zahost/control.php index e0fdcc5777..3dccaf2244 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -286,7 +286,7 @@ class zahost extends control */ public function initHost($hostID) { - $this->view->title = $this->lang->zahost->vmTemplate->common; + $this->view->title = $this->lang->zahost->init; $this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted'); $this->view->hostID = $hostID; diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index 9f8dbd0db6..c026a88c61 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -4,6 +4,7 @@ $lang->zahost->common = 'ZAhost'; $lang->zahost->browse = 'Host List'; $lang->zahost->create = 'Add Host'; $lang->zahost->view = 'Host View'; +$lang->zahost->init = 'Init Host'; $lang->zahost->edit = 'Edit'; $lang->zahost->editAction = 'Edit Host'; $lang->zahost->delete = 'Delete'; @@ -11,10 +12,11 @@ $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 = 'Name'; -$lang->zahost->IP = 'IP/Domain'; -$lang->zahost->extranet = 'IP'; +$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'; @@ -30,7 +32,9 @@ $lang->zahost->registerDate = 'RegisterDate'; $lang->zahost->memorySize = $lang->zahost->memory; $lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; +$lang->zahost->osType = 'Os Version'; $lang->zahost->os = 'System'; +$lang->zahost->osVersion = 'Os Version No'; $lang->zahost->osLang = 'Language'; $lang->zahost->imageName = 'Image File'; @@ -69,7 +73,7 @@ $lang->zahost->image->name = 'Name'; $lang->zahost->image->desc = 'Description'; $lang->zahost->image->memory = $lang->zahost->memory; $lang->zahost->image->disk = $lang->zahost->diskSize; -$lang->zahost->image->os = $lang->zahost->osCategory; +$lang->zahost->image->os = $lang->zahost->os; $lang->zahost->image->imageName = $lang->zahost->imageName; $lang->zahost->image->statusList['created'] = 'Created'; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index 6d4be82372..9b26af35ed 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -4,6 +4,7 @@ $lang->zahost->common = 'ZAhost'; $lang->zahost->browse = 'Host List'; $lang->zahost->create = 'Add Host'; $lang->zahost->view = 'Host View'; +$lang->zahost->init = 'Init Host'; $lang->zahost->edit = 'Edit'; $lang->zahost->editAction = 'Edit Host'; $lang->zahost->delete = 'Delete'; @@ -11,6 +12,7 @@ $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 = 'Name'; $lang->zahost->IP = 'Extranet Address'; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index ee7458fd37..4b8fcc48da 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -4,6 +4,7 @@ $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->init = 'Init Host'; $lang->zahost->edit = 'Éditer'; $lang->zahost->editAction = 'Éditer Hôte'; $lang->zahost->delete = 'Supprimer'; diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php index 96797f4e76..c026a88c61 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -4,6 +4,7 @@ $lang->zahost->common = 'ZAhost'; $lang->zahost->browse = 'Host List'; $lang->zahost->create = 'Add Host'; $lang->zahost->view = 'Host View'; +$lang->zahost->init = 'Init Host'; $lang->zahost->edit = 'Edit'; $lang->zahost->editAction = 'Edit Host'; $lang->zahost->delete = 'Delete'; @@ -11,10 +12,11 @@ $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 = 'Name'; -$lang->zahost->IP = 'IP/Domain'; -$lang->zahost->extranet = 'IP'; +$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'; @@ -71,10 +73,7 @@ $lang->zahost->image->name = 'Name'; $lang->zahost->image->desc = 'Description'; $lang->zahost->image->memory = $lang->zahost->memory; $lang->zahost->image->disk = $lang->zahost->diskSize; -$lang->zahost->image->osType = $lang->zahost->osType; $lang->zahost->image->os = $lang->zahost->os; -$lang->zahost->image->osVersion = $lang->zahost->osVersion; -$lang->zahost->image->osLang = $lang->zahost->osLang; $lang->zahost->image->imageName = $lang->zahost->imageName; $lang->zahost->image->statusList['created'] = 'Created'; diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index 723b45d945..4423563212 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -5,6 +5,7 @@ $lang->zahost->common = '宿主机'; $lang->zahost->browse = '宿主机列表'; $lang->zahost->create = '添加宿主机'; $lang->zahost->view = '宿主机详情'; +$lang->zahost->init = '初始化宿主机'; $lang->zahost->edit = '编辑'; $lang->zahost->editAction = '编辑宿主机'; $lang->zahost->delete = '删除'; @@ -12,6 +13,7 @@ $lang->zahost->deleteAction = '删除宿主机'; $lang->zahost->byQuery = '搜索'; $lang->zahost->all = '全部主机'; $lang->zahost->browseNode = '执行节点列表'; +$lang->zahost->deleted = "已删除"; $lang->zahost->name = '名称'; $lang->zahost->IP = 'IP/域名'; diff --git a/module/zanode/config.php b/module/zanode/config.php index d156d0e8ec..8005b689a2 100644 --- a/module/zanode/config.php +++ b/module/zanode/config.php @@ -1,7 +1,7 @@ zanode->create = new stdClass(); $config->zanode->edit = new stdClass(); -$config->zanode->create->requiredFields = 'name,host,image,cpu,memory,disk,os'; +$config->zanode->create->requiredFields = 'name,host,image,cpu,memory,disk,osName'; $config->zanode->edit->requiredFields = ''; $config->zanode->defaultPort = '8086'; diff --git a/module/zanode/control.php b/module/zanode/control.php index bc06e56a26..6424c049c9 100644 --- a/module/zanode/control.php +++ b/module/zanode/control.php @@ -77,6 +77,37 @@ class zanode extends control return $this->display(); } + /** + * Edit node. + * + * @param int $hostID + * @access public + * @return void + */ + public function edit($id) + { + if($_POST) + { + $changes = $this->zanode->update($id); + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); + + if($changes) + { + $actionID = $this->loadModel('action')->create('zanode', $id, 'Edited'); + if(!empty($changes)) $this->action->logHistory($actionID, $changes); + } + + if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent')); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse'))); + } + + $this->view->title = $this->lang->zanode->editAction; + $this->view->zanode = $this->zanode->getNodeByID($id); + $this->view->host = $this->zanode->getHostByID($this->view->zanode->parent); + $this->view->image = $this->zanode->getImageByID($this->view->zanode->image); + $this->display(); + } + /** * View Node. * @@ -90,7 +121,6 @@ class zanode extends control $this->view->zanode = $this->zanode->getNodeByID($id); $this->view->actions = $this->loadModel('action')->getList('zanode', $id); $this->view->users = $this->loadModel('user')->getPairs('noletter'); - $this->display(); } @@ -157,19 +187,26 @@ class zanode extends control * @param int $nodeID * @return void */ - public function destroy($nodeID) + public function delete($nodeID, $confirm = 'no') { - $error = $this->zanode->destroy($nodeID); - - if($error) + if($confirm == 'no') { - return print(js::alert($error)); + return print(js::confirm($this->lang->zanode->confirmDelete, inlink('delete', "nodeID=$nodeID&confirm=yes"))); } else { - if(isonlybody()) return print(js::alert($this->lang->zanode->actionSuccess) . js::reload('parent.parent')); - return print(js::alert($this->lang->zanode->actionSuccess) . js::reload('parent')); - } + $error = $this->zanode->destroy($nodeID); + + if($error) + { + return print(js::alert($error)); + } + else + { + if(isonlybody()) return print(js::alert($this->lang->zanode->actionSuccess) . js::reload('parent.parent')); + return print(js::alert($this->lang->zanode->actionSuccess) . js::reload('parent')); + } + } } /** diff --git a/module/zanode/js/common.js b/module/zanode/js/common.js index 5b47861cd4..1243c6aa28 100644 --- a/module/zanode/js/common.js +++ b/module/zanode/js/common.js @@ -4,14 +4,16 @@ $(function() $('#parent').change(function() { - var hostID = $('#parent').val(); - var link = createLink('zanode', 'ajaxGetImages', 'hostID=' + hostID); - $.get(link, function(data) - { - $('#template').html('').append(data); - $('#image').chosen().trigger("chosen:updated"); - $('#image').change(); - }); + if(config.currentMethod == 'create'){ + var hostID = $('#parent').val(); + var link = createLink('zanode', 'ajaxGetImages', 'hostID=' + hostID); + $.get(link, function(data) + { + $('#template').html('').append(data); + $('#image').chosen().trigger("chosen:updated"); + $('#image').change(); + }); + } }); $(document).on("change", '#image', function() diff --git a/module/zanode/lang/de.php b/module/zanode/lang/de.php index bc35f47ab6..bbefb5c016 100644 --- a/module/zanode/lang/de.php +++ b/module/zanode/lang/de.php @@ -2,6 +2,7 @@ $lang->zanode->common = 'Execution Node'; $lang->zanode->browse = 'Execution Node List'; $lang->zanode->create = 'Create Execution Node'; +$lang->zanode->editAction = 'Edit Execution Node'; $lang->zanode->view = 'View Execution Node'; $lang->zanode->suspend = 'Suspend Execution Node'; $lang->zanode->destroy = 'Destroy Execution Node'; @@ -21,7 +22,7 @@ $lang->zanode->hostName = 'Host Name'; $lang->zanode->host = $lang->zanode->hostName; $lang->zanode->extranet = 'IP/Domain'; $lang->zanode->osArch = 'Arch'; -$lang->zanode->cpuCores = 'CPU Cores'; +$lang->zanode->cpuCores = 'CPU Cores'; $lang->zanode->memory = 'Memory Size'; $lang->zanode->desc = 'Description'; $lang->zanode->diskSize = 'Disk Size'; @@ -38,6 +39,7 @@ $lang->zanode->confirmShutdown = "Are you sure to shutdown the execution node? $lang->zanode->confirmSuspend = "Are you sure to suspend the execution node?"; $lang->zanode->confirmResume = "Are you sure to resume the execution node?"; $lang->zanode->actionSuccess = 'Success'; +$lang->zanode->deleted = "Deleted"; $lang->zanode->notFoundAgent = 'No Agent service is found'; $lang->zanode->createVmFail = 'Failed to create a execution node'; diff --git a/module/zanode/lang/en.php b/module/zanode/lang/en.php index 610d8d5581..bbefb5c016 100644 --- a/module/zanode/lang/en.php +++ b/module/zanode/lang/en.php @@ -2,6 +2,7 @@ $lang->zanode->common = 'Execution Node'; $lang->zanode->browse = 'Execution Node List'; $lang->zanode->create = 'Create Execution Node'; +$lang->zanode->editAction = 'Edit Execution Node'; $lang->zanode->view = 'View Execution Node'; $lang->zanode->suspend = 'Suspend Execution Node'; $lang->zanode->destroy = 'Destroy Execution Node'; @@ -38,6 +39,7 @@ $lang->zanode->confirmShutdown = "Are you sure to shutdown the execution node? $lang->zanode->confirmSuspend = "Are you sure to suspend the execution node?"; $lang->zanode->confirmResume = "Are you sure to resume the execution node?"; $lang->zanode->actionSuccess = 'Success'; +$lang->zanode->deleted = "Deleted"; $lang->zanode->notFoundAgent = 'No Agent service is found'; $lang->zanode->createVmFail = 'Failed to create a execution node'; diff --git a/module/zanode/lang/fr.php b/module/zanode/lang/fr.php index bc35f47ab6..bbefb5c016 100644 --- a/module/zanode/lang/fr.php +++ b/module/zanode/lang/fr.php @@ -2,6 +2,7 @@ $lang->zanode->common = 'Execution Node'; $lang->zanode->browse = 'Execution Node List'; $lang->zanode->create = 'Create Execution Node'; +$lang->zanode->editAction = 'Edit Execution Node'; $lang->zanode->view = 'View Execution Node'; $lang->zanode->suspend = 'Suspend Execution Node'; $lang->zanode->destroy = 'Destroy Execution Node'; @@ -21,7 +22,7 @@ $lang->zanode->hostName = 'Host Name'; $lang->zanode->host = $lang->zanode->hostName; $lang->zanode->extranet = 'IP/Domain'; $lang->zanode->osArch = 'Arch'; -$lang->zanode->cpuCores = 'CPU Cores'; +$lang->zanode->cpuCores = 'CPU Cores'; $lang->zanode->memory = 'Memory Size'; $lang->zanode->desc = 'Description'; $lang->zanode->diskSize = 'Disk Size'; @@ -38,6 +39,7 @@ $lang->zanode->confirmShutdown = "Are you sure to shutdown the execution node? $lang->zanode->confirmSuspend = "Are you sure to suspend the execution node?"; $lang->zanode->confirmResume = "Are you sure to resume the execution node?"; $lang->zanode->actionSuccess = 'Success'; +$lang->zanode->deleted = "Deleted"; $lang->zanode->notFoundAgent = 'No Agent service is found'; $lang->zanode->createVmFail = 'Failed to create a execution node'; diff --git a/module/zanode/lang/zh-cn.php b/module/zanode/lang/zh-cn.php index 84879d7768..1e1b81b5d6 100644 --- a/module/zanode/lang/zh-cn.php +++ b/module/zanode/lang/zh-cn.php @@ -2,6 +2,7 @@ $lang->zanode->common = '执行节点'; $lang->zanode->browse = '执行节点列表'; $lang->zanode->create = '创建执行节点'; +$lang->zanode->editAction = '编辑执行节点'; $lang->zanode->view = '执行节点详情'; $lang->zanode->suspend = '暂停执行节点'; $lang->zanode->destroy = '销毁执行节点'; @@ -38,6 +39,7 @@ $lang->zanode->confirmShutdown = "您确定关闭执行节点吗?"; $lang->zanode->confirmSuspend = "您确定暂停执行节点吗?"; $lang->zanode->confirmResume = "您确定恢复执行节点吗?"; $lang->zanode->actionSuccess = '操作成功'; +$lang->zanode->deleted = "已删除"; $lang->zanode->notFoundAgent = '没有发现Agent服务'; $lang->zanode->createVmFail = '创建执行节点失败'; diff --git a/module/zanode/model.php b/module/zanode/model.php index 584aa93fda..959ed9a649 100644 --- a/module/zanode/model.php +++ b/module/zanode/model.php @@ -214,17 +214,25 @@ class zanodemodel extends model } /** - * Update Node attribute. + * Update Node. * * @param int $id - * @param array $data * @return void */ - public function update($id, $data) + public function update($id) { - $this->dao->update(TABLE_ZAHOST)->data($data) - ->where('id')->eq($id) - ->exec(); + $oldHost = $this->getNodeById($id); + $hostInfo = fixer::input('post')->get(); + $hostInfo->editedBy = $this->app->user->account; + $hostInfo->editedDate = helper::now(); + + $this->dao->update(TABLE_ZAHOST)->data($hostInfo) + ->batchCheck($this->config->zanode->edit->requiredFields, 'notempty'); + if(dao::isError()) return false; + + $this->dao->update(TABLE_ZAHOST)->data($hostInfo)->autoCheck() + ->where('id')->eq($id)->exec(); + return common::createChanges($oldHost, $hostInfo); } /** @@ -433,7 +441,7 @@ class zanodemodel extends model $returnData = new stdClass(); $returnData->hostIP = $host->extranet; $returnData->agentPort = $host->agentPort; - $returnData->vnc = $vm->vnc; + $returnData->vnc = $vm->vnc; $returnData->token = $result->data->token; return $returnData; } diff --git a/module/zanode/view/browse.html.php b/module/zanode/view/browse.html.php index 3138ea4ec2..72ec091362 100644 --- a/module/zanode/view/browse.html.php +++ b/module/zanode/view/browse.html.php @@ -57,7 +57,7 @@
zanode->osName); ?> zanode->status); ?> zanode->hostName); ?> - actions ?>actions ?>
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
zanode->hostName;?>name, "class='form-control' readonly='readonly'");?>
zanode->name;?>name, "class='form-control' placeholder=\"{$lang->zanode->nameValid}\"");?>
zanode->image;?>name, "class='form-control' readonly='readonly'");?>
zanode->cpuCores;?>zanode->os->cpuCores, $zanode->cpuCores), "class='form-control' readonly='readonly'");?>
zanode->memory;?> +
+ memory, "class='form-control' readonly='readonly'");?> + zahost->unitList['GB'];?> +
+
zanode->diskSize;?> +
+ diskSize, "class='form-control' readonly='readonly'");?> + + zahost->unitList['GB'];?> + +
+
zanode->osName;?>osName, "class='form-control' readonly='readonly'")?>
zanode->desc ?>desc, "class='form-control'")?>
+ + goback, '', "class='btn btn-wide btn-back'");?> +
+ + + + +getModuleRoot() . 'common/view/footer.html.php';?> + diff --git a/module/zanode/view/view.html.php b/module/zanode/view/view.html.php index 52a6c292ac..bdb652eff1 100644 --- a/module/zanode/view/view.html.php +++ b/module/zanode/view/view.html.php @@ -96,10 +96,15 @@ ' . $lang->goback, '', 'btn btn-secondary'); ?>
deleted)) { - if(in_array($zanode->status, array("suspend", ""))) - common::printLink('zanode', 'suspend', "id={$zanode->id}", " " . $lang->zanode->suspend, '', "title='{$lang->zanode->suspend}' class='btn' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmSuspend}\")==false) return false;'"); - common::printLink('zanode', 'resume', "id={$zanode->id}", " " . $lang->zanode->resume, '', "title='{$lang->zanode->resume}' class='btn' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmResume}\")==false) return false;'"); + if (empty($zanode->deleted)) + { + if($zanode->status == "running"){ + common::printLink('zanode', 'suspend', "id={$zanode->id}", " " . $lang->zanode->suspend, '', "title='{$lang->zanode->suspend}' class='btn' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmSuspend}\")==false) return false;'"); + } + elseif($zanode->status == "suspend") + { + common::printLink('zanode', 'resume', "id={$zanode->id}", " " . $lang->zanode->resume, '', "title='{$lang->zanode->resume}' class='btn' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmResume}\")==false) return false;'"); + } common::printLink('zanode', 'getVNC', "id={$zanode->id}", " " . $lang->zanode->getVNC, '', "title='{$lang->zanode->getVNC}' class='btn' target='hiddenwin'"); } ?> From e572022c29c911a7e0a6e40559a600e3fbe71cd4 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Fri, 25 Nov 2022 02:59:55 +0000 Subject: [PATCH 30/36] * Add browse image --- module/zahost/control.php | 2 +- module/zahost/js/browseimage.js | 16 ++++++++++++++-- module/zahost/lang/de.php | 12 +++++++----- module/zahost/lang/en.php | 12 +++++++----- module/zahost/lang/fr.php | 12 +++++++----- module/zahost/lang/vi.php | 12 +++++++----- module/zahost/lang/zh-cn.php | 14 ++++++++------ module/zahost/model.php | 2 +- module/zahost/view/browseimage.html.php | 2 ++ 9 files changed, 54 insertions(+), 30 deletions(-) diff --git a/module/zahost/control.php b/module/zahost/control.php index 3dccaf2244..5d7af791b0 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -256,7 +256,7 @@ class zahost extends control $image = $this->zahost->queryDownloadImageStatus($image); $statusName = zget($this->lang->zahost->image->statusList, $image->status,''); - $statusList[$image->id] = array('statusCode' => $image->status, 'status' => $statusName . '(' . $image->rate * 100 . '%)', 'rate' => $image->rate); + $statusList[$image->id] = array('statusCode' => $image->status, 'status' => $statusName, 'progress' => $image->status == 'inprogress' ? $image->rate * 100 . '%' : ''); } return $this->send(array('result' => 'success', 'message' => '', 'data' => $statusList)); diff --git a/module/zahost/js/browseimage.js b/module/zahost/js/browseimage.js index 4d74829772..2e1ff66fc7 100644 --- a/module/zahost/js/browseimage.js +++ b/module/zahost/js/browseimage.js @@ -1,6 +1,10 @@ $(function() { - setInterval(function() + updateProgress(); +}); + +function updateProgress(){ + var interval = setInterval(function() { $.get(createLink('zahost', 'ajaxImageDownloadProgress', 'hostID=' + hostID)).done(function(response) { @@ -8,13 +12,21 @@ $(function() var statusList = result.data; console.log(statusList); + var hasInprogress = false; for(var imageID in statusList) { if(statusList[imageID].statusCode) { + if(statusList[imageID].statusCode == 'inprogress'){ + hasInprogress = true; + } $('.image-status-' + imageID).text(statusList[imageID].status); + $('.image-progress-' + imageID).text(statusList[imageID].progress); } } + if(!hasInprogress){ + clearInterval(interval) + } }); }, 5000); -}); +} \ No newline at end of file diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index c026a88c61..4b53088ca1 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -75,12 +75,14 @@ $lang->zahost->image->memory = $lang->zahost->memory; $lang->zahost->image->disk = $lang->zahost->diskSize; $lang->zahost->image->os = $lang->zahost->os; $lang->zahost->image->imageName = $lang->zahost->imageName; +$lang->zahost->image->progress = 'Progress'; -$lang->zahost->image->statusList['created'] = 'Created'; -$lang->zahost->image->statusList['canceled'] = 'Canceled'; -$lang->zahost->image->statusList['inprogress'] = 'Inprogress'; -$lang->zahost->image->statusList['completed'] = 'Completed'; -$lang->zahost->image->statusList['failed'] = 'Failed'; +$lang->zahost->image->statusList['notDownloaded'] = 'Not Downloaded'; +$lang->zahost->image->statusList['created'] = 'Inprogress'; +$lang->zahost->image->statusList['canceled'] = 'Canceled'; +$lang->zahost->image->statusList['inprogress'] = 'Inprogress'; +$lang->zahost->image->statusList['completed'] = 'Completed'; +$lang->zahost->image->statusList['failed'] = 'Failed'; $lang->zahost->empty = 'No Host'; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index 9b26af35ed..57a59e2f18 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -75,12 +75,14 @@ $lang->zahost->image->memory = $lang->zahost->memory; $lang->zahost->image->disk = $lang->zahost->diskSize; $lang->zahost->image->os = $lang->zahost->os; $lang->zahost->image->imageName = $lang->zahost->imageName; +$lang->zahost->image->progress = 'Progress'; -$lang->zahost->image->statusList['created'] = 'Created'; -$lang->zahost->image->statusList['canceled'] = 'Canceled'; -$lang->zahost->image->statusList['inprogress'] = 'Inprogress'; -$lang->zahost->image->statusList['completed'] = 'Completed'; -$lang->zahost->image->statusList['failed'] = 'Failed'; +$lang->zahost->image->statusList['notDownloaded'] = 'Not Downloaded'; +$lang->zahost->image->statusList['created'] = 'Inprogress'; +$lang->zahost->image->statusList['canceled'] = 'Canceled'; +$lang->zahost->image->statusList['inprogress'] = 'Inprogress'; +$lang->zahost->image->statusList['completed'] = 'Completed'; +$lang->zahost->image->statusList['failed'] = 'Failed'; $lang->zahost->langList = array(); $lang->zahost->langList['zh_cn'] = 'Simplified Chinese'; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index 4b8fcc48da..4bee698d63 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -73,12 +73,14 @@ $lang->zahost->image->os = $lang->zahost->os; $lang->zahost->image->osVersion = $lang->zahost->osVersion; $lang->zahost->image->osLang = $lang->zahost->osLang; $lang->zahost->image->imageName = $lang->zahost->imageName; +$lang->zahost->image->progress = 'Progress'; -$lang->zahost->image->statusList['created'] = 'Created'; -$lang->zahost->image->statusList['canceled'] = 'Canceled'; -$lang->zahost->image->statusList['inprogress'] = 'Inprogress'; -$lang->zahost->image->statusList['completed'] = 'Completed'; -$lang->zahost->image->statusList['failed'] = 'Failed'; +$lang->zahost->image->statusList['notDownloaded'] = 'Not Downloaded'; +$lang->zahost->image->statusList['created'] = 'Inprogress'; +$lang->zahost->image->statusList['canceled'] = 'Canceled'; +$lang->zahost->image->statusList['inprogress'] = 'Inprogress'; +$lang->zahost->image->statusList['completed'] = 'Completed'; +$lang->zahost->image->statusList['failed'] = 'Failed'; $lang->zahost->empty = 'No Host'; diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php index c026a88c61..4b53088ca1 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -75,12 +75,14 @@ $lang->zahost->image->memory = $lang->zahost->memory; $lang->zahost->image->disk = $lang->zahost->diskSize; $lang->zahost->image->os = $lang->zahost->os; $lang->zahost->image->imageName = $lang->zahost->imageName; +$lang->zahost->image->progress = 'Progress'; -$lang->zahost->image->statusList['created'] = 'Created'; -$lang->zahost->image->statusList['canceled'] = 'Canceled'; -$lang->zahost->image->statusList['inprogress'] = 'Inprogress'; -$lang->zahost->image->statusList['completed'] = 'Completed'; -$lang->zahost->image->statusList['failed'] = 'Failed'; +$lang->zahost->image->statusList['notDownloaded'] = 'Not Downloaded'; +$lang->zahost->image->statusList['created'] = 'Inprogress'; +$lang->zahost->image->statusList['canceled'] = 'Canceled'; +$lang->zahost->image->statusList['inprogress'] = 'Inprogress'; +$lang->zahost->image->statusList['completed'] = 'Completed'; +$lang->zahost->image->statusList['failed'] = 'Failed'; $lang->zahost->empty = 'No Host'; diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index 4423563212..01d2a1a645 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -69,17 +69,19 @@ $lang->zahost->image->startDowload = '开始下载'; $lang->zahost->image->common = '镜像'; $lang->zahost->image->name = '名称'; -$lang->zahost->image->desc = '说明'; +$lang->zahost->image->desc = '描述'; $lang->zahost->image->memory = $lang->zahost->memory; $lang->zahost->image->disk = $lang->zahost->diskSize; $lang->zahost->image->os = $lang->zahost->os; $lang->zahost->image->imageName = $lang->zahost->imageName; +$lang->zahost->image->progress = '进度'; -$lang->zahost->image->statusList['created'] = '已创建'; -$lang->zahost->image->statusList['canceled'] = '已取消'; -$lang->zahost->image->statusList['inprogress'] = '下载中'; -$lang->zahost->image->statusList['completed'] = '已下载'; -$lang->zahost->image->statusList['failed'] = '下载失败'; +$lang->zahost->image->statusList['notDownloaded'] = '未下载'; +$lang->zahost->image->statusList['created'] = '下载中'; +$lang->zahost->image->statusList['canceled'] = '已取消'; +$lang->zahost->image->statusList['inprogress'] = '下载中'; +$lang->zahost->image->statusList['completed'] = '已下载'; +$lang->zahost->image->statusList['failed'] = '下载失败'; $lang->zahost->image->imageEmpty = '无镜像'; $lang->zahost->image->downloadImageFail = '创建下载镜像任务失败'; diff --git a/module/zahost/model.php b/module/zahost/model.php index f0609f85e8..d6a9dc70fe 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -135,7 +135,7 @@ class zahostModel extends model if(empty($downloadedImage)) { $image->id = 0; - $image->status = ''; + $image->status = 'notDownloaded'; } else { diff --git a/module/zahost/view/browseimage.html.php b/module/zahost/view/browseimage.html.php index 014136ecab..48f0bdc8fb 100755 --- a/module/zahost/view/browseimage.html.php +++ b/module/zahost/view/browseimage.html.php @@ -35,6 +35,7 @@
zahost->image->memory);?> zahost->image->disk);?> zahost->status;?>zahost->image->progress;?> actions;?>
memory . zget($this->lang->zahost->unitList, 'GB');?> disk . zget($this->lang->zahost->unitList, 'GB');?> '>zahost->image->statusList, $image->status, '');?>status == 'completed' ? '100%' : '';?> name}&imageID={$image->id}", $image, 'list', 'download');?> createLink('zahost', 'downloadImage', "id={$image->id}"), '', 'hiddenwin', "title='{$lang->zahost->image->downloadImage}' class='btn'");?> From c1205cf2a202afbeb322f6aa8e0ab2252888ee59 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Fri, 25 Nov 2022 05:52:53 +0000 Subject: [PATCH 31/36] * Fix image browse error --- module/zahost/js/browseimage.js | 7 +++++-- module/zahost/model.php | 3 ++- module/zahost/view/browseimage.html.php | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/module/zahost/js/browseimage.js b/module/zahost/js/browseimage.js index 2e1ff66fc7..5ca264a40c 100644 --- a/module/zahost/js/browseimage.js +++ b/module/zahost/js/browseimage.js @@ -19,9 +19,12 @@ function updateProgress(){ { if(statusList[imageID].statusCode == 'inprogress'){ hasInprogress = true; + $('.image-download-' + imageID).addClass('disabled'); + }else if (statusList[imageID].statusCode == 'completed'){ + $('.image-download-' + imageID).addClass('disabled'); } - $('.image-status-' + imageID).text(statusList[imageID].status); - $('.image-progress-' + imageID).text(statusList[imageID].progress); + $('.image-status-' + imageID).text(statusList[imageID].status); + $('.image-progress-' + imageID).text(statusList[imageID].progress); } } if(!hasInprogress){ diff --git a/module/zahost/model.php b/module/zahost/model.php index d6a9dc70fe..0ea82ed18f 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -166,7 +166,8 @@ class zahostModel extends model $imageData->host = $hostID; $imageData->status = 'created'; - $imageData->os = $imageData->os; + $imageData->osName = $imageData->os; + unset($imageData->os); $this->dao->insert(TABLE_IMAGE)->data($imageData, 'desc')->autoCheck()->exec(); if(dao::isError()) return false; diff --git a/module/zahost/view/browseimage.html.php b/module/zahost/view/browseimage.html.php index 48f0bdc8fb..d1ac739a5f 100755 --- a/module/zahost/view/browseimage.html.php +++ b/module/zahost/view/browseimage.html.php @@ -49,7 +49,7 @@ '>zahost->image->statusList, $image->status, '');?> status == 'completed' ? '100%' : '';?> - name}&imageID={$image->id}", $image, 'list', 'download');?> + name}&imageID={$image->id} ", $image, 'list', 'download', '', in_array($image->status, array("completed", "inprogress", "created")) ? "disabled image-download-" . zget($image, 'id', 0) : "image-download-" . zget($image, 'id', 0));?> createLink('zahost', 'downloadImage', "id={$image->id}"), '', 'hiddenwin', "title='{$lang->zahost->image->downloadImage}' class='btn'");?> id}", $image, 'list', 'edit');?> createLink('zahost', 'deleteImage', "id={$image->id}"), '', 'hiddenwin', "title='{$lang->zahost->delete}' class='btn'");?> From 38f77f0ae44f0c3b1077d98c49cdbd44109795ee Mon Sep 17 00:00:00 2001 From: zhaoke Date: Fri, 25 Nov 2022 06:17:10 +0000 Subject: [PATCH 32/36] * Remve unused code. --- db/update18.0.sql | 2 +- module/action/lang/de.php | 2 - module/action/lang/en.php | 2 - module/action/lang/fr.php | 2 - module/action/lang/vi.php | 3 - module/action/lang/zh-cn.php | 2 - module/zahost/view/browse.html.php | 2 +- module/zahost/view/editimage.html.php | 80 --------------------------- test/data/zentao/config.php | 2 - 9 files changed, 2 insertions(+), 95 deletions(-) delete mode 100644 module/zahost/view/editimage.html.php diff --git a/db/update18.0.sql b/db/update18.0.sql index f8b86beaee..a1f600952f 100644 --- a/db/update18.0.sql +++ b/db/update18.0.sql @@ -64,7 +64,7 @@ h.`deleted` = a.`deleted` WHERE h.`assetID` = a.`id`; -ALTER TABLE `zt_host` DROP COLUMN `assetID`, +ALTER TABLE `zt_host` DROP COLUMN `assetID`; DROP TABLE IF EXISTS `zt_asset`; DROP TABLE IF EXISTS `zt_baseimagebrowser`; diff --git a/module/action/lang/de.php b/module/action/lang/de.php index 397a6a56ed..16cbabaf4e 100644 --- a/module/action/lang/de.php +++ b/module/action/lang/de.php @@ -640,8 +640,6 @@ $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->zanode['created'] = 'Create Zagent Node'; $lang->action->dynamicAction->zanode['suspend'] = 'Suspend Zagent Node'; $lang->action->dynamicAction->zanode['resume'] = 'Resume Zagent Node'; diff --git a/module/action/lang/en.php b/module/action/lang/en.php index e0dd127398..dad7cbe63d 100755 --- a/module/action/lang/en.php +++ b/module/action/lang/en.php @@ -641,8 +641,6 @@ $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->zanode['created'] = 'Create Zagent Node'; $lang->action->dynamicAction->zanode['suspend'] = 'Suspend Zagent Node'; $lang->action->dynamicAction->zanode['resume'] = 'Resume Zagent Node'; diff --git a/module/action/lang/fr.php b/module/action/lang/fr.php index c8c4f9d82b..8f98a11ae4 100644 --- a/module/action/lang/fr.php +++ b/module/action/lang/fr.php @@ -640,8 +640,6 @@ $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->zanode['created'] = 'Create Zagent Node'; $lang->action->dynamicAction->zanode['suspend'] = 'Suspend Zagent Node'; $lang->action->dynamicAction->zanode['resume'] = 'Resume Zagent Node'; diff --git a/module/action/lang/vi.php b/module/action/lang/vi.php index 822da8e48d..4b5518d315 100644 --- a/module/action/lang/vi.php +++ b/module/action/lang/vi.php @@ -89,7 +89,6 @@ $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['zanode'] = 'ZA Node'; $lang->action->objectTypes['doc'] = 'Tài liệu'; $lang->action->objectTypes['doclib'] = 'Thư viện tài liệu'; @@ -496,8 +495,6 @@ $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->zanode['created'] = 'Create Zagent Node'; $lang->action->dynamicAction->zanode['suspend'] = 'Suspend Zagent Node'; $lang->action->dynamicAction->zanode['resume'] = 'Resume Zagent Node'; diff --git a/module/action/lang/zh-cn.php b/module/action/lang/zh-cn.php index fa8a8ac6fb..2eccf374dc 100755 --- a/module/action/lang/zh-cn.php +++ b/module/action/lang/zh-cn.php @@ -640,8 +640,6 @@ $lang->action->dynamicAction->caselib['hidden'] = '隐藏用例库'; $lang->action->dynamicAction->zahost['created'] = '创建宿主机'; -$lang->action->dynamicAction->vmtemplate['created'] = '创建虚拟机模板'; - $lang->action->dynamicAction->zanode['created'] = '创建执行节点'; $lang->action->dynamicAction->zanode['suspend'] = '暂停执行节点'; $lang->action->dynamicAction->zanode['resume'] = '恢复执行节点'; diff --git a/module/zahost/view/browse.html.php b/module/zahost/view/browse.html.php index 651cb9e15a..ec88016f08 100644 --- a/module/zahost/view/browse.html.php +++ b/module/zahost/view/browse.html.php @@ -64,7 +64,7 @@ extranet;?> cpuCores;?> memory . $lang->zahost->unitList['GB'];?>diskSize . zget($lang->zahost->unitList, $host->unit);?>diskSize . $lang->zahost->unitList['GB'];?> vsoft;?> host->statusList, $host->status);?> heartbeat) ? '' : $host->heartbeat;?>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
zahost->name;?>name, "class='form-control'");?>
zahost->cpu ;?>cpuCoreNum, "class='form-control'");?>
zahost->memory;?> -
- memorySize, "class='form-control'");?> - MB -
-
zahost->disk;?> -
- diskSize/1024), "class='form-control'");?> - GB -
-
zahost->vmTemplate->osCategory;?>zahost->os->list, $template->osCategory, "class='form-control chosen'")?>
zahost->vmTemplate->osType;?>osType, "class='form-control chosen'")?>
zahost->vmTemplate->osVersion;?>osVersion, "class='form-control chosen'")?>
zahost->vmTemplate->osLang;?>zahost->langList, $template->osLang, "class='form-control chosen'")?>
zahost->vmTemplate->imageName;?>imageName, "class='form-control chosen'")?>
- - - -
- -
-getModuleRoot() . 'common/view/footer.html.php';?> diff --git a/test/data/zentao/config.php b/test/data/zentao/config.php index fc44770af3..60ad6eb595 100644 --- a/test/data/zentao/config.php +++ b/test/data/zentao/config.php @@ -121,6 +121,4 @@ $builder->oauth = array('rows' => 100, 'extends' => array('oauth')); $builder->notify = array('rows' => 10, 'extends' => array('notify')); $builder->vm = array('rows' => 1, 'extends' => array('vm')); -$builder->vmtemplate = array('rows' => 1, 'extends' => array('vmtemplate')); $builder->host = array('rows' => 1, 'extends' => array('host')); -$builder->asset = array('rows' => 1, 'extends' => array('asset')); From 83b5cbd8dd32a38e33cae8b0bd43b52eb27307ad Mon Sep 17 00:00:00 2001 From: zhaoke Date: Fri, 25 Nov 2022 06:20:08 +0000 Subject: [PATCH 33/36] * Fix error. --- module/zahost/control.php | 1 + 1 file changed, 1 insertion(+) diff --git a/module/zahost/control.php b/module/zahost/control.php index 5d7af791b0..2653c22149 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -69,6 +69,7 @@ class zahost extends control $this->view->orderBy = $orderBy; $this->view->nodeList = $this->loadModel("zanode")->getListByHost($this->view->zahost->parent, $orderBy); $this->view->actions = $this->loadModel('action')->getList('zahost', $id); + $this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted'); $this->display(); } From 895513ff339fba197b6c2133019a87e531e0305d Mon Sep 17 00:00:00 2001 From: zhaoke Date: Fri, 25 Nov 2022 06:33:52 +0000 Subject: [PATCH 34/36] * Fix bug. --- module/zahost/view/browseimage.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/zahost/view/browseimage.html.php b/module/zahost/view/browseimage.html.php index d1ac739a5f..f3a6c12fc8 100755 --- a/module/zahost/view/browseimage.html.php +++ b/module/zahost/view/browseimage.html.php @@ -49,7 +49,7 @@
'>zahost->image->statusList, $image->status, '');?> status == 'completed' ? '100%' : '';?> - name}&imageID={$image->id} ", $image, 'list', 'download', '', in_array($image->status, array("completed", "inprogress", "created")) ? "disabled image-download-" . zget($image, 'id', 0) : "image-download-" . zget($image, 'id', 0));?> + name}&imageID={$image->id}", $image, 'list', 'download', '', in_array($image->status, array("completed", "inprogress", "created")) ? "disabled image-download-" . zget($image, 'id', 0) : "image-download-" . zget($image, 'id', 0));?> createLink('zahost', 'downloadImage', "id={$image->id}"), '', 'hiddenwin', "title='{$lang->zahost->image->downloadImage}' class='btn'");?> id}", $image, 'list', 'edit');?> createLink('zahost', 'deleteImage', "id={$image->id}"), '', 'hiddenwin', "title='{$lang->zahost->delete}' class='btn'");?> From 1918eba8f4002084330bccc80616876b0cfc4096 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Fri, 25 Nov 2022 08:21:18 +0000 Subject: [PATCH 35/36] * Fix issue. --- module/zahost/control.php | 1 + module/zahost/js/browseimage.js | 2 +- module/zahost/lang/de.php | 5 +---- module/zahost/lang/en.php | 5 +---- module/zahost/lang/fr.php | 5 +---- module/zahost/lang/vi.php | 5 +---- module/zahost/lang/zh-cn.php | 5 +---- module/zahost/model.php | 1 + module/zahost/view/inithost.html.php | 4 +--- 9 files changed, 9 insertions(+), 24 deletions(-) diff --git a/module/zahost/control.php b/module/zahost/control.php index 2653c22149..05e22299a5 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -290,6 +290,7 @@ class zahost extends control $this->view->title = $this->lang->zahost->init; $this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted'); $this->view->hostID = $hostID; + $this->view->host = $this->zahost->getById($hostID); $this->display(); } diff --git a/module/zahost/js/browseimage.js b/module/zahost/js/browseimage.js index 5ca264a40c..b44d1f8fdb 100644 --- a/module/zahost/js/browseimage.js +++ b/module/zahost/js/browseimage.js @@ -31,5 +31,5 @@ function updateProgress(){ clearInterval(interval) } }); - }, 5000); + }, 3000); } \ No newline at end of file diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index 4b53088ca1..ac658f4b12 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -54,10 +54,7 @@ $lang->zahost->initHost->serviceStatus = [ ]; $lang->zahost->initHost->title = "Initialize Host"; $lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; -$lang->zahost->initHost->descLi = [ - "Download the init script to the host:wget https://pkg.qucheng.com/zenagent/zagentenv", - "Execute the init script on the host and execute the command example under Ubuntu:./zagentenv" -]; +$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->statusTitle = "Service Status"; $lang->zahost->image = new stdclass; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index 57a59e2f18..e014a467ef 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -54,10 +54,7 @@ $lang->zahost->initHost->serviceStatus = [ ]; $lang->zahost->initHost->title = "Initialize Host"; $lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; -$lang->zahost->initHost->descLi = [ - "Download the init script to the host:wget https://pkg.qucheng.com/zenagent/zagentenv", - "Execute the init script on the host and execute the command example under Ubuntu:./zagentenv" -]; +$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->statusTitle = "Service Status"; $lang->zahost->image = new stdclass; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index 4bee698d63..c939bf7ddf 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -50,10 +50,7 @@ $lang->zahost->initHost->serviceStatus = [ ]; $lang->zahost->initHost->title = "Initialize Host"; $lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; -$lang->zahost->initHost->descLi = [ - "Download the init script to the host:wget https://pkg.qucheng.com/zenagent/zagentenv", - "Execute the init script on the host and execute the command example under Ubuntu:./zagentenv" -]; +$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->statusTitle = "Service Status"; $lang->zahost->image = new stdclass; diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php index 4b53088ca1..ac658f4b12 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -54,10 +54,7 @@ $lang->zahost->initHost->serviceStatus = [ ]; $lang->zahost->initHost->title = "Initialize Host"; $lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; -$lang->zahost->initHost->descLi = [ - "Download the init script to the host:wget https://pkg.qucheng.com/zenagent/zagentenv", - "Execute the init script on the host and execute the command example under Ubuntu:./zagentenv" -]; +$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->statusTitle = "Service Status"; $lang->zahost->image = new stdclass; diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index 01d2a1a645..07608caf5e 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -54,10 +54,7 @@ $lang->zahost->initHost->serviceStatus = [ ]; $lang->zahost->initHost->title = "初始化宿主机"; $lang->zahost->initHost->descTitle = "请按照以下步骤在宿主机上完成初始化:"; -$lang->zahost->initHost->descLi = [ - "下载初始化脚本至宿主机:wget https://pkg.qucheng.com/zenagent/zagentenv", - "在宿主机上执行初始化脚本,Ubuntu下执行命令示例:./zagentenv" -]; +$lang->zahost->initHost->initDesc = "在宿主机上执行:bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; $lang->zahost->image = new stdclass; $lang->zahost->image->list = '镜像列表'; diff --git a/module/zahost/model.php b/module/zahost/model.php index 0ea82ed18f..18154e82cd 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -39,6 +39,7 @@ class zahostModel extends model $hostInfo->type = 'zahost'; $hostInfo->createdBy = $this->app->user->account; $hostInfo->createdDate = helper::now(); + $hostInfo->secret = md5($hostInfo->name + time()); $this->dao->update(TABLE_ZAHOST)->data($hostInfo) ->batchCheck($this->config->zahost->create->requiredFields, 'notempty') diff --git a/module/zahost/view/inithost.html.php b/module/zahost/view/inithost.html.php index 932323b5c0..0e71238d84 100644 --- a/module/zahost/view/inithost.html.php +++ b/module/zahost/view/inithost.html.php @@ -22,9 +22,7 @@

zahost->initHost->descTitle;?>

- zahost->initHost->descLi as $key => $li): ?> -
.
- +
zahost->initHost->initDesc . ' ' . $host->secret;?>
From fcf2169b201ce94024e5f8b28f1d6de1e16719a6 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Mon, 28 Nov 2022 06:43:28 +0000 Subject: [PATCH 36/36] Fix indent --- module/zahost/control.php | 4 ++-- module/zahost/lang/de.php | 21 ++++++++++++--------- module/zahost/lang/en.php | 23 +++++++++++++---------- module/zahost/lang/fr.php | 21 ++++++++++++--------- module/zahost/lang/vi.php | 21 ++++++++++++--------- module/zahost/model.php | 6 ++---- module/zahost/view/inithost.html.php | 25 +++++++++++++------------ module/zanode/control.php | 2 +- module/zanode/js/common.js | 2 +- module/zanode/model.php | 2 -- 10 files changed, 68 insertions(+), 59 deletions(-) diff --git a/module/zahost/control.php b/module/zahost/control.php index 05e22299a5..403245c53c 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -110,10 +110,10 @@ class zahost extends control $changes = $this->zahost->update($hostID); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - if($changes) + if(!empty($changes)) { $actionID = $this->loadModel('action')->create('zahost', $hostID, 'Edited'); - if(!empty($changes)) $this->action->logHistory($actionID, $changes); + $this->action->logHistory($actionID, $changes); } if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent')); diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index ac658f4b12..b1ba868eaa 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -39,22 +39,25 @@ $lang->zahost->osLang = 'Language'; $lang->zahost->imageName = 'Image File'; $lang->zahost->initHost = new stdclass; -$lang->zahost->initHost->checkStatus = "Check Service Status"; -$lang->zahost->initHost->not_install = "Not installed"; +$lang->zahost->initHost->checkStatus = "Check Service Status"; +$lang->zahost->initHost->not_install = "Not installed"; $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->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
2. Review the initialization FAQ"; +$lang->zahost->initHost->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ"; + $lang->zahost->initHost->serviceStatus = [ + "nginx" => 'not_install', "kvm" => 'not_install', "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 = "Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; $lang->zahost->initHost->statusTitle = "Service Status"; $lang->zahost->image = new stdclass; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index e014a467ef..ee173c8c9b 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -31,7 +31,7 @@ $lang->zahost->editedDate = 'EditedDate'; $lang->zahost->registerDate = 'RegisterDate'; $lang->zahost->memorySize = $lang->zahost->memory; -$lang->zahost->cpuCoreNum = $lang->zahost->cpuCores ; +$lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; $lang->zahost->osType = 'Os Version'; $lang->zahost->os = 'System'; $lang->zahost->osVersion = 'Os Version No'; @@ -39,22 +39,25 @@ $lang->zahost->osLang = 'Language'; $lang->zahost->imageName = 'Image File'; $lang->zahost->initHost = new stdclass; -$lang->zahost->initHost->checkStatus = "Check Service Status"; -$lang->zahost->initHost->not_install = "Not installed"; +$lang->zahost->initHost->checkStatus = "Check Service Status"; +$lang->zahost->initHost->not_install = "Not installed"; $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->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
2. Review the initialization FAQ"; +$lang->zahost->initHost->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ"; + $lang->zahost->initHost->serviceStatus = [ + "nginx" => 'not_install', "kvm" => 'not_install', "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 = "Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; $lang->zahost->initHost->statusTitle = "Service Status"; $lang->zahost->image = new stdclass; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index c939bf7ddf..e282e447af 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -35,22 +35,25 @@ $lang->zahost->os = 'System'; $lang->zahost->imageName = 'Image File'; $lang->zahost->initHost = new stdclass; -$lang->zahost->initHost->checkStatus = "Check Service Status"; -$lang->zahost->initHost->not_install = "Not installed"; +$lang->zahost->initHost->checkStatus = "Check Service Status"; +$lang->zahost->initHost->not_install = "Not installed"; $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->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
2. Review the initialization FAQ"; +$lang->zahost->initHost->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ"; + $lang->zahost->initHost->serviceStatus = [ + "nginx" => 'not_install', "kvm" => 'not_install', "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 = "Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; $lang->zahost->initHost->statusTitle = "Service Status"; $lang->zahost->image = new stdclass; diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php index ac658f4b12..b1ba868eaa 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -39,22 +39,25 @@ $lang->zahost->osLang = 'Language'; $lang->zahost->imageName = 'Image File'; $lang->zahost->initHost = new stdclass; -$lang->zahost->initHost->checkStatus = "Check Service Status"; -$lang->zahost->initHost->not_install = "Not installed"; +$lang->zahost->initHost->checkStatus = "Check Service Status"; +$lang->zahost->initHost->not_install = "Not installed"; $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->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
2. Review the initialization FAQ"; +$lang->zahost->initHost->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ"; + $lang->zahost->initHost->serviceStatus = [ + "nginx" => 'not_install', "kvm" => 'not_install', "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 = "Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; $lang->zahost->initHost->statusTitle = "Service Status"; $lang->zahost->image = new stdclass; diff --git a/module/zahost/model.php b/module/zahost/model.php index 18154e82cd..134d22cdf8 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -378,10 +378,8 @@ class zahostModel extends model $menu = ''; $params = "hostID=$host->id"; - $menu .= $this->buildMenu('zahost', 'edit', $params, $host, 'view'); - - $params = "hostID=$host->id"; - $menu .= $this->buildMenu('zahost', 'delete', $params, $host, 'view', 'trash', 'hiddenwin'); + $menu .= $this->buildMenu('zahost', 'edit', $params, $host, 'view'); + $menu .= $this->buildMenu('zahost', 'delete', $params, $host, 'view', 'trash', 'hiddenwin'); return $menu; } diff --git a/module/zahost/view/inithost.html.php b/module/zahost/view/inithost.html.php index 0e71238d84..21070cf6c7 100644 --- a/module/zahost/view/inithost.html.php +++ b/module/zahost/view/inithost.html.php @@ -1,4 +1,5 @@ - - -zahost);?> + + +zahost); ?>
-

zahost->initHost->title;?>

+

zahost->initHost->title; ?>

-

zahost->initHost->descTitle;?>

-
zahost->initHost->initDesc . ' ' . $host->secret;?>
+

zahost->initHost->descTitle; ?>

+
zahost->initHost->initDesc . ' ' . $host->secret; ?>
-
- - createLink('zahost', 'browseImage', "hostID={$hostID}"), $lang->zahost->initHost->next, '', "title='{$lang->zahost->initHost->next}' class='btn btn-primary margin-top-18' disabled='disabled' id='jumpToImageList'");?> -
+
+ + createLink('zahost', 'browseImage', "hostID={$hostID}"), $lang->zahost->initHost->next, '', "title='{$lang->zahost->initHost->next}' class='btn btn-primary margin-top-18' disabled='disabled' id='jumpToImageList'"); ?> +
+
-
- + \ No newline at end of file diff --git a/module/zanode/control.php b/module/zanode/control.php index 6424c049c9..66d8530cd4 100644 --- a/module/zanode/control.php +++ b/module/zanode/control.php @@ -118,7 +118,7 @@ class zanode extends control public function view($id) { $this->view->title = $this->lang->zanode->view; - $this->view->zanode = $this->zanode->getNodeByID($id); + $this->view->zanode = $this->zanode->getNodeByID($id); $this->view->actions = $this->loadModel('action')->getList('zanode', $id); $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->display(); diff --git a/module/zanode/js/common.js b/module/zanode/js/common.js index 1243c6aa28..af78b5fd6f 100644 --- a/module/zanode/js/common.js +++ b/module/zanode/js/common.js @@ -19,7 +19,7 @@ $(function() $(document).on("change", '#image', function() { var image = $('#image').val(); - var link = createLink('zanode', 'ajaxGetImage', 'image=' + image); + var link = createLink('zanode', 'ajaxGetImage', 'image=' + image); $.get(link, function(data) { data = JSON.parse(data); diff --git a/module/zanode/model.php b/module/zanode/model.php index 959ed9a649..aba3906471 100644 --- a/module/zanode/model.php +++ b/module/zanode/model.php @@ -454,8 +454,6 @@ class zanodemodel extends model $params = "id=$node->id"; $menu .= $this->buildMenu('zanode', 'edit', $params, $node, 'view'); - - $params = "id=$node->id"; $menu .= $this->buildMenu('zanode', 'delete', $params, $node, 'view', 'trash', 'hiddenwin'); return $menu;