* Finish task 77678.
This commit is contained in:
@@ -88,6 +88,10 @@ class zahost extends control
|
||||
{
|
||||
return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
}
|
||||
elseif($hostID === false)
|
||||
{
|
||||
return $this->send(array('result' => 'fail', 'message' => array("extranet" => array($this->lang->zahost->netError))));
|
||||
}
|
||||
|
||||
$initLink = $this->createLink('zahost', 'inithost', "hostID=$hostID");
|
||||
return print("<script>showModal('$initLink')</script>");
|
||||
@@ -111,7 +115,14 @@ class zahost extends control
|
||||
if($_POST)
|
||||
{
|
||||
$changes = $this->zahost->update($hostID);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
if(dao::isError())
|
||||
{
|
||||
return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
}
|
||||
elseif($hostID === false)
|
||||
{
|
||||
return $this->send(array('result' => 'fail', 'message' => array("extranet" => array($this->lang->zahost->netError))));
|
||||
}
|
||||
|
||||
if(!empty($changes))
|
||||
{
|
||||
|
||||
@@ -40,6 +40,7 @@ $lang->zahost->createZanode = 'Create Zanode';
|
||||
$lang->zahost->initHostNotice = 'Save successfully, initialize the ZAhost or return list';
|
||||
$lang->zahost->createZanodeNotice = 'Initialization successful, ready to create the zanode';
|
||||
$lang->zahost->downloadImageNotice = 'Initialization successful, download the image to create zanode';
|
||||
$lang->zahost->netError = 'Unable to connect to the host, please check the network and try again.';
|
||||
|
||||
$lang->zahost->initHost = new stdclass;
|
||||
$lang->zahost->initHost->checkStatus = "Check Service Status";
|
||||
|
||||
@@ -40,6 +40,7 @@ $lang->zahost->createZanode = 'Create Zanode';
|
||||
$lang->zahost->initHostNotice = 'Save successfully, initialize the ZAhost or return list';
|
||||
$lang->zahost->createZanodeNotice = 'Initialization successful, ready to create the zanode';
|
||||
$lang->zahost->downloadImageNotice = 'Initialization successful, download the image to create zanode';
|
||||
$lang->zahost->netError = 'Unable to connect to the host, please check the network and try again.';
|
||||
|
||||
$lang->zahost->initHost = new stdclass;
|
||||
$lang->zahost->initHost->checkStatus = "Check Service Status";
|
||||
|
||||
@@ -40,6 +40,7 @@ $lang->zahost->createZanode = 'Create Zanode';
|
||||
$lang->zahost->initHostNotice = 'Save successfully, initialize the ZAhost or return list';
|
||||
$lang->zahost->createZanodeNotice = 'Initialization successful, ready to create the zanode';
|
||||
$lang->zahost->downloadImageNotice = 'Initialization successful, download the image to create zanode';
|
||||
$lang->zahost->netError = 'Unable to connect to the host, please check the network and try again.';
|
||||
|
||||
$lang->zahost->initHost = new stdclass;
|
||||
$lang->zahost->initHost->checkStatus = "Check Service Status";
|
||||
|
||||
@@ -39,6 +39,12 @@ $lang->zahost->osVersion = 'Os Version No';
|
||||
$lang->zahost->osLang = 'Language';
|
||||
$lang->zahost->imageName = 'Image File';
|
||||
|
||||
$lang->zahost->createZanode = 'Create Zanode';
|
||||
$lang->zahost->initHostNotice = 'Save successfully, initialize the ZAhost or return list';
|
||||
$lang->zahost->createZanodeNotice = 'Initialization successful, ready to create the zanode';
|
||||
$lang->zahost->downloadImageNotice = 'Initialization successful, download the image to create zanode';
|
||||
$lang->zahost->netError = 'Unable to connect to the host, please check the network and try again.';
|
||||
|
||||
$lang->zahost->initHost = new stdclass;
|
||||
$lang->zahost->initHost->checkStatus = "Check Service Status";
|
||||
$lang->zahost->initHost->not_install = "Not installed";
|
||||
|
||||
@@ -40,6 +40,7 @@ $lang->zahost->createZanode = '创建执行节点';
|
||||
$lang->zahost->initHostNotice = '保存成功,请您初始化宿主机或返回列表。';
|
||||
$lang->zahost->createZanodeNotice = '初始化成功,您现在可以创建执行节点了。';
|
||||
$lang->zahost->downloadImageNotice = '初始化成功,请下载镜像用于创建执行节点。';
|
||||
$lang->zahost->netError = '无法连接到宿主机,请检查网络后重试。';
|
||||
|
||||
$lang->zahost->initHost = new stdclass;
|
||||
$lang->zahost->initHost->statusTitle = "服务状态";
|
||||
|
||||
@@ -49,6 +49,12 @@ class zahostModel extends model
|
||||
->autoCheck();
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$ping = $this->checkAddress($hostInfo->extranet);
|
||||
if(!$ping)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->dao->insert(TABLE_ZAHOST)->data($hostInfo)->autoCheck()->exec();
|
||||
$hostID = $this->dao->lastInsertID();
|
||||
if(!dao::isError())
|
||||
@@ -79,6 +85,12 @@ class zahostModel extends model
|
||||
->batchCheck('diskSize,memory', 'float');
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$ping = $this->checkAddress($hostInfo->extranet);
|
||||
if(!$ping)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->dao->update(TABLE_ZAHOST)->data($hostInfo, 'name')->autoCheck()
|
||||
->batchCheck('cpuCores,diskSize', 'gt', 0)
|
||||
->batchCheck('diskSize,memory', 'float')
|
||||
@@ -86,6 +98,58 @@ class zahostModel extends model
|
||||
return common::createChanges($oldHost, $hostInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ping ip/domain.
|
||||
*
|
||||
* @param string $address
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function ping($address)
|
||||
{
|
||||
if (strcasecmp(PHP_OS, 'WINNT') === 0)
|
||||
{
|
||||
exec("ping -n 1 {$address}", $outcome, $status);
|
||||
}
|
||||
elseif (strcasecmp(PHP_OS, 'Linux') === 0)
|
||||
{
|
||||
exec("ping -c 1 {$address}", $outcome, $status);
|
||||
}
|
||||
|
||||
if (0 == $status)
|
||||
{
|
||||
$status = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$status = false;
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Telnet ip/domain.
|
||||
*
|
||||
* @param string $address
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function checkAddress($address)
|
||||
{
|
||||
$address = str_replace(array('https://', 'http://'), '', $address);
|
||||
|
||||
if ($this->ping($address)) return true;
|
||||
|
||||
foreach(array(80, 443, 8086) as $port)
|
||||
{
|
||||
$fp = fsockopen($address, $port, $errno, $errstr, 3);
|
||||
if ($fp) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image by ID.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user