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/api/v1/entries/executionnodeheartbeat.php b/api/v1/entries/zanodeheartbeat.php similarity index 63% rename from api/v1/entries/executionnodeheartbeat.php rename to api/v1/entries/zanodeheartbeat.php index 8a2d30dc34..5923d0fc10 100644 --- a/api/v1/entries/executionnodeheartbeat.php +++ b/api/v1/entries/zanodeheartbeat.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/config/zentaopms.php b/config/zentaopms.php index 454b31f5f2..974fc0f9c5 100644 --- a/config/zentaopms.php +++ b/config/zentaopms.php @@ -254,10 +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`'); - -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_IMAGE', '`' . $config->db->prefix . 'image`'); define('TABLE_PRODUCT', '`' . $config->db->prefix . 'product`'); define('TABLE_BRANCH', '`' . $config->db->prefix . 'branch`'); @@ -400,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_VM; $config->newFeatures = array('introduction', 'tutorial', 'youngBlueTheme', 'visions'); $config->disabledFeatures = ''; diff --git a/db/update17.8.sql b/db/update17.8.sql index 62dd3545a3..facd98b749 100644 --- a/db/update17.8.sql +++ b/db/update17.8.sql @@ -7,6 +7,94 @@ ALTER TABLE `zt_release` CHANGE `branch` `branch` varchar(255) NOT NULL; ALTER TABLE `zt_release` CHANGE `build` `build` varchar(255) NOT NULL; ALTER TABLE `zt_release` ADD `shadow` mediumint(8) unsigned NOT NULL DEFAULT '0' AFTER `branch`; +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`; + +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, + `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 '', + `osName` 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, + `createdBy` varchar(30) NOT NULL, + `createdDate` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB 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 8b2dc9dbdf..8faa92f382 100755 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -7250,71 +7250,65 @@ 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` ( +-- DROP TABLE IF EXISTS `zt_host`; +CREATE TABLE `zt_host` ( `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, + `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, + `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` char(30) NOT NULL, + `editedBy` varchar(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; +) 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 '', - `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, - `cpuCores` varchar(30) NOT NULL, - `cpuRate` varchar(30) NOT NULL, - `memory` varchar(30) NOT NULL, - `diskType` varchar(30) NOT NULL, - `diskSize` varchar(30) NOT NULL, - `unit` enum('GB','TB') NOT NULL DEFAULT 'GB', - `privateIP` varchar(128) NOT NULL, - `publicIP` 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, - `heartbeatTime` 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 '', +-- DROP TABLE IF EXISTS `zt_image`; +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 '', + `osName` 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, + `createdBy` varchar(30) NOT NULL, + `createdDate` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -7561,94 +7555,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` ( 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 6ad34a579a..d59614b43e 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'; @@ -642,13 +641,11 @@ $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->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 912fe25df4..e488db7bbf 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'; @@ -643,13 +642,11 @@ $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->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 efa1463c66..21cf20f924 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'; @@ -641,13 +641,11 @@ $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->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..4b5518d315 100644 --- a/module/action/lang/vi.php +++ b/module/action/lang/vi.php @@ -89,8 +89,7 @@ $lang->action->objectTypes['testsuite'] = 'Suite'; $lang->action->objectTypes['testtask'] = 'Test bản dựng'; $lang->action->objectTypes['testreport'] = 'Báo cáo'; $lang->action->objectTypes['zahost'] = 'Host'; -$lang->action->objectTypes['vmtemplate'] = 'Virtual Host Template'; -$lang->action->objectTypes['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'; @@ -496,13 +495,11 @@ $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->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 0776ad0e2b..1bf368aa5e 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'] = '文档库'; @@ -642,13 +641,11 @@ $lang->action->dynamicAction->caselib['hidden'] = '隐藏用例库'; $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 3bc026f8d5..7c9a96d28e 100644 --- a/module/common/lang/de.php +++ b/module/common/lang/de.php @@ -179,9 +179,9 @@ $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->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 4a6a2af654..e066e9a34b 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.php @@ -179,9 +179,9 @@ $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->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 1279c07c73..2344a2f744 100644 --- a/module/common/lang/fr.php +++ b/module/common/lang/fr.php @@ -179,9 +179,9 @@ $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->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 5394e6288d..da37384bf7 100644 --- a/module/common/lang/menu.php +++ b/module/common/lang/menu.php @@ -450,9 +450,9 @@ $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'); +$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 64333554af..c88c52df88 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -179,9 +179,9 @@ $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->zanode->common = '执行节点'; $lang->team->common = '团队'; $lang->user->common = '用户'; $lang->custom->common = '自定义'; diff --git a/module/common/model.php b/module/common/model.php index 36662cf31a..28e9733bcd 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -3200,6 +3200,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/executionnode/config.php b/module/executionnode/config.php deleted file mode 100755 index cf3727c872..0000000000 --- a/module/executionnode/config.php +++ /dev/null @@ -1,51 +0,0 @@ -executionnode->create = new stdClass(); -$config->executionnode->edit = new stdClass(); -$config->executionnode->create->requiredFields = 'name,hostID,templateID,osCpu,osMemory,osDisk'; -$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->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'; - -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']['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']['publicIP'] = $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' => ''); -$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' => ''); diff --git a/module/executionnode/css/create.css b/module/executionnode/css/create.css deleted file mode 100644 index 662cc09295..0000000000 --- a/module/executionnode/css/create.css +++ /dev/null @@ -1,3 +0,0 @@ -#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;} diff --git a/module/executionnode/js/common.js b/module/executionnode/js/common.js deleted file mode 100755 index 912da9a03a..0000000000 --- a/module/executionnode/js/common.js +++ /dev/null @@ -1,33 +0,0 @@ -$(function() -{ - if(config.currentMethod == 'create') $('#hostID').change(); - - $('#hostID').change(function() - { - var hostID = $('#hostID').val(); - var link = createLink('executionnode', 'ajaxGetTemplates', 'hostID=' + hostID); - $.get(link, function(data) - { - $('#template').html('').append(data); - $('#templateID').chosen().trigger("chosen:updated"); - $('#templateID').change(); - }); - }); - - $(document).on("change", '#templateID', function() - { - var templateID = $('#templateID').val(); - var link = createLink('executionnode', 'ajaxGetTemplateInfo', 'templateID=' + templateID); - $.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); - }); - }); - - if(typeof templateID == 'undefined' || !templateID) $('#osCategory').change(); -}) diff --git a/module/executionnode/lang/de.php b/module/executionnode/lang/de.php deleted file mode 100755 index 0687a90e7c..0000000000 --- a/module/executionnode/lang/de.php +++ /dev/null @@ -1,99 +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->osCategory = 'System'; -$lang->executionnode->osType = 'Os Version'; -$lang->executionnode->osVersion = 'Os Version No'; -$lang->executionnode->vmTemplate = 'VM Template'; -$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->status = 'Status'; -$lang->executionnode->macAddress = '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->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?"; -$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->templateEmpty = 'No Template'; - -$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'; - -$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 deleted file mode 100755 index 0687a90e7c..0000000000 --- a/module/executionnode/lang/en.php +++ /dev/null @@ -1,99 +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->osCategory = 'System'; -$lang->executionnode->osType = 'Os Version'; -$lang->executionnode->osVersion = 'Os Version No'; -$lang->executionnode->vmTemplate = 'VM Template'; -$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->status = 'Status'; -$lang->executionnode->macAddress = '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->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?"; -$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->templateEmpty = 'No Template'; - -$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'; - -$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 deleted file mode 100755 index 2f87c20538..0000000000 --- a/module/executionnode/lang/fr.php +++ /dev/null @@ -1,101 +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->osCategory = 'System'; -$lang->executionnode->osType = 'Os Version'; -$lang->executionnode->osVersion = 'Os Version No'; -$lang->executionnode->vmTemplate = 'VM Template'; -$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->status = 'Status'; -$lang->executionnode->macAddress = '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->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?"; -$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->templateEmpty = 'No Template'; - -$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'; - -$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 deleted file mode 100755 index 1bb1dc695a..0000000000 --- a/module/executionnode/lang/zh-cn.php +++ /dev/null @@ -1,100 +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->osCategory = '操作系统平台'; -$lang->executionnode->osType = '操作系统版本'; -$lang->executionnode->osVersion = '操作系统版本号'; -$lang->executionnode->vmTemplate = '虚拟机模板'; -$lang->executionnode->name = '执行节点名称'; -$lang->executionnode->start = '创建后自动开启'; -$lang->executionnode->hostName = '所属宿主机'; -$lang->executionnode->hostID = $lang->executionnode->hostName; -$lang->executionnode->ip = 'IP'; -$lang->executionnode->osArch = '架构'; -$lang->executionnode->osLang = '系统语言'; -$lang->executionnode->cpu = 'CPU核心数'; -$lang->executionnode->osMemory = '内存'; -$lang->executionnode->osDisk = '硬盘'; -$lang->executionnode->status = '状态'; -$lang->executionnode->macAddress = 'MAC地址'; -$lang->executionnode->vnc = 'VNC端口'; -$lang->executionnode->destroyAt = '销毁时间'; -$lang->executionnode->creater = '创建人'; -$lang->executionnode->createdDate = '创建日期'; -$lang->executionnode->template = '模板'; -$lang->executionnode->templateID = '虚拟机模板'; -$lang->executionnode->templateList = '模板列表'; -$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->templateEmpty = '暂时没有模板'; - -$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'] = '销毁失败'; - -$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 deleted file mode 100755 index 641288a976..0000000000 --- a/module/executionnode/model.php +++ /dev/null @@ -1,523 +0,0 @@ - - * @package ops - * @version $Id$ - * @link http://www.zentao.net - */ -class executionnodemodel extends model -{ - - const STATUS_CREATED = 'created'; - const STATUS_LAUNCH = 'launch'; - const STATUS_FAIL_CREATE = 'vm_fail_create'; - const STATUS_RUNNING = 'running'; - const STATUS_SHUTOFF = 'shutoff'; - const STATUS_BUSY = 'busy'; - const STATUS_READY = 'ready'; - const STATUS_UNKNOWN = 'unknown'; - const STATUS_DESTROY = 'destroy'; - const STATUS_DESTROY_FAIL = 'vim_destroy_fail'; - - const KVM_CREATE_PATH = '/api/v1/kvm/create'; - const KVM_TOKEN_PATH = '/api/v1/vnc/getToken'; - - - /** - * Create an VM. - * - * @param object $data - * @param int $templateID - * @access public - * @return void - */ - public function create() - { - $data = fixer::input('post')->get(); - - /* Batch check fields. */ - $this->lang->vm = $this->lang->executionnode; - $this->dao->update(TABLE_VM)->data($data) - ->batchCheck($this->config->executionnode->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; - return false; - } - - /* Get Vmtemplate. */ - $vmTemplate = $this->getVmTemplateByID($data->templateID); - $data->osCategory = $vmTemplate->osCategory; - $data->osType = $vmTemplate->osType; - $data->osVersion = $vmTemplate->osVersion; - $data->osLang = $vmTemplate->osLang; - - /* Get host info. */ - $host = $this->getHostByID($vmTemplate->hostID); - - /* Gen mac address */ - $macAddress = $this->genMacAddress(); - - /* Prepare create params. */ - $agnetUrl = 'http://' . $host->publicIP . ':' . $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, - ); - - $result = json_decode(commonModel::http($agnetUrl . static::KVM_CREATE_PATH, json_encode($param), null)); - - if(empty($result)) - { - dao::$errors[] = $this->lang->executionnode->notFoundAgent; - return false; - } - if($result->code != 1) - { - dao::$errors[] = $this->lang->executionnode->createVmFail; - return false; - } - - /* Prepare create execution node data. */ - $data->templateID = $data->templateID; - $data->hostID = $host->id; - $data->macAddress = $macAddress; - $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; - - /* Save execution node. */ - $this->dao->insert(TABLE_VM)->data($data)->autoCheck()->exec(); - if(dao::isError()) return false; - - $nodeID = $this->dao->lastInsertID(); - - /* update action log. */ - $this->loadModel('action')->create('executionnode', $nodeID, 'Created'); - return true; - } - - /** - * Action VM. - * - * @param int $id - * @param string $type - * @return string - */ - public function handleVM($id, $type) - { - $node = $this->getVMByID($id); - $host = $this->getHostByID($node->hostID); - - /* Prepare create params. */ - $agnetUrl = 'http://' . $host->publicIP . ':' . $this->config->executionnode->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($data['code'] != 1) return zget($this->lang->executionnode->apiError, $data['code'], $data['msg']); - - if($type != 'reboot') - { - $status = $type == 'suspend' ? 'suspend' : 'running'; - $this->dao->update(TABLE_VM)->set('status')->eq($status)->where('id')->eq($id)->exec(); - } - - $this->loadModel('action')->create('executionnode', $id, ucfirst($type)); - return; - } - - /** - * Destroy VM. - * - * @param int $id - * @access public - * @return void - */ - public function destroy($id) - { - $node = $this->getVMByID($id); - $host = $this->getHostByID($node->hostID); - - $req = array( 'vmUniqueName' => $node->name ); - - /* Prepare create params. */ - if($host) - { - $agnetUrl = 'http://' . $host->publicIP . ':' . $this->config->executionnode->defaultPort; - $result = commonModel::http($agnetUrl . '/api/v1/kvm/' . $node->name . '/destroy', 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']); - } - - /* delete execution node. */ - $this->dao->update(TABLE_VM) - ->set('deleted')->eq(1) - ->set('destroyAt')->eq(helper::now()) - ->where('id')->eq($id) - ->exec(); - $this->loadModel('action')->create('executionnode', $id, 'destroy'); - return; - } - - /** - * Get execution node created action record by node ID. - * - * @param int $id - * @access public - * @return object - */ - public function getNodeCreateActionByID($id) - { - return $this->dao->select('*')->from(TABLE_ACTION) - ->where('objectType')->eq('executionnode') - ->andWhere('objectID')->eq($id) - ->andWhere('action')->eq('created') - ->fetch(); - } - - /** - * Callback update host data. - * - * @access public - * @return mixed - */ - public function updateHostByCallback() - { - $data = array(); - $data['status'] = isset($_POST['status']) ? $_POST['status'] : ''; - $data['agentPort'] = isset($_POST['port']) ? $_POST['port'] : ''; - $ip = isset($_POST['ip']) ? $_POST['ip'] : ''; - - if(empty($ip)) return false; - - $host = $this->getHostByIP($ip); - if(empty($host)) return 'Not Found'; - - $this->dao->update(TABLE_ZAHOST)->data($data) - ->where('id')->eq($host->id) - ->exec(); - return true; - } - - /** - * Update VM attribute. - * - * @param int $id - * @param array $data - * @return void - */ - public function update($id, $data) - { - $this->dao->update(TABLE_VM)->data($data) - ->where('id')->eq($id) - ->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_VM)->data(array('name' => $name)) - ->where('id')->eq($id) - ->exec(); - $vm['name'] = $name; - return $vm; - } - - /** - * Get vm list. - * - * @param string $browseType - * @param int $param - * @param string $orderBy - * @param object $pager - * @return void - */ - public function getListByQuery($browseType = 'all', $param = 0, $orderBy = 'id_desc', $pager = null) - { - $query = ''; - if($browseType == 'bysearch') - { - if($param) - { - $query = $this->loadModel('search')->getQuery($param); - if($query) - { - $this->session->set('vmQuery', $query->sql); - $this->session->set('vmForm', $query->form); - } - else - { - $this->session->set('vmQuery', ' 1 = 1'); - } - } - else - { - if($this->session->vmQuery == false) $this->session->set('vmQuery', ' 1 = 1'); - } - $query = $this->session->vmQuery; - $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('`hostID`', 't1.`hostID`', $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.publicIP as hostIP,t4.osVersion')->from(TABLE_VM)->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') - ->where('t1.deleted')->eq(0) - ->andWhere("((t1.public = 1) OR (t1.createdBy = '{$this->app->user->account}'))") - ->beginIF($query)->andWhere($query)->fi() - ->orderBy($orderBy) - ->page($pager) - ->fetchAll(); - } - - - /** - * Get Host by id. - * - * @param int $id - * @access public - * @return object - */ - public function getHostByID($id) - { - return $this->dao->select('*')->from(TABLE_ZAHOST) - ->where('id')->eq($id) - ->fetch(); - } - - /** - * Get Host by IP. - * - * @param string $ip - * @access public - * @return object - */ - public function getHostByIP($ip) - { - return $this->dao->select('*')->from(TABLE_ZAHOST) - ->where('publicIP')->eq($ip) - ->fetch(); - } - - /** - * Get BaseImage by name. - * - * @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) - { - return $this->dao->select('*')->from(TABLE_VMTEMPLATE) - ->where('id')->eq($id) - ->fetch(); - } - - /** - * 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 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. - * - * @param string $orderBy - * @param int $pager - * @access public - * @return array - */ - public function getVmTemplateList($orderBy = 'id_desc', $pager = null) - { - return $this->dao->select('*')->from(TABLE_VMTEMPLATE)->orderBy($orderBy)->page($pager)->fetchAll(); - } - - /** - * Get Vm Templaete pairs. - * - * @param string $osCategory - * @param string $osType - * @param string $osVersion - * @access public - * @return array - */ - public function getVmTemplatePairs($osCategory = '', $osType = '', $osVersion = '') - { - return $this->dao->select('id,name')->from(TABLE_VMTEMPLATE) - ->where('osCategory')->eq($osCategory) - ->andwhere('osType')->eq($osType) - ->andwhere('osVersion')->eq($osVersion) - ->fetchPairs(); - } - - /** - * Get VM by id. - * - * @param int $id - * @return object - */ - public function getVMByID($id) - { - return $this->dao->select('t1.*, t3.name as hostName, t2.publicIP as ip,t4.osVersion')->from(TABLE_VM)->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') - ->where('t1.id')->eq($id) - ->fetch(); - } - - /** - * Get VM by mac address. - * - * @param string $mac - * @return object - */ - public function getVMByMac($mac) - { - return $this->dao->select('*')->from(TABLE_VM) - ->where('macAddress')->eq($mac) - ->fetch(); - } - - /** - * Generage unique mac address. - * - * @return void - */ - private function genMacAddress() - { - $buf = array( - 0x1C, - 0x1C, - 0x1C, - mt_rand(0x00, 0x7f), - mt_rand(0x00, 0xff), - mt_rand(0x00, 0xff) - ); - $mac = join(':',array_map(function($v) - { - return sprintf("%02X",$v); - },$buf)); - - $VM = $this->getVMByMac($mac); - if(empty($VM)) - { - return $mac; - } - $this->genMacAddress(); - } - - /** - * Get vnc url. - * - * @param int $vmID - * @access public - * @return void - */ - public function getVncUrl($vmID) - { - $vm = $this->getVMByID($vmID); - if(empty($vm) or empty($vm->hostID) or empty($vm->vncPort)) return false; - - $host = $this->getHostByID($vm->hostID); - if(empty($host)) return false; - - $agnetUrl = 'http://' . $host->publicIP . ':' . $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->agentPort = $host->agentPort; - $returnData->vncPort = $vm->vncPort; - $returnData->token = $result->data->token; - return $returnData; - } -} diff --git a/module/executionnode/view/browse.html.php b/module/executionnode/view/browse.html.php deleted file mode 100755 index 76db50882f..0000000000 --- a/module/executionnode/view/browse.html.php +++ /dev/null @@ -1,105 +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->os->type[$node->osCategory][$node->osType] . ' ' . $lang->executionnode->versionList[$node->osType][$node->osVersion];?> - - - - - - - - - -
idAB);?>executionnode->name);?>executionnode->ip);?>executionnode->cpu);?>executionnode->osMemory);?>executionnode->osDisk);?>executionnode->osCategory);?>executionnode->osType);?>executionnode->osVersion);?>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->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/executionnode/view/view.html.php b/module/executionnode/view/view.html.php deleted file mode 100644 index db464de934..0000000000 --- a/module/executionnode/view/view.html.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @package host - * @version $Id$ - * @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;?>vncPort;?>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/footer.html.php';?> diff --git a/module/group/lang/resource.php b/module/group/lang/resource.php index 3eaebec920..ac4b0996d2 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'; @@ -1236,22 +1236,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 fd89e3a387..79c16a3b7d 100644 --- a/module/upgrade/config.php +++ b/module/upgrade/config.php @@ -396,7 +396,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', 'transfer', '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/config.php b/module/zahost/config.php index 7cda82f889..2b612315c3 100644 --- a/module/zahost/config.php +++ b/module/zahost/config.php @@ -1,44 +1,28 @@ 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,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,cpuCores,memory,diskSize,virtualSoftware,instanceNum'; +$config->zahost->edit->requiredFields = 'name,hostType,cpuCores,memory,diskSize,vsoft'; -$config->zahost->createtemplate = new stdclass(); -$config->zahost->createtemplate->requiredFields = 'name,cpuCoreNum,memorySize,diskSize,osCategory,osType,osVersion,osLang,imageName'; +$config->zahost->imageListUrl = 'https://pkg.qucheng.com/zenagent/list.json'; -$config->zahost->edittemplate = new stdclass(); -$config->zahost->edittemplate->requiredFields = 'name,cpuCoreNum,memorySize,diskSize,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; $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']['extranet'] = $lang->zahost->IP; $config->zahost->search['fields']['cpuCores'] = $lang->zahost->cpuCores; $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']['vsoft'] = $lang->zahost->vsoft; $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; @@ -48,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']['publicIP'] = array('operator' => 'include', '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']['diskSize'] = array('operator' => '=', 'control' => 'input', 'values' => ''); -$config->zahost->search['params']['virtualSoftware'] = array('operator' => 'include', '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'); @@ -61,61 +45,6 @@ $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->vmTemplate = new stdclass(); -$config->vmTemplate->os = new stdClass(); -$config->vmTemplate->os->list = array(); -$config->vmTemplate->os->list['windows'] = 'Windows'; -$config->vmTemplate->os->list['linux'] = 'Linux'; - -$config->vmTemplate->os->cpu = array(); -$config->vmTemplate->os->cpu['1'] = '1'; -$config->vmTemplate->os->cpu['2'] = '2'; -$config->vmTemplate->os->cpu['4'] = '4'; -$config->vmTemplate->os->cpu['6'] = '6'; -$config->vmTemplate->os->cpu['8'] = '8'; -$config->vmTemplate->os->cpu['12'] = '12'; -$config->vmTemplate->os->cpu['16'] = '16'; - -$config->vmTemplate->os->memory = array(); -$config->vmTemplate->os->memory['512'] = '512MB'; -$config->vmTemplate->os->memory['1024'] = '1GB'; -$config->vmTemplate->os->memory['2048'] = '2GB'; -$config->vmTemplate->os->memory['4096'] = '4GB'; -$config->vmTemplate->os->memory['9120'] = '8GB'; -$config->vmTemplate->os->memory['16384'] = '16GB'; - -$config->vmTemplate->os->disk = array(); -$config->vmTemplate->os->disk['10240'] = '10GB'; -$config->vmTemplate->os->disk['20480'] = '20GB'; -$config->vmTemplate->os->disk['40960'] = '40GB'; -$config->vmTemplate->os->disk['61440'] = '60GB'; -$config->vmTemplate->os->disk['81920'] = '80GB'; -$config->vmTemplate->os->disk['102400'] = '100GB'; -$config->vmTemplate->os->disk['204800'] = '200GB'; -$config->vmTemplate->os->disk['307200'] = '300GB'; - -$config->vmTemplate->os->type = array(); -$config->vmTemplate->os->type['windows']['winServer'] = 'Windows Server'; -$config->vmTemplate->os->type['windows']['win11'] = 'Windows 11'; -$config->vmTemplate->os->type['windows']['win10'] = 'Windows 10'; -$config->vmTemplate->os->type['windows']['win7'] = 'Windows 7'; -$config->vmTemplate->os->type['windows']['winxp'] = 'Windows XP'; -$config->vmTemplate->os->type['linux']['ubuntu'] = 'Ubuntu'; -$config->vmTemplate->os->type['linux']['centos'] = 'CentOS'; -$config->vmTemplate->os->type['linux']['debian'] = 'Debian'; - -$config->vmTemplate->search['module'] = 'vmTemplate'; -$config->vmTemplate->search['fields']['id'] = $lang->zahost->id; -$config->vmTemplate->search['fields']['name'] = $lang->zahost->name; -$config->vmTemplate->search['fields']['cpuCoreNum'] = $lang->zahost->cpuCores; -$config->vmTemplate->search['fields']['memorySize'] = $lang->zahost->memory; -$config->vmTemplate->search['fields']['diskSize'] = $lang->zahost->diskSize; -$config->vmTemplate->search['fields']['osType'] = $lang->zahost->vmTemplate->osType; -$config->vmTemplate->search['fields']['osVersion'] = $lang->zahost->vmTemplate->osVersion; - -$config->vmTemplate->search['params']['id'] = array('operator' => '=', 'control' => 'input', 'values' => ''); -$config->vmTemplate->search['params']['name'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); -$config->vmTemplate->search['params']['memorySize'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $config->vmTemplate->os->memory); -$config->vmTemplate->search['params']['diskSize'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $config->vmTemplate->os->disk); -$config->vmTemplate->search['params']['osType'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $config->vmTemplate->os->type['windows'] + $config->vmTemplate->os->type['linux']); -$config->vmTemplate->search['params']['cpuCoreNum'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $config->vmTemplate->os->cpu); +$config->zahost->editor = new stdclass(); +$config->zahost->editor->create = array('id' => 'desc', 'tools' => 'simpleTools'); +$config->zahost->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools'); diff --git a/module/zahost/control.php b/module/zahost/control.php index def6586261..403245c53c 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 @@ -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; @@ -52,6 +52,27 @@ 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("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(); + } + /** * Create host. * @@ -62,13 +83,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; @@ -89,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')); @@ -120,7 +141,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. */ @@ -143,18 +164,50 @@ 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)); + $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 createTemplate($hostID) + public function createImage($hostID) { $host = $this->zahost->getById($hostID); if($_POST) { - $this->zahost->createTemplate($host); + $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}"))); @@ -166,132 +219,48 @@ class zahost extends control } /** - * Edit template + * Sent download image request to Host. * - * @param int $templateID + * @param int $hostID + * @param string $imageName * @access public - * @return void + * @return object */ - public function editTemplate($templateID) + public function ajaxDownloadImage($hostID, $imageName) { - $template = $this->zahost->getTemplateById($templateID); - if($_POST) + $image = $this->zahost->getImageByNameAndHostID($imageName, $hostID); + if(empty($image)) { - $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}"))); + $image = $this->zahost->createImage($hostID, $imageName); } - $this->view->title = $this->lang->zahost->edit; - $this->view->template = $template; - $this->view->imageOptions = array('' => $this->lang->zahost->notice->loading); - $this->display(); + $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->downloadImageSuccess)); } /** - * Delete host. + * Query downloading progress of images of host. * - * @param int $templateID - * @param string $confirm + * @param int $hostID * @access public * @return void */ - public function deleteTemplate($templateID, $confirm = 'no') + public function ajaxImageDownloadProgress($hostID) { - if($confirm == 'no') + $statusList = array(); + + $imageList = $this->zahost->getImageList($hostID); + foreach($imageList as $image) { - return print(js::confirm($this->lang->zahost->confirmDeleteVMTemplate, inlink('deleteTemplate', "templateID=$templateID&confirm=yes"))); + $image = $this->zahost->queryDownloadImageStatus($image); + $statusName = zget($this->lang->zahost->image->statusList, $image->status,''); + + $statusList[$image->id] = array('statusCode' => $image->status, 'status' => $statusName, 'progress' => $image->status == 'inprogress' ? $image->rate * 100 . '%' : ''); } - $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. - * - * @param string $IP - * @access public - * @return void - */ - public function ajaxCheckPublicIP($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))))); - - $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))); + return $this->send(array('result' => 'success', 'message' => '', 'data' => $statusList)); } /** @@ -302,13 +271,43 @@ 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)))); } + + /* + * Init host. + * + * @param int $hostID + * @return void + */ + public function initHost($hostID) + { + $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(); + } + + /** + * 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/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/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/css/create.css b/module/zahost/css/create.css index 662cc09295..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;} +#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{text-align: center;width: 63px;} \ No newline at end of file diff --git a/module/zahost/css/edit.css b/module/zahost/css/edit.css index 5c73ea1c78..c4a1a000f2 100644 --- a/module/zahost/css/edit.css +++ b/module/zahost/css/edit.css @@ -1,4 +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;width: 63px;} \ 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..adb9649d82 --- /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: 20px; +} +.host-action{ + margin-top: 60px; +} +.host-action .btn{ + margin-left: 20px; + min-width: 100px; +} 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/js/browseimage.js b/module/zahost/js/browseimage.js new file mode 100644 index 0000000000..b44d1f8fdb --- /dev/null +++ b/module/zahost/js/browseimage.js @@ -0,0 +1,35 @@ +$(function() +{ + updateProgress(); +}); + +function updateProgress(){ + var interval = setInterval(function() + { + $.get(createLink('zahost', 'ajaxImageDownloadProgress', 'hostID=' + hostID)).done(function(response) + { + var result = JSON.parse(response); + 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-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); + } + } + if(!hasInprogress){ + clearInterval(interval) + } + }); + }, 3000); +} \ No newline at end of file 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/js/create.js b/module/zahost/js/create.js index 31f671a597..283ee28487 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()); + // $('#address').on('blur', function() + // { + // var url = createLink('zahost', 'ajaxCheckaddress', "IP=" + $('#address').val()); - $.get(url, function(response) - { - $('#publicIPLabel').remove(); - $('#publicIP').removeClass('has-error'); - $('#registerCommand').remove(); - $('#Secret').remove(); + // $.get(url, function(response) + // { + // $('#addressLabel').remove(); + // $('#address').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(""); + // $('#address').after("
" + resultData.data.registerCommand + "
"); + // return; + // } - $('#publicIP').addClass('has-error'); + // $('#address').addClass('has-error'); - if(resultData.message.publicIP) - { - var errors = resultData.message.publicIP.join(''); - $('#publicIP').after("
" + errors + "
"); - } - }); - }); + // if(resultData.message.address) + // { + // var errors = resultData.message.address.join(''); + // $('#address').after("
" + errors + "
"); + // } + // }); + // }); }); diff --git a/module/zahost/js/inithost.js b/module/zahost/js/inithost.js new file mode 100644 index 0000000000..5b4ca1d12d --- /dev/null +++ b/module/zahost/js/inithost.js @@ -0,0 +1,29 @@ +$('#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 + '

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

' + zahostLang.initHost.initFailNoticeTitle + '

'; + html += '
' + zahostLang.initHost.initFailNoticeDesc + 'https://github.com/easysoft/zenagent/
' + $('#jumpToImageList').attr('disabled', 'disabled') + } + $('#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..b1ba868eaa 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -4,24 +4,23 @@ $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'; $lang->zahost->deleteAction = 'Delete Host'; $lang->zahost->byQuery = 'Search'; $lang->zahost->all = 'All'; -$lang->zahost->browseTemplate = 'Template Browse'; -$lang->zahost->createTemplate = 'Create Template'; -$lang->zahost->editTemplate = 'Edit Template'; -$lang->zahost->deleteTemplate = 'Delete Template'; +$lang->zahost->browseNode = 'ZAnode Browse'; +$lang->zahost->deleted = "Deleted"; $lang->zahost->name = 'Name'; -$lang->zahost->IP = 'IP'; -$lang->zahost->publicIP = 'IP'; +$lang->zahost->IP = 'Extranet Address'; +$lang->zahost->extranet = 'Extranet Address'; $lang->zahost->cpuCores = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; -$lang->zahost->diskSize = 'Disk Size'; -$lang->zahost->instanceNum = 'Instance Number'; +$lang->zahost->diskSize = 'diskSize Size'; +$lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -34,35 +33,63 @@ $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->os = 'System'; $lang->zahost->osVersion = 'Os Version No'; $lang->zahost->osLang = 'Language'; $lang->zahost->imageName = 'Image File'; -$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->diskSize = $lang->zahost->diskSize; -$lang->zahost->vmTemplate->osType = $lang->zahost->osType; -$lang->zahost->vmTemplate->osCategory = $lang->zahost->osCategory; -$lang->zahost->vmTemplate->osVersion = $lang->zahost->osVersion; -$lang->zahost->vmTemplate->osLang = $lang->zahost->osLang; -$lang->zahost->vmTemplate->imageName = $lang->zahost->imageName; +$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->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->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->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->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->diskSize; +$lang->zahost->image->os = $lang->zahost->os; +$lang->zahost->image->imageName = $lang->zahost->imageName; +$lang->zahost->image->progress = 'Progress'; + +$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'; -$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'; @@ -72,35 +99,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 b34bfae7a7..ee173c8c9b 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -4,24 +4,23 @@ $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'; $lang->zahost->deleteAction = 'Delete Host'; $lang->zahost->byQuery = 'Search'; $lang->zahost->all = 'All'; -$lang->zahost->browseTemplate = 'Template Browse'; -$lang->zahost->createTemplate = 'Create Template'; -$lang->zahost->editTemplate = 'Edit Template'; -$lang->zahost->deleteTemplate = 'Delete Template'; +$lang->zahost->browseNode = 'ZAnode Browse'; +$lang->zahost->deleted = "Deleted"; $lang->zahost->name = 'Name'; -$lang->zahost->IP = 'IP'; -$lang->zahost->publicIP = 'IP'; +$lang->zahost->IP = 'Extranet Address'; +$lang->zahost->extranet = 'Extranet Address'; $lang->zahost->cpuCores = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; -$lang->zahost->diskSize = 'Disk Size'; -$lang->zahost->instanceNum = 'Instance Number'; +$lang->zahost->diskSize = 'diskSize Size'; +$lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -34,22 +33,56 @@ $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->os = 'System'; $lang->zahost->osVersion = 'Os Version No'; $lang->zahost->osLang = 'Language'; $lang->zahost->imageName = 'Image File'; -$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->diskSize = $lang->zahost->diskSize; -$lang->zahost->vmTemplate->osType = $lang->zahost->osType; -$lang->zahost->vmTemplate->osCategory = $lang->zahost->osCategory; -$lang->zahost->vmTemplate->osVersion = $lang->zahost->osVersion; -$lang->zahost->vmTemplate->osLang = $lang->zahost->osLang; -$lang->zahost->vmTemplate->imageName = $lang->zahost->imageName; +$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->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 = [ + "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->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->diskSize; +$lang->zahost->image->os = $lang->zahost->os; +$lang->zahost->image->imageName = $lang->zahost->imageName; +$lang->zahost->image->progress = 'Progress'; + +$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'; @@ -57,12 +90,11 @@ $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'; -$lang->zahost->virtualSoftware = 'VM Software'; +$lang->zahost->vsoft = 'VM Software'; $lang->zahost->softwareList['kvm'] = 'KVM'; $lang->zahost->unitList['GB'] = 'GB'; @@ -72,35 +104,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/fr.php b/module/zahost/lang/fr.php index a3be1a830d..e282e447af 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -4,24 +4,22 @@ $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'; $lang->zahost->deleteAction = 'Supprimer Hôte'; $lang->zahost->byQuery = 'Recherche'; $lang->zahost->all = 'Tous les hôtes'; -$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 = 'Nom'; -$lang->zahost->IP = 'IP'; -$lang->zahost->publicIP = 'IP'; -$lang->zahost->cpuCores = 'CPU Cores'; +$lang->zahost->IP = 'IP/Domain'; +$lang->zahost->extranet = 'IP'; +$lang->zahost->cpuCore = 'CPU Cores'; $lang->zahost->memory = 'Mémoire Espace'; $lang->zahost->diskSize = 'Disque Espace'; -$lang->zahost->instanceNum = 'Max instances'; +$lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -33,36 +31,63 @@ $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->osLang = 'Language'; +$lang->zahost->os = 'System'; $lang->zahost->imageName = 'Image File'; -$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->memorySize = $lang->zahost->memory; -$lang->zahost->vmTemplate->diskSize = $lang->zahost->diskSize; -$lang->zahost->vmTemplate->osType = $lang->zahost->osType; -$lang->zahost->vmTemplate->osCategory = $lang->zahost->osCategory; -$lang->zahost->vmTemplate->osVersion = $lang->zahost->osVersion; -$lang->zahost->vmTemplate->osLang = $lang->zahost->osLang; -$lang->zahost->vmTemplate->imageName = $lang->zahost->imageName; +$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->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->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->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->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->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; +$lang->zahost->image->progress = 'Progress'; + +$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'; -$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'; @@ -72,35 +97,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 0f06360118..b1ba868eaa 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -4,24 +4,23 @@ $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'; $lang->zahost->deleteAction = 'Delete Host'; $lang->zahost->byQuery = 'Search'; $lang->zahost->all = 'All'; -$lang->zahost->browseTemplate = 'Template Browse'; -$lang->zahost->createTemplate = 'Create Template'; -$lang->zahost->editTemplate = 'Edit Template'; -$lang->zahost->deleteTemplate = 'Delete Template'; +$lang->zahost->browseNode = 'ZAnode Browse'; +$lang->zahost->deleted = "Deleted"; $lang->zahost->name = 'Name'; -$lang->zahost->IP = 'IP'; -$lang->zahost->publicIP = 'IP'; +$lang->zahost->IP = 'Extranet Address'; +$lang->zahost->extranet = 'Extranet Address'; $lang->zahost->cpuCores = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; -$lang->zahost->diskSize = 'Disk Size'; -$lang->zahost->instanceNum = 'Instance Number'; +$lang->zahost->diskSize = 'diskSize Size'; +$lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; @@ -34,35 +33,63 @@ $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->os = 'System'; $lang->zahost->osVersion = 'Os Version No'; $lang->zahost->osLang = 'Language'; $lang->zahost->imageName = 'Image File'; -$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->diskSize = $lang->zahost->diskSize; -$lang->zahost->vmTemplate->osType = $lang->zahost->osType; -$lang->zahost->vmTemplate->osCategory = $lang->zahost->osCategory; -$lang->zahost->vmTemplate->osVersion = $lang->zahost->osVersion; -$lang->zahost->vmTemplate->osLang = $lang->zahost->osLang; -$lang->zahost->vmTemplate->imageName = $lang->zahost->imageName; +$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->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 = [ + "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->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->diskSize; +$lang->zahost->image->os = $lang->zahost->os; +$lang->zahost->image->imageName = $lang->zahost->imageName; +$lang->zahost->image->progress = 'Progress'; + +$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'; -$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'; -$lang->zahost->virtualSoftware = 'VM Software'; +$lang->zahost->vsoft = 'VM Software'; $lang->zahost->softwareList['kvm'] = 'KVM'; $lang->zahost->unitList['GB'] = 'GB'; @@ -72,35 +99,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 a0c0e9110d..07608caf5e 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -1,27 +1,27 @@ 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->init = '初始化宿主机'; $lang->zahost->edit = '编辑'; $lang->zahost->editAction = '编辑宿主机'; $lang->zahost->delete = '删除'; $lang->zahost->deleteAction = '删除宿主机'; $lang->zahost->byQuery = '搜索'; $lang->zahost->all = '全部主机'; -$lang->zahost->browseTemplate = '虚拟机模板列表'; -$lang->zahost->createTemplate = '创建虚拟机模板'; -$lang->zahost->editTemplate = '编辑虚拟机模板'; -$lang->zahost->deleteTemplate = '删除虚拟机模板'; +$lang->zahost->browseNode = '执行节点列表'; +$lang->zahost->deleted = "已删除"; $lang->zahost->name = '名称'; -$lang->zahost->IP = 'IP'; -$lang->zahost->publicIP = 'IP'; +$lang->zahost->IP = 'IP/域名'; +$lang->zahost->extranet = 'IP/域名'; $lang->zahost->memory = '内存'; $lang->zahost->cpuCores = 'CPU核心数'; $lang->zahost->diskSize = '硬盘容量'; -$lang->zahost->instanceNum = '最大实例数'; +$lang->zahost->desc = '描述'; $lang->zahost->type = '类型'; $lang->zahost->status = '状态'; @@ -33,36 +33,64 @@ $lang->zahost->registerDate = '最后注册时间'; $lang->zahost->memorySize = $lang->zahost->memory; $lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; -$lang->zahost->osType = '操作系统版本'; -$lang->zahost->osCategory = '操作系统平台'; -$lang->zahost->osVersion = '操作系统版本号'; -$lang->zahost->osLang = '系统语言'; +$lang->zahost->os = '操作系统平台'; $lang->zahost->imageName = '镜像文件'; -$lang->zahost->vmTemplate = new stdclass; -$lang->zahost->vmTemplate->name = '名称'; -$lang->zahost->vmTemplate->common = '虚拟机模板'; -$lang->zahost->vmTemplate->cpuCoreNum = $lang->zahost->cpuCores; -$lang->zahost->vmTemplate->memorySize = $lang->zahost->memory; -$lang->zahost->vmTemplate->diskSize = $lang->zahost->diskSize; -$lang->zahost->vmTemplate->osType = $lang->zahost->osType; -$lang->zahost->vmTemplate->osCategory = $lang->zahost->osCategory; -$lang->zahost->vmTemplate->osVersion = $lang->zahost->osVersion; -$lang->zahost->vmTemplate->osLang = $lang->zahost->osLang; -$lang->zahost->vmTemplate->imageName = $lang->zahost->imageName; +$lang->zahost->initHost = new stdclass; +$lang->zahost->initHost->statusTitle = "服务状态"; +$lang->zahost->initHost->checkStatus = "检测服务状态"; +$lang->zahost->initHost->not_install = "未安装"; +$lang->zahost->initHost->not_available = "已安装,未启动"; +$lang->zahost->initHost->ready = "已就绪"; +$lang->zahost->initHost->next = "下一步"; -$lang->zahost->langList = array(); -$lang->zahost->langList['zh_cn'] = '简体中文'; -$lang->zahost->langList['zh_tw'] = '繁体中文'; -$lang->zahost->langList['en_us'] = '美式英语'; +$lang->zahost->initHost->initSuccessNotice = "初始化成功,请点击下一步完成后续操作。"; +$lang->zahost->initHost->initFailNoticeTitle = "初始化失败,请查看初始化脚本执行日志并尝试以下两种解决方案:"; +$lang->zahost->initHost->initFailNoticeDesc = "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->initDesc = "在宿主机上执行:bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; -$lang->zahost->empty = '暂时没有主机'; -$lang->zahost->templateEmpty = '暂时没有模板'; +$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->common = '镜像'; +$lang->zahost->image->name = '名称'; +$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['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 = '创建下载镜像任务失败'; +$lang->zahost->image->downloadImageSuccess = '创建下载镜像任务成功'; + + +$lang->zahost->empty = '暂时没有宿主机'; $lang->zahost->statusList['ready'] = '准备中'; $lang->zahost->statusList['online'] = '已上架'; -$lang->zahost->virtualSoftware = '虚拟化软件'; +$lang->zahost->vsoft = '虚拟化软件'; $lang->zahost->softwareList['kvm'] = 'KVM'; $lang->zahost->unitList['GB'] = 'GB'; @@ -72,35 +100,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 08f956f26e..134d22cdf8 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; } /** @@ -36,40 +35,26 @@ class zahostModel extends model ->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(); + $hostInfo->secret = md5($hostInfo->name + time()); + $this->dao->update(TABLE_ZAHOST)->data($hostInfo) ->batchCheck($this->config->zahost->create->requiredFields, 'notempty') - ->batchCheck('cpuCores,diskSize,instanceNum', 'gt', 0) + ->batchCheck('cpuCores,diskSize', 'gt', 0) ->batchCheck('diskSize,memory', 'float') + ->check('name', 'unique') ->autoCheck(); if(dao::isError()) return false; - if(!preg_match('/((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/', $hostInfo->publicIP)) - { - dao::$errors['publicIP'][] = sprintf($this->lang->zahost->notice->ip, $this->lang->zahost->publicIP); - return false; - } - - $this->dao->update(TABLE_ASSET)->data($hostInfo)->check('name', 'unique'); - if(dao::isError()) return false; - - $assetInfo['name'] = $hostInfo->name; - $assetInfo['type'] = 'zahost'; - $assetInfo['status'] = 'normal'; - $assetInfo['createdBy'] = $this->app->user->account; - $assetInfo['createdDate'] = helper::now(); - - $this->dao->insert(TABLE_ASSET)->data($assetInfo)->autoCheck()->exec(); - if(dao::isError()) return false; - - $hostInfo->assetID = $this->dao->lastInsertID(); - - $this->dao->insert(TABLE_ZAHOST)->data($hostInfo, $skipFields='name')->autoCheck()->exec(); + $this->dao->insert(TABLE_ZAHOST)->data($hostInfo)->autoCheck()->exec(); $hostID = $this->dao->lastInsertID(); if(!dao::isError()) { $this->loadModel('action')->create('zahost', $hostID, 'created'); - return true; + return $hostID; } return false; @@ -84,126 +69,212 @@ 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('diskSize,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(); - if(dao::isError()) return false; - $this->dao->update(TABLE_ZAHOST)->data($hostInfo, 'name')->autoCheck() - ->batchCheck('cpuCores,diskSize,instanceNum', 'gt', 0) + ->batchCheck('cpuCores,diskSize', 'gt', 0) ->batchCheck('diskSize,memory', 'float') ->where('id')->eq($hostID)->exec(); return common::createChanges($oldHost, $hostInfo); } /** - * Create vm template. + * Get image by ID. * - * @param object $host + * @param int $imageID * @access public - * @return void + * @return object */ - public function createTemplate($host) + public function getImageByID($imageID) { - $template = fixer::input('post') - ->setIF($this->post->diskSize > 0, 'diskSize', $this->post->diskSize * 1024) - ->setDefault('imageName', '') - ->get(); - - $this->dao->insert(TABLE_VMTEMPLATE)->data($template) - ->batchCheck($this->config->zahost->createtemplate->requiredFields, 'notempty') - ->batchCheck('cpuCoreNum,diskSize,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'); + return $this->dao->select('*')->from(TABLE_IMAGE)->where('id')->eq($imageID)->fetch(); } /** - * Edit template + * Get image by name. * - * @param int $templateID + * @param string $imageName + * @param int $hostID * @access public - * @return bool|object + * @return object */ - public function updateTemplate($templateID) + public function getImageByNameAndHostID($imageName, $hostID) { - $oldHost = $this->getTemplateById($templateID); - $templateInfo = fixer::input('post') - ->setIF($this->post->diskSize > 0, 'diskSize', $this->post->diskSize * 1024) - ->get(); - - $this->dao->update(TABLE_VMTEMPLATE)->data($templateInfo) - ->batchCheck($this->config->zahost->edittemplate->requiredFields, 'notempty') - ->batchCheck('cpuCoreNum,diskSize,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); + return $this->dao->select('*')->from(TABLE_IMAGE) + ->where('host')->eq($hostID) + ->andWhere('name')->eq($imageName)->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) + $imageList = json_decode(file_get_contents($this->config->zahost->imageListUrl)); + + $downloadedImageList = $this->dao->select('*')->from(TABLE_IMAGE) + ->where('host')->eq($hostID) + ->orderBy($orderBy) + ->page($pager) + ->fetchAll('name'); + + foreach($imageList as &$image) { - $result = new stdclass; - $result->data = array(); + $downloadedImage = zget($downloadedImageList, $image->name, ''); + if(empty($downloadedImage)) + { + $image->id = 0; + $image->status = 'notDownloaded'; + } + else + { + $image->id = $downloadedImage->id; + $image->status = $downloadedImage->status; + } + + $image->host = $hostID; } - $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); - return $imageList; } + /** + * create image. + * + * @param int $hostID + * @param string $imageName + * @access public + * @return object + */ + public function createImage($hostID, $imageName) + { + $imageList = json_decode(file_get_contents($this->config->zahost->imageListUrl)); + + $imageData = new stdclass; + foreach($imageList as $item) if($item->name == $imageName) $imageData = $item; + + $imageData->host = $hostID; + $imageData->status = 'created'; + $imageData->osName = $imageData->os; + unset($imageData->os); + + $this->dao->insert(TABLE_IMAGE)->data($imageData, 'desc')->autoCheck()->exec(); + if(dao::isError()) return false; + + $imageID = $this->dao->lastInsertID(); + $this->loadModel('action')->create('image', $imageID, 'Created'); + + return $this->getImageByID($imageID); + } + + /** + * Send download image command to HOST. + * + * @param object $image + * @access public + * @return bool + */ + public function downloadImage($image) + { + $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; + $apiParams['task'] = intval($image->id); + + $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->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; + + foreach($result->data as $status => $group) + { + $currentTask = null; + foreach($group as $host) + { + if($host->task == $image->id ) + { + $currentTask = $host; + break; + } + } + + if($currentTask) + { + $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; + } + + /** + * Query download image status. + * + * @param object $image + * @access public + * @return object + */ + public function downloadImageStatus($image) + { + $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')); + + a($response); + if($response->code == 200) return true; + + dao::$errors[] = $response->msg; + return false; + + } + /** * Get host by id. * @@ -213,9 +284,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(); } @@ -226,12 +296,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'); } @@ -246,7 +315,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') @@ -270,15 +339,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) @@ -286,82 +351,67 @@ class zahostModel extends model } /** - * Get VM template list. + * Build test task menu. * - * @param int $hostID - * @param string $browseType - * @param int $param - * @param string $orderBy - * @param int $pager + * @param object $host + * @param string $type * @access public - * @return array + * @return string */ - public function getVmTemplateList($hostID, $browseType = 'all', $param = 0, $orderBy = 'id_desc', $pager = null) + public function buildOperateMenu($host, $type = 'view') { - $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->diskSize > 1024) - { - $template->diskSize = round($template->diskSize / 1024); - $template->unit = zget($this->lang->zahost->unitList, 'GB'); - } - } - return $templateList; + $function = 'buildOperate' . ucfirst($type) . 'Menu'; + return $this->$function($host); } /** - * Get template pairs by 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->id"; + + $menu .= $this->buildMenu('zahost', 'edit', $params, $host, 'view'); + $menu .= $this->buildMenu('zahost', 'delete', $params, $host, 'view', 'trash', 'hiddenwin'); + + return $menu; + } + + /** + * Get image pairs by host. * * @param int $hostID * @access public * @return array */ - public function getTemplatePairs($hostID) + public function getImagePairs($hostID) { - return $this->dao->select('id,name')->from(TABLE_VMTEMPLATE)->where('hostID')->eq($hostID)->fetchPairs(); + return $this->dao->select('id,name')->from(TABLE_IMAGE)->where('host')->eq($hostID)->andWhere('status')->eq('completed')->fetchPairs(); } /** - * Get template by id. + * Get service status from ZAgent server. * - * @param int $templateID + * @param object $host * @access public - * @return object + * @return array */ - public function getTemplateByID($templateID) + public function getServiceStatus($host) { - return $this->dao->select('*')->from(TABLE_VMTEMPLATE)->where('id')->eq($templateID)->fetch(); + $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; + $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..ec88016f08 100644 --- a/module/zahost/view/browse.html.php +++ b/module/zahost/view/browse.html.php @@ -42,16 +42,15 @@ recTotal}&recPerPage={$pager->recPerPage}";?> - idAB);?> + idAB);?> zahost->name);?> - zahost->type);?> - zahost->IP);?> - zahost->cpuCores);?> + zahost->type);?> + zahost->extranet);?> + zahost->cpuCores);?> zahost->memory);?> - zahost->diskSize);?> - zahost->virtualSoftware);?> + zahost->diskSize);?> + zahost->vsoft);?> zahost->status);?> - zahost->instanceNum);?> zahost->registerDate);?> actions;?> @@ -60,16 +59,15 @@ hostID);?> - inlink('browsetemplate', "id=$host->hostID"), $host->name) : $host->name;?> + inlink('view', "id=$host->hostID"), $host->name, '', "");?> zahost->zaHostTypeList, $host->hostType);?> - publicIP;?> + extranet;?> cpuCores;?> memory . $lang->zahost->unitList['GB'];?> - diskSize . zget($lang->zahost->unitList, $host->unit);?> - virtualSoftware;?> + diskSize . $lang->zahost->unitList['GB'];?> + vsoft;?> host->statusList, $host->status);?> - instanceNum;?> - 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/browseimage.html.php b/module/zahost/view/browseimage.html.php new file mode 100755 index 0000000000..f3a6c12fc8 --- /dev/null +++ b/module/zahost/view/browseimage.html.php @@ -0,0 +1,66 @@ + + * @package zahost + * @version $Id$ + * @link http://www.zentao.net + */ +?> + + + +
' data-module='vmTemplate'>
+
+ recTotal}&recPerPage={$pager->recPerPage}";?> + +
+

