2013-12-21 17:27:00 -05:00
|
|
|
package iso
|
2013-06-11 18:45:52 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/mitchellh/multistep"
|
2013-12-21 18:00:48 -05:00
|
|
|
vboxcommon "github.com/mitchellh/packer/builder/virtualbox/common"
|
2013-06-11 18:45:52 -04:00
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
|
|
|
// This step sets some variables in VirtualBox so that annoying
|
|
|
|
// pop-up messages don't exist.
|
|
|
|
type stepSuppressMessages struct{}
|
|
|
|
|
2013-08-31 15:44:58 -04:00
|
|
|
func (stepSuppressMessages) Run(state multistep.StateBag) multistep.StepAction {
|
2013-12-21 18:00:48 -05:00
|
|
|
driver := state.Get("driver").(vboxcommon.Driver)
|
2013-08-31 15:44:58 -04:00
|
|
|
ui := state.Get("ui").(packer.Ui)
|
2013-06-11 18:45:52 -04:00
|
|
|
|
|
|
|
log.Println("Suppressing annoying messages in VirtualBox")
|
|
|
|
if err := driver.SuppressMessages(); err != nil {
|
2013-06-20 00:07:53 -04:00
|
|
|
err := fmt.Errorf("Error configuring VirtualBox to suppress messages: %s", err)
|
2013-08-31 15:44:58 -04:00
|
|
|
state.Put("error", err)
|
2013-06-20 00:07:53 -04:00
|
|
|
ui.Error(err.Error())
|
2013-06-11 18:45:52 -04:00
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
2013-08-31 15:44:58 -04:00
|
|
|
func (stepSuppressMessages) Cleanup(multistep.StateBag) {}
|