add/remove cdrom & floppy only if vm is started

This commit is contained in:
Michael Kuzmin 2018-05-05 00:10:43 +03:00
parent a981a426bc
commit aedfab264f
1 changed files with 17 additions and 18 deletions

View File

@ -39,18 +39,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
&StepCreateVM{ &StepCreateVM{
Config: &b.config.CreateConfig, Config: &b.config.CreateConfig,
}, },
&StepAddCDRom{
Config: &b.config.CDRomConfig,
},
&packerCommon.StepCreateFloppy{
Files: b.config.FloppyFiles,
Directories: b.config.FloppyDirectories,
},
&StepAddFloppy{
Config: &b.config.FloppyConfig,
Datastore: b.config.Datastore,
Host: b.config.Host,
},
&StepConfigParams{ &StepConfigParams{
Config: &b.config.ConfigParamsConfig, Config: &b.config.ConfigParamsConfig,
}, },
@ -58,6 +46,18 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
if b.config.Comm.Type != "none" { if b.config.Comm.Type != "none" {
steps = append(steps, steps = append(steps,
&StepAddCDRom{
Config: &b.config.CDRomConfig,
},
&packerCommon.StepCreateFloppy{
Files: b.config.FloppyFiles,
Directories: b.config.FloppyDirectories,
},
&StepAddFloppy{
Config: &b.config.FloppyConfig,
Datastore: b.config.Datastore,
Host: b.config.Host,
},
&common.StepRun{ &common.StepRun{
Config: &b.config.RunConfig, Config: &b.config.RunConfig,
}, },
@ -74,15 +74,15 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
&common.StepShutdown{ &common.StepShutdown{
Config: &b.config.ShutdownConfig, Config: &b.config.ShutdownConfig,
}, },
&StepRemoveCDRom{},
&StepRemoveFloppy{
Datastore: b.config.Datastore,
Host: b.config.Host,
},
) )
} }
steps = append(steps, steps = append(steps,
&StepRemoveCDRom{},
&StepRemoveFloppy{
Datastore: b.config.Datastore,
Host: b.config.Host,
},
&common.StepCreateSnapshot{ &common.StepCreateSnapshot{
CreateSnapshot: b.config.CreateSnapshot, CreateSnapshot: b.config.CreateSnapshot,
}, },
@ -91,7 +91,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
}, },
) )
// Run!
b.runner = packerCommon.NewRunner(steps, b.config.PackerConfig, ui) b.runner = packerCommon.NewRunner(steps, b.config.PackerConfig, ui)
b.runner.Run(state) b.runner.Run(state)