+ zahost->image->imageEmpty;?> +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
zahost->image->name);?>zahost->image->desc;?>zahost->image->memory);?>zahost->image->disk);?>zahost->status;?>zahost->image->progress;?>actions;?>
name;?>desc;?>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', '', 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'");?> +
+ + +
+getModuleRoot() . 'common/view/footer.html.php';?> diff --git a/module/zahost/view/browsetemplate.html.php b/module/zahost/view/browsetemplate.html.php deleted file mode 100755 index e9a7fb7d47..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->diskSize);?>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 861a17515a..5bcb7c257a 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 @@
+ + + + @@ -29,19 +34,19 @@ - - + + - + @@ -51,18 +56,15 @@
- zahost->unitList, 'GB', "class='form-control chosen w-50px'");?> + zahost->unitList['GB'];?>
- - - - - - + + +
zahost->vsoft;?>zahost->softwareList, '', "class='form-control chosen'");?>
zahost->zaHostType;?> zahost->zaHostTypeList, 'virtual', "class='form-control chosen'");?>
zahost->IP;?>zahost->extranet;?>
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/createtemplate.html.php b/module/zahost/view/createimage.html.php similarity index 64% rename from module/zahost/view/createtemplate.html.php rename to module/zahost/view/createimage.html.php index 5148a42785..ded6cb2492 100644 --- a/module/zahost/view/createtemplate.html.php +++ b/module/zahost/view/createimage.html.php @@ -1,6 +1,6 @@ hostID);?>
-

