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.'); } }