ajout heimdall

This commit is contained in:
2025-01-01 11:24:01 +01:00
parent f8be42e486
commit c52f60fca9
1477 changed files with 15692 additions and 0 deletions
+117
View File
@@ -0,0 +1,117 @@
<?php namespace App\SupportedApps\Proxmox;
class Proxmox extends \App\SupportedApps implements \App\EnhancedApps
{
public $config;
public function getRequestAttrs()
{
$token_id = $this->getConfigValue("token_id", null);
$token_value = $this->getConfigValue("token_value", null);
$ignoreTls = $this->getConfigValue("ignore_tls", false);
$auth = "PVEAPIToken=" . $token_id . "=" . $token_value;
$attrs["headers"] = [
"Accept" => "application/json",
"Authorization" => $auth,
];
if ($ignoreTls) {
$attrs["verify"] = false;
}
return $attrs;
}
function __construct()
{
}
public function test()
{
$attrs = $this->getRequestAttrs();
$test = parent::appTest($this->url("version"), $attrs);
echo $test->status;
}
public function livestats()
{
$status = "active";
$attrs = $this->getRequestAttrs();
$nodes = explode(",", $this->getConfigValue("nodes", ""));
if ($nodes == [""]) {
$nodes = array_map(function ($v) {
return $v->node;
}, $this->apiCall("nodes"));
}
$vm_running = 0;
$vm_total = 0;
$container_running = 0;
$container_total = 0;
$cpu_percent_sum = 0.0;
$memory_total = 0.0;
$memory_used = 0.0;
foreach ($nodes as $node) {
$node_status = $this->apiCall("nodes/" . $node . "/status");
$cpu_percent_sum += $node_status->cpu;
$memory_used += $node_status->memory->used;
$memory_total += $node_status->memory->total;
$vm_stats = $this->apiCall("nodes/" . $node . "/qemu");
$vm_total += count($vm_stats);
$vm_running += count(
array_filter($vm_stats, function ($v) {
return $v->status == "running";
})
);
$container_stats = $this->apiCall("nodes/" . $node . "/lxc");
$container_total += count($container_stats);
$container_running += count(
array_filter($container_stats, function ($v) {
return $v->status == "running";
})
);
}
$res = parent::execute($this->url("version"), $attrs);
$details = json_decode($res->getBody())->data;
$data = [
"vm_running" => $vm_running,
"vm_total" => $vm_total,
"container_running" => $container_running,
"container_total" => $container_total,
"cpu_percent" => ($cpu_percent_sum / count($nodes)) * 100,
"memory_percent" => (100 / $memory_total) * $memory_used,
];
return parent::getLiveStats($status, $data);
}
public function url($endpoint)
{
$api_stub = "api2/json/";
$api_url =
parent::normaliseurl(
$this->getConfigValue("override_url", $this->config->url)
) .
$api_stub .
$endpoint;
return $api_url;
}
public function apiCall($endpoint)
{
$res = parent::execute($this->url($endpoint), $this->getRequestAttrs());
return json_decode($res->getBody())->data;
}
public function getConfigValue($key, $default = null)
{
return isset($this->config) && isset($this->config->$key)
? $this->config->$key
: $default;
}
}
+10
View File
@@ -0,0 +1,10 @@
{
"appid": "391f2b7f3fe853e1ea09723eeafc354fa291ab48",
"name": "Proxmox",
"website": "https://www.proxmox.com/en/",
"license": "GNU Affero General Public License v3.0 only",
"description": "Proxmox Virtual Environment is an open-source server virtualization environment. It allows deployment and management of virtual machines and containers",
"enhanced": true,
"tile_background": "light",
"icon": "proxmox.svg"
}
+40
View File
@@ -0,0 +1,40 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
<div class="items" style="flex-wrap: wrap;">
<div class="input">
<label>{{ strtoupper(__('app.url')) }}</label>
{!! Form::text('config[override_url]', isset($item) ? $item->getconfig()->override_url : null, ['placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control']) !!}
</div>
<div class="input">
<label>Node(s) (comma separated list)</label>
{!! Form::text('config[nodes]', isset($item) ? $item->getconfig()->nodes : null, ['placeholder' => 'Leave blank for all nodes in cluster', 'data-config' => 'nodes', 'class' => 'form-control config-item']) !!}
</div>
<div class="input">
<label>Skip TLS verification</label>
<div class="toggleinput" style="margin-top: 26px; padding-left: 15px;">
{!! Form::hidden('config[ignore_tls]', 0, ['class' => 'config-item', 'data-config' => 'ignore_tls']) !!}
<label class="switch">
<?php
$checked = false;
if (isset($item) && !empty($item) && isset($item->getconfig()->ignore_tls)) {
$checked = $item->getconfig()->ignore_tls;
}
$set_checked = $checked ? ' checked="checked"' : '';
?>
<input type="checkbox" class="config-item" data-config="ignore_tls" name="config[ignore_tls]" value="1" <?php echo $set_checked; ?> />
<span class="slider round"></span>
</label>
</div>
</div>
<div class="input">
<label>API Token ID</label>
{!! Form::text('config[token_id]', isset($item) ? $item->getconfig()->token_id : null, ['placeholder' => 'user@realm!token_name', 'data-config' => 'token_id', 'class' => 'form-control config-item']) !!}
</div>
<div class="input">
<label>{{ __('app.apps.apikey') }}</label>
{!! Form::input('password', 'config[token_value]', isset($item) ? $item->getconfig()->token_value : null, ['placeholder' => '01234567-89ab-cdef-0123-456789abcdef', 'data-config' => 'token_value', 'class' => 'form-control config-item']) !!}
<p style="font-size: .8em;">Requires at least <code>Sys.Audit</code> permission for <code>/nodes</code> path (and propagated).</p>
</div>
<div class="input">
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
</div>
</div>
@@ -0,0 +1,18 @@
<ul class="livestats">
<li>
<span class="title">VM</span>
<strong><span>{!! $vm_running !!}/{!! $vm_total !!}</span></strong>
</li>
<li>
<span class="title">LXC</span>
<strong><span>{!! $container_running !!}/{!! $container_total !!}</span></strong>
</li>
<li>
<span class="title">CPU</span>
<strong>{!! round($cpu_percent, 1) !!}%</strong>
</li>
<li>
<span class="title">RAM</span>
<strong>{!! round($memory_percent, 1) !!}%</strong>
</li>
</ul>
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB