diff --git a/config/zentaopms.php b/config/zentaopms.php index 51434732d2..082241d00f 100644 --- a/config/zentaopms.php +++ b/config/zentaopms.php @@ -248,8 +248,9 @@ 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_ASSET')) define('TABLE_ASSET', '`' . $config->db->prefix . 'asset`'); +if(!defined('TABLE_VMTEMPLATE')) define('TABLE_VMTEMPLATE', '`' . $config->db->prefix . 'vmtemplate`'); +if(!defined('TABLE_VM')) define('TABLE_VM', '`' . $config->db->prefix . 'vm`'); define('TABLE_PRODUCT', '`' . $config->db->prefix . 'product`'); define('TABLE_BRANCH', '`' . $config->db->prefix . 'branch`'); @@ -343,54 +344,56 @@ define('TABLE_CHART', '`' . $config->db->prefix . 'chart`'); define('TABLE_DASHBOARD', '`' . $config->db->prefix . 'dashboard`'); define('TABLE_DATASET', '`' . $config->db->prefix . 'dataset`'); -$config->objectTables['product'] = TABLE_PRODUCT; -$config->objectTables['productplan'] = TABLE_PRODUCTPLAN; -$config->objectTables['story'] = TABLE_STORY; -$config->objectTables['requirement'] = TABLE_STORY; -$config->objectTables['release'] = TABLE_RELEASE; -$config->objectTables['program'] = TABLE_PROJECT; -$config->objectTables['project'] = TABLE_PROJECT; -$config->objectTables['execution'] = TABLE_PROJECT; -$config->objectTables['task'] = TABLE_TASK; -$config->objectTables['build'] = TABLE_BUILD; -$config->objectTables['bug'] = TABLE_BUG; -$config->objectTables['case'] = TABLE_CASE; -$config->objectTables['testcase'] = TABLE_CASE; -$config->objectTables['testtask'] = TABLE_TESTTASK; -$config->objectTables['testsuite'] = TABLE_TESTSUITE; -$config->objectTables['testreport'] = TABLE_TESTREPORT; -$config->objectTables['user'] = TABLE_USER; -$config->objectTables['api'] = TABLE_API; -$config->objectTables['doc'] = TABLE_DOC; -$config->objectTables['doclib'] = TABLE_DOCLIB; -$config->objectTables['todo'] = TABLE_TODO; -$config->objectTables['custom'] = TABLE_LANG; -$config->objectTables['branch'] = TABLE_BRANCH; -$config->objectTables['module'] = TABLE_MODULE; -$config->objectTables['caselib'] = TABLE_TESTSUITE; -$config->objectTables['entry'] = TABLE_ENTRY; -$config->objectTables['webhook'] = TABLE_WEBHOOK; -$config->objectTables['stakeholder'] = TABLE_STAKEHOLDER; -$config->objectTables['job'] = TABLE_JOB; -$config->objectTables['team'] = TABLE_TEAM; -$config->objectTables['pipeline'] = TABLE_PIPELINE; -$config->objectTables['mr'] = TABLE_MR; -$config->objectTables['kanban'] = TABLE_KANBAN; -$config->objectTables['kanbanspace'] = TABLE_KANBANSPACE; -$config->objectTables['kanbanregion'] = TABLE_KANBANREGION; -$config->objectTables['kanbancolumn'] = TABLE_KANBANCOLUMN; -$config->objectTables['kanbanlane'] = TABLE_KANBANLANE; -$config->objectTables['kanbanorder'] = TABLE_KANBANORDER; -$config->objectTables['kanbangroup'] = TABLE_KANBANGROUP; -$config->objectTables['kanbancard'] = TABLE_KANBANCARD; -$config->objectTables['sonarqube'] = TABLE_PIPELINE; -$config->objectTables['gitea'] = TABLE_PIPELINE; -$config->objectTables['gogs'] = TABLE_PIPELINE; -$config->objectTables['gitlab'] = TABLE_PIPELINE; -$config->objectTables['jebkins'] = TABLE_PIPELINE; -$config->objectTables['stage'] = TABLE_STAGE; -$config->objectTables['apistruct'] = TABLE_APISTRUCT; -$config->objectTables['repo'] = TABLE_REPO; +$config->objectTables['product'] = TABLE_PRODUCT; +$config->objectTables['productplan'] = TABLE_PRODUCTPLAN; +$config->objectTables['story'] = TABLE_STORY; +$config->objectTables['requirement'] = TABLE_STORY; +$config->objectTables['release'] = TABLE_RELEASE; +$config->objectTables['program'] = TABLE_PROJECT; +$config->objectTables['project'] = TABLE_PROJECT; +$config->objectTables['execution'] = TABLE_PROJECT; +$config->objectTables['task'] = TABLE_TASK; +$config->objectTables['build'] = TABLE_BUILD; +$config->objectTables['bug'] = TABLE_BUG; +$config->objectTables['case'] = TABLE_CASE; +$config->objectTables['testcase'] = TABLE_CASE; +$config->objectTables['testtask'] = TABLE_TESTTASK; +$config->objectTables['testsuite'] = TABLE_TESTSUITE; +$config->objectTables['testreport'] = TABLE_TESTREPORT; +$config->objectTables['user'] = TABLE_USER; +$config->objectTables['api'] = TABLE_API; +$config->objectTables['doc'] = TABLE_DOC; +$config->objectTables['doclib'] = TABLE_DOCLIB; +$config->objectTables['todo'] = TABLE_TODO; +$config->objectTables['custom'] = TABLE_LANG; +$config->objectTables['branch'] = TABLE_BRANCH; +$config->objectTables['module'] = TABLE_MODULE; +$config->objectTables['caselib'] = TABLE_TESTSUITE; +$config->objectTables['entry'] = TABLE_ENTRY; +$config->objectTables['webhook'] = TABLE_WEBHOOK; +$config->objectTables['stakeholder'] = TABLE_STAKEHOLDER; +$config->objectTables['job'] = TABLE_JOB; +$config->objectTables['team'] = TABLE_TEAM; +$config->objectTables['pipeline'] = TABLE_PIPELINE; +$config->objectTables['mr'] = TABLE_MR; +$config->objectTables['kanban'] = TABLE_KANBAN; +$config->objectTables['kanbanspace'] = TABLE_KANBANSPACE; +$config->objectTables['kanbanregion'] = TABLE_KANBANREGION; +$config->objectTables['kanbancolumn'] = TABLE_KANBANCOLUMN; +$config->objectTables['kanbanlane'] = TABLE_KANBANLANE; +$config->objectTables['kanbanorder'] = TABLE_KANBANORDER; +$config->objectTables['kanbangroup'] = TABLE_KANBANGROUP; +$config->objectTables['kanbancard'] = TABLE_KANBANCARD; +$config->objectTables['sonarqube'] = TABLE_PIPELINE; +$config->objectTables['gitea'] = TABLE_PIPELINE; +$config->objectTables['gogs'] = TABLE_PIPELINE; +$config->objectTables['gitlab'] = TABLE_PIPELINE; +$config->objectTables['jebkins'] = TABLE_PIPELINE; +$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'); diff --git a/db/update17.6.1.sql b/db/update17.6.1.sql index 96b91e9b47..cadbd9042d 100644 --- a/db/update17.6.1.sql +++ b/db/update17.6.1.sql @@ -10,3 +10,4 @@ ALTER TABLE `zt_vmtemplate` ADD `createdBy` varchar(30) NOT NULL; ALTER TABLE `zt_vmtemplate` ADD `createdDate` datetime NOT NULL; ALTER TABLE `zt_vmtemplate` ADD `editedBy` varchar(30) NOT NULL; ALTER TABLE `zt_vmtemplate` ADD `editedDate` datetime NOT NULL; +ALTER TABLE `zt_vm` ADD `osVersion` varchar(50) NOT NULL DEFAULT '' AFTER `osCategory`; diff --git a/db/zentao.sql b/db/zentao.sql index 9cdd84b026..437fa94cb1 100755 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -7483,6 +7483,7 @@ CREATE TABLE IF NOT EXISTS `zt_vm` ( `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 '', diff --git a/module/action/config.php b/module/action/config.php index 09bd45b25c..e45059328a 100755 --- a/module/action/config.php +++ b/module/action/config.php @@ -1,53 +1,54 @@ action->objectNameFields['product'] = 'name'; -$config->action->objectNameFields['story'] = 'title'; -$config->action->objectNameFields['requirement'] = 'title'; -$config->action->objectNameFields['productplan'] = 'title'; -$config->action->objectNameFields['release'] = 'name'; -$config->action->objectNameFields['program'] = 'name'; -$config->action->objectNameFields['project'] = 'name'; -$config->action->objectNameFields['execution'] = 'name'; -$config->action->objectNameFields['task'] = 'name'; -$config->action->objectNameFields['build'] = 'name'; -$config->action->objectNameFields['bug'] = 'title'; -$config->action->objectNameFields['testcase'] = 'title'; -$config->action->objectNameFields['case'] = 'title'; -$config->action->objectNameFields['testtask'] = 'name'; -$config->action->objectNameFields['user'] = 'account'; -$config->action->objectNameFields['api'] = 'title'; -$config->action->objectNameFields['doc'] = 'title'; -$config->action->objectNameFields['doclib'] = 'name'; -$config->action->objectNameFields['todo'] = 'name'; -$config->action->objectNameFields['branch'] = 'name'; -$config->action->objectNameFields['module'] = 'name'; -$config->action->objectNameFields['testsuite'] = 'name'; -$config->action->objectNameFields['caselib'] = 'name'; -$config->action->objectNameFields['testreport'] = 'title'; -$config->action->objectNameFields['entry'] = 'name'; -$config->action->objectNameFields['webhook'] = 'name'; -$config->action->objectNameFields['risk'] = 'name'; -$config->action->objectNameFields['issue'] = 'title'; -$config->action->objectNameFields['design'] = 'name'; -$config->action->objectNameFields['stakeholder'] = 'user'; -$config->action->objectNameFields['budget'] = 'name'; -$config->action->objectNameFields['job'] = 'name'; -$config->action->objectNameFields['team'] = 'name'; -$config->action->objectNameFields['pipeline'] = 'name'; -$config->action->objectNameFields['mr'] = 'title'; -$config->action->objectNameFields['reviewcl'] = 'title'; -$config->action->objectNameFields['kanbancolumn'] = 'name'; -$config->action->objectNameFields['kanbanlane'] = 'name'; -$config->action->objectNameFields['kanbanspace'] = 'name'; -$config->action->objectNameFields['kanbanregion'] = 'name'; -$config->action->objectNameFields['kanban'] = 'name'; -$config->action->objectNameFields['kanbancard'] = 'name'; -$config->action->objectNameFields['sonarqube'] = 'name'; -$config->action->objectNameFields['gitlab'] = 'name'; -$config->action->objectNameFields['gitea'] = 'name'; -$config->action->objectNameFields['gogs'] = 'name'; -$config->action->objectNameFields['stage'] = 'name'; -$config->action->objectNameFields['apistruct'] = 'name'; -$config->action->objectNameFields['repo'] = 'name'; +$config->action->objectNameFields['product'] = 'name'; +$config->action->objectNameFields['story'] = 'title'; +$config->action->objectNameFields['requirement'] = 'title'; +$config->action->objectNameFields['productplan'] = 'title'; +$config->action->objectNameFields['release'] = 'name'; +$config->action->objectNameFields['program'] = 'name'; +$config->action->objectNameFields['project'] = 'name'; +$config->action->objectNameFields['execution'] = 'name'; +$config->action->objectNameFields['task'] = 'name'; +$config->action->objectNameFields['build'] = 'name'; +$config->action->objectNameFields['bug'] = 'title'; +$config->action->objectNameFields['testcase'] = 'title'; +$config->action->objectNameFields['case'] = 'title'; +$config->action->objectNameFields['testtask'] = 'name'; +$config->action->objectNameFields['user'] = 'account'; +$config->action->objectNameFields['api'] = 'title'; +$config->action->objectNameFields['doc'] = 'title'; +$config->action->objectNameFields['doclib'] = 'name'; +$config->action->objectNameFields['todo'] = 'name'; +$config->action->objectNameFields['branch'] = 'name'; +$config->action->objectNameFields['module'] = 'name'; +$config->action->objectNameFields['testsuite'] = 'name'; +$config->action->objectNameFields['caselib'] = 'name'; +$config->action->objectNameFields['testreport'] = 'title'; +$config->action->objectNameFields['entry'] = 'name'; +$config->action->objectNameFields['webhook'] = 'name'; +$config->action->objectNameFields['risk'] = 'name'; +$config->action->objectNameFields['issue'] = 'title'; +$config->action->objectNameFields['design'] = 'name'; +$config->action->objectNameFields['stakeholder'] = 'user'; +$config->action->objectNameFields['budget'] = 'name'; +$config->action->objectNameFields['job'] = 'name'; +$config->action->objectNameFields['team'] = 'name'; +$config->action->objectNameFields['pipeline'] = 'name'; +$config->action->objectNameFields['mr'] = 'title'; +$config->action->objectNameFields['reviewcl'] = 'title'; +$config->action->objectNameFields['kanbancolumn'] = 'name'; +$config->action->objectNameFields['kanbanlane'] = 'name'; +$config->action->objectNameFields['kanbanspace'] = 'name'; +$config->action->objectNameFields['kanbanregion'] = 'name'; +$config->action->objectNameFields['kanban'] = 'name'; +$config->action->objectNameFields['kanbancard'] = 'name'; +$config->action->objectNameFields['sonarqube'] = 'name'; +$config->action->objectNameFields['gitlab'] = 'name'; +$config->action->objectNameFields['gitea'] = 'name'; +$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->commonImgSize = 870; diff --git a/module/action/lang/de.php b/module/action/lang/de.php index c05c715921..68a9f269ea 100644 --- a/module/action/lang/de.php +++ b/module/action/lang/de.php @@ -113,6 +113,7 @@ $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['doc'] = 'Dok'; $lang->action->objectTypes['api'] = 'Interface'; $lang->action->objectTypes['doclib'] = 'Dok Bibliothek'; @@ -225,6 +226,10 @@ $lang->action->desc->reopen = '$date, reopened by $actoraction->desc->merged = '$date, merged by $actor .' . "\n"; $lang->action->desc->submitreview = '$date, submitted for review by $actor.' . "\n"; $lang->action->desc->ganttmove = '$date, sort by $actor .' . "\n"; +$lang->action->desc->suspend = '$date, the execution node is suspended by $actor .' . "\n"; +$lang->action->desc->resume = '$date, the execution node is resumed by $actor .' . "\n"; +$lang->action->desc->reboot = '$date, the execution node is reboot by $actor .' . "\n"; +$lang->action->desc->destroy = '$date, the execution node is destroyed by $actor .' . "\n"; /* Used to describe the history of operations related to parent-child tasks. */ $lang->action->desc->createchildren = '$date, $actor created a child task $extra。' . "\n"; @@ -392,6 +397,10 @@ $lang->action->label->tolib = 'imported'; $lang->action->label->updatetolib = 'updated'; $lang->action->label->ganttmove = 'sorted'; $lang->action->label->submitreview = 'submitted'; +$lang->action->label->suspend = 'suspended'; +$lang->action->label->resume = 'resumed'; +$lang->action->label->reboot = 'reboot'; +$lang->action->label->destroy = 'destroyed'; /* Dynamic information is grouped by object. */ $lang->action->dynamicAction = new stdclass; @@ -617,6 +626,12 @@ $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->doclib['created'] = 'Create Doc Library'; $lang->action->dynamicAction->doclib['edited'] = 'Edit Doc Library'; $lang->action->dynamicAction->doclib['deleted'] = 'Delete Doc Library'; diff --git a/module/action/lang/en.php b/module/action/lang/en.php index 47fff5fdb9..225eca1d76 100755 --- a/module/action/lang/en.php +++ b/module/action/lang/en.php @@ -113,6 +113,7 @@ $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['doc'] = 'Document'; $lang->action->objectTypes['api'] = 'Interface'; $lang->action->objectTypes['doclib'] = 'Document Library'; @@ -225,6 +226,10 @@ $lang->action->desc->reopen = '$date, reopened by $actoraction->desc->merged = '$date, merged by $actor .' . "\n"; $lang->action->desc->submitreview = '$date, submitted for review by $actor.' . "\n"; $lang->action->desc->ganttmove = '$date, sort by $actor .' . "\n"; +$lang->action->desc->suspend = '$date, the execution node is suspended by $actor .' . "\n"; +$lang->action->desc->resume = '$date, the execution node is resumed by $actor .' . "\n"; +$lang->action->desc->reboot = '$date, the execution node is reboot by $actor .' . "\n"; +$lang->action->desc->destroy = '$date, the execution node is destroyed by $actor .' . "\n"; /* Used to describe the history of operations related to parent-child tasks. */ $lang->action->desc->createchildren = '$date, $actor created a child task $extra。' . "\n"; @@ -392,6 +397,10 @@ $lang->action->label->tolib = 'imported'; $lang->action->label->updatetolib = 'updated'; $lang->action->label->ganttmove = 'sorted'; $lang->action->label->submitreview = 'submitted'; +$lang->action->label->suspend = 'suspended'; +$lang->action->label->resume = 'resumed'; +$lang->action->label->reboot = 'reboot'; +$lang->action->label->destroy = 'destroyed'; /* Dynamic information is grouped by object. */ $lang->action->dynamicAction = new stdclass; @@ -617,6 +626,12 @@ $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->doclib['created'] = 'Create Doc Library'; $lang->action->dynamicAction->doclib['edited'] = 'Edit Doc Library'; $lang->action->dynamicAction->doclib['deleted'] = 'Delete Doc Library'; diff --git a/module/action/lang/fr.php b/module/action/lang/fr.php index 4baf1ad0ad..697e7ad2fa 100644 --- a/module/action/lang/fr.php +++ b/module/action/lang/fr.php @@ -112,6 +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['doc'] = 'Document'; $lang->action->objectTypes['api'] = 'Interface'; $lang->action->objectTypes['doclib'] = 'Répertoire Documents'; @@ -224,6 +225,10 @@ $lang->action->desc->reopen = '$date, reopened by $actoraction->desc->merged = '$date, merged by $actor .' . "\n"; $lang->action->desc->submitreview = '$date, submitted for review by $actor.' . "\n"; $lang->action->desc->ganttmove = '$date, sort by $actor .' . "\n"; +$lang->action->desc->suspend = '$date, the execution node is suspended by $actor .' . "\n"; +$lang->action->desc->resume = '$date, the execution node is resumed by $actor .' . "\n"; +$lang->action->desc->reboot = '$date, the execution node is reboot by $actor .' . "\n"; +$lang->action->desc->destroy = '$date, the execution node is destroyed by $actor .' . "\n"; /* Used to describe the history of operations related to parent-child tasks. */ $lang->action->desc->createchildren = '$date, $actor a créé un sous-tâche $extra。' . "\n"; @@ -391,6 +396,10 @@ $lang->action->label->tolib = 'Importé'; $lang->action->label->updatetolib = 'MàJ'; $lang->action->label->ganttmove = 'sorted'; $lang->action->label->submitreview = 'submitted'; +$lang->action->label->suspend = 'suspended'; +$lang->action->label->resume = 'resumed'; +$lang->action->label->reboot = 'reboot'; +$lang->action->label->destroy = 'destroyed'; /* Dynamic information is grouped by object. */ $lang->action->dynamicAction = new stdclass(); @@ -616,6 +625,12 @@ $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->doclib['created'] = 'Créer Doc Library'; $lang->action->dynamicAction->doclib['edited'] = 'Editer Doc Library'; $lang->action->dynamicAction->doclib['deleted'] = 'Delete Doc Library'; diff --git a/module/action/lang/vi.php b/module/action/lang/vi.php index 659238be5b..e033c06e64 100644 --- a/module/action/lang/vi.php +++ b/module/action/lang/vi.php @@ -90,6 +90,7 @@ $lang->action->objectTypes['testtask'] = 'Test bản dựng'; $lang->action->objectTypes['testreport'] = 'Báo cáo'; $lang->action->objectTypes['zahost'] = 'Host'; $lang->action->objectTypes['vmtemplate'] = 'Virtual Host Template'; +$lang->action->objectTypes['executionnode'] = 'Execution Node'; $lang->action->objectTypes['doc'] = 'Tài liệu'; $lang->action->objectTypes['doclib'] = 'Thư viện tài liệu'; $lang->action->objectTypes['todo'] = 'Việc làm'; @@ -186,6 +187,10 @@ $lang->action->desc->syncexecution = '$date, starting the task sets the execut $lang->action->desc->reopen = '$date, reopened by $actor .' . "\n"; $lang->action->desc->merged = '$date, merged by $actor .' . "\n"; $lang->action->desc->submitreview = '$date, submitted for review by $actor.' . "\n"; +$lang->action->desc->suspend = '$date, the execution node is suspended by $actor .' . "\n"; +$lang->action->desc->resume = '$date, the execution node is resumed by $actor .' . "\n"; +$lang->action->desc->reboot = '$date, the execution node is reboot by $actor .' . "\n"; +$lang->action->desc->destroy = '$date, the execution node is destroyed by $actor .' . "\n"; /* Used to describe the history of operations related to parent-child tasks. */ $lang->action->desc->createchildren = '$date, $actor created a child task $extra。' . "\n"; @@ -308,6 +313,10 @@ $lang->action->label->syncproject = 'start'; $lang->action->label->syncexecution = 'start'; $lang->action->label->startProgram = '(The start of the project sets the status of the program as Ongoing)'; $lang->action->label->submitreview = 'submitted'; +$lang->action->label->suspend = 'suspended'; +$lang->action->label->resume = 'resumed'; +$lang->action->label->reboot = 'reboot'; +$lang->action->label->destroy = 'destroyed'; /* Dynamic information is grouped by object. */ $lang->action->dynamicAction = new stdclass; @@ -478,6 +487,12 @@ $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->doclib['created'] = 'Tạo Doc thư viện'; $lang->action->dynamicAction->doclib['edited'] = 'Sửa Doc thư viện'; $lang->action->dynamicAction->doclib['deleted'] = 'Delete Doc Library'; diff --git a/module/action/lang/zh-cn.php b/module/action/lang/zh-cn.php index 2195dacd35..330b3193b0 100755 --- a/module/action/lang/zh-cn.php +++ b/module/action/lang/zh-cn.php @@ -113,6 +113,7 @@ $lang->action->objectTypes['testtask'] = '测试单'; $lang->action->objectTypes['testreport'] = '报告'; $lang->action->objectTypes['zahost'] = '宿主机'; $lang->action->objectTypes['vmtemplate'] = '虚拟机模板'; +$lang->action->objectTypes['executionnode'] = '执行节点'; $lang->action->objectTypes['doc'] = '文档'; $lang->action->objectTypes['api'] = '接口'; $lang->action->objectTypes['doclib'] = '文档库'; @@ -225,6 +226,10 @@ $lang->action->desc->reopen = '$date, 由 $actor $lang->action->desc->merged = '$date, 由 $actor 合并。' . "\n"; $lang->action->desc->submitreview = '$date, 由 $actor 提交评审。' . "\n"; $lang->action->desc->ganttmove = '$date, 由 $actor 排序。' . "\n"; +$lang->action->desc->suspend = '$date, 由 $actor 暂停。' . "\n"; +$lang->action->desc->resume = '$date, 由 $actor 恢复。' . "\n"; +$lang->action->desc->reboot = '$date, 由 $actor 重启。' . "\n"; +$lang->action->desc->destroy = '$date, 由 $actor 销毁。' . "\n"; /* 用来描述和父子任务相关的操作历史记录。*/ $lang->action->desc->createchildren = '$date, 由 $actor 创建子任务 $extra。' . "\n"; @@ -392,6 +397,10 @@ $lang->action->label->tolib = '导入了'; $lang->action->label->updatetolib = '更新了'; $lang->action->label->ganttmove = '排序了'; $lang->action->label->submitreview = '提交了评审'; +$lang->action->label->suspend = '暂停了'; +$lang->action->label->resume = '恢复了'; +$lang->action->label->reboot = '重启了'; +$lang->action->label->destroy = '销毁了'; /* 动态信息按照对象分组 */ $lang->action->dynamicAction = new stdclass(); @@ -617,6 +626,12 @@ $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->doclib['created'] = '创建文档库'; $lang->action->dynamicAction->doclib['edited'] = '编辑文档库'; $lang->action->dynamicAction->doclib['deleted'] = '删除文档库'; diff --git a/module/common/lang/menu.php b/module/common/lang/menu.php index 6b644af043..5d19774e4c 100644 --- a/module/common/lang/menu.php +++ b/module/common/lang/menu.php @@ -651,17 +651,17 @@ $lang->navGroup->api = 'doc'; $lang->navGroup->report = 'report'; -$lang->navGroup->qa = 'qa'; -$lang->navGroup->bug = 'qa'; -$lang->navGroup->testcase = 'qa'; -$lang->navGroup->testtask = 'qa'; -//$lang->navGroup->automation = 'qa'; -$lang->navGroup->zahost = 'qa'; -$lang->navGroup->testreport = 'qa'; -$lang->navGroup->testcase = 'qa'; -$lang->navGroup->testtask = 'qa'; -$lang->navGroup->testsuite = 'qa'; -$lang->navGroup->caselib = 'qa'; +$lang->navGroup->qa = 'qa'; +$lang->navGroup->bug = 'qa'; +$lang->navGroup->testcase = 'qa'; +$lang->navGroup->testtask = 'qa'; +$lang->navGroup->zahost = 'qa'; +$lang->navGroup->executionnode = 'qa'; +$lang->navGroup->testreport = 'qa'; +$lang->navGroup->testcase = 'qa'; +$lang->navGroup->testtask = 'qa'; +$lang->navGroup->testsuite = 'qa'; +$lang->navGroup->caselib = 'qa'; $lang->navGroup->devops = 'devops'; $lang->navGroup->repo = 'devops'; diff --git a/module/executionnode/config.php b/module/executionnode/config.php new file mode 100755 index 0000000000..ac8e8e93fd --- /dev/null +++ b/module/executionnode/config.php @@ -0,0 +1,69 @@ +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->memory = array(); +$config->executionnode->os->memory['512'] = '512MB'; +$config->executionnode->os->memory['1024'] = '1GB'; +$config->executionnode->os->memory['2048'] = '2GB'; +$config->executionnode->os->memory['4096'] = '4GB'; +$config->executionnode->os->memory['9120'] = '8GB'; +$config->executionnode->os->memory['16384'] = '16GB'; + +$config->executionnode->os->disk = array(); +$config->executionnode->os->disk['10240'] = '10GB'; +$config->executionnode->os->disk['20480'] = '20GB'; +$config->executionnode->os->disk['40960'] = '40GB'; +$config->executionnode->os->disk['61440'] = '60GB'; +$config->executionnode->os->disk['81920'] = '80GB'; +$config->executionnode->os->disk['102400'] = '100GB'; +$config->executionnode->os->disk['204800'] = '200GB'; +$config->executionnode->os->disk['307200'] = '300GB'; + +$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'] = 'vm'; +$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->memory; +$config->executionnode->search['fields']['osDisk'] = $lang->executionnode->disk; +$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' => 'select', 'values' => array('' => '') + $config->executionnode->os->memory); +$config->executionnode->search['params']['osDisk'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $config->executionnode->os->disk); diff --git a/module/executionnode/control.php b/module/executionnode/control.php new file mode 100755 index 0000000000..ec558f361d --- /dev/null +++ b/module/executionnode/control.php @@ -0,0 +1,207 @@ + + * @package qa + * @version $Id$ + * @link http://www.zentao.net + */ +class executionnode extends control +{ + + /** + * Browse execution node page. + * + * @param string $browseType + * @param string $param + * @param string $orderBy + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID + * @access public + * @return void + */ + public function browse($browseType = 'all', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + { + $browseType = strtolower($browseType); + + $this->app->loadClass('pager', $static = true); + + + $queryID = ($browseType == 'bysearch') ? (int)$param : 0; + $pager = pager::init($recTotal, $recPerPage, $pageID); + $nodeList = $this->executionnode->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); + + $this->view->title = $this->lang->executionnode->common; + $this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted'); + $this->view->nodeList = $nodeList; + $this->view->pager = $pager; + $this->view->param = $param; + $this->view->orderBy = $orderBy; + $this->view->browseType = $browseType; + + $this->display(); + } + + /** + * Create node page. + * + * @param int $templateID + * @access public + * @return void + */ + public function create() + { + if(!empty($_POST)) + { + $this->executionnode->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->hostPairs = $this->loadModel('zahost')->getPairs('host'); + + return $this->display(); + } + + /** + * View VM. + * + * @param int $id + * @access public + * @return void + */ + 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->users = $this->loadModel('user')->getPairs('noletter'); + + $this->display(); + } + + /** + * Suspend VM. + * + * @param int $nodeID + * @access public + * @return void + */ + public function suspend($nodeID) + { + $this->handleVM($nodeID, 'suspend'); + } + + /** + * Reboot VM. + * + * @param int $nodeID + * @access public + * @return void + */ + public function reboot($nodeID) + { + $this->handleVM($nodeID, 'reboot'); + } + + /** + * Resume VM. + * + * @param int $nodeID + * @access public + * @return void + */ + public function resume($nodeID) + { + $this->handleVM($nodeID, 'resume'); + } + + /** + * Boot node. + * + * @param int $nodeID + * @param string $type + * @return void + */ + public function handleVM($nodeID, $type) + { + $error = $this->executionnode->handleVM($nodeID, $type); + + if($error) + { + return print(js::error($error)); + } + else + { + return print(js::alert($this->lang->executionnode->actionSuccess) . js::reload('parent')); + } + } + + /** + * Desctroy node. + * + * @param int $nodeID + * @return void + */ + public function destroy($nodeID) + { + $error = $this->executionnode->destroy($nodeID); + + if($error) + { + return print(js::alert($error)); + } + 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')); + } + } + + /** + * Ajax get template pairs by api. + * + * @param int $hostID + * @access public + * @return void + */ + public function ajaxGetTemplates($hostID) + { + $templatePairs = $this->loadModel('zahost')->getTemplatePairs($hostID); + return print(html::select('templateID', $templatePairs, '', "class='form-control chosen'")); + } + + /** + * Ajax get template info. + * + * @param int $templateID + * @access public + * @return void + */ + public function ajaxGetTemplateInfo($templateID) + { + $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); + } + return print(json_encode($template)); + } +} diff --git a/module/executionnode/css/create.css b/module/executionnode/css/create.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/module/executionnode/css/template.css b/module/executionnode/css/template.css new file mode 100644 index 0000000000..368ff7cf94 --- /dev/null +++ b/module/executionnode/css/template.css @@ -0,0 +1,2 @@ +.c-host, .c-type {width: 150px;} +.c-category, .c-version, .c-lang {width: 120px;} diff --git a/module/executionnode/js/browse.js b/module/executionnode/js/browse.js new file mode 100755 index 0000000000..e69de29bb2 diff --git a/module/executionnode/js/common.js b/module/executionnode/js/common.js new file mode 100755 index 0000000000..912da9a03a --- /dev/null +++ b/module/executionnode/js/common.js @@ -0,0 +1,33 @@ +$(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 new file mode 100755 index 0000000000..7ca4d598d2 --- /dev/null +++ b/module/executionnode/lang/de.php @@ -0,0 +1,96 @@ +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->ip = 'IP'; +$lang->executionnode->osArch = 'Arch'; +$lang->executionnode->osLang = 'Language'; +$lang->executionnode->cpu = 'CPU Cores'; +$lang->executionnode->memory = 'Memory Size'; +$lang->executionnode->disk = '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->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 new file mode 100755 index 0000000000..7ca4d598d2 --- /dev/null +++ b/module/executionnode/lang/en.php @@ -0,0 +1,96 @@ +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->ip = 'IP'; +$lang->executionnode->osArch = 'Arch'; +$lang->executionnode->osLang = 'Language'; +$lang->executionnode->cpu = 'CPU Cores'; +$lang->executionnode->memory = 'Memory Size'; +$lang->executionnode->disk = '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->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 new file mode 100755 index 0000000000..b296f42a32 --- /dev/null +++ b/module/executionnode/lang/fr.php @@ -0,0 +1,98 @@ +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->ip = 'IP'; +$lang->executionnode->osArch = 'Arch'; +$lang->executionnode->osLang = 'Language'; +$lang->executionnode->cpu = 'CPU Cores'; +$lang->executionnode->memory = 'Memory Size'; +$lang->executionnode->disk = '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->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 new file mode 100755 index 0000000000..7b749e505f --- /dev/null +++ b/module/executionnode/lang/zh-cn.php @@ -0,0 +1,96 @@ +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->ip = 'IP'; +$lang->executionnode->osArch = '架构'; +$lang->executionnode->osLang = '系统语言'; +$lang->executionnode->cpu = 'CPU核心数'; +$lang->executionnode->memory = '内存'; +$lang->executionnode->disk = '硬盘'; +$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->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['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/lang/zh-tw.php b/module/executionnode/lang/zh-tw.php new file mode 100644 index 0000000000..e69de29bb2 diff --git a/module/executionnode/model.php b/module/executionnode/model.php new file mode 100755 index 0000000000..a2b0cecf82 --- /dev/null +++ b/module/executionnode/model.php @@ -0,0 +1,522 @@ + + * @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 != 200) + { + 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'] != 200) return $data['message']; + + 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'] != 200) return $data['message']; + } + + /* 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); + } + + 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 != 200) 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 new file mode 100755 index 0000000000..ba5152e11c --- /dev/null +++ b/module/executionnode/view/browse.html.php @@ -0,0 +1,97 @@ + + * @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->hostName);?> + executionnode->osType);?>executionnode->cpu);?>executionnode->memory);?>executionnode->disk);?>executionnode->status);?>executionnode->creater);?>actions?>
id;?>inlink('view', "id=$node->id", 'html', true), $node->name, '',"class='iframe'");?>hostName;?>executionnode->os->cpu, $node->osCpu);?>executionnode->os->memory, $node->osMemory);?>executionnode->os->disk, $node->osDisk);?>executionnode->statusList, $node->status);?>createdBy);?> + status == 'running' ? 'disabled' : ''; + $stopClass = $node->status == 'suspend' ? 'disabled' : ''; + common::printLink('executionnode', 'suspend', "executionnodeID={$node->id}", " ", '', "title='{$lang->executionnode->suspend}' class='btn btn-primary' {$stopClass} target='hiddenwin' onclick='if(confirm(\"{$lang->executionnode->confirmSuspend}\")==false) return false;'"); + common::printLink('executionnode', 'resume', "executionnodeID={$node->id}", " ", '', "title='{$lang->executionnode->resume}' class='btn btn-primary' {$startClass} target='hiddenwin' onclick='if(confirm(\"{$lang->executionnode->confirmResume}\")==false) return false;'"); + common::printLink('executionnode', 'reboot', "executionnodeID={$node->id}", " ", '', "title='{$lang->executionnode->reboot}' class='btn btn-primary' {$stopClass} target='hiddenwin' onclick='if(confirm(\"{$lang->executionnode->confirmReboot}\")==false) return false;'"); + 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;'"); + common::printIcon('executionnode', 'getVNC', "executionnodeID={$node->id}", '', 'list', 'link', 'hiddenwin', $stopClass); + ?> +
+
+ + +
+ +getModuleRoot() . 'common/view/footer.html.php';?> diff --git a/module/executionnode/view/create.html.php b/module/executionnode/view/create.html.php new file mode 100755 index 0000000000..ed386c6fa6 --- /dev/null +++ b/module/executionnode/view/create.html.php @@ -0,0 +1,71 @@ + + * @package host + * @version $Id$ + * @link http://www.zentao.net + */ +?> + +
+
+

executionnode->create;?>

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
executionnode->name;?>executionnode->nameValid}\"");?>
executionnode->hostName;?>
executionnode->vmTemplate;?>
executionnode->cpu;?>executionnode->os->cpu, '', "class='form-control chosen'")?>
executionnode->memory;?>executionnode->os->memory, '', "class='form-control chosen'")?>
executionnode->disk;?>executionnode->os->disk, '', "class='form-control chosen'")?>
executionnode->osCategory;?>
executionnode->osType;?>
executionnode->osVersion;?>
executionnode->osLang;?>
+ + goback, '', "class='btn btn-wide btn-back'");?> +
+
+
+getModuleRoot() . 'common/view/footer.html.php';?> + diff --git a/module/executionnode/view/getvnc.html.php b/module/executionnode/view/getvnc.html.php new file mode 100644 index 0000000000..82f8b0d6de --- /dev/null +++ b/module/executionnode/view/getvnc.html.php @@ -0,0 +1,23 @@ + + * @package vm + * @version $Id$ + * @link http://www.zentao.net + */ +?> +getModuleRoot() . 'common/view/header.lite.html.php';?> +
+ webRoot}js/vnc/vnc_lite.html?host=$host&port=6080&path=websockify/?token=$token&password=pass'>";?> +
+ diff --git a/module/executionnode/view/view.html.php b/module/executionnode/view/view.html.php new file mode 100644 index 0000000000..db464de934 --- /dev/null +++ b/module/executionnode/view/view.html.php @@ -0,0 +1,79 @@ + + * @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/upgrade/config.php b/module/upgrade/config.php index c60d898753..2872a2caf0 100644 --- a/module/upgrade/config.php +++ b/module/upgrade/config.php @@ -370,9 +370,9 @@ $config->delete['17_2'][] = 'extension/lite/workflowrelation/ext/view/admin.flow $config->delete['17_2'][] = 'extension/lite/extension/lite/workflowrule/ext/view/browse.flow.html.hook.php'; $config->delete['17_2'][] = 'extension/lite/extension/lite/workflowrule/ext/view/view.flow.html.hook.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', 'projectrelease', 'projectstory', 'qa', 'release', 'repo', 'report', 'risk', 'score', 'search', 'setting', 'sonarqube', 'sso', 'stage', 'stakeholder', 'story', 'subject', 'svn', 'task', 'testcase', 'testreport', 'testsuite', 'testtask', 'todo', 'tree', 'tutorial', 'upgrade', 'user', 'webhook', 'weekly', 'workestimation', 'gitea', 'gogs', 'port'); +$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', 'executionnode', 'extension', 'file', 'git', 'gitlab', 'group', 'gitea', 'gogs', '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', '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', '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'); +$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'); global $lang; $config->upgrade->defaultActions = array();