feat: Add IP address and DNS fields to module_vmware table
- Introduced `ip` and `dns` columns to the `module_vmware` table to store assigned IP addresses and DNS configurations. - Implemented `ChangePasswordViaSshJob` for secure password changes via SSH. - Created `ChangePasswordJob` for handling password changes during VM provisioning. - Developed `ChangePasswordViaVsphereJob` to reset VM guest OS passwords using PowerShell scripts executed on the vSphere host. - Added `SendVmCredentialsEmailJob` to send final VM credentials to customers. - Implemented `WaitVmReadyJob` to poll vSphere API until VMware Tools are running and guest IP is available. - Created `VmProvisionService` for managing VM provisioning tasks, including password generation and updates. - Developed `VsphereHostSshService` for executing PowerShell scripts on the vSphere host via SSH. - Added `IpPoolSeeder` to populate IP pools for VM service initialization.
This commit is contained in:
@@ -1159,13 +1159,25 @@ PS;
|
||||
->status();
|
||||
}
|
||||
|
||||
public function ConfigVirtualMachineUbuntu($vmware_id = '', $product = [], $password = ''): void
|
||||
public function ConfigVirtualMachineUbuntu($vmware_id = '', $product = null, $password = ''): void
|
||||
{
|
||||
$this->SetConfig($product->IpAddress->Host->Datacenter->vCenter);
|
||||
if (!$product) {
|
||||
Log::error('ConfigVirtualMachineUbuntu: Product is null', ['vmware_id' => $vmware_id]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Use resolveVCenterFromProduct to get vCenter
|
||||
$vcenter = $this->resolveVCenterFromProduct($product);
|
||||
if (!$vcenter) {
|
||||
Log::error('ConfigVirtualMachineUbuntu: Cannot resolve vCenter', ['vmware_id' => $vmware_id]);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->SetConfig($vcenter);
|
||||
$VirtualMachine = "VirtualMachine-$vmware_id";
|
||||
$IPAddress = $product->IpAddress->ip;
|
||||
$Gateway = $product->IpAddress->gateway;
|
||||
$HostName = strtolower($product->hostname);
|
||||
$IPAddress = $product->ipAddress?->ip ?? '0.0.0.0';
|
||||
$Gateway = $product->ipAddress?->gateway ?? '0.0.0.0';
|
||||
$HostName = strtolower($product->hostname ?? 'vm');
|
||||
|
||||
Log::channel('Custom')->info("\r\n");
|
||||
|
||||
@@ -1317,11 +1329,20 @@ PS;
|
||||
|
||||
public function ConfigCentOSVersion8($vmware_id = '', $product = [], $password = ''): void
|
||||
{
|
||||
$this->SetConfig($product->IpAddress->Host->Datacenter->vCenter);
|
||||
// Use resolveVCenterFromProduct to get vCenter
|
||||
$vcenter = null;
|
||||
if ($product) {
|
||||
$vcenter = $this->resolveVCenterFromProduct($product);
|
||||
}
|
||||
if (!$vcenter) {
|
||||
Log::error('Cannot resolve vCenter', ['vmware_id' => $vmware_id]);
|
||||
return;
|
||||
}
|
||||
$this->SetConfig($vcenter);
|
||||
$VirtualMachine = "VirtualMachine-$vmware_id";
|
||||
$IPAddress = $product->IpAddress->ip;
|
||||
$Gateway = $product->IpAddress->gateway;
|
||||
$HostName = strtolower($product->hostname);
|
||||
$IPAddress = $product->ipAddress?->ip ?? '0.0.0.0';
|
||||
$Gateway = $product->ipAddress?->gateway ?? '0.0.0.0';
|
||||
$HostName = strtolower($product->hostname ?? 'vm');
|
||||
Log::channel('Custom')->info("\r\n");
|
||||
|
||||
try {
|
||||
@@ -1350,11 +1371,20 @@ PS;
|
||||
|
||||
public function ConfigCentOSVersion7($vmware_id = '', $product = [], $password = ''): void
|
||||
{
|
||||
$this->SetConfig($product->IpAddress->Host->Datacenter->vCenter);
|
||||
// Use resolveVCenterFromProduct to get vCenter
|
||||
$vcenter = null;
|
||||
if ($product) {
|
||||
$vcenter = $this->resolveVCenterFromProduct($product);
|
||||
}
|
||||
if (!$vcenter) {
|
||||
Log::error('Cannot resolve vCenter', ['vmware_id' => $vmware_id]);
|
||||
return;
|
||||
}
|
||||
$this->SetConfig($vcenter);
|
||||
$VirtualMachine = "VirtualMachine-$vmware_id";
|
||||
$IPAddress = $product->IpAddress->ip;
|
||||
$Gateway = $product->IpAddress->gateway;
|
||||
$HostName = strtolower($product->hostname);
|
||||
$IPAddress = $product->ipAddress?->ip ?? '0.0.0.0';
|
||||
$Gateway = $product->ipAddress?->gateway ?? '0.0.0.0';
|
||||
$HostName = strtolower($product->hostname ?? 'vm');
|
||||
Log::channel('Custom')->info("\r\n");
|
||||
|
||||
try {
|
||||
@@ -1385,19 +1415,21 @@ PS;
|
||||
{
|
||||
try {
|
||||
// Kiểm tra null safety
|
||||
if (!$product || !$product->IpAddress || !$product->IpAddress->Host || !$product->IpAddress->Host->Datacenter || !$product->IpAddress->Host->Datacenter->vCenter) {
|
||||
Log::error('❌ ConfigWindowsVersion10: Missing required data', [
|
||||
'vmware_id' => $vmware_id,
|
||||
'product_id' => $product?->id ?? 'unknown',
|
||||
'ip_address' => $product?->IpAddress?->ip ?? 'unknown',
|
||||
'host' => $product?->IpAddress?->Host?->name ?? 'unknown',
|
||||
'datacenter' => $product?->IpAddress?->Host?->Datacenter?->name ?? 'unknown',
|
||||
'vcenter' => $product?->IpAddress?->Host?->Datacenter?->vCenter?->host ?? 'unknown'
|
||||
]);
|
||||
if (!$product) {
|
||||
Log::error('❌ ConfigWindowsVersion10: Product is null', ['vmware_id' => $vmware_id]);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->SetConfig($product->IpAddress->Host->Datacenter->vCenter);
|
||||
// Use resolveVCenterFromProduct to get vCenter
|
||||
$vcenter = null;
|
||||
if ($product) {
|
||||
$vcenter = $this->resolveVCenterFromProduct($product);
|
||||
}
|
||||
if (!$vcenter) {
|
||||
Log::error('Cannot resolve vCenter', ['vmware_id' => $vmware_id]);
|
||||
return;
|
||||
}
|
||||
$this->SetConfig($vcenter);
|
||||
$VirtualMachine = "VirtualMachine-$vmware_id";
|
||||
$IPAddress = $product->IpAddress->ip;
|
||||
$Gateway = $product->IpAddress->gateway;
|
||||
@@ -1429,19 +1461,21 @@ PS;
|
||||
{
|
||||
try {
|
||||
// Kiểm tra null safety
|
||||
if (!$product || !$product->IpAddress || !$product->IpAddress->Host || !$product->IpAddress->Host->Datacenter || !$product->IpAddress->Host->Datacenter->vCenter) {
|
||||
Log::error('❌ ConfigWindowsServer: Missing required data', [
|
||||
'vmware_id' => $vmware_id,
|
||||
'product_id' => $product?->id ?? 'unknown',
|
||||
'ip_address' => $product?->IpAddress?->ip ?? 'unknown',
|
||||
'host' => $product?->IpAddress?->Host?->name ?? 'unknown',
|
||||
'datacenter' => $product?->IpAddress?->Host?->Datacenter?->name ?? 'unknown',
|
||||
'vcenter' => $product?->IpAddress?->Host?->Datacenter?->vCenter?->host ?? 'unknown'
|
||||
]);
|
||||
if (!$product) {
|
||||
Log::error('❌ ConfigWindowsServer: Product is null', ['vmware_id' => $vmware_id]);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->SetConfig($product->IpAddress->Host->Datacenter->vCenter);
|
||||
// Use resolveVCenterFromProduct to get vCenter
|
||||
$vcenter = null;
|
||||
if ($product) {
|
||||
$vcenter = $this->resolveVCenterFromProduct($product);
|
||||
}
|
||||
if (!$vcenter) {
|
||||
Log::error('Cannot resolve vCenter', ['vmware_id' => $vmware_id]);
|
||||
return;
|
||||
}
|
||||
$this->SetConfig($vcenter);
|
||||
$VirtualMachine = "VirtualMachine-$vmware_id";
|
||||
$IPAddress = $product->IpAddress->ip;
|
||||
$Gateway = $product->IpAddress->gateway;
|
||||
@@ -1473,19 +1507,18 @@ PS;
|
||||
{
|
||||
try {
|
||||
// Kiểm tra null safety
|
||||
if (!$product || !$product->IpAddress || !$product->IpAddress->Host || !$product->IpAddress->Host->Datacenter || !$product->IpAddress->Host->Datacenter->vCenter) {
|
||||
Log::error('❌ ConfigFixWindowsClick: Missing required data', [
|
||||
'vmware_id' => $vmware_id,
|
||||
'product_id' => $product?->id ?? 'unknown',
|
||||
'ip_address' => $product?->IpAddress?->ip ?? 'unknown',
|
||||
'host' => $product?->IpAddress?->Host?->name ?? 'unknown',
|
||||
'datacenter' => $product?->IpAddress?->Host?->Datacenter?->name ?? 'unknown',
|
||||
'vcenter' => $product?->IpAddress?->Host?->Datacenter?->vCenter?->host ?? 'unknown'
|
||||
]);
|
||||
if (!$product) {
|
||||
Log::error('❌ ConfigFixWindowsClick: Product is null', ['vmware_id' => $vmware_id]);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->SetConfig($product->IpAddress->Host->Datacenter->vCenter);
|
||||
// Use resolveVCenterFromProduct to get vCenter
|
||||
$vcenter = $this->resolveVCenterFromProduct($product);
|
||||
if (!$vcenter) {
|
||||
Log::error('Cannot resolve vCenter', ['vmware_id' => $vmware_id]);
|
||||
return;
|
||||
}
|
||||
$this->SetConfig($vcenter);
|
||||
$VirtualMachine = "VirtualMachine-$vmware_id";
|
||||
|
||||
Log::channel('Custom')->info("===================================================================");
|
||||
@@ -1513,23 +1546,22 @@ PS;
|
||||
{
|
||||
try {
|
||||
// Kiểm tra null safety
|
||||
if (!$product || !$product->IpAddress || !$product->IpAddress->Host || !$product->IpAddress->Host->Datacenter || !$product->IpAddress->Host->Datacenter->vCenter) {
|
||||
Log::error('❌ ConfigRockyLinuxVersion9: Missing required data', [
|
||||
'vmware_id' => $vmware_id,
|
||||
'product_id' => $product?->id ?? 'unknown',
|
||||
'ip_address' => $product?->IpAddress?->ip ?? 'unknown',
|
||||
'host' => $product?->IpAddress?->Host?->name ?? 'unknown',
|
||||
'datacenter' => $product?->IpAddress?->Host?->Datacenter?->name ?? 'unknown',
|
||||
'vcenter' => $product?->IpAddress?->Host?->Datacenter?->vCenter?->host ?? 'unknown'
|
||||
]);
|
||||
if (!$product) {
|
||||
Log::error('❌ ConfigRockyLinuxVersion9: Product is null', ['vmware_id' => $vmware_id]);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->SetConfig($product->IpAddress->Host->Datacenter->vCenter);
|
||||
// Use resolveVCenterFromProduct to get vCenter
|
||||
$vcenter = $this->resolveVCenterFromProduct($product);
|
||||
if (!$vcenter) {
|
||||
Log::error('Cannot resolve vCenter', ['vmware_id' => $vmware_id]);
|
||||
return;
|
||||
}
|
||||
$this->SetConfig($vcenter);
|
||||
$VirtualMachine = "VirtualMachine-$vmware_id";
|
||||
$IPAddress = $product->IpAddress->ip;
|
||||
$Gateway = $product->IpAddress->gateway;
|
||||
$HostName = strtolower($product->hostname);
|
||||
$IPAddress = $product->ipAddress?->ip ?? '0.0.0.0';
|
||||
$Gateway = $product->ipAddress?->gateway ?? '0.0.0.0';
|
||||
$HostName = strtolower($product->hostname ?? 'vm');
|
||||
|
||||
Log::channel('Custom')->info("\r\n");
|
||||
Log::channel('Custom')->info("===================================================================");
|
||||
|
||||
Reference in New Issue
Block a user