feat: VM metrics via portal-monitor integration
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
0b08689ea4
commit
9ed77a85fd
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Internal;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Facade\SignRSA;
|
||||
use App\Models\vCenter;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class PortalMonitorVCenterController extends Controller
|
||||
{
|
||||
public function __invoke(): JsonResponse
|
||||
{
|
||||
$vcenter = vCenter::query()
|
||||
->where('status', 1)
|
||||
->orderBy('id')
|
||||
->first();
|
||||
|
||||
if (!$vcenter) {
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => 'Active vCenter configuration is unavailable',
|
||||
], 503);
|
||||
}
|
||||
|
||||
$username = trim((string) $vcenter->user);
|
||||
$password = SignRSA::DecryptFunc($vcenter->password);
|
||||
$host = trim((string) $vcenter->host);
|
||||
$port = 443;
|
||||
|
||||
if ($host === '' || $port < 1 || $username === '' || $password === '') {
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => 'Active vCenter configuration is incomplete',
|
||||
], 503);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => [
|
||||
'host' => $host,
|
||||
'port' => $port,
|
||||
'username' => $username,
|
||||
'password' => $password,
|
||||
],
|
||||
])->header('Cache-Control', 'no-store, private');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user