feat: initialize Infra Manager with React, Tailwind CSS, and Inertia.js
- Added main application entry point (app.jsx) and bootstrap file for React setup. - Created Wiki index page (Index.jsx) for documentation and file management. - Implemented utility functions for formatting and status handling in utils.js. - Set up Blade template (app.blade.php) for Inertia.js integration. - Defined API routes for metrics and terminal access in api.php. - Established console commands for scheduled tasks in console.php. - Created web routes for various application features including authentication, hypervisors, containers, cloud accounts, security, backups, and wiki management in web.php. - Developed setup scripts for Windows (setup.ps1) and Linux (setup.sh) environments. - Configured Tailwind CSS for styling with custom themes and animations in tailwind.config.js. - Set up Vite for asset bundling and development server in vite.config.js.
This commit is contained in:
60
app/Http/Controllers/Hypervisor/VirtualMachineController.php
Normal file
60
app/Http/Controllers/Hypervisor/VirtualMachineController.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Hypervisor;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\VirtualMachine;
|
||||
use App\Services\Hypervisor\HypervisorManager;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class VirtualMachineController extends Controller
|
||||
{
|
||||
public function __construct(private HypervisorManager $manager) {}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return Inertia::render('Hypervisor/VMs', [
|
||||
'vms' => VirtualMachine::with('hypervisor')->orderBy('name')->paginate(50),
|
||||
]);
|
||||
}
|
||||
|
||||
public function show(VirtualMachine $vm)
|
||||
{
|
||||
return Inertia::render('Hypervisor/VMShow', ['vm' => $vm->load('hypervisor')]);
|
||||
}
|
||||
|
||||
public function power(Request $request, VirtualMachine $vm)
|
||||
{
|
||||
$action = $request->validate(['action' => 'required|in:start,stop,reboot,suspend'])['action'];
|
||||
$driver = $this->manager->driver($vm->hypervisor);
|
||||
|
||||
match ($action) {
|
||||
'start' => $driver->powerOn($vm->remote_id),
|
||||
'stop' => $driver->powerOff($vm->remote_id),
|
||||
'reboot' => $driver->reboot($vm->remote_id),
|
||||
'suspend' => $driver->suspend($vm->remote_id),
|
||||
};
|
||||
|
||||
return back()->with('success', "VM {$action} initiated.");
|
||||
}
|
||||
|
||||
public function snapshot(Request $request, VirtualMachine $vm)
|
||||
{
|
||||
$data = $request->validate(['name' => 'required|string', 'description' => 'nullable|string']);
|
||||
$this->manager->driver($vm->hypervisor)->createSnapshot($vm->remote_id, $data['name'], $data['description'] ?? '');
|
||||
return back()->with('success', 'Snapshot created.');
|
||||
}
|
||||
|
||||
public function clone(Request $request, VirtualMachine $vm)
|
||||
{
|
||||
$data = $request->validate(['name' => 'required|string']);
|
||||
$this->manager->driver($vm->hypervisor)->cloneVM($vm->remote_id, $data['name'], []);
|
||||
return back()->with('success', 'Clone initiated.');
|
||||
}
|
||||
|
||||
public function migrate(Request $request, VirtualMachine $vm)
|
||||
{
|
||||
return back()->with('info', 'Migration not yet implemented for this hypervisor type.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user