Skip to content

Commit

Permalink
fix smbios error at clone
Browse files Browse the repository at this point in the history
  • Loading branch information
bpg committed Aug 5, 2023
1 parent 94f2cde commit a559a5a
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions proxmoxtf/resource/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2258,9 +2258,6 @@ func vmCreateCustom(ctx context.Context, d *schema.ResourceData, m interface{})
serialDevices := vmGetSerialDeviceList(d)

smbios := vmGetSMBIOS(d)
if smbios != nil && (smbios.UUID == nil || *smbios.UUID == "") {
smbios.UUID = types.StrPtr(uuid.New().String())
}

startupOrder := vmGetStartupOrder(d)

Expand Down Expand Up @@ -3139,7 +3136,7 @@ func vmGetSMBIOS(d *schema.ResourceData) *vms.CustomSMBIOS {
serial, _ := smbiosBlock[mkResourceVirtualEnvironmentVMSMBIOSSerial].(string)
sku, _ := smbiosBlock[mkResourceVirtualEnvironmentVMSMBIOSSKU].(string)
version, _ := smbiosBlock[mkResourceVirtualEnvironmentVMSMBIOSVersion].(string)
uuid, _ := smbiosBlock[mkResourceVirtualEnvironmentVMSMBIOSUUID].(string)
uid, _ := smbiosBlock[mkResourceVirtualEnvironmentVMSMBIOSUUID].(string)

smbios := vms.CustomSMBIOS{
Base64: &b64,
Expand Down Expand Up @@ -3175,10 +3172,13 @@ func vmGetSMBIOS(d *schema.ResourceData) *vms.CustomSMBIOS {
smbios.Version = &v
}

if uuid != "" {
smbios.UUID = &uuid
if uid != "" {
smbios.UUID = &uid
}

if smbios.UUID == nil || *smbios.UUID == "" {
smbios.UUID = types.StrPtr(uuid.New().String())
}
return &smbios

Check failure on line 3182 in proxmoxtf/resource/vm.go

View workflow job for this annotation

GitHub Actions / lint

return statements should not be cuddled if block has more than two lines (wsl)
}

Expand Down Expand Up @@ -4336,7 +4336,7 @@ func vmReadCustom(
//nolint:gocritic
if len(clone) > 0 {
if len(currentSMBIOS) > 0 {
err := d.Set(mkResourceVirtualEnvironmentVMSMBIOS, []interface{}{currentSMBIOS})
err := d.Set(mkResourceVirtualEnvironmentVMSMBIOS, currentSMBIOS)
diags = append(diags, diag.FromErr(err)...)
}
} else if len(smbios) == 0 {
Expand Down Expand Up @@ -5173,10 +5173,16 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D

if d.HasChange(mkResourceVirtualEnvironmentVMSMBIOS) {
updateBody.SMBIOS = vmGetSMBIOS(d)
if updateBody.SMBIOS == nil {
del = append(del, "smbios1")
}
}

if d.HasChange(mkResourceVirtualEnvironmentVMStartup) {
updateBody.StartupOrder = vmGetStartupOrder(d)
if updateBody.StartupOrder == nil {
del = append(del, "startup")
}
}

// Prepare the new VGA configuration.
Expand Down

0 comments on commit a559a5a

Please sign in to comment.