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:
baodev0
2026-07-21 21:37:28 +07:00
parent 2d43e95855
commit 5d3ed57b32
33 changed files with 708 additions and 152 deletions
+7 -2
View File
@@ -38,6 +38,7 @@ class SyncNetwork implements ShouldQueue
*/
public function handle()
{
$networkCount = 0;
foreach ($this->data as $item) {
if (!$item->token) {
@@ -62,13 +63,13 @@ class SyncNetwork implements ShouldQueue
if ($allHost) {
foreach ($allHost as $hostItem) {
$network = $this->vCenter->loadNetWork($item, $hostItem->host_id);
$network = $this->vCenter->loadNetWork($item, $hostItem->host_id, $_item->datacenter_id);
if ($network === "Login_Again") {
$token = $this->vCenter->loginServer($item);
if ($token) {
vCenter::where('id', $item->id)->update(['token' => $token]);
$this->vCenter->token = $token;
$network = $this->vCenter->loadNetWork($item, $hostItem->host_id);
$network = $this->vCenter->loadNetWork($item, $hostItem->host_id, $_item->datacenter_id);
}
}
@@ -82,8 +83,11 @@ class SyncNetwork implements ShouldQueue
[
'name' => $_subItem['name'],
'type' => $_subItem['type'],
'vcenter_id' => $item->id,
'status' => 1,
]
);
$networkCount++;
}
}
}
@@ -94,6 +98,7 @@ class SyncNetwork implements ShouldQueue
(new \App\Http\Services\Telegram())->SendJobRunInfo('SyncNetwork', 'Success', [
'message' => 'Sync network completed successfully',
'synced_vcenters' => $this->data->count(),
'synced_network_count' => $networkCount,
]);
}
}