zahost->createTemplate;?>

+

zahost->image->createImage;?>

- + - - - + + - - + + + + + + + - + - + - + - + - + - - - -
zahost->name;?>zahost->common;?>name;?>
zahost->cpuCores;?>zahost->image->choseImage;?>
zahost->name;?>
zahost->memory;?>
- + MB
zahost->diskSize;?>zahost->disk;?>
- + GB
zahost->vmTemplate->osCategory;?>zahost->image->osCategory;?> zahost->os->list, '', "class='form-control chosen'")?>
zahost->vmTemplate->osType;?>zahost->image->osType;?>
zahost->vmTemplate->osVersion;?>zahost->image->osVersion;?>
zahost->vmTemplate->osLang;?>zahost->image->osLang;?> zahost->langList, '', "class='form-control chosen'")?>
zahost->vmTemplate->imageName;?>
- + id);?>
diff --git a/module/zahost/view/edit.html.php b/module/zahost/view/edit.html.php index b73712b481..a1879cffa9 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 @@
+ + + + @@ -30,18 +35,18 @@ - + - + @@ -51,18 +56,15 @@
diskSize, "class='form-control'");?> - zahost->unitList, $host->unit, "class='form-control chosen w-50px'");?> + zahost->unitList['GB'];?>
- - - - - - + + +
zahost->vsoft;?>zahost->softwareList, $host->vsoft, "class='form-control chosen'");?>
zahost->zaHostType;?> zahost->zaHostTypeList, $host->hostType, "class='form-control chosen'");?>
zahost->IP;?>publicIP, "class='form-control' disabled");?>extranet, "class='form-control' disabled");?>
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/edittemplate.html.php b/module/zahost/view/edittemplate.html.php deleted file mode 100644 index e7faa05750..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->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';?> diff --git a/module/zahost/view/inithost.html.php b/module/zahost/view/inithost.html.php new file mode 100644 index 0000000000..21070cf6c7 --- /dev/null +++ b/module/zahost/view/inithost.html.php @@ -0,0 +1,38 @@ + + * @package automation + * @version $Id$ + * @link http://www.zentao.net + */ +?> + + +zahost); ?> + +
+
+
+
+

