This commit is contained in:
olevole
2020-11-26 23:57:51 +03:00
parent 72bdb201f3
commit 7cd1029ac6
7 changed files with 199 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
<?php
class ClonOS {
public $server_name='';
public $workdir='';
@@ -98,7 +99,8 @@ class ClonOS {
if($this->environment=='development')
{
include($this->realpath_php.'sentry.php');
$sentry_file=$this->realpath_php.'sentry.php';
if(file_exists($sentry_file))include($sentry_file);
}
if(isset($_SERVER['SERVER_NAME']) && !empty(trim($_SERVER['SERVER_NAME'])))
@@ -194,9 +196,9 @@ class ClonOS {
$ccmd_res=$this->$cfunc();
if(is_array($ccmd_res))
$new_array=array_merge($this->sys_vars,$ccmd_res);
else
{
$new_array=array_merge($this->sys_vars,$ccmd_res);
}else{
echo json_encode($ccmd_res);
return;
}
@@ -311,7 +313,7 @@ class ClonOS {
exit;
}
}
echo '{}';
echo json_encode($this->sys_vars);
exit;
}
@@ -2220,6 +2222,7 @@ class ClonOS {
if(isset($_COOKIE['mhash']))
{
$mhash=$db->escape($_COOKIE['mhash']);
if(!preg_match('#^[a-f0-9]{32}$#',$mhash)) return array('error'=>true,'error_message'=>'bad data, man...');
$query1="select user_id from auth_list WHERE sess_id='${mhash}' limit 1";
$res1=$db->selectAssoc($query1);
{

View File

@@ -60,6 +60,12 @@ class Config
'icon'=>'icon-cubes',
),
'k8s'=>array(
'name'=>'K8S clusters',
'title'=>'Manage K8S clusters',
'icon'=>'icon-cubes',
),
'vpnet'=>array(
'name'=>'Virtual Private Network',
'title'=>'Manage for virtual private networks',

View File

@@ -18,6 +18,8 @@ $lang=array(
'Nodes control panel'=>'Панель управления нодами',
'VM Packages'=>'Шаблоны виртуальных машин',
'Manage for virtual machine packages'=>'Управление профилями виртуальных машин',
'K8S clusters'=>'Кластеры K8S',
'Manage K8S clusters'=>'Управление K8S кластерами',
'Virtual Private Network'=>'Виртуальные сети',
'Manage for virtual private networks'=>'Панель управления подсетями',
'Authkeys'=>'Ключи авторизации',

View File

@@ -0,0 +1,94 @@
<?php
$res=json_decode('{
"clusters": [
{
"name": "ole",
"cluster": "k8s.bhyve.io",
"masters": 3,
"workers": 3,
"bhyves": [
"master1",
"master2",
"master3",
"worker1",
"worker2",
"worker3"
]
},
{
"name": "mon",
"cluster": "mon.bhyve.io",
"masters": 1,
"workers": 1,
"bhyves": [
"master1",
"worker1"
]
}
]
}',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]);
if($hres!==false)
{
$vars=array(
'nth-num'=>'nth0',
'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=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'k8slist',
//'tasks'=>$tasks,
'template'=>$html_tpl_1,
//'protected'=>$protected,
);

View File

@@ -0,0 +1,39 @@
<?php
/*
if(isset($clonos->uri_chunks[1]))
{
include('helpers.php');
return;
}
*/
/*
$clonos->useDialogs(array(
'vnc',
'jail-settings',
'jail-settings-config-menu',
'jail-import',
'jail-clone',
'jail-rename',
));
*/
?>
<h1>K8S clusters:</h1>
<!--
<p><span class="top-button icon-plus id:jail-settings">Создать контейнер</span>
<span class="top-button icon-upload id:jail-import">Импортировать</span></p>
-->
<table class="tsimple" id="k8slist" width="100%">
<thead>
<tr>
<th class="elastic">name</th>
<th class="txtcenter wdt-80">masters</th>
<th class="txtcenter wdt-80">workers</th>
<th class="txtleft">bhyves</th>
<th colspan="4" class="txtcenter wdt-100">action</th>
</tr>
</thead>
<tbody></tbody>
</table>

View File

@@ -0,0 +1,12 @@
<tbody>
<tr class="#nth-num##desktop##maintenance#" id="#name#">
<td class="wordwreck node">#cluster#</td>
<td class="txtcenter">#masters#</td>
<td class="txtcenter">#workers#</td>
<td class="txtleft">#bhyves#</td>
<td class="ops"><span class="icon-cnt"><span class="icon-#icon#"></span></span></td>
<td class="op-settings"><span class="icon-cog"></span></td>
<td class="op-reboot" title="#reboot_title#"><span class="icon-arrows-cw"></span></td>
<td class="op-del"#protitle#><span class="#protected#"></span></td>
</tr>
</tbody>

View File

@@ -0,0 +1,39 @@
<?php
/*
if(isset($clonos->uri_chunks[1]))
{
include('helpers.php');
return;
}
*/
/*
$clonos->useDialogs(array(
'vnc',
'jail-settings',
'jail-settings-config-menu',
'jail-import',
'jail-clone',
'jail-rename',
));
*/
?>
<h1>K8S кластеры:</h1>
<!--
<p><span class="top-button icon-plus id:jail-settings">Создать контейнер</span>
<span class="top-button icon-upload id:jail-import">Импортировать</span></p>
-->
<table class="tsimple" id="k8slist" width="100%">
<thead>
<tr>
<th class="elastic">Имя кластера</th>
<th class="txtcenter wdt-80">Кол-во master нод</th>
<th class="txtcenter wdt-80">Кол-во worker нод</th>
<th class="txtleft">Список виртуальных машин</th>
<th colspan="4" class="txtcenter wdt-100">Действия</th>
</tr>
</thead>
<tbody></tbody>
</table>