diff --git a/module/host/config.php b/module/host/config.php index c77124fede..c223cdbba6 100644 --- a/module/host/config.php +++ b/module/host/config.php @@ -2,9 +2,9 @@ $config->host->create = new stdclass(); $config->host->edit = new stdclass(); $config->host->changestatus = new stdclass(); -$config->host->create->requiredFields = 'name,tags,provider,intranet,extranet'; -$config->host->edit->requiredFields = 'name,tags,provider,intranet,extranet'; -$config->host->create->intFields = 'cpuNumber,cpuCores'; +$config->host->create->requiredFields = 'name,zap,tags,provider,intranet,extranet'; +$config->host->edit->requiredFields = 'name,zap,tags,provider,intranet,extranet'; +$config->host->create->intFields = 'cpuNumber,cpuCores,zap'; $config->host->create->ipFields = 'intranet,extranet'; $config->host->editor = new stdclass(); @@ -31,24 +31,4 @@ $config->host->featureBar = array( $config->host->actions = new stdclass(); $config->host->actions->view = array(); -$config->host->actions->view['suffixActions'] = array('edit', 'delete'); - -$config->host->defaultPort = '55001'; -$config->host->imageListUrl = 'https://pkg.qucheng.com/zenagent/list.json'; - -$config->host->cpuCoreList = array(1 => 1, 2 => 2, 4 => 4, 6 => 6, 8 => 8, 10 => 10, 12 => 12, 16 => 16, 24 => 24, 32 => 32, 64 => 64); - -$config->host->initBash = 'curl -sSL https://pkg.qucheng.com/zenagent/zagent.sh | bash /dev/stdin -k %s -z %s'; - -$config->host->editor = new stdclass(); -$config->host->editor->create = array('id' => 'desc', 'tools' => 'simpleTools'); -$config->host->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools'); -$config->host->editor->view = array('id' => 'comment,lastComment', 'tools' => 'simpleTools'); - -$config->host->automation = new stdclass(); -$config->host->automation->zenAgentURL = 'https://github.com/easysoft/zenagent/blob/main/guide/deploy/index.md'; -$config->host->automation->ztfURL = 'https://ztf.im/'; -$config->host->automation->kvmURL = 'https://www.linux-kvm.org/page/Documents'; -$config->host->automation->nginxURL = 'http://nginx.org/en/docs/'; -$config->host->automation->novncURL = 'https://novnc.com/info.html'; -$config->host->automation->websockifyURL = 'https://github.com/novnc/websockify'; \ No newline at end of file +$config->host->actions->view['suffixActions'] = array('edit', 'delete'); \ No newline at end of file diff --git a/module/host/config/dtable.php b/module/host/config/dtable.php index 7d4aa6e815..5efbc85ead 100644 --- a/module/host/config/dtable.php +++ b/module/host/config/dtable.php @@ -1,7 +1,6 @@ loadLang('serverroom'); -$app->loadLang('zahost'); $config->host->dtable = new stdclass(); @@ -60,13 +59,6 @@ $config->host->dtable->fieldList['status']['sortType'] = true; $config->host->dtable->fieldList['status']['width'] = 80; $config->host->dtable->fieldList['status']['map'] = $lang->host->statusList; -$config->host->dtable->fieldList['heartbeat']['title'] = $lang->host->registerDate; -$config->host->dtable->fieldList['heartbeat']['name'] = 'heartbeat'; -$config->host->dtable->fieldList['heartbeat']['type'] = 'datetime'; -$config->host->dtable->fieldList['heartbeat']['sortType'] = true; -$config->host->dtable->fieldList['heartbeat']['width'] = 80; -$config->host->dtable->fieldList['heartbeat']['map'] = $lang->host->statusList; - $config->host->actionList = array(); $config->host->actionList['online']['icon'] = 'arrow-up'; $config->host->actionList['online']['text'] = $lang->host->online; @@ -102,58 +94,3 @@ $config->host->dtable->fieldList['actions']['sortType'] = false; $config->host->dtable->fieldList['actions']['fixed'] = 'right'; $config->host->dtable->fieldList['actions']['menu'] = array('online|offline', 'edit', 'delete'); $config->host->dtable->fieldList['actions']['list'] = $config->host->actionList; - -$config->host->imageDtable = new stdclass(); - -$config->host->imageDtable->fieldList['name']['title'] = $lang->zahost->image->name; -$config->host->imageDtable->fieldList['name']['name'] = 'name'; -$config->host->imageDtable->fieldList['name']['sortType'] = true; -$config->host->imageDtable->fieldList['name']['width'] = 120; -$config->host->imageDtable->fieldList['name']['hint'] = true; - -$config->host->imageDtable->fieldList['osName']['title'] = $lang->zahost->image->os; -$config->host->imageDtable->fieldList['osName']['name'] = 'osName'; -$config->host->imageDtable->fieldList['osName']['sortType'] = true; -$config->host->imageDtable->fieldList['osName']['width'] = 120; -$config->host->imageDtable->fieldList['osName']['hint'] = true; - -$config->host->imageDtable->fieldList['status']['title'] = $lang->zahost->status; -$config->host->imageDtable->fieldList['status']['name'] = 'status'; -$config->host->imageDtable->fieldList['status']['sortType'] = false; -$config->host->imageDtable->fieldList['status']['width'] = 100; -$config->host->imageDtable->fieldList['status']['map'] = $lang->zahost->image->statusList; - -$config->host->imageDtable->fieldList['path']['title'] = $lang->zahost->image->path; -$config->host->imageDtable->fieldList['path']['name'] = 'path'; -$config->host->imageDtable->fieldList['path']['type'] = 'desc'; -$config->host->imageDtable->fieldList['path']['sortType'] = false; -$config->host->imageDtable->fieldList['path']['hint'] = true; - -$config->host->imageDtable->fieldList['progress']['title'] = $lang->zahost->image->progress; -$config->host->imageDtable->fieldList['progress']['name'] = 'progress'; -$config->host->imageDtable->fieldList['progress']['sortType'] = false; -$config->host->imageDtable->fieldList['progress']['width'] = 120; -$config->host->imageDtable->fieldList['progress']['hint'] = true; - -$config->host->imageActionList = array(); -$config->host->imageActionList['download']['icon'] = 'download'; -$config->host->imageActionList['download']['text'] = $lang->zahost->image->downloadImage; -$config->host->imageActionList['download']['hint'] = $lang->zahost->image->downloadImage; -$config->host->imageActionList['download']['url'] = helper::createLink('host', 'downloadImage', 'imageID={id}'); -$config->host->imageActionList['download']['ajaxSubmit'] = true; -$config->host->imageActionList['download']['data-confirm'] = false; - -$config->host->imageActionList['cancel']['icon'] = 'ban-circle'; -$config->host->imageActionList['cancel']['text'] = $lang->cancel; -$config->host->imageActionList['cancel']['hint'] = $lang->cancel; -$config->host->imageActionList['cancel']['url'] = helper::createLink('host', 'cancelDownload', 'id={id}'); -$config->host->imageActionList['cancel']['ajaxSubmit'] = true; -$config->host->imageActionList['cancel']['data-confirm'] = $lang->zahost->cancelDelete; - -$config->host->imageDtable->fieldList['actions']['name'] = 'actions'; -$config->host->imageDtable->fieldList['actions']['title'] = $lang->actions; -$config->host->imageDtable->fieldList['actions']['type'] = 'actions'; -$config->host->imageDtable->fieldList['actions']['sortType'] = false; -$config->host->imageDtable->fieldList['actions']['fixed'] = 'right'; -$config->host->imageDtable->fieldList['actions']['menu'] = array('download', 'cancel'); -$config->host->imageDtable->fieldList['actions']['list'] = $config->host->imageActionList; diff --git a/module/host/control.php b/module/host/control.php index b3273c3e9b..863d644d91 100644 --- a/module/host/control.php +++ b/module/host/control.php @@ -49,7 +49,6 @@ class host extends control $this->loadModel('search')->setSearchParams($this->config->host->search); $this->loadModel('tree'); - $this->app->loadLang('zahost'); $this->view->title = $this->lang->host->common; $this->view->hostList = $hostList; $this->view->pager = $pager; @@ -66,110 +65,35 @@ class host extends control $this->display(); } - /** - * 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->host->getImageList($hostID, $browseType, $param, $orderBy, $pager); - - $this->app->loadLang('zahost'); - $this->view->title = $this->lang->zahost->image->browseImage; - $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(); - } - - /** - * Sent download image request to Host. - * - * @param int $hostID - * @param int $imageID - * @access public - * @return object - */ - public function downloadImage($imageID) - { - $this->loadModel('zahost'); - $image = $this->zahost->getImageByID($imageID); - $this->zahost->downloadImage($image); - if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => $this->lang->zahost->image->downloadImageFail)); - - return $this->send(array('result' => 'success', 'load' => true)); - } - - /** - * Sent cancel download image request to Host. - * - * @param int $hostID - * @param string $imageName - * @access public - * @return object - */ - public function cancelDownload($imageID) - { - $this->loadModel('zahost'); - $image = $this->zahost->getImageByID($imageID); - - $this->zahost->cancelDownload($image); - if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => $this->lang->zahost->image->downloadImageFail)); - - $this->send(array('result' => 'success', 'load' => true)); - } - /** * Create host. * * @access public * @return void */ - public function create($osName = 'linux', $hostType = 'physical', $isTestNode = 0) + public function create($osName = 'linux') { if($_POST) { $id = $this->host->create(); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $_POST['testType'] === 'node' && $_POST['$isTestNode'] == 1 ? inlink('view', "id=$id") : inlink('browse'))); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse'))); } $this->view->defaultParams = array( - 'pri' => '100', - 'bridgeID' => 'br0', + 'zap' => '8085', + 'pri' => '100', + 'bridgeID' => 'br0', ); - $testTypes = $this->lang->host->testTypes; - if($hostType != 'physical') unset($testTypes['kvm']); - $this->view->title = $this->lang->host->create; $this->view->osName = $osName; - $this->view->hostType = $hostType; - $this->view->testTypes = $testTypes; - $this->view->isTestNode = intval($isTestNode); $this->view->position[] = html::a($this->createLink('host', 'browse'), $this->lang->host->common); $this->view->position[] = $this->lang->host->create; + $this->view->rooms = $this->loadModel('serverroom')->getPairs(); $this->view->accounts = $this->loadModel('account')->getPairs(); - $this->view->products = $this->loadModel('product')->getPairs('', 0, '', 'all'); $this->view->optionMenu = $this->loadModel('tree')->getOptionMenu(0, 'host'); $this->display(); @@ -181,7 +105,7 @@ class host extends control * @access public * @return void */ - public function edit($id, $osName = '', $hostType = 'physical', $isTestNode = -1) + public function edit($id, $osName = '') { if($_POST) { @@ -194,29 +118,19 @@ class host extends control if(!empty($changes)) $this->action->logHistory($actionID, $changes); } - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $_POST['testType'] === 'node' && $_POST['isTestNode'] == 1 ? inlink('view', "id=$id") : inlink('browse'), 'closeModal' => true)); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => inlink('browse'), 'closeModal' => true)); } - $host = $this->host->getById($id); - $testTypes = $this->lang->host->testTypes; - if($hostType != 'physical') unset($testTypes['kvm']); - if($isTestNode == -1) $isTestNode = $host->testType ? 1 : 0; - - $this->view->osName = $osName; - $this->view->hostType = $hostType; - $this->view->testTypes = $testTypes; - $this->view->isTestNode = intval($isTestNode); $this->view->accounts = $this->loadModel('account')->getPairs(); $this->view->title = $this->lang->host->edit; $this->view->position[] = html::a($this->createLink('host', 'browse'), $this->lang->host->common); $this->view->position[] = $this->lang->host->edit; - $this->view->host = $host; + $this->view->host = $this->host->getById($id); $this->view->osName = $osName ? $osName : $this->view->host->osName; $this->view->accounts = $this->loadModel('account')->getPairs(); $this->view->rooms = $this->loadModel('serverroom')->getPairs(); $this->view->optionMenu = $this->loadModel('tree')->getOptionMenu(0, 'host'); - $this->view->products = $this->loadModel('product')->getPairs('', 0, '', 'all'); $this->display(); } diff --git a/module/host/js/browse.ui.js b/module/host/js/browse.ui.js index 0c3d1c820c..1cd652aa99 100644 --- a/module/host/js/browse.ui.js +++ b/module/host/js/browse.ui.js @@ -11,27 +11,7 @@ window.renderCell = function(result, {col, row}) if(col.name === 'osVersion') { const{osName, osVersion} = row.data; - if(osName && osVersion != '') result[0] = {html: hostLang[osName + 'List'][osVersion]}; - - return result; - } - - if(col.name === 'status') - { - let status = ''; - if(row.data.testType === '') - { - status = hostLang.statusList[row.data.status]; - result[0] = {html: status}; - } - else - { - status = zahostLang.statusList[row.data.status]; - let html = "" + status + ""; - if(row.data.status === 'wait') html = "" + status + ""; - result[0] = {html: html}; - - } + if(osName) result[0] = {html: hostLang[osName + 'List'][osVersion]}; return result; } diff --git a/module/host/js/create.ui.js b/module/host/js/create.ui.js index 09271d43ec..44a291ffdb 100644 --- a/module/host/js/create.ui.js +++ b/module/host/js/create.ui.js @@ -1,18 +1,4 @@ -var params = 'osName={osName}&hostType={hostType}&isTestNode={isTestNode}'; window.osChange = function(e) { - var currentParam = params.replace('{osName}', e.target.value).replace('{hostType}', hostType).replace('{isTestNode}', isTestNode); - loadPage($.createLink('host', 'create', currentParam), '#osVersion'); -} -window.hostTypeChange = function(e) -{ - var currentParam = params.replace('{osName}', osName).replace('{hostType}', e.target.value).replace('{isTestNode}', isTestNode); - loadPage($.createLink('host', 'create', currentParam), '#testType'); -} - -window.isTestNodeChange = function(e) -{ - const checked = $('#isTestNode').prop('checked'); - var currentParam = params.replace('{osName}', osName).replace('{hostType}', hostType).replace('{isTestNode}', checked ? 1 : 0); - loadPage($.createLink('host', 'create', currentParam), '#testContainer'); + loadPage($.createLink('host', 'create', 'osName=' + e.target.value), '#osVersion'); } \ No newline at end of file diff --git a/module/host/js/edit.ui.js b/module/host/js/edit.ui.js index 6f7c78171c..894d3eed0d 100644 --- a/module/host/js/edit.ui.js +++ b/module/host/js/edit.ui.js @@ -1,18 +1,4 @@ -var params = 'id=' + host.id + '&osName={osName}&hostType={hostType}&isTestNode={isTestNode}'; window.osChange = function(e) { - var currentParam = params.replace('{osName}', e.target.value).replace('{hostType}', hostType).replace('{isTestNode}', isTestNode); - loadPage($.createLink('host', 'edit', currentParam), '#osVersion'); -} -window.hostTypeChange = function(e) -{ - var currentParam = params.replace('{osName}', osName).replace('{hostType}', e.target.value).replace('{isTestNode}', isTestNode); - loadPage($.createLink('host', 'edit', currentParam), '#testType'); -} - -window.isTestNodeChange = function(e) -{ - const checked = $('#isTestNode_1').prop('checked'); - var currentParam = params.replace('{osName}', osName).replace('{hostType}', hostType).replace('{isTestNode}', checked ? 1 : 0); - loadPage($.createLink('host', 'edit', currentParam), '#testContainer'); -} + loadPage($.createLink('host', 'edit', 'id=' + host.id + '&osName=' + e.target.value), '#osVersion'); +} \ No newline at end of file diff --git a/module/host/lang/de.php b/module/host/lang/de.php index a08967f216..58fd0aa49e 100644 --- a/module/host/lang/de.php +++ b/module/host/lang/de.php @@ -11,7 +11,6 @@ $lang->host->treemap = 'Host Topology'; $lang->host->changeStatus = 'Online/Offline'; $lang->host->byQuery = 'Search'; $lang->host->reason = 'Reason'; -$lang->host->testType = 'Type'; $lang->host->name = 'Name'; $lang->host->type = 'Type'; @@ -29,14 +28,12 @@ $lang->host->cpuCores = 'CPU Cores'; $lang->host->cpuRate = 'CPU Rate'; $lang->host->memory = 'Memory Size'; $lang->host->serverRoom = 'IDC'; -$lang->host->isTestNode = 'Used as test node'; -$lang->host->createdBy = 'CreatedBy'; -$lang->host->createdDate = 'CreatedDate'; -$lang->host->editedBy = 'EditedBy'; -$lang->host->editedDate = 'EditedDate'; -$lang->host->registerDate = 'RegisterDate'; -$lang->host->all = 'All Hosts'; +$lang->host->createdBy = 'CreatedBy'; +$lang->host->createdDate = 'CreatedDate'; +$lang->host->editedBy = 'EditedBy'; +$lang->host->editedDate = 'EditedDate'; +$lang->host->all = 'All Hosts'; $lang->host->empty = 'No Host'; diff --git a/module/host/lang/en.php b/module/host/lang/en.php index a08967f216..58fd0aa49e 100644 --- a/module/host/lang/en.php +++ b/module/host/lang/en.php @@ -11,7 +11,6 @@ $lang->host->treemap = 'Host Topology'; $lang->host->changeStatus = 'Online/Offline'; $lang->host->byQuery = 'Search'; $lang->host->reason = 'Reason'; -$lang->host->testType = 'Type'; $lang->host->name = 'Name'; $lang->host->type = 'Type'; @@ -29,14 +28,12 @@ $lang->host->cpuCores = 'CPU Cores'; $lang->host->cpuRate = 'CPU Rate'; $lang->host->memory = 'Memory Size'; $lang->host->serverRoom = 'IDC'; -$lang->host->isTestNode = 'Used as test node'; -$lang->host->createdBy = 'CreatedBy'; -$lang->host->createdDate = 'CreatedDate'; -$lang->host->editedBy = 'EditedBy'; -$lang->host->editedDate = 'EditedDate'; -$lang->host->registerDate = 'RegisterDate'; -$lang->host->all = 'All Hosts'; +$lang->host->createdBy = 'CreatedBy'; +$lang->host->createdDate = 'CreatedDate'; +$lang->host->editedBy = 'EditedBy'; +$lang->host->editedDate = 'EditedDate'; +$lang->host->all = 'All Hosts'; $lang->host->empty = 'No Host'; diff --git a/module/host/lang/fr.php b/module/host/lang/fr.php index 4ee4f9110c..30216996f3 100644 --- a/module/host/lang/fr.php +++ b/module/host/lang/fr.php @@ -11,7 +11,6 @@ $lang->host->treemap = 'Topologie Serveur'; $lang->host->changeStatus = 'Online/Offline'; $lang->host->byQuery = 'Recherche'; $lang->host->reason = 'Raison'; -$lang->host->testType = 'Type'; $lang->host->name = 'Nom'; $lang->host->type = 'Type'; @@ -29,14 +28,12 @@ $lang->host->cpuCores = 'CPU Cores'; $lang->host->cpuRate = 'CPU Freq.'; $lang->host->memory = 'Capacité Mémoire'; $lang->host->serverRoom = 'IDC'; -$lang->host->isTestNode = 'Used as test node'; -$lang->host->createdBy = 'Créé par'; -$lang->host->createdDate = 'Créé le'; -$lang->host->editedBy = 'Edité par'; -$lang->host->editedDate = 'Edité le'; -$lang->host->registerDate = 'RegisterDate'; -$lang->host->all = 'Tous Serveurs'; +$lang->host->createdBy = 'Créé par'; +$lang->host->createdDate = 'Créé le'; +$lang->host->editedBy = 'Edité par'; +$lang->host->editedDate = 'Edité le'; +$lang->host->all = 'Tous Serveurs'; $lang->host->empty = 'No Host'; diff --git a/module/host/lang/vi.php b/module/host/lang/vi.php index 5c0cd2d50f..c651ab195b 100644 --- a/module/host/lang/vi.php +++ b/module/host/lang/vi.php @@ -11,7 +11,6 @@ $lang->host->treemap = 'Cấu trúc Host'; $lang->host->changeStatus = 'Online/Offline'; $lang->host->byQuery = 'Tìm kiếm'; $lang->host->reason = 'Lý do'; -$lang->host->testType = 'Type'; $lang->host->name = 'Tên'; $lang->host->type = 'Loại'; @@ -29,14 +28,12 @@ $lang->host->cpuCores = 'CPU Cores'; $lang->host->cpuRate = 'CPU Rate'; $lang->host->memory = 'Memory Size'; $lang->host->serverRoom = 'IDC'; -$lang->host->isTestNode = 'Used as test node'; -$lang->host->createdBy = 'Người tạo'; -$lang->host->createdDate = 'Ngày tạo'; -$lang->host->editedBy = 'Người sửa'; -$lang->host->editedDate = 'Ngày sửa'; -$lang->host->registerDate = 'RegisterDate'; -$lang->host->all = 'Tất cả Hosts'; +$lang->host->createdBy = 'Người tạo'; +$lang->host->createdDate = 'Ngày tạo'; +$lang->host->editedBy = 'Người sửa'; +$lang->host->editedDate = 'Ngày sửa'; +$lang->host->all = 'Tất cả Hosts'; $lang->host->groupMaintenance = 'Quản lý Group'; diff --git a/module/host/lang/zh-cn.php b/module/host/lang/zh-cn.php index 688bcbcb8e..d55d9bee85 100644 --- a/module/host/lang/zh-cn.php +++ b/module/host/lang/zh-cn.php @@ -11,7 +11,6 @@ $lang->host->treemap = '主机拓扑图'; $lang->host->changeStatus = '上架/下架'; $lang->host->byQuery = '搜索'; $lang->host->reason = '原因'; -$lang->host->testType = '方式'; $lang->host->name = '名称'; $lang->host->type = '类型'; @@ -29,14 +28,12 @@ $lang->host->cpuCores = '单CPU核心数'; $lang->host->cpuRate = 'CPU频率'; $lang->host->memory = '内存大小'; $lang->host->serverRoom = '机房'; -$lang->host->isTestNode = '用于自动化测试'; -$lang->host->createdBy = '由谁创建'; -$lang->host->createdDate = '创建时间'; -$lang->host->editedBy = '由谁编辑'; -$lang->host->editedDate = '编辑时间'; -$lang->host->registerDate = '最后注册时间'; -$lang->host->all = '全部主机'; +$lang->host->createdBy = '由谁创建'; +$lang->host->createdDate = '创建时间'; +$lang->host->editedBy = '由谁编辑'; +$lang->host->editedDate = '编辑时间'; +$lang->host->all = '全部主机'; $lang->host->empty = '暂时没有主机'; @@ -47,9 +44,6 @@ $lang->host->statusList['online'] = '已上架'; $lang->host->statusList['busy'] = '已超载'; $lang->host->statusList['offline'] = '已下架'; -$lang->host->testTypes['node'] = '使用主机执行测试'; -$lang->host->testTypes['kvm'] = '使用主机生成的虚拟机执行测试'; - $lang->host->online = '上架'; $lang->host->busy = '超载'; $lang->host->offline = '下架'; diff --git a/module/host/lang/zh-tw.php b/module/host/lang/zh-tw.php index 7b1dfe50c7..076f77df46 100644 --- a/module/host/lang/zh-tw.php +++ b/module/host/lang/zh-tw.php @@ -9,7 +9,6 @@ $lang->host->treemap = '拓撲圖'; $lang->host->changeStatus = '上架/下架'; $lang->host->byQuery = '搜索'; $lang->host->reason = '原因'; -$lang->host->testType = '方式'; $lang->host->name = '名稱'; $lang->host->type = '類型'; @@ -25,14 +24,12 @@ $lang->host->cpuCores = '單CPU核心數'; $lang->host->cpuRate = 'CPU頻率'; $lang->host->memory = '內存大小'; $lang->host->serverRoom = '機房'; -$lang->host->isTestNode = '用於自動化測試'; -$lang->host->createdBy = '由誰創建'; -$lang->host->createdDate = '創建時間'; -$lang->host->editedBy = '由誰編輯'; -$lang->host->editedDate = '編輯時間'; -$lang->host->registerDate = '最後注冊時間'; -$lang->host->all = '所有主機'; +$lang->host->createdBy = '由誰創建'; +$lang->host->createdDate = '創建時間'; +$lang->host->editedBy = '由誰編輯'; +$lang->host->editedDate = '編輯時間'; +$lang->host->all = '所有主機'; $lang->host->groupMaintenance = '分組維護'; diff --git a/module/host/model.php b/module/host/model.php index 295d8aec2c..d28d159ef4 100644 --- a/module/host/model.php +++ b/module/host/model.php @@ -24,22 +24,6 @@ class hostModel extends model ->where('id')->eq($id) ->fetch(); - if($host->testType === 'kvm') - { - $host->heartbeat = empty($host->heartbeat) ? '' : $host->heartbeat; - - if(time() - strtotime($host->heartbeat) > 60 && $host->status == 'online') - { - $host->status = 'offline'; - } - } - elseif($host->testType === 'node') - { - if(time() - strtotime($host->heartbeat) > 60) - { - $host->status = 'offline'; - } - } return $host; } @@ -77,7 +61,7 @@ class hostModel extends model /* Concatenate the conditions for the query. */ if($param) { - $query = $this->loadModel('search')->getZinQuery($param); + $query = $this->loadModel('search')->getQuery($param); if($query) { $this->session->set('hostQuery', $query->sql); @@ -100,35 +84,15 @@ class hostModel extends model } $orderBy = str_replace($orderBy, 't1.', ''); - $hostList = $this->dao->select('*,id as hostID')->from(TABLE_HOST) + $host = $this->dao->select('*,id as hostID')->from(TABLE_HOST) ->where('deleted')->eq('0') - ->andWhere('type')->in('normal,zahost') + ->andWhere('type')->eq('normal') ->beginIF($modules)->andWhere('`group`')->in($modules)->fi() ->beginIF($query)->andWhere($query)->fi() ->orderBy($orderBy) ->page($pager) ->fetchAll(); - - foreach($hostList as $host) - { - - $host->heartbeat = empty($host->heartbeat) ? '' : $host->heartbeat; - if($host->testType === 'kvm') - { - if(time() - strtotime($host->heartbeat) > 60 && $host->status == 'online') - { - $host->status = 'offline'; - } - } - elseif($host->testType === 'node') - { - if(time() - strtotime($host->heartbeat) > 60) - { - $host->status = 'offline'; - } - } - } - return $hostList; + return $host; } /** @@ -146,7 +110,7 @@ class hostModel extends model return $this->dao->select('id,name')->from(TABLE_HOST) ->where('deleted')->eq('0') ->andWhere('`id`')->in($hostIdList) - ->andWhere('type')->in('normal,zahost') + ->andWhere('type')->eq('normal') ->orderBy('`group`') ->fetchPairs('id', 'name'); } @@ -174,7 +138,7 @@ class hostModel extends model return $this->dao->select("id,name")->from(TABLE_HOST) ->where('deleted')->eq('0') - ->andWhere('type')->in('normal,zahost') + ->andWhere('type')->eq('normal') ->beginIF($modules)->andWhere('`group`')->in($modules)->fi() ->orderBy('`group`') ->fetchPairs('id', 'name'); @@ -191,33 +155,11 @@ class hostModel extends model $hostInfo = fixer::input('post') ->setDefault('hardwareType', 'server') ->setDefault('cpuNumber,cpuCores,diskSize,memory', 0) - ->trim('extranet') ->get(); - if(isset($hostInfo->isTestNode)) - { - $hostInfo->product = empty($hostInfo->product) ? '' : ',' . implode(',', $hostInfo->product) . ','; - if($hostInfo->testType === 'kvm') - { - $hostInfo->status = 'wait'; - $hostInfo->zap = $this->config->zahost->defaultPort; - $hostInfo->secret = md5($hostInfo->name . time()); - } - } - else - { - $hostInfo->product = ''; - $hostInfo->testType = ''; - } - - unset($hostInfo->isTestNode); - - $hostInfo->admin = intval($hostInfo->admin); - $hostInfo->serverRoom = intval($hostInfo->serverRoom); $this->dao->update(TABLE_HOST)->data($hostInfo) ->batchCheck($this->config->host->create->requiredFields, 'notempty') - ->batchCheck('diskSize,memory', 'float') - ->check('name', 'unique', "type='normal'"); + ->batchCheck('diskSize,memory', 'float'); if(dao::isError()) return false; $intFields = explode(',', $this->config->host->create->intFields); @@ -248,7 +190,7 @@ class hostModel extends model { $hostID = $this->dao->lastInsertID(); $this->loadModel('action')->create('host', $hostID, 'created'); - return $hostID; + return true; } return false; @@ -270,29 +212,12 @@ class hostModel extends model ->setDefault('cpuNumber,cpuCores,diskSize,memory', 0) ->get(); - if(isset($hostInfo->isTestNode)) - { - $hostInfo->product = empty($hostInfo->product) ? '' : ',' . implode(',', $hostInfo->product) . ','; - if($hostInfo->testType === 'kvm') - { - $hostInfo->status = 'wait'; - $hostInfo->zap = $this->config->zahost->defaultPort; - $hostInfo->secret = md5($hostInfo->name . time()); - } - } - else - { - $hostInfo->product = ''; - $hostInfo->testType = ''; - } - unset($hostInfo->isTestNode); $hostInfo->admin = intval($hostInfo->admin); $hostInfo->serverRoom = intval($hostInfo->serverRoom); $this->dao->update(TABLE_HOST)->data($hostInfo) ->batchCheck($this->config->host->create->requiredFields, 'notempty') - ->batchCheck('diskSize,memory', 'float') - ->check('name', 'unique', "id != $id and type='normal'"); + ->batchCheck('diskSize,memory', 'float'); if(dao::isError()) return false; $intFields = explode(',', $this->config->host->create->intFields); @@ -314,7 +239,7 @@ class hostModel extends model return false; } } - $hostInfo->type = 'normal'; + $hostInfo->editedBy = $this->app->user->account; $hostInfo->editedDate = helper::now(); $this->dao->update(TABLE_HOST)->data($hostInfo)->autoCheck()->where('id')->eq($id)->exec(); @@ -347,7 +272,7 @@ class hostModel extends model $stmt = $this->dao->select('t1.id,t1.name,t3.id as roomID,t3.city,t3.name as roomName,t1.extranet')->from(TABLE_HOST)->alias('t1') ->leftJoin(TABLE_SERVERROOM)->alias('t3')->on('t1.serverRoom=t3.id') ->where('t1.deleted')->eq(0) - ->andWhere('t1.type')->in('normal,zahost') + ->andWhere('t1.type')->eq('normal') ->andWhere('t3.deleted')->eq(0) ->andWhere('t1.serverRoom')->ne(0) ->orderBy('t3.city,t3.id,t1.id') @@ -407,7 +332,7 @@ class hostModel extends model $this->app->loadLang('serverroom'); $hostGroups = $this->dao->select('id,name,`group`,extranet')->from(TABLE_HOST) ->where('deleted')->eq(0) - ->andWhere('type')->in('normal,zahost') + ->andWhere('type')->eq('normal') ->fetchGroup('group', 'id'); /* Get module list by host group. */ @@ -475,70 +400,11 @@ class hostModel extends model public static function isClickable($host, $action) { if(!$host->id) return false; - if (in_array($action, array('online', 'offline')) && !common::hasPriv('host', 'changeStatus')) return false; - if (in_array($action, array('online', 'offline')) && $host->testType !== '') return false; + if (!common::hasPriv('host', 'changeStatus')) return false; if($host->status == 'online' && $action == 'online') return false; if($host->status == 'offline' && $action == 'offline') return false; - if($action === 'download') - { - if(in_array($host->status, array("completed", "inprogress", "created")) || $host->from == 'user') return false; - } - - if($action === 'cancel') - { - if(!in_array($host->status, array("inprogress", "created"))) return false; - } - return true; } - - /** - * Get image files from ZAgent server. - * - * @param object $hostID - * @access public - * @return array - */ - public function getImageList($hostID, $browseType = 'all', $param = 0, $orderBy = 'id', $pager = null) - { - $imageList = json_decode(commonModel::http($this->config->host->imageListUrl, array(), array())); - if(empty($imageList)) return array(); - - $downloadedImageList = $this->dao->select('*')->from(TABLE_IMAGE) - ->where('host')->eq($hostID) - ->orderBy($orderBy) - ->page($pager) - ->fetchAll('name'); - - $refreshPageData = false; - foreach($imageList as $remoteImage) - { - $downloadedImage = zget($downloadedImageList, $remoteImage->name, ''); - if(empty($downloadedImage)) - { - $refreshPageData = true; - $remoteImage->status = 'notDownloaded'; - $remoteImage->from = 'zentao'; - $remoteImage->osName = $remoteImage->os; - $remoteImage->host = $hostID; - $remoteImage->status = 'notDownloaded'; - - unset($remoteImage->os); - $this->dao->insert(TABLE_IMAGE)->data($remoteImage, 'desc')->autoCheck()->exec(); - } - } - - if($refreshPageData) - { - $downloadedImageList = $this->dao->select('*')->from(TABLE_IMAGE) - ->where('host')->eq($hostID) - ->orderBy($orderBy) - ->page($pager) - ->fetchAll('name'); - } - - return $downloadedImageList; - } } diff --git a/module/host/ui/browse.html.php b/module/host/ui/browse.html.php index 4520ea22d3..469637d38b 100644 --- a/module/host/ui/browse.html.php +++ b/module/host/ui/browse.html.php @@ -12,9 +12,8 @@ declare(strict_types=1); namespace zin; -jsVar('orderBy', $orderBy); -jsVar('hostLang', $lang->host); -jsVar('zahostLang', $lang->zahost); +jsVar('orderBy', $orderBy); +jsVar('hostLang', $lang->host); jsVar('sortLink', helper::createLink('host', 'browse', "browseType=$browseType¶m=$param&orderBy={orderBy}&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}")); $config->host->featureBar[0]['active'] = true; diff --git a/module/host/ui/create.html.php b/module/host/ui/create.html.php index e892114b83..7fb8edb3f7 100644 --- a/module/host/ui/create.html.php +++ b/module/host/ui/create.html.php @@ -12,10 +12,6 @@ declare(strict_types=1); namespace zin; -jsVar('osName', $osName); -jsVar('hostType', $hostType); -jsVar('isTestNode', $isTestNode); - formPanel ( set::id('hostCreateForm'), @@ -130,8 +126,7 @@ formPanel set::control('picker'), set::name('hostType'), set::items($lang->host->hostTypeList), - set::value($hostType), - on::change('hostTypeChange'), + set::value('virtual') ) ), formRow @@ -151,7 +146,6 @@ formPanel set::width('1/3'), set::label($lang->host->osVersion), set::control('picker'), - set::required(true), set::name('osVersion'), set::items($lang->host->{"{$osName}List"}), ) @@ -161,10 +155,9 @@ formPanel formGroup ( set::width('1/3'), - set::label($lang->host->provider), - set::control('picker'), - set::name('provider'), - set::items($lang->host->providerList), + set::name('zap'), + set::label($lang->host->zap), + set::value(8086), ), formGroup ( @@ -196,10 +189,10 @@ formPanel formGroup ( set::width('1/3'), - set::label($lang->host->isTestNode), - set::control('checkbox'), - set::name('isTestNode'), - on::change('isTestNodeChange'), + set::label($lang->host->provider), + set::control('picker'), + set::name('provider'), + set::items($lang->host->providerList), ), formGroup ( @@ -212,27 +205,4 @@ formPanel set::items($lang->host->statusList), ) ), - formRow - ( - setID('testContainer'), - formGroup - ( - set::width('1/3'), - setClass($isTestNode ? '' : 'hidden'), - set::name("product[]"), - set::label($lang->story->product), - set::control(array("type" => "picker","multiple" => true)), - set::items($products), - ), - formGroup - ( - set::width('1/3'), - setClass($isTestNode ? '' : 'hidden'), - set::name("testType"), - set::required(true), - set::label($lang->host->testType), - set::control('picker'), - set::items($testTypes), - ), - ), ); diff --git a/module/host/ui/edit.html.php b/module/host/ui/edit.html.php index adc61d77fe..ae0f9cf7b0 100644 --- a/module/host/ui/edit.html.php +++ b/module/host/ui/edit.html.php @@ -13,9 +13,6 @@ declare(strict_types=1); namespace zin; jsVar('host', $host); -jsVar('osName', $osName); -jsVar('hostType', $hostType); -jsVar('isTestNode', $isTestNode); formPanel ( @@ -163,7 +160,7 @@ formPanel set::label($lang->host->osVersion), set::control('picker'), set::name('osVersion'), - set::items(empty($osName) ? array() : $lang->host->{"{$osName}List"}), + set::items($lang->host->{"{$osName}List"}), set::value($host->osVersion) ) ), @@ -172,11 +169,9 @@ formPanel formGroup ( set::width('400px'), - set::label($lang->host->provider), - set::control('picker'), - set::name('provider'), - set::items($lang->host->providerList), - set::value($host->provider) + set::name('zap'), + set::label($lang->host->zap), + set::value($host->zap ? $host->zap : 8086), ), formGroup ( @@ -194,7 +189,6 @@ formPanel ( set::width('400px'), set::name('intranet'), - set::readonly($host->testType === 'kvm'), set::label($lang->host->intranet), set::value($host->intranet), ), @@ -202,7 +196,6 @@ formPanel ( set::width('400px'), set::name('extranet'), - set::readonly($host->testType === 'kvm'), set::label($lang->host->extranet), set::value($host->extranet), ) @@ -211,50 +204,22 @@ formPanel ( formGroup ( - set::width('1/3'), - set::label($lang->host->isTestNode), - set::control('checkbox'), - set::name('isTestNode'), - set::disabled($host->testType == 'kvm'), - on::change('isTestNodeChange'), - set::value($host->testType ? '1' : ''), - set::items(array('1' => '')) + set::width('400px'), + set::label($lang->host->provider), + set::control('picker'), + set::name('provider'), + set::items($lang->host->providerList), + set::value($host->provider) ), - $host->testType == 'kvm' ? null : formGroup + formGroup ( - set::width('1/3'), + set::width('400px'), set::name('status'), set::control('radioList'), set::label($lang->host->status), - set::value('online'), + set::value($host->status ? $host->status : 'online'), set::inline(true), set::items($lang->host->statusList), ) ), - formRow - ( - setID('testContainer'), - formGroup - ( - set::width('1/3'), - setClass($isTestNode ? '' : 'hidden'), - set::name("product[]"), - set::label($lang->story->product), - set::control(array("type" => "picker","multiple" => true)), - set::items($products), - set::value(trim($host->product, ',')), - ), - formGroup - ( - set::width('1/3'), - setClass($isTestNode ? '' : 'hidden'), - set::name("testType"), - set::required(true), - set::label($lang->host->testType), - set::control('picker'), - set::items($testTypes), - set::disabled($host->testType == 'kvm'), - set::value($host->testType), - ), - ), );