github.com/tonnydourado/packer@v0.6.1-0.20140701134019-5d0cd9676a37/builder/parallels/iso/step_attach_iso.go (about)

     1  package iso
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/mitchellh/multistep"
     6  	parallelscommon "github.com/mitchellh/packer/builder/parallels/common"
     7  	"github.com/mitchellh/packer/packer"
     8  )
     9  
    10  // This step attaches the ISO to the virtual machine.
    11  //
    12  // Uses:
    13  //
    14  // Produces:
    15  type stepAttachISO struct {
    16  	diskPath string
    17  }
    18  
    19  func (s *stepAttachISO) Run(state multistep.StateBag) multistep.StepAction {
    20  	driver := state.Get("driver").(parallelscommon.Driver)
    21  	isoPath := state.Get("iso_path").(string)
    22  	ui := state.Get("ui").(packer.Ui)
    23  	vmName := state.Get("vmName").(string)
    24  
    25  	// Attach the disk to the controller
    26  	command := []string{
    27  		"set", vmName,
    28  		"--device-set", "cdrom0",
    29  		"--image", isoPath,
    30  		"--enable", "--connect",
    31  	}
    32  	if err := driver.Prlctl(command...); err != nil {
    33  		err := fmt.Errorf("Error attaching ISO: %s", err)
    34  		state.Put("error", err)
    35  		ui.Error(err.Error())
    36  		return multistep.ActionHalt
    37  	}
    38  
    39  	// Set some state so we know to remove
    40  	state.Put("attachedIso", true)
    41  
    42  	return multistep.ActionContinue
    43  }
    44  
    45  func (s *stepAttachISO) Cleanup(state multistep.StateBag) {}