Merge branch 'feature/42422' into zenops_66
This commit is contained in:
@@ -37,7 +37,7 @@ class hostHeartbeatEntry extends baseEntry
|
||||
$conditionValue = $secret ? $secret : $token;
|
||||
|
||||
$this->dao = $this->loadModel('common')->dao;
|
||||
$hostInfo = $this->dao->select('id,tokenSN,hostType')->from(TABLE_ZAHOST)
|
||||
$hostInfo = $this->dao->select('id,tokenSN,hostType,type')->from(TABLE_ZAHOST)
|
||||
->beginIF($secret)->where('secret')->eq($secret)->fi()
|
||||
->beginIF(!$secret)->where('tokenSN')->eq($token)
|
||||
->andWhere('tokenTime')->gt($now)->fi()
|
||||
@@ -45,13 +45,15 @@ class hostHeartbeatEntry extends baseEntry
|
||||
if(empty($hostInfo->id))
|
||||
{
|
||||
if(empty($token)) return $this->sendError(400, 'Secret error.');
|
||||
$hostInfo = $this->dao->select('id,tokenSN')->from(TABLE_ZAHOST)
|
||||
$hostInfo = $this->dao->select('id,tokenSN,hostType,type')->from(TABLE_ZAHOST)
|
||||
->where('oldTokenSN')->eq($token)
|
||||
->andWhere('tokenTime')->gt(date(DT_DATETIME1, strtotime($now) - 30))->fi()
|
||||
->fetch();
|
||||
if(empty($hostInfo->id)) return $this->sendError(400, 'Secret error.');
|
||||
}
|
||||
|
||||
$isPhysicsNode = $hostInfo->type == 'node' && $hostInfo->hostType == 'physics' ? true : false;
|
||||
|
||||
$host = new stdclass();
|
||||
$host->status = $status;
|
||||
if($secret)
|
||||
@@ -69,12 +71,7 @@ class hostHeartbeatEntry extends baseEntry
|
||||
foreach($vms as $vm)
|
||||
{
|
||||
$heartbeat = strtotime(substr($vm->heartbeat, 0, 19));
|
||||
$node = $this->loadModel('zanode')->getNodeByMac($vm->macAddress);
|
||||
|
||||
if(empty($node)) continue;
|
||||
if(in_array($node->status, array('restoring', 'creating_img', 'creating_snap')))
|
||||
$vm->status = $node->status;
|
||||
$vmData = array(
|
||||
$vmData = array(
|
||||
'vnc' => $vm->vncPortOnHost,
|
||||
'zap' => $vm->agentPortOnHost,
|
||||
'ztf' => $vm->ztfPortOnHost,
|
||||
@@ -85,21 +82,26 @@ class hostHeartbeatEntry extends baseEntry
|
||||
);
|
||||
|
||||
if(!$vm->sshPortOnHost) unset($vmData['ssh']);
|
||||
|
||||
if($heartbeat > 0) $vmData['heartbeat'] = date("Y-m-d H:i:s", $heartbeat);
|
||||
|
||||
if($hostInfo->hostType == 'physics')
|
||||
if($isPhysicsNode)
|
||||
{
|
||||
unset($vmData['extranet']);
|
||||
$this->dao->update(TABLE_ZAHOST)->data($vmData)->where('id')->eq($hostInfo->id)->exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
$node = $this->loadModel('zanode')->getNodeByMac($vm->macAddress);
|
||||
if(empty($node)) continue;
|
||||
|
||||
if(in_array($node->status, array('restoring', 'creating_img', 'creating_snap')))
|
||||
$vmData->status = $vm->status = $node->status;
|
||||
$this->dao->update(TABLE_ZAHOST)->data($vmData)->where('mac')->eq($vm->macAddress)->exec();
|
||||
}
|
||||
|
||||
if($vm->status == 'running' && $hostInfo->hostType != 'physics')
|
||||
if($vm->status == 'running' && !$isPhysicsNode)
|
||||
{
|
||||
$node = $this->loadModel('zanode')->getNodeByMac($vm->macAddress);
|
||||
if(!empty($node))
|
||||
{
|
||||
$snaps = $this->loadModel('zanode')->getSnapshotList($node->id);
|
||||
|
||||
@@ -18,5 +18,5 @@
|
||||
.btn-info {background-color: unset;}
|
||||
.btn.disabled i {color: #fff;}
|
||||
.btn-toolbar a img{margin-bottom: 1px;}
|
||||
.btn-snap-create{width: 100px;height: 30px;}
|
||||
.zanode-init{padding:15px;background: #f4f5f7;margin:10px 0;}
|
||||
.btn-snap-create{height: 30px;}
|
||||
|
||||
@@ -857,10 +857,9 @@ class zanodemodel extends model
|
||||
$node = $this->dao->select('*')->from(TABLE_ZAHOST)
|
||||
->where('mac')->eq($mac)
|
||||
->fetch();
|
||||
|
||||
if(empty($node)) return $node;
|
||||
|
||||
$host = $node->hostType == '' ? $this->loadModel("zahost")->getByID($node->parent) : $node;
|
||||
$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')
|
||||
|
||||
Reference in New Issue
Block a user