diff --git a/module/zanode/control.php b/module/zanode/control.php
index d3e2de60a2..8566dd5cbe 100644
--- a/module/zanode/control.php
+++ b/module/zanode/control.php
@@ -192,7 +192,7 @@ class zanode extends control
$task = '';
$node = $this->zanode->getNodeByID($zanodeID);
$customImage = $this->zanode->getCustomImage($zanodeID, 'created,inprogress');
- if($customImage) $task = $this->zanode->getTaskStatus($node->ip, $customImage->id, 'exportVm');
+ if($customImage) $task = $this->zanode->getTaskStatus($node->ip, $customImage->id, 'exportVm', '', $node->tokenSN);
if($_POST)
{
@@ -299,7 +299,9 @@ class zanode extends control
*/
public function ajaxGetTaskStatus($extranet, $taskID = 0, $type = '', $status = '')
{
- $result = $this->zanode->getTaskStatus($extranet, $taskID, $type, $status);
+ $task = $this->zanode->getImageByID($taskID);
+ $node = $this->zanode->getNodeByID($task->from);
+ $result = $this->zanode->getTaskStatus($extranet, $taskID, $type, $status, $node->tokenSN);
return print(json_encode($result));
}
diff --git a/module/zanode/lang/de.php b/module/zanode/lang/de.php
index fb5352dff4..4273c3fc44 100644
--- a/module/zanode/lang/de.php
+++ b/module/zanode/lang/de.php
@@ -54,6 +54,8 @@ $lang->zanode->createImageNotice = 'The system will be created based on the cur
$lang->zanode->createImageSuccess = 'Successed, You can use this image to create node. Created';
$lang->zanode->createImageFail = 'Failed to create';
+$lang->zanode->imageNameEmpty = 'Name can not be empty.';
+
$lang->zanode->apiError['-10100'] = 'Execution node not found.';
$lang->zanode->publicList[0] = 'Private';
diff --git a/module/zanode/lang/en.php b/module/zanode/lang/en.php
index fb5352dff4..4273c3fc44 100644
--- a/module/zanode/lang/en.php
+++ b/module/zanode/lang/en.php
@@ -54,6 +54,8 @@ $lang->zanode->createImageNotice = 'The system will be created based on the cur
$lang->zanode->createImageSuccess = 'Successed, You can use this image to create node. Created';
$lang->zanode->createImageFail = 'Failed to create';
+$lang->zanode->imageNameEmpty = 'Name can not be empty.';
+
$lang->zanode->apiError['-10100'] = 'Execution node not found.';
$lang->zanode->publicList[0] = 'Private';
diff --git a/module/zanode/lang/fr.php b/module/zanode/lang/fr.php
index fb5352dff4..4273c3fc44 100644
--- a/module/zanode/lang/fr.php
+++ b/module/zanode/lang/fr.php
@@ -54,6 +54,8 @@ $lang->zanode->createImageNotice = 'The system will be created based on the cur
$lang->zanode->createImageSuccess = 'Successed, You can use this image to create node. Created';
$lang->zanode->createImageFail = 'Failed to create';
+$lang->zanode->imageNameEmpty = 'Name can not be empty.';
+
$lang->zanode->apiError['-10100'] = 'Execution node not found.';
$lang->zanode->publicList[0] = 'Private';
diff --git a/module/zanode/lang/zh-cn.php b/module/zanode/lang/zh-cn.php
index a24562f30d..f1179e09fd 100644
--- a/module/zanode/lang/zh-cn.php
+++ b/module/zanode/lang/zh-cn.php
@@ -54,6 +54,8 @@ $lang->zanode->createImageNotice = '系统将基于当前执行节点创建镜
$lang->zanode->createImageSuccess = '镜像创建成功,您可以使用此镜像创建执行节点。去创建';
$lang->zanode->createImageFail = '镜像创建失败';
+$lang->zanode->imageNameEmpty = '名称不能为空';
+
$lang->zanode->apiError['-10100'] = '执行节点不存在';
$lang->zanode->publicList[0] = '不共享';
diff --git a/module/zanode/model.php b/module/zanode/model.php
index 63304c6eb6..efb772af09 100644
--- a/module/zanode/model.php
+++ b/module/zanode/model.php
@@ -118,13 +118,14 @@ class zanodemodel extends model
{
$data = fixer::input('post')->get();
- if(empty($data->name)) dao::$errors['message'][] = '名称不能为空';
+ if(empty($data->name)) dao::$errors['message'][] = $this->lang->zanode->imageNameEmpty;
if(dao::isError()) return false;
$node = $this->getNodeByID($zanodeID);
$image = $this->getImageByID($node->image);
$newImage = new stdClass();
+ $newImage->host = $node->host;
$newImage->name = $data->name;
$newImage->status = 'created';
$newImage->osName = $node->osName;
@@ -148,7 +149,7 @@ class zanodemodel extends model
'vm' => $node->name
);
- $result = json_decode(commonModel::http($agnetUrl . static::KVM_EXPORT_PATH, json_encode($param,JSON_NUMERIC_CHECK), null));
+ $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;
@@ -458,7 +459,7 @@ class zanodemodel extends model
*/
public function getNodeByID($id)
{
- return $this->dao->select('t1.*, t1.name as hostName, t2.extranet as ip,t3.osName')->from(TABLE_ZAHOST)->alias('t1')
+ return $this->dao->select('t1.*, t1.name as hostName, t2.extranet as ip, t2.tokenSN as tokenSN, t3.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.id')->eq($id)
@@ -538,17 +539,18 @@ class zanodemodel extends model
/**
* Get task status by zagent api.
*
- * @param int $extranet
+ * @param string $extranet
* @param int $taskID
* @param string $type
* @param string $status
+ * @param string $token
* @access public
- * @return void
+ * @return array
*/
- public function getTaskStatus($extranet = '', $taskID = 0, $type = '', $status = '')
+ public function getTaskStatus($extranet = '', $taskID = 0, $type = '', $status = '', $token = '')
{
$agnetUrl = 'http://' . $extranet . ':8086' . static::KVM_STATUS_PATH;
- $result = json_decode(commonModel::http("$agnetUrl", array(), array(CURLOPT_CUSTOMREQUEST => 'POST'), array(), 'json'));
+ $result = json_decode(commonModel::http("$agnetUrl", array(), array(CURLOPT_CUSTOMREQUEST => 'POST'), array("Authorization:$token"), 'json'));
if(empty($result) or $result->code != 'success') return false;
$data = $result->data;