zahost->initHost->title; ?>

+
+
+

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'"); ?> +
+
+
+ \ No newline at end of file diff --git a/module/zahost/view/view.html.php b/module/zahost/view/view.html.php new file mode 100644 index 0000000000..47d2887808 --- /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 + */ +?> +getModuleRoot() . 'common/view/header.html.php';?> +getModuleRoot() . 'common/view/kindeditor.html.php'; ?> +session->zahostList ? $this->session->zahostList : $this->createLink('zahost', 'browse', "");?> +hostID}&orderBy=%s";?> + +
+
+
+
+
zahost->view;?>
+
+
+
+
+
zahost->zaHostType;?>:
+
zahost->zaHostTypeList[$zahost->hostType];?>
+
+
+
+
+
zahost->extranet;?>:
+
extranet;?>
+
+
+
+
+
zahost->memory;?>:
+
memory;?>
+
+
+
+
+
+
+
zahost->vsoft;?>:
+
vsoft;?>
+
+
+
+
+
zahost->cpuCores;?>:
+
cpuCores;?>
+
+
+
+
+
zahost->diskSize;?>:
+
diskSize;?>
+
+
+
+
+
+
+
zahost->desc;?>
+
desc) ? $zahost->desc : $lang->noData;?>
+
+ +
+
zahost->browseNode;?>
+
+ + + + + + + + + + + + + + + + + + + + + + + +
zahost->name);?>zanode->cpuCores);?>zanode->memory);?>zanode->diskSize);?>zanode->osName);?>zanode->status);?>
name;?>zanode->os->cpuCores, $node->cpuCores);?>memory . $this->lang->zahost->unitList['GB'];?>diskSize . $this->lang->zahost->unitList['GB'];?>osName;?>zanode->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');?> +
+
+
+
+
+
+
+ +
+ +
+ diff --git a/module/zanode/config.php b/module/zanode/config.php new file mode 100644 index 0000000000..8005b689a2 --- /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,osName'; +$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']['extranet'] = $lang->zanode->extranet; +$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 50% rename from module/executionnode/control.php rename to module/zanode/control.php index 9f117bd1c7..66d8530cd4 --- 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 { /** @@ -24,7 +24,7 @@ class executionnode extends control * @access public * @return void */ - public function browse($browseType = 'all', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function browse($browseType = 'all', $param = 0, $orderBy = 't1.id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { $browseType = strtolower($browseType); @@ -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']['host']['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; @@ -58,7 +58,7 @@ class executionnode extends control /** * Create node page. * - * @param int $templateID + * @param int $imageID * @access public * @return void */ @@ -66,19 +66,50 @@ 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(); } /** - * View VM. + * 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. * * @param int $id * @access public @@ -86,16 +117,15 @@ 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->zanode = $this->zanode->getNodeByID($id); + $this->view->actions = $this->loadModel('action')->getList('zanode', $id); $this->view->users = $this->loadModel('user')->getPairs('noletter'); - $this->display(); } /** - * Suspend VM. + * Suspend Node. * * @param int $nodeID * @access public @@ -103,11 +133,11 @@ class executionnode extends control */ public function suspend($nodeID) { - $this->handleVM($nodeID, 'suspend'); + $this->handleNode($nodeID, 'suspend'); } /** - * Reboot VM. + * Reboot Node. * * @param int $nodeID * @access public @@ -115,11 +145,11 @@ class executionnode extends control */ public function reboot($nodeID) { - $this->handleVM($nodeID, 'reboot'); + $this->handleNode($nodeID, 'reboot'); } /** - * Resume VM. + * Resume Node. * * @param int $nodeID * @access public @@ -127,7 +157,7 @@ class executionnode extends control */ public function resume($nodeID) { - $this->handleVM($nodeID, 'resume'); + $this->handleNode($nodeID, 'resume'); } /** @@ -137,9 +167,9 @@ class executionnode extends control * @param string $type * @return void */ - public function handleVM($nodeID, $type) + public function handleNode($nodeID, $type) { - $error = $this->executionnode->handleVM($nodeID, $type); + $error = $this->zanode->handleNode($nodeID, $type); if($error) { @@ -147,7 +177,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')); } } @@ -157,19 +187,26 @@ class executionnode extends control * @param int $nodeID * @return void */ - public function destroy($nodeID) + public function delete($nodeID, $confirm = 'no') { - $error = $this->executionnode->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->executionnode->actionSuccess) . js::reload('parent.parent')); - return print(js::alert($this->lang->executionnode->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')); + } + } } /** @@ -179,29 +216,23 @@ 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('image', $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); - 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 = $this->loadModel('zahost')->getImageByID($imageID); return print(json_encode($template)); } } 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/zanode/css/create.css b/module/zanode/css/create.css new file mode 100644 index 0000000000..f5c8086763 --- /dev/null +++ b/module/zanode/css/create.css @@ -0,0 +1,3 @@ +#unit {padding: 0px !important; width:0px; border-left: 0px;width:63px;} +.input-group-addon {border: 0px; width: 100px;} +#memory-addon {width:63px;} diff --git a/module/zanode/css/view.css b/module/zanode/css/view.css new file mode 100644 index 0000000000..dba5746e72 --- /dev/null +++ b/module/zanode/css/view.css @@ -0,0 +1,5 @@ +.zanode-detail .text-right{text-align: right;} +.zanode-detail .col-8{padding-left: 10px;} +.zanode-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/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/zanode/js/common.js b/module/zanode/js/common.js new file mode 100644 index 0000000000..af78b5fd6f --- /dev/null +++ b/module/zanode/js/common.js @@ -0,0 +1,38 @@ +$(function() +{ + if(config.currentMethod == 'create') $('#parent').change(); + + $('#parent').change(function() + { + 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() + { + var image = $('#image').val(); + var link = createLink('zanode', 'ajaxGetImage', 'image=' + image); + $.get(link, function(data) + { + data = JSON.parse(data); + console.log(data); + $('#osName').val(data.osName); + if(data.memory != 0){ + $('#memory').val(data.memory); + } + if(data.memory != 0){ + $('#diskSize').val(data.disk); + } + }); + }); + + if(typeof image == 'undefined' || !image) $('#os').change(); +}) diff --git a/module/zanode/lang/de.php b/module/zanode/lang/de.php new file mode 100644 index 0000000000..bbefb5c016 --- /dev/null +++ b/module/zanode/lang/de.php @@ -0,0 +1,62 @@ +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'; +$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->extranet = 'IP/Domain'; +$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->deleted = "Deleted"; + +$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..bbefb5c016 --- /dev/null +++ b/module/zanode/lang/en.php @@ -0,0 +1,62 @@ +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'; +$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->extranet = 'IP/Domain'; +$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->deleted = "Deleted"; + +$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..bbefb5c016 --- /dev/null +++ b/module/zanode/lang/fr.php @@ -0,0 +1,62 @@ +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'; +$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->extranet = 'IP/Domain'; +$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->deleted = "Deleted"; + +$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..1e1b81b5d6 --- /dev/null +++ b/module/zanode/lang/zh-cn.php @@ -0,0 +1,64 @@ +zanode->common = '执行节点'; +$lang->zanode->browse = '执行节点列表'; +$lang->zanode->create = '创建执行节点'; +$lang->zanode->editAction = '编辑执行节点'; +$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->extranet = '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->deleted = "已删除"; + +$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/zanode/model.php b/module/zanode/model.php new file mode 100644 index 0000000000..aba3906471 --- /dev/null +++ b/module/zanode/model.php @@ -0,0 +1,461 @@ + + * @package ops + * @version $Id$ + * @link http://www.zentao.net + */ +class zanodemodel extends model +{ + + const STATUS_CREATED = 'created'; + const STATUS_LAUNCH = 'launch'; + const STATUS_FAIL_CREATE = 'vm_fail_create'; + const STATUS_RUNNING = 'running'; + const STATUS_SHUTOFF = 'shutoff'; + const STATUS_BUSY = 'busy'; + const STATUS_READY = 'ready'; + const STATUS_UNKNOWN = 'unknown'; + const STATUS_DESTROY = 'destroy'; + const STATUS_DESTROY_FAIL = 'vim_destroy_fail'; + + const KVM_CREATE_PATH = '/api/v1/kvm/create'; + const KVM_TOKEN_PATH = '/api/v1/vnc/getToken'; + + + /** + * Create an Node. + * + * @param object $data + * @access public + * @return void + */ + public function create() + { + $data = fixer::input('post')->get(); + + /* Batch check fields. */ + $this->lang->vm = $this->lang->zanode; + $data->type = 'node'; + $this->dao->update(TABLE_ZAHOST)->data($data) + ->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->zanode->nameValid; + return false; + } + + /* Get image. */ + $image = $this->getImageByID($data->image); + + /* Get host info. */ + $host = $this->getHostByID($data->parent); + + /* Gen mac address */ + $mac = $this->genmac(); + + /* Prepare create params. */ + $agnetUrl = 'http://' . $host->extranet . ':' . $this->config->zanode->defaultPort; + $param = array( + 'os' => $image->os, + '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)); + + if(empty($result)) + { + dao::$errors[] = $this->lang->zanode->notFoundAgent; + return false; + } + if($result->code != 'success') + { + dao::$errors[] = $this->lang->zanode->createVmFail; + return false; + } + + /* Prepare create execution node data. */ + $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; + + /* Save execution node. */ + $this->dao->insert(TABLE_ZAHOST)->data($data)->autoCheck()->exec(); + if(dao::isError()) return false; + + $nodeID = $this->dao->lastInsertID(); + + /* update action log. */ + $this->loadModel('action')->create('zanode', $nodeID, 'Created'); + return true; + } + + /** + * Action Node. + * + * @param int $id + * @param string $type + * @return string + */ + public function handleNode($id, $type) + { + $node = $this->getNodeByID($id); + $host = $this->getHostByID($node->parent); + + /* Prepare create params. */ + $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->zanode->notFoundAgent; + + if($data['code'] != 'success') return zget($this->lang->zanode->apiError, $data['code'], $data['msg']); + + if($type != 'reboot') + { + $status = $type == 'suspend' ? 'suspend' : 'running'; + $this->dao->update(TABLE_ZAHOST)->set('status')->eq($status)->where('id')->eq($id)->exec(); + } + + $this->loadModel('action')->create('zanode', $id, ucfirst($type)); + return; + } + + /** + * Destroy Node. + * + * @param int $id + * @access public + * @return void + */ + public function destroy($id) + { + $node = $this->getNodeByID($id); + $host = $this->getHostByID($node->parent); + + $req = array( 'name' => $node->name ); + + /* Prepare create params. */ + if($host) + { + $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->zanode->notFoundAgent; + + if($data['code'] != 'success') return zget($this->lang->zanode->apiError, $data['code'], $data['msg']); + } + + /* delete execution node. */ + $this->dao->update(TABLE_ZAHOST) + ->set('deleted')->eq(1) + ->where('id')->eq($id) + ->exec(); + $this->loadModel('action')->create('zanode', $id, 'destroy'); + return; + } + + /** + * Get execution node created action record by node ID. + * + * @param int $id + * @access public + * @return object + */ + public function getNodeCreateActionByID($id) + { + return $this->dao->select('*')->from(TABLE_ACTION) + ->where('objectType')->eq('zanode') + ->andWhere('objectID')->eq($id) + ->andWhere('action')->eq('created') + ->fetch(); + } + + /** + * Callback update host data. + * + * @access public + * @return mixed + */ + public function updateHostByCallback() + { + $data = array(); + $data['status'] = isset($_POST['status']) ? $_POST['status'] : ''; + $data['agentPort'] = isset($_POST['port']) ? $_POST['port'] : ''; + $ip = isset($_POST['ip']) ? $_POST['ip'] : ''; + + if(empty($ip)) return false; + + $host = $this->getHostByIP($ip); + if(empty($host)) return 'Not Found'; + + $this->dao->update(TABLE_ZAHOST)->data($data) + ->where('id')->eq($host->id) + ->exec(); + return true; + } + + /** + * Update Node. + * + * @param int $id + * @return void + */ + public function update($id) + { + $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); + } + + /** + * Get vm list. + * + * @param string $browseType + * @param int $param + * @param string $orderBy + * @param object $pager + * @return void + */ + public function getListByQuery($browseType = 'all', $param = 0, $orderBy = 't1.id_desc', $pager = null) + { + $query = ''; + if($browseType == 'bysearch') + { + if($param) + { + $query = $this->loadModel('search')->getQuery($param); + if($query) + { + $this->session->set('nodeQuery', $query->sql); + $this->session->set('nodeForm', $query->form); + } + else + { + $this->session->set('nodeQuery', ' 1 = 1'); + } + } + else + { + if($this->session->zanodeQuery == false) $this->session->set('zanodeQuery', ' 1 = 1'); + } + $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); + $query = str_replace('`os`', 't1.`os`', $query); + $query = str_replace('`parent`', 't1.`parent`', $query); + $query = str_replace('`hostID`', 't2.`id`', $query); + } + + return $this->dao->select('t1.*, t1.name as hostName, t2.extranet,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) + ->andWhere("t1.type")->eq("node") + ->andWhere("(t1.createdBy = '{$this->app->user->account}')") + ->beginIF($query)->andWhere($query)->fi() + ->orderBy($orderBy) + ->page($pager) + ->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, cpuCores, memory, diskSize, osName, status')->from(TABLE_ZAHOST) + ->where('deleted')->eq(0) + ->andWhere("parent")->eq($hostID) + ->orderBy($orderBy) + ->fetchAll(); + } + + + /** + * Get Host by id. + * + * @param int $id + * @access public + * @return object + */ + public function getHostByID($id) + { + return $this->dao->select('*')->from(TABLE_ZAHOST) + ->where('id')->eq($id) + ->fetch(); + } + + /** + * Get Host by IP. + * + * @param string $ip + * @access public + * @return object + */ + public function getHostByIP($ip) + { + return $this->dao->select('*')->from(TABLE_ZAHOST) + ->where('extranet')->eq($ip) + ->fetch(); + } + + /** + * Get Image. + * + * @param int $id + * @access public + * @return object + */ + public function getImageByID($id) + { + return $this->dao->select('*')->from(TABLE_IMAGE) + ->where('id')->eq($id) + ->fetch(); + } + + /** + * Get Node image list. + * + * @param string $orderBy + * @param int $pager + * @access public + * @return array + */ + public function getimageList($orderBy = 'id_desc', $pager = null) + { + return $this->dao->select('*')->from(TABLE_IMAGE)->orderBy($orderBy)->page($pager)->fetchAll(); + } + + /** + * Get Node by id. + * + * @param int $id + * @return object + */ + public function getNodeByID($id) + { + 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) + ->fetch(); + } + + /** + * Get Node by mac address. + * + * @param string $mac + * @return object + */ + public function getNodeByMac($mac) + { + return $this->dao->select('*')->from(TABLE_ZAHOST) + ->where('mac')->eq($mac) + ->andWhere("type")->eq('node') + ->fetch(); + } + + /** + * Generage unique mac address. + * + * @return void + */ + private function genmac() + { + $buf = array( + 0x1C, + 0x1C, + 0x1C, + mt_rand(0x00, 0x7f), + mt_rand(0x00, 0xff), + mt_rand(0x00, 0xff) + ); + $mac = join(':',array_map(function($v) + { + return sprintf("%02X",$v); + },$buf)); + + $Node = $this->getNodeByMac($mac); + if(empty($Node)) + { + return $mac; + } + $this->genmac(); + } + + /** + * Get vnc url. + * + * @param int $vmID + * @access public + * @return void + */ + public function getVncUrl($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->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->extranet; + $returnData->agentPort = $host->agentPort; + $returnData->vnc = $vm->vnc; + $returnData->token = $result->data->token; + return $returnData; + } + + public function buildOperateMenu($node) + { + if($node->deleted) return ''; + + $menu = ''; + $params = "id=$node->id"; + + $menu .= $this->buildMenu('zanode', 'edit', $params, $node, 'view'); + $menu .= $this->buildMenu('zanode', 'delete', $params, $node, 'view', 'trash', 'hiddenwin'); + + return $menu; + } +} diff --git a/module/zanode/view/browse.html.php b/module/zanode/view/browse.html.php new file mode 100644 index 0000000000..72ec091362 --- /dev/null +++ b/module/zanode/view/browse.html.php @@ -0,0 +1,102 @@ + + * @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"'); ?> +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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::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;'"); + ?> +
+
+ + +
+ +getModuleRoot() . 'common/view/footer.html.php'; ?> \ No newline at end of file diff --git a/module/executionnode/view/create.html.php b/module/zanode/view/create.html.php old mode 100755 new mode 100644 similarity index 50% rename from module/executionnode/view/create.html.php rename to module/zanode/view/create.html.php index a25ef88315..a5c4b957e3 --- a/module/executionnode/view/create.html.php +++ b/module/zanode/view/create.html.php @@ -11,66 +11,60 @@ */ ?> +getModuleRoot() . 'common/view/kindeditor.html.php';?>
-

executionnode->create;?>

+

zanode->create;?>

- - + + + + + + - - + + - - + + - - - - - + - + - - + + - - - - - - - - - - + + +
executionnode->name;?>executionnode->nameValid}\"");?>zanode->hostName;?>
zanode->name;?>zanode->nameValid}\"");?>
executionnode->hostName;?>zanode->image;?>
executionnode->vmTemplate;?>zanode->cpuCores;?>zanode->os->cpuCores, '', "class='form-control chosen'")?>
executionnode->cpu;?>executionnode->os->cpu, '', "class='form-control chosen'")?>
executionnode->osMemory;?>zanode->memory;?>
- - zahost->unitList['GB'];?> + + zahost->unitList['GB'];?>
executionnode->osDisk;?>zanode->diskSize;?>
- + - zahost->unitList, 'GB', "class='form-control chosen w-50px'");?> + zahost->unitList['GB'];?>
executionnode->osCategory;?>zanode->osName;?>
executionnode->osType;?>
executionnode->osVersion;?>
executionnode->osLang;?>zanode->desc ?>
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;?>

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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/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/zanode/view/view.html.php b/module/zanode/view/view.html.php new file mode 100644 index 0000000000..bdb652eff1 --- /dev/null +++ b/module/zanode/view/view.html.php @@ -0,0 +1,124 @@ + + * @package zanode + * @version $Id: view.html.php $ + * @link http://www.zentao.net + */ +?> +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"; ?> + +
+
+
+
+
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($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'"); + } + ?> +
+ zanode->buildOperateMenu($zanode, 'view'); ?> +
+
+
+
+
+
+
+ +
+ +
+ \ No newline at end of file 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/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')); 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: ""