feat(vm): hoàn tiền khi cấp VM lỗi, theo dõi job queue, uuid dịch vụ cho ticket, chuẩn hoá RAM addon
- VmProvisionException/VmProvisionRefund xử lý lỗi cấp phát VM - QueueJobInspector + QueueMonitorController xem chi tiết job - Thêm service uuid cho ticket, thời lượng cho activity_logs - Migration chuẩn hoá RAM addon sang MB, trạng thái deleting cho snapshot Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
7136bec265
commit
62596d9063
@@ -8,9 +8,44 @@ use App\Models\Os;
|
||||
use App\Services\VmProvisionService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
trait ManagesVmAccess
|
||||
{
|
||||
private const CLICK_LABELS = [
|
||||
'snapshot' => 'Snapshot',
|
||||
'change-password' => 'Đổi mật khẩu',
|
||||
'change-ip' => 'Đổi IP',
|
||||
'change-port' => 'Đổi Remote Port',
|
||||
'renew' => 'Gia hạn',
|
||||
'console' => 'Truy cập console',
|
||||
'rebuild' => 'Rebuild máy chủ',
|
||||
'addons' => 'Addons',
|
||||
];
|
||||
|
||||
public function actionClick(Request $request): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'product' => 'required',
|
||||
'action' => ['required', 'string', Rule::in(array_keys(self::CLICK_LABELS))],
|
||||
]);
|
||||
|
||||
$vm = $this->resolveVmById($data['product'], $request);
|
||||
if ($vm instanceof JsonResponse) {
|
||||
return $vm;
|
||||
}
|
||||
|
||||
$this->activityLogger->log(
|
||||
event: 'click_' . str_replace('-', '_', $data['action']),
|
||||
logName: 'VM',
|
||||
description: "Customer {$request->user()->email} bấm \"" . self::CLICK_LABELS[$data['action']] . "\" trên VM: {$vm->name} (ID: {$vm->vmware_id})",
|
||||
subject: $vm,
|
||||
newValues: ['action' => $data['action']],
|
||||
);
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
}
|
||||
|
||||
public function consoleTicket(Request $request, vCenter $serviceVCenter): JsonResponse
|
||||
{
|
||||
$productId = $request->get('product');
|
||||
@@ -53,7 +88,7 @@ trait ManagesVmAccess
|
||||
$validated = $request->validate([
|
||||
'product' => ['required'],
|
||||
'current_password' => ['required', 'string'],
|
||||
'new_password' => ['required', 'string', 'min:8'],
|
||||
'new_password' => ['required', 'string', 'min:12', 'max:64', 'regex:/^[A-Za-z0-9!@#^*_+=?.,:~]+$/'],
|
||||
]);
|
||||
|
||||
$vm = $this->resolveVmById($validated['product'], $request);
|
||||
|
||||
Reference in New Issue
Block a user