This commit is contained in:
Momchil Bozhinov
2022-08-05 19:10:04 +03:00
parent 26fffa3b79
commit 0a39784518
3 changed files with 73 additions and 98 deletions

View File

@@ -2,86 +2,82 @@
/* hardcode API ip. Change it later */ /* hardcode API ip. Change it later */
//$api_ip='https://bitclouds.convectix.com:1443'; //$api_ip='https://bitclouds.convectix.com:1443';
$api_ip='http://144.76.225.238'; $api_ip = 'http://144.76.225.238';
function getSslPage($url) { function getSslPage($url) {
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch); $result = curl_exec($ch);
curl_close($ch); curl_close($ch);
return $result; return $result;
}
$file=getSslPage($api_ip.'/clusters');
$html='';
$res=json_decode($file,true);
$nth=0;
$hres=$this->getTableChunk('k8slist','tbody');
if(!empty($res) && isset($res['clusters']))foreach($res['clusters'] as $cluster)
{
$num=$nth & 1;
$html_tpl=$hres[1];
$vars=array(
'nth-num'=>'nth'.$num,
'name'=>$cluster['name'],
'cluster'=>$cluster['cluster'],
'masters'=>$cluster['masters'],
'workers'=>$cluster['workers'],
'bhyves'=>join('; ',$cluster['bhyves']),
//'jstatus'=>$this->translate($statuses[$status]),
//'icon'=>($status==0)?'play':'stop',
//'desktop'=>($status==0)?' s-off':' s-on',
//'maintenance'=>($status==3)?' maintenance':'',
//'protected'=>($jail['protected']==1)?'icon-lock':'icon-cancel',
//'protitle'=>($jail['protected']==1)?' title="'.$this->translate('Protected jail').'"':' title="'.$this->translate('Delete').'"',
//'vnc_title'=>$this->translate('Open VNC'),
//'reboot_title'=>$this->translate('Restart jail'),
);
foreach($vars as $var=>$val)
$html_tpl=str_replace('#'.$var.'#',$val,$html_tpl);
// if($node!='local') $html_tpl=str_replace('<span class="icon-cog"></span>','',$html_tpl);
$html.=$html_tpl;
$nth++;
} }
$html_tpl_1=str_replace(array("\n","\r","\t"),'',$hres[1]); $file = getSslPage($api_ip.'/clusters');
if($hres!==false) $html = '';
{ $res = json_decode($file, true);
$vars=array( $nth = 0;
'nth-num'=>'nth0', $hres = $this->getTableChunk('k8slist','tbody');
'status'=>'',
'jstatus'=>$this->translate('Creating'), if(!empty($res) && isset($res['clusters'])){
'icon'=>'spin6 animate-spin', foreach($res['clusters'] as $cluster){
'desktop'=>' s-off', $num = $nth & 1;
'maintenance'=>' maintenance busy', $html_tpl = $hres[1];
'protected'=>'icon-cancel', $vars = [
'protitle'=>'', 'nth-num' => 'nth'.$num,
'vnc_title'=>$this->translate('Open VNC'), 'name' => $cluster['name'],
'reboot_title'=>$this->translate('Restart jail'), 'cluster' => $cluster['cluster'],
); 'masters' => $cluster['masters'],
'workers' => $cluster['workers'],
foreach($vars as $var=>$val) 'bhyves' => join('; ',$cluster['bhyves']),
$html_tpl_1=str_replace('#'.$var.'#',$val,$html_tpl_1); //'jstatus'=>$this->translate($statuses[$status]),
//'icon'=>($status==0)?'play':'stop',
//'desktop'=>($status==0)?' s-off':' s-on',
//'maintenance'=>($status==3)?' maintenance':'',
//'protected'=>($jail['protected']==1)?'icon-lock':'icon-cancel',
//'protitle'=>($jail['protected']==1)?' title="'.$this->translate('Protected jail').'"':' title="'.$this->translate('Delete').'"',
//'vnc_title'=>$this->translate('Open VNC'),
//'reboot_title'=>$this->translate('Restart jail'),
];
foreach($vars as $var => $val){
$html_tpl = str_replace('#'.$var.'#', $val, $html_tpl);
}
// if($node!='local') $html_tpl=str_replace('<span class="icon-cog"></span>','',$html_tpl);
$html .= $html_tpl;
$nth++;
} }
$included_result_array=array( $html_tpl_1 = str_replace(["\n","\r","\t"], '', $hres[1]);
'tbody'=>$html, if($hres !== false){
'error'=>false, $vars = [
'func'=>'fillTable', 'nth-num' => 'nth0',
'id'=>'k8slist', 'status' => '',
'jstatus' => $this->translate('Creating'),
'icon' => 'spin6 animate-spin',
'desktop' => ' s-off',
'maintenance' => ' maintenance busy',
'protected' => 'icon-cancel',
'protitle' => '',
'vnc_title' => $this->translate('Open VNC'),
'reboot_title' => $this->translate('Restart jail')
];
foreach($vars as $var => $val){
$html_tpl_1 = str_replace('#'.$var.'#', $val, $html_tpl_1);
}
}
$included_result_array = [
'tbody' => $html,
'error' => false,
'func' => 'fillTable',
'id' => 'k8slist',
//'tasks'=>$tasks, //'tasks'=>$tasks,
'template'=>$html_tpl_1, 'template' => $html_tpl_1,
//'protected'=>$protected, //'protected'=>$protected,
); ];

View File

@@ -1,16 +1,5 @@
<?php <?php
/* $clonos->useDialogs(['k8s-new']);
if(isset($clonos->uri_chunks[1]))
{
include('helpers.php');
return;
}
*/
$clonos->useDialogs(array(
'k8s-new',
));
?> ?>
<h1>K8S Сlusters:</h1> <h1>K8S Сlusters:</h1>
<p><span class="top-button icon-plus id:k8s-new">Создать Kubernetes</span></p> <p><span class="top-button icon-plus id:k8s-new">Создать Kubernetes</span></p>

View File

@@ -1,15 +1,5 @@
<?php <?php
/* $clonos->useDialogs(['k8s-new']);
if(isset($clonos->uri_chunks[1]))
{
include('helpers.php');
return;
}
*/
$clonos->useDialogs(array(
'k8s-new',
));
/* /*
Модуль kubernetes использует в работе преднастроенный образ Linux, который не входит в базовую установку ClonOS. Модуль kubernetes использует в работе преднастроенный образ Linux, который не входит в базовую установку ClonOS.