feat: Enhance vCenter integration with resource pool and folder support
- Added methods to ResourceService for fetching resource pools and updated existing methods to include datacenter filtering. - Modified CreateVirtualMachine to accept folder and resource pool parameters from product data. - Updated various jobs to synchronize resource pools and include them in the provisioning process. - Introduced new ModuleResourcePool model and migration for resource pool management. - Enhanced existing models (ModuleDatastore, ModuleNetwork, Os) to include relationships with vCenter and resource pools. - Added netmask field to IpPool and updated related logic for IP reservation. - Improved error handling and logging in VM creation and IP reservation processes. - Updated API routes to include sync functionality for vCenter.
This commit is contained in:
@@ -16,7 +16,7 @@ class OsGroupController extends Controller
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = OsGroup::withCount('os')
|
||||
->with(['os' => fn($q) => $q->with('host.datacenter.vCenter')->orderBy('version')])
|
||||
->with(['os' => fn($q) => $q->with(['host.datacenter.vCenter', 'datastore', 'network'])->orderBy('version')])
|
||||
->when(
|
||||
$request->get('filter'),
|
||||
fn($q, $f) => $q->where('name', 'like', "%{$f}%")
|
||||
@@ -50,7 +50,7 @@ class OsGroupController extends Controller
|
||||
public function show(int $id): JsonResponse
|
||||
{
|
||||
$group = OsGroup::withCount('os')
|
||||
->with(['os' => fn($q) => $q->with('host.datacenter.vCenter')->orderBy('version')])
|
||||
->with(['os' => fn($q) => $q->with(['host.datacenter.vCenter', 'datastore', 'network'])->orderBy('version')])
|
||||
->find($id);
|
||||
|
||||
if (! $group) {
|
||||
@@ -141,18 +141,24 @@ class OsGroupController extends Controller
|
||||
|
||||
private function formatOs(\App\Models\Os $os): array
|
||||
{
|
||||
$host = $os->relationLoaded('host') ? $os->host : null;
|
||||
$host = $os->relationLoaded('host') ? $os->host : null;
|
||||
$datastore = $os->relationLoaded('datastore') ? $os->datastore : null;
|
||||
$network = $os->relationLoaded('network') ? $os->network : null;
|
||||
|
||||
return [
|
||||
'id' => $os->id,
|
||||
'version' => $os->version,
|
||||
'template_id' => $os->template_id,
|
||||
'is_active' => (bool) $os->status,
|
||||
'os_group_id' => $os->os_group_id,
|
||||
'module_host_id' => $os->module_host_id,
|
||||
'host_name' => $host?->name,
|
||||
'datacenter_name' => $host?->datacenter?->name,
|
||||
'vcenter_name' => $host?->datacenter?->vCenter?->host,
|
||||
'id' => $os->id,
|
||||
'version' => $os->version,
|
||||
'template_id' => $os->template_id,
|
||||
'is_active' => (bool) $os->status,
|
||||
'os_group_id' => $os->os_group_id,
|
||||
'module_host_id' => $os->module_host_id,
|
||||
'datastore_id' => $os->datastore_id,
|
||||
'module_network_id' => $os->module_network_id,
|
||||
'datastore_name' => $datastore?->name,
|
||||
'network_name' => $network?->name,
|
||||
'host_name' => $host?->name,
|
||||
'datacenter_name' => $host?->datacenter?->name,
|
||||
'vcenter_name' => $host?->datacenter?->vCenter?->host,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user