Skip to content

Commit

Permalink
Merge pull request #1 from hasusuf/add-vm-support-to-snapshot
Browse files Browse the repository at this point in the history
Add vm support to snapshot
  • Loading branch information
hasusuf authored Nov 30, 2021
2 parents c3cae14 + d55071f commit 397870c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 1.7.0 (Unreleased)

IMPROVEMENTS
* Added `virtual-machine` support to `lxd_container_snapshot` [GH-248](https://github.com/terraform-lxd/terraform-provider-lxd/pull/248)

## 1.6.0 (October 7, 2021)

BUG FIXES
Expand Down
11 changes: 5 additions & 6 deletions lxd/resource_lxd_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"log"
"strings"

"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
Expand Down Expand Up @@ -70,7 +69,7 @@ func resourceLxdSnapshotCreate(d *schema.ResourceData, meta interface{}) error {

ctrName := d.Get("container_name").(string)

snapPost := api.ContainerSnapshotsPost{}
snapPost := api.InstanceSnapshotsPost{}
snapPost.Name = d.Get("name").(string)
snapPost.Stateful = d.Get("stateful").(bool)

Expand All @@ -79,7 +78,7 @@ func resourceLxdSnapshotCreate(d *schema.ResourceData, meta interface{}) error {
var i int
for i = 0; i < 5; i++ {

op, err := server.CreateContainerSnapshot(ctrName, snapPost)
op, err := server.CreateInstanceSnapshot(ctrName, snapPost)
if err != nil {
return err
}
Expand Down Expand Up @@ -119,7 +118,7 @@ func resourceLxdSnapshotRead(d *schema.ResourceData, meta interface{}) error {

snapID := newSnapshotIDFromResourceID(d.Id())

snap, _, err := server.GetContainerSnapshot(snapID.container, snapID.snapshot)
snap, _, err := server.GetInstanceSnapshot(snapID.container, snapID.snapshot)
if err != nil {
if err.Error() == "not found" {
d.SetId("")
Expand All @@ -145,7 +144,7 @@ func resourceLxdSnapshotDelete(d *schema.ResourceData, meta interface{}) error {
}
snapID := newSnapshotIDFromResourceID(d.Id())

server.DeleteContainerSnapshot(snapID.container, snapID.snapshot)
server.DeleteInstanceSnapshot(snapID.container, snapID.snapshot)

return nil
}
Expand All @@ -158,7 +157,7 @@ func resourceLxdSnapshotExists(d *schema.ResourceData, meta interface{}) (bool,
}
snapID := newSnapshotIDFromResourceID(d.Id())

snap, _, err := server.GetContainerSnapshot(snapID.container, snapID.snapshot)
snap, _, err := server.GetInstanceSnapshot(snapID.container, snapID.snapshot)

if err != nil && err.Error() == "not found" {
err = nil
Expand Down

0 comments on commit 397870c

Please sign in to comment.