2018-01-24 09:56:14 -05:00
|
|
|
package iso
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/packer/packer"
|
|
|
|
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
|
|
|
|
"github.com/mitchellh/multistep"
|
2018-01-31 12:29:03 -05:00
|
|
|
"fmt"
|
2018-01-24 09:56:14 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type CDRomConfig struct {
|
2018-01-31 12:29:03 -05:00
|
|
|
ISOPaths []string `mapstructure:"iso_paths"`
|
2018-01-24 09:56:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *CDRomConfig) Prepare() []error {
|
2018-01-30 11:45:56 -05:00
|
|
|
return nil
|
2018-01-24 09:56:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
type StepAddCDRom struct {
|
2018-02-01 06:47:09 -05:00
|
|
|
Config *CDRomConfig
|
2018-01-24 09:56:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *StepAddCDRom) Run(state multistep.StateBag) multistep.StepAction {
|
|
|
|
ui := state.Get("ui").(packer.Ui)
|
|
|
|
|
2018-01-31 12:29:03 -05:00
|
|
|
ui.Say("Adding CDRoms...")
|
2018-01-24 09:56:14 -05:00
|
|
|
|
|
|
|
vm := state.Get("vm").(*driver.VirtualMachine)
|
2018-02-01 06:47:09 -05:00
|
|
|
for _, path := range s.Config.ISOPaths {
|
2018-01-31 12:29:03 -05:00
|
|
|
if err := vm.AddCdrom(path); err != nil {
|
|
|
|
state.Put("error", fmt.Errorf("error adding a cdrom: %v", err))
|
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
2018-01-24 09:56:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *StepAddCDRom) Cleanup(state multistep.StateBag) {
|
|
|
|
// nothing
|
|
|
|
}
|