2013-07-21 14:32:59 -04:00
|
|
|
package instance
|
|
|
|
|
|
|
|
import (
|
2013-07-24 00:19:44 -04:00
|
|
|
"fmt"
|
2013-07-21 14:32:59 -04:00
|
|
|
"github.com/mitchellh/multistep"
|
2013-07-24 00:19:44 -04:00
|
|
|
"github.com/mitchellh/packer/packer"
|
2013-07-21 14:32:59 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type StepBundleVolume struct{}
|
|
|
|
|
|
|
|
func (s *StepBundleVolume) Run(state map[string]interface{}) multistep.StepAction {
|
2013-07-24 00:19:44 -04:00
|
|
|
comm := state["communicator"].(packer.Communicator)
|
|
|
|
ui := state["ui"].(packer.Ui)
|
|
|
|
|
|
|
|
// Verify the AMI tools are available
|
|
|
|
ui.Say("Checking for EC2 AMI tools...")
|
|
|
|
cmd := &packer.RemoteCmd{Command: "ec2-ami-tools-version"}
|
|
|
|
if err := comm.Start(cmd); err != nil {
|
|
|
|
state["error"] = fmt.Errorf("Error checking for AMI tools: %s", err)
|
|
|
|
ui.Error(state["error"].(error).Error())
|
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
cmd.Wait()
|
|
|
|
|
|
|
|
if cmd.ExitStatus != 0 {
|
|
|
|
state["error"] = fmt.Errorf(
|
|
|
|
"The EC2 AMI tools could not be detected. These must be manually\n" +
|
|
|
|
"via a provisioner or some other means and are required for Packer\n" +
|
|
|
|
"to create an instance-store AMI.")
|
|
|
|
ui.Error(state["error"].(error).Error())
|
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
2013-07-21 14:32:59 -04:00
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *StepBundleVolume) Cleanup(map[string]interface{}) {}
|