Merge branch 'zenops_46_tanghucheng' of https://gitlab.zcorp.cc/easycorp/zentaopms into zenops_46_tanghucheng

This commit is contained in:
zhaoke
2022-12-08 03:16:22 +00:00
7 changed files with 211 additions and 120 deletions
+57 -1
View File
@@ -489,6 +489,19 @@ class zanodemodel extends model
->fetch();
}
/**
* Get automation by id.
*
* @param int $id
* @return object
*/
public function getScriptByID($id)
{
return $this->dao->select('*')->from(TABLE_AUTOMATION)
->where('id')->eq($id)
->fetch();
}
/**
* Generage unique mac address.
*
@@ -636,7 +649,7 @@ class zanodemodel extends model
"server" => getWebRoot(true),
);
$result = json_decode(commonModel::http("http://{$node->extranet}:{$node->zap}/api/v1/service/setup", json_encode($param), array(), array("Authorization:$node->tokenSN")));
if(empty($result->data) || $result->code != 'success')
{
$result = new stdclass;
@@ -663,6 +676,19 @@ class zanodemodel extends model
->fetch();
}
/**
* Get automation by id.
*
* @param int $id
* @return object
*/
public function getAutomationByID($id)
{
return $this->dao->select('*')->from(TABLE_AUTOMATION)
->where('id')->eq($id)
->fetch();
}
/**
* Set automation setting.
*
@@ -687,4 +713,34 @@ class zanodemodel extends model
if(dao::isError()) return false;
return $this->dao->lastInsertID();
}
/**
* Run ZTFScript.
*
* @access public
* @return void
*/
public function runZTFScript()
{
$params = array(
'cmd' => '',
'ids' => '',
'path' => '',
'task' => '',
'workspace' => ''
);
$result = json_decode(commonModel::http("http://{$node->ip}:{$node->zap}/api/v1/jobs/add", json_encode($params), array(), array("Authorization:$node->tokenSN")));
if(empty($result->data) || $result->code != 'success')
{
$result = new stdclass;
$result->data = $this->lang->zanode->init->serviceStatus;
}
return array(
"ZenAgent" => "ready",
"ZTF" => $result->data->ztfStatus,
);
}
}