feat: Implement comprehensive vCenter integration with new services for VM configuration, power management, templates, snapshots, and resource management, alongside infrastructure management and synchronization job updates.

This commit is contained in:
pbao9
2026-02-12 17:23:01 +07:00
parent f3a679d7f3
commit 64c3182b00
16 changed files with 1979 additions and 223 deletions
+18 -18
View File
@@ -42,19 +42,16 @@ class SyncHost implements ShouldQueue
public function handle()
{
try {
// Initialize new services
$client = new \App\Http\Services\vCenter\Client();
$resourceService = new \App\Http\Services\vCenter\ResourceService($client);
$templateService = new \App\Http\Services\vCenter\TemplateService($client);
foreach ($this->data as $item) {
$this->vCenter->apiUri = $item->host;
// Login via Client service
$token = $client->loginServer($item);
if (!$item->token) {
$token = $this->vCenter->loginServer($item);
if ($token) {
vCenter::where('id', $item->id)->update(['token' => $token]);
$this->vCenter->token = $token;
}
}
$this->vCenter->token = $item->token;
if (!$this->vCenter->token) {
if (!$token) {
continue;
}
@@ -63,23 +60,26 @@ class SyncHost implements ShouldQueue
->get();
foreach ($dataCenter as $_item) {
$host = $this->vCenter->getAllHost($_item['datacenter_id']);
// Use ResourceService to get hosts
$host = $resourceService->getAllHost($_item['datacenter_id']);
if ($host === "Login_Again") {
$token = $this->vCenter->loginServer($item);
$token = $client->loginServer($item);
if ($token) {
vCenter::where('id', $item->id)->update(['token' => $token]);
$this->vCenter->token = $token;
$host = $resourceService->getAllHost($_item['datacenter_id']);
}
}
$host = $this->vCenter->getAllHost($_item['datacenter_id']);
if (!is_array($host)) {
continue; // Skip if still invalid or Login_Again
}
$template = $this->vCenter->getAllTemplate();
// Use TemplateService
$template = $templateService->getAllTemplate();
if ($host) {
foreach ($host as $_subItem) {
if (!ModuleHost::where('host_id', $_subItem['host'])->first()) {
if (!ModuleHost::where('host_id', $_subItem['host'])->exists()) {
ModuleHost::create([
'name' => $_subItem['name'],
'host_id' => $_subItem['host'],