diff options
author | Thomas Hipp <thipp@suse.de> | 2017-09-15 09:37:45 +0200 |
---|---|---|
committer | Thomas Hipp <thipp@suse.de> | 2017-09-15 10:01:36 +0200 |
commit | 651fe263818d1c4ad5ba8adf8c8485ce647dc40b (patch) | |
tree | fc73bb74bdcce03c48169ce624698bf240b55e6b /vendor/github.com/mitchellh/packer/builder/lxd/step_lxd_launch.go | |
parent | 23635373aed10aab286a2436459670b686b581bb (diff) | |
download | terraform-provider-libvirt-651fe263818d1c4ad5ba8adf8c8485ce647dc40b.tar terraform-provider-libvirt-651fe263818d1c4ad5ba8adf8c8485ce647dc40b.tar.gz |
vendor: update deps
This updates all vendored packages. The Glide config has been changed to
try and stick to versions instead of commit IDs if possible.
Signed-off-by: Thomas Hipp <thipp@suse.de>
Diffstat (limited to 'vendor/github.com/mitchellh/packer/builder/lxd/step_lxd_launch.go')
-rw-r--r-- | vendor/github.com/mitchellh/packer/builder/lxd/step_lxd_launch.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/vendor/github.com/mitchellh/packer/builder/lxd/step_lxd_launch.go b/vendor/github.com/mitchellh/packer/builder/lxd/step_lxd_launch.go new file mode 100644 index 00000000..1ec573b1 --- /dev/null +++ b/vendor/github.com/mitchellh/packer/builder/lxd/step_lxd_launch.go @@ -0,0 +1,50 @@ +package lxd + +import ( + "fmt" + "github.com/hashicorp/packer/packer" + "github.com/mitchellh/multistep" + "time" +) + +type stepLxdLaunch struct{} + +func (s *stepLxdLaunch) Run(state multistep.StateBag) multistep.StepAction { + config := state.Get("config").(*Config) + ui := state.Get("ui").(packer.Ui) + + name := config.ContainerName + image := config.Image + + args := []string{ + "launch", "--ephemeral=false", image, name, + } + + ui.Say("Creating container...") + _, err := LXDCommand(args...) + if err != nil { + err := fmt.Errorf("Error creating container: %s", err) + state.Put("error", err) + ui.Error(err.Error()) + return multistep.ActionHalt + } + // TODO: Should we check `lxc info <container>` for "Running"? + // We have to do this so /tmp doens't get cleared and lose our provisioner scripts. + time.Sleep(1 * time.Second) + + return multistep.ActionContinue +} + +func (s *stepLxdLaunch) Cleanup(state multistep.StateBag) { + config := state.Get("config").(*Config) + ui := state.Get("ui").(packer.Ui) + + args := []string{ + "delete", "--force", config.ContainerName, + } + + ui.Say("Unregistering and deleting deleting container...") + if _, err := LXDCommand(args...); err != nil { + ui.Error(fmt.Sprintf("Error deleting container: %s", err)) + } +} |