Refactor vCenter snapshot handling and VM operations

- Introduced a new method `resolveVCenterFromProduct` in `SnapshotService` to streamline vCenter resolution from product data.
- Updated `CreateSnapshot`, `RemoveSnapshot`, and `RevertSnapshot` jobs to utilize the new vCenter resolution method.
- Enhanced the `VmController` to support UUID-based service identification for VM operations.
- Added new actions for changing VM IP and RDP port, encapsulating the logic for these operations.
- Improved error handling and logging for VM operations, including detailed responses for API consumers.
- Removed unnecessary relationships in model queries to optimize performance.
This commit is contained in:
pbao9
2026-04-15 23:38:38 +07:00
parent 64a9d603e2
commit bb73d6c5a2
14 changed files with 987 additions and 120 deletions
+8 -1
View File
@@ -30,7 +30,9 @@ class ModuleVmware extends Model
'status'
];
protected $casts = ['password' => 'hashed'];
// NOTE: password must NOT use 'hashed' cast — it is a VM guest credential
// used in plaintext by PowerShell scripts (Invoke-VMScript) via SSH/PowerCLI.
protected $casts = [];
public function customer()
{
return $this->belongsTo(\App\Models\Customer::class);
@@ -56,6 +58,11 @@ class ModuleVmware extends Model
return $this->belongsTo(\App\Models\Order::class);
}
public function services()
{
return $this->hasMany(\App\Models\Service::class, 'vm_id', 'vmware_id');
}
public function getStatus()
{
return match ($this->status) {