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:
@@ -17,6 +17,7 @@ class IpPool extends Model
|
||||
'ip_address',
|
||||
'gateway',
|
||||
'cidr',
|
||||
'netmask',
|
||||
'module_network_id',
|
||||
'status',
|
||||
'service_id',
|
||||
|
||||
@@ -17,6 +17,7 @@ class ModuleDatastore extends Model
|
||||
'type',
|
||||
'space',
|
||||
'module_host_id',
|
||||
'vcenter_id',
|
||||
'status'
|
||||
];
|
||||
|
||||
@@ -24,4 +25,9 @@ class ModuleDatastore extends Model
|
||||
{
|
||||
return $this->belongsTo(\App\Models\ModuleHost::class,'module_host_id','id');
|
||||
}
|
||||
|
||||
public function vcenter()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\vCenter::class, 'vcenter_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,4 +33,8 @@ class ModuleHost extends Model
|
||||
{
|
||||
return $this->hasMany(\App\Models\ModuleNetwork::class);
|
||||
}
|
||||
public function resourcePool()
|
||||
{
|
||||
return $this->hasMany(\App\Models\ModuleResourcePool::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ class ModuleNetwork extends Model
|
||||
'type',
|
||||
'network',
|
||||
'module_host_id',
|
||||
'vcenter_id',
|
||||
'status',
|
||||
];
|
||||
|
||||
@@ -23,6 +24,11 @@ class ModuleNetwork extends Model
|
||||
{
|
||||
return $this->belongsTo(\App\Models\ModuleHost::class,'module_host_id','id');
|
||||
}
|
||||
|
||||
public function vcenter()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\vCenter::class, 'vcenter_id', 'id');
|
||||
}
|
||||
public function ipAddresses()
|
||||
{
|
||||
return $this->hasMany(\App\Models\ModuleIpAddress::class, 'module_network_id');
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ModuleResourcePool extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'module_resource_pool';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'resource_pool',
|
||||
'module_host_id',
|
||||
'vcenter_id',
|
||||
'status',
|
||||
];
|
||||
|
||||
public function host()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\ModuleHost::class, 'module_host_id', 'id');
|
||||
}
|
||||
|
||||
public function vcenter()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\vCenter::class, 'vcenter_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,9 @@ class Os extends Model
|
||||
'template_id',
|
||||
'module_host_id',
|
||||
'datastore_id',
|
||||
'module_network_id',
|
||||
'resource_pool_id',
|
||||
'folder_id',
|
||||
'status',
|
||||
];
|
||||
|
||||
@@ -34,6 +37,21 @@ class Os extends Model
|
||||
{
|
||||
return $this->belongsTo(\App\Models\ModuleDatastore::class, 'datastore_id');
|
||||
}
|
||||
|
||||
public function network()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\ModuleNetwork::class, 'module_network_id');
|
||||
}
|
||||
|
||||
public function resourcePool()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\ModuleResourcePool::class, 'resource_pool_id');
|
||||
}
|
||||
|
||||
public function folder()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\ModuleFolder::class, 'folder_id');
|
||||
}
|
||||
public function getStatus()
|
||||
{
|
||||
return match ($this->attributes['status']){
|
||||
|
||||
Reference in New Issue
Block a user