builder/virtualbox: upload guest additions to VM
This commit is contained in:
parent
43b6c1fa89
commit
a599074185
|
@ -225,6 +225,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
new(stepTypeBootCommand),
|
||||
new(stepWaitForSSH),
|
||||
new(stepUploadVersion),
|
||||
new(stepUploadGuestAdditions),
|
||||
new(stepProvision),
|
||||
new(stepShutdown),
|
||||
new(stepExport),
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package virtualbox
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mitchellh/multistep"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
"os"
|
||||
)
|
||||
|
||||
// This step uploads a file containing the VirtualBox version, which
|
||||
// can be useful for various provisioning reasons.
|
||||
type stepUploadGuestAdditions struct{}
|
||||
|
||||
func (s *stepUploadGuestAdditions) Run(state map[string]interface{}) multistep.StepAction {
|
||||
comm := state["communicator"].(packer.Communicator)
|
||||
config := state["config"].(*config)
|
||||
guestAdditionsPath := state["guest_additions_path"].(string)
|
||||
ui := state["ui"].(packer.Ui)
|
||||
|
||||
f, err := os.Open(guestAdditionsPath)
|
||||
if err != nil {
|
||||
state["error"] = fmt.Errorf("Error opening guest additions ISO: %s", err)
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
ui.Say("Upload VirtualBox guest additions ISO...")
|
||||
if err := comm.Upload(config.GuestAdditionsPath, f); err != nil {
|
||||
state["error"] = fmt.Errorf("Error uploading guest additions: %s", err)
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
return multistep.ActionContinue
|
||||
}
|
||||
|
||||
func (s *stepUploadGuestAdditions) Cleanup(state map[string]interface{}) {}
|
Loading…
Reference in New Issue