update layout control vm

This commit is contained in:
Pham Bao
2025-08-10 22:07:52 +07:00
parent cb0e263f44
commit 3ef83f8662
6 changed files with 110 additions and 0 deletions
@@ -739,6 +739,61 @@ class ServiceController extends Controller
}
}
/**
* Change public IP for VM (request-based), logs request.
*/
public function changeIP(Request $request)
{
try {
$user = customer();
if (!$user) {
return response()->json([
'error' => true,
'message' => __('Chưa đăng nhập. Vui lòng đăng nhập để sử dụng tính năng này.'),
], 401);
}
$validated = FacadesValidator::make($request->all(), [
'product_id' => 'required|string|max:255',
'ip' => ['required', 'string', 'regex:/^(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})$/'],
]);
if ($validated->fails()) {
return response()->json([
'error' => true,
'message' => __('Dữ liệu không hợp lệ'),
'errors' => $validated->errors(),
], 422);
}
$productId = $this->sanitizeInput($request->product_id);
$desiredIp = $this->sanitizeInput($request->ip);
// Persist an audit log entry for ops to handle allocation if needed
Log::info('Khách yêu cầu đổi IP', [
'user_id' => $user->id,
'product_vmware_id' => $productId,
'desired_ip' => $desiredIp,
]);
// Here you could enqueue a Job to validate/assign IP from pool
// For now, return accepted message
return response()->json([
'error' => false,
'message' => __('Yêu cầu đổi IP đã được ghi nhận, chúng tôi sẽ xử lý trong thời gian sớm nhất.'),
]);
} catch (\Exception $e) {
Log::error('Lỗi changeIP', [
'user_id' => customer()?->id,
'error' => $e->getMessage(),
]);
return response()->json([
'error' => true,
'message' => __('Có lỗi xảy ra khi đổi IP'),
], 500);
}
}
/**
* Secure remove snapshot using session authentication - NO BEARER TOKEN
*/