diff --git a/api/v1/entries/executionnodeheartbeat.php b/api/v1/entries/zanodeheartbeat.php similarity index 100% rename from api/v1/entries/executionnodeheartbeat.php rename to api/v1/entries/zanodeheartbeat.php diff --git a/module/zahost/control.php b/module/zahost/control.php index e0fdcc5777..3dccaf2244 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -286,7 +286,7 @@ class zahost extends control */ public function initHost($hostID) { - $this->view->title = $this->lang->zahost->vmTemplate->common; + $this->view->title = $this->lang->zahost->init; $this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted'); $this->view->hostID = $hostID; diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index 9f8dbd0db6..c026a88c61 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -4,6 +4,7 @@ $lang->zahost->common = 'ZAhost'; $lang->zahost->browse = 'Host List'; $lang->zahost->create = 'Add Host'; $lang->zahost->view = 'Host View'; +$lang->zahost->init = 'Init Host'; $lang->zahost->edit = 'Edit'; $lang->zahost->editAction = 'Edit Host'; $lang->zahost->delete = 'Delete'; @@ -11,10 +12,11 @@ $lang->zahost->deleteAction = 'Delete Host'; $lang->zahost->byQuery = 'Search'; $lang->zahost->all = 'All'; $lang->zahost->browseNode = 'ZAnode Browse'; +$lang->zahost->deleted = "Deleted"; $lang->zahost->name = 'Name'; -$lang->zahost->IP = 'IP/Domain'; -$lang->zahost->extranet = 'IP'; +$lang->zahost->IP = 'Extranet Address'; +$lang->zahost->extranet = 'Extranet Address'; $lang->zahost->cpuCores = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; $lang->zahost->diskSize = 'diskSize Size'; @@ -30,7 +32,9 @@ $lang->zahost->registerDate = 'RegisterDate'; $lang->zahost->memorySize = $lang->zahost->memory; $lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; +$lang->zahost->osType = 'Os Version'; $lang->zahost->os = 'System'; +$lang->zahost->osVersion = 'Os Version No'; $lang->zahost->osLang = 'Language'; $lang->zahost->imageName = 'Image File'; @@ -69,7 +73,7 @@ $lang->zahost->image->name = 'Name'; $lang->zahost->image->desc = 'Description'; $lang->zahost->image->memory = $lang->zahost->memory; $lang->zahost->image->disk = $lang->zahost->diskSize; -$lang->zahost->image->os = $lang->zahost->osCategory; +$lang->zahost->image->os = $lang->zahost->os; $lang->zahost->image->imageName = $lang->zahost->imageName; $lang->zahost->image->statusList['created'] = 'Created'; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index 6d4be82372..9b26af35ed 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -4,6 +4,7 @@ $lang->zahost->common = 'ZAhost'; $lang->zahost->browse = 'Host List'; $lang->zahost->create = 'Add Host'; $lang->zahost->view = 'Host View'; +$lang->zahost->init = 'Init Host'; $lang->zahost->edit = 'Edit'; $lang->zahost->editAction = 'Edit Host'; $lang->zahost->delete = 'Delete'; @@ -11,6 +12,7 @@ $lang->zahost->deleteAction = 'Delete Host'; $lang->zahost->byQuery = 'Search'; $lang->zahost->all = 'All'; $lang->zahost->browseNode = 'ZAnode Browse'; +$lang->zahost->deleted = "Deleted"; $lang->zahost->name = 'Name'; $lang->zahost->IP = 'Extranet Address'; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index ee7458fd37..4b8fcc48da 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -4,6 +4,7 @@ $lang->zahost->common = 'ZAhost'; $lang->zahost->browse = 'Hôte Liste'; $lang->zahost->create = 'Ajouter Hôte'; $lang->zahost->view = 'Hôte Détail'; +$lang->zahost->init = 'Init Host'; $lang->zahost->edit = 'Éditer'; $lang->zahost->editAction = 'Éditer Hôte'; $lang->zahost->delete = 'Supprimer'; diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php index 96797f4e76..c026a88c61 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -4,6 +4,7 @@ $lang->zahost->common = 'ZAhost'; $lang->zahost->browse = 'Host List'; $lang->zahost->create = 'Add Host'; $lang->zahost->view = 'Host View'; +$lang->zahost->init = 'Init Host'; $lang->zahost->edit = 'Edit'; $lang->zahost->editAction = 'Edit Host'; $lang->zahost->delete = 'Delete'; @@ -11,10 +12,11 @@ $lang->zahost->deleteAction = 'Delete Host'; $lang->zahost->byQuery = 'Search'; $lang->zahost->all = 'All'; $lang->zahost->browseNode = 'ZAnode Browse'; +$lang->zahost->deleted = "Deleted"; $lang->zahost->name = 'Name'; -$lang->zahost->IP = 'IP/Domain'; -$lang->zahost->extranet = 'IP'; +$lang->zahost->IP = 'Extranet Address'; +$lang->zahost->extranet = 'Extranet Address'; $lang->zahost->cpuCores = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; $lang->zahost->diskSize = 'diskSize Size'; @@ -71,10 +73,7 @@ $lang->zahost->image->name = 'Name'; $lang->zahost->image->desc = 'Description'; $lang->zahost->image->memory = $lang->zahost->memory; $lang->zahost->image->disk = $lang->zahost->diskSize; -$lang->zahost->image->osType = $lang->zahost->osType; $lang->zahost->image->os = $lang->zahost->os; -$lang->zahost->image->osVersion = $lang->zahost->osVersion; -$lang->zahost->image->osLang = $lang->zahost->osLang; $lang->zahost->image->imageName = $lang->zahost->imageName; $lang->zahost->image->statusList['created'] = 'Created'; diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index 723b45d945..4423563212 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -5,6 +5,7 @@ $lang->zahost->common = '宿主机'; $lang->zahost->browse = '宿主机列表'; $lang->zahost->create = '添加宿主机'; $lang->zahost->view = '宿主机详情'; +$lang->zahost->init = '初始化宿主机'; $lang->zahost->edit = '编辑'; $lang->zahost->editAction = '编辑宿主机'; $lang->zahost->delete = '删除'; @@ -12,6 +13,7 @@ $lang->zahost->deleteAction = '删除宿主机'; $lang->zahost->byQuery = '搜索'; $lang->zahost->all = '全部主机'; $lang->zahost->browseNode = '执行节点列表'; +$lang->zahost->deleted = "已删除"; $lang->zahost->name = '名称'; $lang->zahost->IP = 'IP/域名'; diff --git a/module/zanode/config.php b/module/zanode/config.php index d156d0e8ec..8005b689a2 100644 --- a/module/zanode/config.php +++ b/module/zanode/config.php @@ -1,7 +1,7 @@ zanode->create = new stdClass(); $config->zanode->edit = new stdClass(); -$config->zanode->create->requiredFields = 'name,host,image,cpu,memory,disk,os'; +$config->zanode->create->requiredFields = 'name,host,image,cpu,memory,disk,osName'; $config->zanode->edit->requiredFields = ''; $config->zanode->defaultPort = '8086'; diff --git a/module/zanode/control.php b/module/zanode/control.php index bc06e56a26..6424c049c9 100644 --- a/module/zanode/control.php +++ b/module/zanode/control.php @@ -77,6 +77,37 @@ class zanode extends control return $this->display(); } + /** + * Edit node. + * + * @param int $hostID + * @access public + * @return void + */ + public function edit($id) + { + if($_POST) + { + $changes = $this->zanode->update($id); + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); + + if($changes) + { + $actionID = $this->loadModel('action')->create('zanode', $id, 'Edited'); + if(!empty($changes)) $this->action->logHistory($actionID, $changes); + } + + if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent')); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse'))); + } + + $this->view->title = $this->lang->zanode->editAction; + $this->view->zanode = $this->zanode->getNodeByID($id); + $this->view->host = $this->zanode->getHostByID($this->view->zanode->parent); + $this->view->image = $this->zanode->getImageByID($this->view->zanode->image); + $this->display(); + } + /** * View Node. * @@ -90,7 +121,6 @@ class zanode extends control $this->view->zanode = $this->zanode->getNodeByID($id); $this->view->actions = $this->loadModel('action')->getList('zanode', $id); $this->view->users = $this->loadModel('user')->getPairs('noletter'); - $this->display(); } @@ -157,19 +187,26 @@ class zanode extends control * @param int $nodeID * @return void */ - public function destroy($nodeID) + public function delete($nodeID, $confirm = 'no') { - $error = $this->zanode->destroy($nodeID); - - if($error) + if($confirm == 'no') { - return print(js::alert($error)); + return print(js::confirm($this->lang->zanode->confirmDelete, inlink('delete', "nodeID=$nodeID&confirm=yes"))); } else { - if(isonlybody()) return print(js::alert($this->lang->zanode->actionSuccess) . js::reload('parent.parent')); - return print(js::alert($this->lang->zanode->actionSuccess) . js::reload('parent')); - } + $error = $this->zanode->destroy($nodeID); + + if($error) + { + return print(js::alert($error)); + } + else + { + if(isonlybody()) return print(js::alert($this->lang->zanode->actionSuccess) . js::reload('parent.parent')); + return print(js::alert($this->lang->zanode->actionSuccess) . js::reload('parent')); + } + } } /** diff --git a/module/zanode/js/common.js b/module/zanode/js/common.js index 5b47861cd4..1243c6aa28 100644 --- a/module/zanode/js/common.js +++ b/module/zanode/js/common.js @@ -4,14 +4,16 @@ $(function() $('#parent').change(function() { - var hostID = $('#parent').val(); - var link = createLink('zanode', 'ajaxGetImages', 'hostID=' + hostID); - $.get(link, function(data) - { - $('#template').html('').append(data); - $('#image').chosen().trigger("chosen:updated"); - $('#image').change(); - }); + if(config.currentMethod == 'create'){ + var hostID = $('#parent').val(); + var link = createLink('zanode', 'ajaxGetImages', 'hostID=' + hostID); + $.get(link, function(data) + { + $('#template').html('').append(data); + $('#image').chosen().trigger("chosen:updated"); + $('#image').change(); + }); + } }); $(document).on("change", '#image', function() diff --git a/module/zanode/lang/de.php b/module/zanode/lang/de.php index bc35f47ab6..bbefb5c016 100644 --- a/module/zanode/lang/de.php +++ b/module/zanode/lang/de.php @@ -2,6 +2,7 @@ $lang->zanode->common = 'Execution Node'; $lang->zanode->browse = 'Execution Node List'; $lang->zanode->create = 'Create Execution Node'; +$lang->zanode->editAction = 'Edit Execution Node'; $lang->zanode->view = 'View Execution Node'; $lang->zanode->suspend = 'Suspend Execution Node'; $lang->zanode->destroy = 'Destroy Execution Node'; @@ -21,7 +22,7 @@ $lang->zanode->hostName = 'Host Name'; $lang->zanode->host = $lang->zanode->hostName; $lang->zanode->extranet = 'IP/Domain'; $lang->zanode->osArch = 'Arch'; -$lang->zanode->cpuCores = 'CPU Cores'; +$lang->zanode->cpuCores = 'CPU Cores'; $lang->zanode->memory = 'Memory Size'; $lang->zanode->desc = 'Description'; $lang->zanode->diskSize = 'Disk Size'; @@ -38,6 +39,7 @@ $lang->zanode->confirmShutdown = "Are you sure to shutdown the execution node? $lang->zanode->confirmSuspend = "Are you sure to suspend the execution node?"; $lang->zanode->confirmResume = "Are you sure to resume the execution node?"; $lang->zanode->actionSuccess = 'Success'; +$lang->zanode->deleted = "Deleted"; $lang->zanode->notFoundAgent = 'No Agent service is found'; $lang->zanode->createVmFail = 'Failed to create a execution node'; diff --git a/module/zanode/lang/en.php b/module/zanode/lang/en.php index 610d8d5581..bbefb5c016 100644 --- a/module/zanode/lang/en.php +++ b/module/zanode/lang/en.php @@ -2,6 +2,7 @@ $lang->zanode->common = 'Execution Node'; $lang->zanode->browse = 'Execution Node List'; $lang->zanode->create = 'Create Execution Node'; +$lang->zanode->editAction = 'Edit Execution Node'; $lang->zanode->view = 'View Execution Node'; $lang->zanode->suspend = 'Suspend Execution Node'; $lang->zanode->destroy = 'Destroy Execution Node'; @@ -38,6 +39,7 @@ $lang->zanode->confirmShutdown = "Are you sure to shutdown the execution node? $lang->zanode->confirmSuspend = "Are you sure to suspend the execution node?"; $lang->zanode->confirmResume = "Are you sure to resume the execution node?"; $lang->zanode->actionSuccess = 'Success'; +$lang->zanode->deleted = "Deleted"; $lang->zanode->notFoundAgent = 'No Agent service is found'; $lang->zanode->createVmFail = 'Failed to create a execution node'; diff --git a/module/zanode/lang/fr.php b/module/zanode/lang/fr.php index bc35f47ab6..bbefb5c016 100644 --- a/module/zanode/lang/fr.php +++ b/module/zanode/lang/fr.php @@ -2,6 +2,7 @@ $lang->zanode->common = 'Execution Node'; $lang->zanode->browse = 'Execution Node List'; $lang->zanode->create = 'Create Execution Node'; +$lang->zanode->editAction = 'Edit Execution Node'; $lang->zanode->view = 'View Execution Node'; $lang->zanode->suspend = 'Suspend Execution Node'; $lang->zanode->destroy = 'Destroy Execution Node'; @@ -21,7 +22,7 @@ $lang->zanode->hostName = 'Host Name'; $lang->zanode->host = $lang->zanode->hostName; $lang->zanode->extranet = 'IP/Domain'; $lang->zanode->osArch = 'Arch'; -$lang->zanode->cpuCores = 'CPU Cores'; +$lang->zanode->cpuCores = 'CPU Cores'; $lang->zanode->memory = 'Memory Size'; $lang->zanode->desc = 'Description'; $lang->zanode->diskSize = 'Disk Size'; @@ -38,6 +39,7 @@ $lang->zanode->confirmShutdown = "Are you sure to shutdown the execution node? $lang->zanode->confirmSuspend = "Are you sure to suspend the execution node?"; $lang->zanode->confirmResume = "Are you sure to resume the execution node?"; $lang->zanode->actionSuccess = 'Success'; +$lang->zanode->deleted = "Deleted"; $lang->zanode->notFoundAgent = 'No Agent service is found'; $lang->zanode->createVmFail = 'Failed to create a execution node'; diff --git a/module/zanode/lang/zh-cn.php b/module/zanode/lang/zh-cn.php index 84879d7768..1e1b81b5d6 100644 --- a/module/zanode/lang/zh-cn.php +++ b/module/zanode/lang/zh-cn.php @@ -2,6 +2,7 @@ $lang->zanode->common = '执行节点'; $lang->zanode->browse = '执行节点列表'; $lang->zanode->create = '创建执行节点'; +$lang->zanode->editAction = '编辑执行节点'; $lang->zanode->view = '执行节点详情'; $lang->zanode->suspend = '暂停执行节点'; $lang->zanode->destroy = '销毁执行节点'; @@ -38,6 +39,7 @@ $lang->zanode->confirmShutdown = "您确定关闭执行节点吗?"; $lang->zanode->confirmSuspend = "您确定暂停执行节点吗?"; $lang->zanode->confirmResume = "您确定恢复执行节点吗?"; $lang->zanode->actionSuccess = '操作成功'; +$lang->zanode->deleted = "已删除"; $lang->zanode->notFoundAgent = '没有发现Agent服务'; $lang->zanode->createVmFail = '创建执行节点失败'; diff --git a/module/zanode/model.php b/module/zanode/model.php index 584aa93fda..959ed9a649 100644 --- a/module/zanode/model.php +++ b/module/zanode/model.php @@ -214,17 +214,25 @@ class zanodemodel extends model } /** - * Update Node attribute. + * Update Node. * * @param int $id - * @param array $data * @return void */ - public function update($id, $data) + public function update($id) { - $this->dao->update(TABLE_ZAHOST)->data($data) - ->where('id')->eq($id) - ->exec(); + $oldHost = $this->getNodeById($id); + $hostInfo = fixer::input('post')->get(); + $hostInfo->editedBy = $this->app->user->account; + $hostInfo->editedDate = helper::now(); + + $this->dao->update(TABLE_ZAHOST)->data($hostInfo) + ->batchCheck($this->config->zanode->edit->requiredFields, 'notempty'); + if(dao::isError()) return false; + + $this->dao->update(TABLE_ZAHOST)->data($hostInfo)->autoCheck() + ->where('id')->eq($id)->exec(); + return common::createChanges($oldHost, $hostInfo); } /** @@ -433,7 +441,7 @@ class zanodemodel extends model $returnData = new stdClass(); $returnData->hostIP = $host->extranet; $returnData->agentPort = $host->agentPort; - $returnData->vnc = $vm->vnc; + $returnData->vnc = $vm->vnc; $returnData->token = $result->data->token; return $returnData; } diff --git a/module/zanode/view/browse.html.php b/module/zanode/view/browse.html.php index 3138ea4ec2..72ec091362 100644 --- a/module/zanode/view/browse.html.php +++ b/module/zanode/view/browse.html.php @@ -57,7 +57,7 @@