Skip to content

Commit

Permalink
Add check for same instance ID
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Kita committed Oct 30, 2024
1 parent f1afbf4 commit 8933960
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions ibm/service/power/resource_ibm_pi_virtual_serial_number.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,28 +124,30 @@ func resourceIBMPIVirtualSerialNumberCreate(ctx context.Context, d *schema.Resou
return diag.FromErr(err)
}

serialNumber := d.Get(Arg_Serial).(string)
addBody := &models.AddServerVirtualSerialNumber{
Serial: &serialNumber,
}
if v, ok := d.GetOk(Arg_Description); ok {
addBody.Description = v.(string)
}
err = client.PVMInstanceAttachVSN(pvmInstanceIdArg, addBody)
if err != nil {
return diag.FromErr(err)
}

_, err = isWaitForPIInstanceStopped(ctx, instanceClient, pvmInstanceIdArg, d.Timeout(schema.TimeoutCreate))
if err != nil {
return diag.FromErr(err)
}
if oldPvmInstanceId == "" {
serialNumber := d.Get(Arg_Serial).(string)
addBody := &models.AddServerVirtualSerialNumber{
Serial: &serialNumber,
}
if v, ok := d.GetOk(Arg_Description); ok {
addBody.Description = v.(string)
}
err = client.PVMInstanceAttachVSN(pvmInstanceIdArg, addBody)
if err != nil {
return diag.FromErr(err)
}

if restartInstance {
err = startLparAfterVSNChange(ctx, instanceClient, pvmInstanceIdArg, d.Timeout(schema.TimeoutCreate))
_, err = isWaitForPIInstanceStopped(ctx, instanceClient, pvmInstanceIdArg, d.Timeout(schema.TimeoutCreate))
if err != nil {
return diag.FromErr(err)
}

if restartInstance {
err = startLparAfterVSNChange(ctx, instanceClient, pvmInstanceIdArg, d.Timeout(schema.TimeoutCreate))
if err != nil {
return diag.FromErr(err)
}
}
}

if vsnArg == AutoAssign {
Expand Down

0 comments on commit 8933960

Please sign in to comment.