update
This commit is contained in:
@@ -8,6 +8,7 @@ use Illuminate\Http\Client\ConnectionException;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Http\Services\Discord;
|
||||
use App\Models\ModuleDatastore;
|
||||
use App\Services\VirtualMachine\VmProviderSettingsService;
|
||||
use Exception;
|
||||
|
||||
class VirtualMachineService
|
||||
@@ -77,11 +78,13 @@ class VirtualMachineService
|
||||
'addon' => $addon
|
||||
]);
|
||||
|
||||
$datastores = ModuleDatastore::where('module_host_id', $host->id)->get();
|
||||
/** @var VmProviderSettingsService $providerSettings */
|
||||
$providerSettings = app(VmProviderSettingsService::class);
|
||||
|
||||
$datastoreId = $datastores->isNotEmpty()
|
||||
? $datastores->first()->datastore
|
||||
: 'datastore-3004';
|
||||
$activeDatastore = ModuleDatastore::where('module_host_id', $host->id)
|
||||
->where('status', 1)
|
||||
->first();
|
||||
$datastoreId = $activeDatastore?->datastore ?? $providerSettings->defaultDatastore();
|
||||
|
||||
$body = [
|
||||
'spec' => [
|
||||
@@ -89,9 +92,9 @@ class VirtualMachineService
|
||||
'source' => $template,
|
||||
'placement' => [
|
||||
'datacenter' => $datacenter->datacenter_id,
|
||||
'folder' => 'group-v1008',
|
||||
'folder' => $providerSettings->defaultFolder(),
|
||||
'host' => $host->host_id,
|
||||
'resource_pool' => 'resgroup-3002',
|
||||
'resource_pool' => $providerSettings->defaultResourcePool(),
|
||||
'datastore' => $datastoreId,
|
||||
],
|
||||
'power_on' => false,
|
||||
|
||||
Reference in New Issue
Block a user