Skip to content

Commit 5be794b

Browse files
authored
Update details if changed for an instance (#91)
1 parent 976e564 commit 5be794b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

cloudstack/resource_cloudstack_instance.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,14 +677,26 @@ func resourceCloudStackInstanceUpdate(d *schema.ResourceData, meta interface{})
677677
}
678678
}
679679

680-
// Check is the tags have changed and if so, update the tags
680+
// Check if the tags have changed and if so, update the tags
681681
if d.HasChange("tags") {
682682
if err := updateTags(cs, d, "UserVm"); err != nil {
683683
return fmt.Errorf("Error updating tags on instance %s: %s", name, err)
684684
}
685685
d.SetPartial("tags")
686686
}
687687

688+
// Check if the details have changed and if so, update the details
689+
if d.HasChange("details") {
690+
p := cs.VirtualMachine.NewUpdateVirtualMachineParams(d.Id())
691+
vmDetails := make(map[string]string)
692+
if details := d.Get("details"); details != nil {
693+
for k, v := range details.(map[string]interface{}) {
694+
vmDetails[k] = v.(string)
695+
}
696+
}
697+
p.SetDetails(vmDetails)
698+
}
699+
688700
d.Partial(false)
689701

690702
return resourceCloudStackInstanceRead(d, meta)

0 commit comments

Comments
 (0)