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:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* vCenter's REST API has no per-host filter for datastore/network listing
|
||||
* (filter.hosts is silently ignored), so sync fans out the full vCenter-wide
|
||||
* inventory to every host — legitimate duplication, kept as-is since
|
||||
* VmIpReservationService/VmRebuildCloneService/IpPoolController still key off
|
||||
* module_host_id. This adds vcenter_id so the active-chain feature can scope
|
||||
* "exactly one active datastore/network" per vCenter instead of per host.
|
||||
*/
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('module_datastore', function (Blueprint $table) {
|
||||
$table->foreignId('vcenter_id')->nullable()->after('module_host_id')
|
||||
->constrained('module_vcenter')->nullOnDelete();
|
||||
});
|
||||
|
||||
Schema::table('module_network', function (Blueprint $table) {
|
||||
$table->foreignId('vcenter_id')->nullable()->after('module_host_id')
|
||||
->constrained('module_vcenter')->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('module_datastore', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('vcenter_id');
|
||||
});
|
||||
|
||||
Schema::table('module_network', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('vcenter_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
if (!Schema::hasColumn('ip_pools', 'netmask')) {
|
||||
Schema::table('ip_pools', function (Blueprint $table) {
|
||||
$table->string('netmask')->nullable()->after('cidr');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('ip_pools', function (Blueprint $table) {
|
||||
$table->dropColumn('netmask');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('os', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('module_network_id')->nullable()->after('datastore_id');
|
||||
$table->foreign('module_network_id')
|
||||
->references('id')
|
||||
->on('module_network')
|
||||
->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('os', function (Blueprint $table) {
|
||||
$table->dropForeign(['module_network_id']);
|
||||
$table->dropColumn('module_network_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('module_resource_pool', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 255)->nullable();
|
||||
$table->string('resource_pool', 255)->nullable();
|
||||
$table->foreignId('module_host_id')->index()->constrained('module_host')->nullable();
|
||||
$table->foreignId('vcenter_id')->nullable()->constrained('module_vcenter')->nullOnDelete();
|
||||
$table->tinyInteger('status')->default(1);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('module_resource_pool');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('os', function (Blueprint $table) {
|
||||
$table->foreignId('resource_pool_id')->nullable()
|
||||
->constrained('module_resource_pool')->nullOnDelete();
|
||||
$table->foreignId('folder_id')->nullable()
|
||||
->constrained('module_folder')->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('os', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('resource_pool_id');
|
||||
$table->dropConstrainedForeignId('folder_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user