diff --git a/api/v1/entries/hostheartbeat.php b/api/v1/entries/hostheartbeat.php
index 1d54b4c9c2..16946fb0f7 100644
--- a/api/v1/entries/hostheartbeat.php
+++ b/api/v1/entries/hostheartbeat.php
@@ -28,8 +28,8 @@ class hostHeartbeatEntry extends baseEntry
/* Check param. */
$status = $this->requestBody->status;
- $vms = $this->requestBody->Vms;
- $zap = $this->requestBody->port;
+ $vms = !empty($this->requestBody->Vms) ? $this->requestBody->Vms : array();
+ $zap = !empty($this->requestBody->port) ? $this->requestBody->port : 0;
$now = helper::now();
if(!$status) return $this->sendError(400, 'Params error.');
@@ -37,7 +37,7 @@ class hostHeartbeatEntry extends baseEntry
$conditionValue = $secret ? $secret : $token;
$this->dao = $this->loadModel('common')->dao;
- $hostInfo = $this->dao->select('id,tokenSN')->from(TABLE_ZAHOST)
+ $hostInfo = $this->dao->select('id,tokenSN,hostType')->from(TABLE_ZAHOST)
->beginIF($secret)->where('secret')->eq($secret)->fi()
->beginIF(!$secret)->where('tokenSN')->eq($token)
->andWhere('tokenTime')->gt($now)->fi()
@@ -83,11 +83,18 @@ class hostHeartbeatEntry extends baseEntry
if($heartbeat > 0) $vmData['heartbeat'] = date("Y-m-d H:i:s", $heartbeat);
- $this->dao->update(TABLE_ZAHOST)->data($vmData)->where('mac')->eq($vm->macAddress)->exec();
-
- if($vm->status == 'running')
+ if($hostInfo->hostType == 'physics')
{
- $node = $this->loadModel('zanode')->getNodeByMac($vm->macAddress);
+ $this->dao->update(TABLE_ZAHOST)->data($vmData)->where('id')->eq($hostInfo->id)->exec();
+ }
+ else
+ {
+ $this->dao->update(TABLE_ZAHOST)->data($vmData)->where('mac')->eq($vm->macAddress)->exec();
+ }
+
+ if($vm->status == 'running' && $hostInfo->hostType != 'physics')
+ {
+ $node = $this->loadModel('zanode')->getNodeByMac($vm->macAddress);
if(!empty($node))
{
$snaps = $this->loadModel('zanode')->getSnapshotList($node->id);
diff --git a/module/zanode/config.php b/module/zanode/config.php
index c8a81099d6..cf21004640 100644
--- a/module/zanode/config.php
+++ b/module/zanode/config.php
@@ -12,7 +12,7 @@ $config->zanode->defaultAccount = 'z';
$config->zanode->defaultWinAccount = 'admin';
$config->zanode->defaultPwd = 'CQdliYQn6tKkoFhP';
-$config->zanode->initBash = 'curl -sSL https://pkg.qucheng.com/zenagent/zagent.sh | bash /dev/stdin -szvm -z%s';
+$config->zanode->initBash = 'curl -sSL https://pkg.qucheng.com/zenagent/zagent.sh | bash /dev/stdin -s zvm -k %s -z %s';
$config->zanode->os = new stdClass();
diff --git a/module/zanode/control.php b/module/zanode/control.php
index d10c470029..87ee162afc 100644
--- a/module/zanode/control.php
+++ b/module/zanode/control.php
@@ -161,17 +161,16 @@ class zanode extends control
$node = $this->zanode->getNodeByID($id);
$vnc = $this->zanode->getVncUrl($node);
- /* Add action log. */
- // if(!empty($vnc->token)) $this->loadModel('action')->create('zanode', $id, 'getVNC');
-
- $this->view->url = $node->ip . ":" . $node->hzap;
- $this->view->host = !empty($vnc->hostIP) ? $vnc->hostIP:'';
- $this->view->token = !empty($vnc->token) ? $vnc->token:'';
- $this->view->title = $this->lang->zanode->view;
- $this->view->zanode = $node;
+ $this->view->url = $node->ip . ":" . $node->hzap;
+ $this->view->host = !empty($vnc->hostIP) ? $vnc->hostIP:'';
+ $this->view->token = !empty($vnc->token) ? $vnc->token:'';
+ $this->view->title = $this->lang->zanode->view;
+ $this->view->zanode = $node;
$this->view->snapshotList = $this->zanode->getSnapshotList($id);
- $this->view->actions = $this->loadModel('action')->getList('zanode', $id);
- $this->view->users = $this->loadModel('user')->getPairs('noletter');
+ $this->view->initBash = sprintf($this->config->zanode->initBash, $node->secret, getWebRoot(true));
+ $this->view->actions = $this->loadModel('action')->getList('zanode', $id);
+ $this->view->users = $this->loadModel('user')->getPairs('noletter');
+
$this->display();
}
diff --git a/module/zanode/css/view.css b/module/zanode/css/view.css
index 1c198cb0cf..2861d331c8 100644
--- a/module/zanode/css/view.css
+++ b/module/zanode/css/view.css
@@ -7,10 +7,10 @@
.zanode-mt-8{margin-top: 8px;}
.zanode-status-text{margin-left: 10px;font:small-caption;color:#838a9d;}
.zanode-status-text i{color:#18a6fd}
-.status-notice{margin-top: 8px;margin-left: 18px;line-height: 28px;}
+.status-notice{margin-top: 16px;line-height: 28px;}
.status-notice a{color: #2463c7;}
.service-status a{color: #2463c7;}
-.service-status{margin-top: 10px;}
+.service-status{margin-top: 5px;}
.vnc-detail{height: 60vh;min-height: 550px;}
.vnc-mask{width: 100%;height:100%;background-color: rgba(0,0,0,0);position: absolute;z-index: 1;}
.checkStatus{color: #313c52;}
@@ -19,3 +19,4 @@
.btn.disabled i {color: #fff;}
.btn-toolbar a img{margin-bottom: 1px;}
#serviceContent{min-height: 120px;}
+.zanode-init{padding:15px;background: #f4f5f7;margin:10px 0;}
diff --git a/module/zanode/js/create.js b/module/zanode/js/create.js
index 4fa5ae9c80..153bc3b0d0 100644
--- a/module/zanode/js/create.js
+++ b/module/zanode/js/create.js
@@ -6,7 +6,7 @@
*/
function zanodeType()
{
- if($('#type').val() == 'physics')
+ if($('#hostType').val() == 'physics')
{
$('#parent').closest('tr').hide();
$('#image').closest('tr').hide();
diff --git a/module/zanode/js/view.js b/module/zanode/js/view.js
index d46022f99f..8a3d6c81c5 100644
--- a/module/zanode/js/view.js
+++ b/module/zanode/js/view.js
@@ -88,14 +88,14 @@ function checkServiceStatus(){
if(!isSuccess)
{
- // $('.init-fail').show();
+ $('.init-fail').show();
$('.init-success').hide();
}
else
{
clearInterval(checkInterval)
$('.init-success').show();
- // $('.init-fail').hide();
+ $('.init-fail').hide();
}
setTimeout(function() {
$('#serviceContent').removeClass('loading');
@@ -161,6 +161,28 @@ $('.btn-pwd-copy').live('click', function()
}, 2000)
})
+$('.btn-init-copy').live('click', function()
+{
+ var copyText = $('#initBash');
+ copyText.show();
+ copyText .select();
+ document.execCommand("Copy");
+ copyText.hide();
+ $('.btn-init-copy').tooltip({
+ trigger: 'click',
+ placement: 'top',
+ title: zanodeLang.copied,
+ tipClass: 'tooltip-success'
+ });
+
+ $(this).tooltip('show');
+ var that = this;
+ setTimeout(function()
+ {
+ $(that).tooltip('hide')
+ }, 2000)
+})
+
$('.btn-pwd-show').live('click', function()
{
var pwd = $('#pwd-copy').text();
diff --git a/module/zanode/lang/de.php b/module/zanode/lang/de.php
index 2d269e533c..2af03c56ef 100644
--- a/module/zanode/lang/de.php
+++ b/module/zanode/lang/de.php
@@ -63,6 +63,9 @@ $lang->zanode->manual = 'Manual';
$lang->zanode->initializing = 'Initializing';
$lang->zanode->showPwd = 'Show Password';
$lang->zanode->hidePwd = 'Hide Password';
+$lang->zanode->baseInfo = 'Basic information';
+$lang->zanode->cpuUnit = 'CORE';
+$lang->zanode->IP = 'Extranet Address';
$lang->zanode->typeList['node'] = 'Virtual machine';
$lang->zanode->typeList['physics'] = 'Physical machine';
@@ -149,8 +152,7 @@ $lang->zanode->init->next = "Next";
$lang->zanode->init->button = "Go To Settings";
$lang->zanode->init->initSuccessNoticeTitle = "The service is ready, and it takes two steps to execute the automated test on the execution node:
1. Configure the automated test running environment according to the %s
2. Go to %s";
-$lang->zanode->init->initFailNoticeTitle = "Initialization failed, check the init script execution log and try the following two solutions:";
-$lang->zanode->init->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ";
+$lang->zanode->init->initFailNotice = "Fail,Execute the installation service command on the node or See Help.";
$lang->zanode->init->serviceStatus = array(
"ZenAgent" => 'not_install',
diff --git a/module/zanode/lang/en.php b/module/zanode/lang/en.php
index 996e12770c..0201c94e57 100644
--- a/module/zanode/lang/en.php
+++ b/module/zanode/lang/en.php
@@ -63,6 +63,9 @@ $lang->zanode->manual = 'Manual';
$lang->zanode->initializing = 'Initializing';
$lang->zanode->showPwd = 'Show Password';
$lang->zanode->hidePwd = 'Hide Password';
+$lang->zanode->baseInfo = 'Basic information';
+$lang->zanode->cpuUnit = 'CORE';
+$lang->zanode->IP = 'Extranet Address';
$lang->zanode->typeList['node'] = 'Virtual machine';
$lang->zanode->typeList['physics'] = 'Physical machine';
@@ -149,8 +152,7 @@ $lang->zanode->init->next = "Next";
$lang->zanode->init->button = "Go To Settings";
$lang->zanode->init->initSuccessNoticeTitle = "The service is ready, and it takes two steps to execute the automated test on the execution node:
1. Configure the automated test running environment according to the %s
2. Go to %s";
-$lang->zanode->init->initFailNoticeTitle = "Initialization failed, check the init script execution log and try the following two solutions:";
-$lang->zanode->init->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ";
+$lang->zanode->init->initFailNotice = "Fail,Execute the installation service command on the node or See Help.";
$lang->zanode->init->serviceStatus = array(
"ZenAgent" => 'not_install',
diff --git a/module/zanode/lang/fr.php b/module/zanode/lang/fr.php
index 2d269e533c..91a75a7818 100644
--- a/module/zanode/lang/fr.php
+++ b/module/zanode/lang/fr.php
@@ -63,6 +63,9 @@ $lang->zanode->manual = 'Manual';
$lang->zanode->initializing = 'Initializing';
$lang->zanode->showPwd = 'Show Password';
$lang->zanode->hidePwd = 'Hide Password';
+$lang->zanode->baseInfo = 'Basic information';
+$lang->zanode->cpuUnit = 'CORE';
+$lang->zanode->IP = 'Extranet Address';
$lang->zanode->typeList['node'] = 'Virtual machine';
$lang->zanode->typeList['physics'] = 'Physical machine';
diff --git a/module/zanode/lang/zh-cn.php b/module/zanode/lang/zh-cn.php
index abfcbd593d..74b264d066 100644
--- a/module/zanode/lang/zh-cn.php
+++ b/module/zanode/lang/zh-cn.php
@@ -63,6 +63,9 @@ $lang->zanode->manual = '手册';
$lang->zanode->initializing = '初始化中';
$lang->zanode->showPwd = '显示密码';
$lang->zanode->hidePwd = '隐藏密码';
+$lang->zanode->baseInfo = '基础信息';
+$lang->zanode->cpuUnit = '核';
+$lang->zanode->IP = 'IP/域名';
$lang->zanode->typeList['node'] = '虚拟机';
$lang->zanode->typeList['physics'] = '物理机';
@@ -149,8 +152,7 @@ $lang->zanode->init->next = "下一步";
$lang->zanode->init->button = "去设置";
$lang->zanode->init->initSuccessNoticeTitle = "服务已就绪,还需两步即可在执行节点上执行自动化测试:
1、根据%s配置自动化测试运行环境。
2、进行%s";
-$lang->zanode->init->initFailNoticeTitle = "初始化失败,请查看初始化脚本执行日志并尝试以下两种解决方案:";
-$lang->zanode->init->initFailNoticeDesc = "1、 重新执行脚本
2、 查看初始化常见问题";
+$lang->zanode->init->initFailNotice = "服务未就绪,在执行节点上执行安装服务命令或查看帮助.";
$lang->zanode->init->serviceStatus = array(
"ZenAgent" => 'not_install',
diff --git a/module/zanode/model.php b/module/zanode/model.php
index cd278381fb..4079c65161 100644
--- a/module/zanode/model.php
+++ b/module/zanode/model.php
@@ -54,14 +54,22 @@ class zanodemodel extends model
public function create()
{
$data = fixer::input('post')
- ->setIF($this->post->type == 'physics', 'parent', 0)
- ->setIF($this->post->type == 'physics', 'osName', $this->post->osNamePhysics)
+ ->setIF($this->post->hostType == 'physics', 'parent', 0)
+ ->setIF($this->post->hostType == 'physics', 'osName', $this->post->osNamePhysics)
->remove('osNamePhysics')
->get();
+ $data->type = "node";
+
+ if($data->hostType == 'physics')
+ {
+ $data->secret = md5($data->name . time());
+ $data->status = "offline";
+ }
+
/* Batch check fields. */
$this->dao->update(TABLE_ZAHOST)->data($data)
- ->batchCheck($data->type == 'node' ? $this->config->zanode->create->requiredFields : $this->config->zanode->create->physicsRequiredFields, 'notempty');
+ ->batchCheck($data->hostType != 'physics' ? $this->config->zanode->create->requiredFields : $this->config->zanode->create->physicsRequiredFields, 'notempty');
if(dao::isError()) return false;
@@ -72,10 +80,10 @@ class zanodemodel extends model
}
/* If name already exists return error. */
- $node = $this->dao->select('*')->from(TABLE_ZAHOST)->where('name')->eq($data->name)->andWhere('type')->in('node,physics')->fetch();
+ $node = $this->dao->select('*')->from(TABLE_ZAHOST)->where('name')->eq($data->name)->andWhere('type')->eq('node')->fetch();
if($node) return dao::$errors[] = $this->lang->zanode->nameUnique;
- if($data->type == 'physics')
+ if($data->hostType == 'physics')
{
$ping = $this->loadModel('zahost')->checkAddress($data->extranet);
if(!$ping)
@@ -450,7 +458,7 @@ class zanodemodel extends model
{
$node = $this->getNodeByID($id);
- if($node)
+ if($node && $node->hostType != 'physics')
{
$req = array( 'name' => $node->name );
$agnetUrl = 'http://' . $node->ip . ':' . $node->hzap;
@@ -570,11 +578,11 @@ class zanodemodel extends model
$query = str_replace('`hostID`', 't2.`id`', $query);
}
- $list = $this->dao->select("t1.*, t2.name as hostName, if(t1.type='node', t2.extranet, t1.extranet) extranet,if(t1.type='node', t3.osName, t1.osName) osName")->from(TABLE_ZAHOST)->alias('t1')
+ $list = $this->dao->select("t1.*, t2.name as hostName, if(t1.hostType='', t2.extranet, t1.extranet) extranet,if(t1.hostType='', t3.osName, t1.osName) osName")->from(TABLE_ZAHOST)->alias('t1')
->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t1.parent = t2.id')
->leftJoin(TABLE_IMAGE)->alias('t3')->on('t3.id = t1.image')
->where('t1.deleted')->eq(0)
- ->andWhere("((t1.type = 'node' and t2.type = 'zahost') or t1.type = 'physics')")
+ ->andWhere("t1.type = 'node'")
->beginIF($query)->andWhere($query)->fi()
->orderBy($orderBy)
->page($pager)
@@ -587,7 +595,9 @@ class zanodemodel extends model
foreach($list as $l)
{
- $host = zget($hosts, $l->parent);
+ $host = $l->hostType == '' ? zget($hosts, $l->parent) : clone $l;
+ $host->status = in_array($host->status, array('running', 'ready')) ? "online" : $host->status;
+
if($l->status == 'running' || $l->status == 'ready')
{
if(empty($host))
@@ -604,7 +614,7 @@ class zanodemodel extends model
if(time() - strtotime($l->heartbeat) > 60)
{
- $l->status = 'wait';
+ $l->status = $l->hostType == '' ? 'wait' : 'offline';
}
}
}
@@ -654,6 +664,8 @@ class zanodemodel extends model
*/
public function getListByHost($hostID, $orderBy = 'id_desc')
{
+ if(!$hostID) return array();
+
$list = $this->dao->select('id, name, vnc, cpuCores, memory, diskSize, osName, status, heartbeat')->from(TABLE_ZAHOST)
->where('deleted')->eq(0)
->andWhere("parent")->eq($hostID)
@@ -786,14 +798,16 @@ class zanodemodel extends model
*/
public function getNodeByID($id)
{
- $node = $this->dao->select("t1.*, t2.name as hostName, t2.extranet as ip,t2.zap as hzap,if(t1.type='node', t3.osName, t1.osName) osName, t2.tokenSN as tokenSN, t2.secret as secret")->from(TABLE_ZAHOST)
+ $node = $this->dao->select("t1.*, t2.name as hostName, if(t1.hostType='', t2.extranet, t1.extranet) ip,t2.zap as hzap,if(t1.hostType='', t3.osName, t1.osName) osName, if(t1.hostType='', t2.tokenSN, t1.tokenSN) tokenSN, if(t1.hostType='', t2.secret, t1.secret) secret")->from(TABLE_ZAHOST)
->alias('t1')
->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t1.parent = t2.id')
->leftJoin(TABLE_IMAGE)->alias('t3')->on('t3.id = t1.image')
->where('t1.id')->eq($id)
->fetch();
- $host = $this->loadModel("zahost")->getByID($node->type == 'node' ? $node->parent : $node->id);
+ $host = $node->hostType == '' ? $this->loadModel("zahost")->getByID($node->parent) : clone $node;
+ $host->status = in_array($host->status, array('running', 'ready')) ? "online" : $host->status;
+
if($node->status == 'running' || $node->status == 'ready')
{
if(empty($host) || $host->status != 'online')
@@ -802,7 +816,7 @@ class zanodemodel extends model
}
elseif(time() - strtotime($node->heartbeat) > 60)
{
- $node->status = 'wait';
+ $node->status = $node->hostType == '' ? 'wait' : 'offline';
}
}
@@ -821,7 +835,9 @@ class zanodemodel extends model
->where('mac')->eq($mac)
->fetch();
- $host = $this->loadModel("zahost")->getByID($node->parent);
+ $host = $node->hostType == '' ? $this->loadModel("zahost")->getByID($node->parent) : $node;
+ $host->status = in_array($host->status, array('running', 'ready')) ? "online" : $host->status;
+
if($node->status == 'running' || $node->status == 'ready')
{
if(empty($host) || $host->status != 'online')
diff --git a/module/zanode/view/browse.html.php b/module/zanode/view/browse.html.php
index 6f32044c4f..26e45c9bd5 100644
--- a/module/zanode/view/browse.html.php
+++ b/module/zanode/view/browse.html.php
@@ -80,26 +80,26 @@
| zahost->type;?> | -zanode->typeList, 'virtual', "class='form-control chosen' onchange='zanodeType()'")?> | +zanode->typeList, 'virtual', "class='form-control chosen' onchange='zanodeType()'")?> | |
|---|---|---|---|