This commit is contained in:
zhaoke
2023-03-02 09:56:28 +08:00
parent 925456c326
commit 37df7cfba8
6 changed files with 51 additions and 25 deletions
+5 -1
View File
@@ -69,6 +69,11 @@ 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(
'vnc' => $vm->vncPortOnHost,
'zap' => $vm->agentPortOnHost,
@@ -87,7 +92,6 @@ class hostHeartbeatEntry extends baseEntry
if($vm->status == 'running')
{
$node = $this->loadModel('zanode')->getNodeByMac($vm->macAddress);
if(!empty($node))
{
$snaps = $this->loadModel('zanode')->getSnapshotList($node->id);
+2
View File
@@ -133,6 +133,8 @@ $lang->zanode->statusList['destroy_fail'] = 'Destroy Fail';
$lang->zanode->statusList['wait'] = 'Initializing';
$lang->zanode->statusList['online'] = 'Online';
$lang->zanode->statusList['restoring'] = 'Restoring';
$lang->zanode->statusList['Creating_snap'] = 'Creating Snapshot';
$lang->zanode->statusList['Creating_img'] = 'Creating Image';
$lang->zanode->initNotice = "Succeeded. Please initialize the execution node or return to the list.";
$lang->zanode->initButton = "Initialize";
+2
View File
@@ -133,6 +133,8 @@ $lang->zanode->statusList['destroy_fail'] = 'Destroy Fail';
$lang->zanode->statusList['wait'] = 'Initializing';
$lang->zanode->statusList['online'] = 'Online';
$lang->zanode->statusList['restoring'] = 'Restoring';
$lang->zanode->statusList['Creating_snap'] = 'Creating Snapshot';
$lang->zanode->statusList['Creating_img'] = 'Creating Image';
$lang->zanode->initNotice = "Succeeded. Please initialize the execution node or return to the list.";
$lang->zanode->initButton = "Initialize";
+2
View File
@@ -133,6 +133,8 @@ $lang->zanode->statusList['destroy_fail'] = 'Destroy Fail';
$lang->zanode->statusList['wait'] = 'Initializing';
$lang->zanode->statusList['online'] = 'Online';
$lang->zanode->statusList['restoring'] = 'Restoring';
$lang->zanode->statusList['Creating_snap'] = 'Creating Snapshot';
$lang->zanode->statusList['Creating_img'] = 'Creating Image';
$lang->zanode->initNotice = "Succeeded. Please initialize the execution node or return to the list.";
$lang->zanode->initButton = "Initialize";
+15 -13
View File
@@ -120,19 +120,21 @@ $lang->zanode->apiError['notRunning'] = '请检查执行节点状态';
$lang->zanode->publicList[0] = '不共享';
$lang->zanode->publicList[1] = '共享';
$lang->zanode->statusList['created'] = '已创建';
$lang->zanode->statusList['launch'] = '运行中';
$lang->zanode->statusList['ready'] = '运行中';
$lang->zanode->statusList['running'] = '运行中';
$lang->zanode->statusList['suspend'] = '休眠';
$lang->zanode->statusList['offline'] = '下线';
$lang->zanode->statusList['destroy'] = '已销毁';
$lang->zanode->statusList['shutoff'] = '已关机';
$lang->zanode->statusList['shutodown'] = '已关机';
$lang->zanode->statusList['destroy_fail'] = '销毁失败';
$lang->zanode->statusList['wait'] = '初始化中';
$lang->zanode->statusList['online'] = '已上架';
$lang->zanode->statusList['restoring'] = '还原中';
$lang->zanode->statusList['created'] = '已创建';
$lang->zanode->statusList['launch'] = '运行中';
$lang->zanode->statusList['ready'] = '运行中';
$lang->zanode->statusList['running'] = '运行中';
$lang->zanode->statusList['suspend'] = '休眠';
$lang->zanode->statusList['offline'] = '下线';
$lang->zanode->statusList['destroy'] = '已销毁';
$lang->zanode->statusList['shutoff'] = '已关机';
$lang->zanode->statusList['shutodown'] = '已关机';
$lang->zanode->statusList['destroy_fail'] = '销毁失败';
$lang->zanode->statusList['wait'] = '初始化中';
$lang->zanode->statusList['online'] = '已上架';
$lang->zanode->statusList['restoring'] = '还原中';
$lang->zanode->statusList['Creating_snap'] = '创建快照中';
$lang->zanode->statusList['Creating_img'] = '导出镜像中';
$lang->zanode->initNotice = "保存成功,请初始化执行节点或返回列表。";
$lang->zanode->initButton = "去初始化";
+25 -11
View File
@@ -12,16 +12,19 @@
class zanodemodel 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 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_RESTORING = 'restoring';
const STATUS_CREATING_SNAP = 'Creating_snap';
const STATUS_CREATING_IMG = 'Creating_img';
const STATUS_DESTROY_FAIL = 'vim_destroy_fail';
const KVM_CREATE_PATH = '/api/v1/kvm/create';
const KVM_TOKEN_PATH = '/api/v1/virtual/getVncToken';
@@ -181,7 +184,12 @@ class zanodemodel extends model
$result = json_decode(commonModel::http($agnetUrl . static::KVM_EXPORT_PATH, json_encode($param,JSON_NUMERIC_CHECK), null, array("Authorization:$node->tokenSN")));
if(!empty($result) and $result->code == 'success') return $newID;
if(!empty($result) and $result->code == 'success')
{
$this->dao->update(TABLE_HOST)->set('status')->eq(static::STATUS_CREATING_SNAP)->where('id')->eq($node->id)->exec();
return $newID;
}
$this->dao->delete()->from(TABLE_IMAGE)->where('id')->eq($newID)->exec();
return false;
@@ -239,11 +247,14 @@ class zanodemodel extends model
if(!empty($result) and $result->code == 'success')
{
$this->loadModel('action')->create('zanode', $zanodeID, 'createdSnapshot', '', $data->name);
$this->dao->update(TABLE_HOST)->set('status')->eq(static::STATUS_CREATING_SNAP)->where('id')->eq($node->id)->exec();
return $newID;
}
$this->dao->delete()->from(TABLE_IMAGE)->where('id')->eq($newID)->exec();
dao::$errors[] = (!empty($result) and !empty($result->msg)) ? $result->msg : $this->app->lang->fail;
return false;
}
@@ -286,11 +297,14 @@ class zanodemodel extends model
if(!empty($result) and $result->code == 'success')
{
$this->dao->update(TABLE_HOST)->set('status')->eq(static::STATUS_CREATING_SNAP)->where('id')->eq($node->id)->exec();
return $newID;
}
$this->dao->delete()->from(TABLE_IMAGE)->where('id')->eq($newID)->exec();
dao::$errors[] = (!empty($result) and !empty($result->msg)) ? $result->msg : $this->app->lang->fail;
return false;
}