Fix 'Unexpected EOF' in builds without floppies
This commit is contained in:
parent
903febc4ea
commit
689f1789eb
|
@ -25,8 +25,7 @@ func (s *StepAddFloppy) Run(_ context.Context, state multistep.StateBag) multist
|
||||||
vm := state.Get("vm").(*driver.VirtualMachine)
|
vm := state.Get("vm").(*driver.VirtualMachine)
|
||||||
d := state.Get("driver").(*driver.Driver)
|
d := state.Get("driver").(*driver.Driver)
|
||||||
|
|
||||||
tmpFloppy := state.Get("floppy_path").(string)
|
if floppyPath, ok := state.GetOk("floppy_path"); ok {
|
||||||
if tmpFloppy != "" {
|
|
||||||
ui.Say("Uploading created floppy image")
|
ui.Say("Uploading created floppy image")
|
||||||
|
|
||||||
ds, err := d.FindDatastore(s.Datastore, s.Host)
|
ds, err := d.FindDatastore(s.Datastore, s.Host)
|
||||||
|
@ -41,7 +40,7 @@ func (s *StepAddFloppy) Run(_ context.Context, state multistep.StateBag) multist
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadPath := fmt.Sprintf("%v/packer-tmp-created-floppy.flp", vmDir)
|
uploadPath := fmt.Sprintf("%v/packer-tmp-created-floppy.flp", vmDir)
|
||||||
if err := ds.UploadFile(tmpFloppy, uploadPath); err != nil {
|
if err := ds.UploadFile(floppyPath.(string), uploadPath); err != nil {
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,15 +30,14 @@ func (s *StepRemoveFloppy) Run(_ context.Context, state multistep.StateBag) mult
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
UploadedFloppyPath := state.Get("uploaded_floppy_path").(string)
|
if UploadedFloppyPath, ok := state.GetOk("uploaded_floppy_path"); ok {
|
||||||
if UploadedFloppyPath != "" {
|
|
||||||
ui.Say("Deleting Floppy image...")
|
ui.Say("Deleting Floppy image...")
|
||||||
ds, err := d.FindDatastore(s.Datastore, s.Host)
|
ds, err := d.FindDatastore(s.Datastore, s.Host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
if err := ds.Delete(UploadedFloppyPath); err != nil {
|
if err := ds.Delete(UploadedFloppyPath.(string)); err != nil {
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue