Support floppy_files for vmx on esxi
This commit is contained in:
parent
35922ca327
commit
67be007f45
|
@ -1,28 +1,29 @@
|
||||||
package iso
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
vmwcommon "github.com/hashicorp/packer/builder/vmware/common"
|
|
||||||
"github.com/hashicorp/packer/helper/multistep"
|
"github.com/hashicorp/packer/helper/multistep"
|
||||||
"github.com/hashicorp/packer/packer"
|
"github.com/hashicorp/packer/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// stepRemoteUpload uploads some thing from the state bag to a remote driver
|
// stepRemoteUpload uploads some thing from the state bag to a remote driver
|
||||||
// (if it can) and stores that new remote path into the state bag.
|
// (if it can) and stores that new remote path into the state bag.
|
||||||
type stepRemoteUpload struct {
|
type StepRemoteUpload struct {
|
||||||
Key string
|
Key string
|
||||||
Message string
|
Message string
|
||||||
DoCleanup bool
|
DoCleanup bool
|
||||||
|
Checksum string
|
||||||
|
ChecksumType string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *stepRemoteUpload) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
func (s *StepRemoteUpload) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||||
driver := state.Get("driver").(vmwcommon.Driver)
|
driver := state.Get("driver").(Driver)
|
||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
|
|
||||||
remote, ok := driver.(vmwcommon.RemoteDriver)
|
remote, ok := driver.(RemoteDriver)
|
||||||
if !ok {
|
if !ok {
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
@ -32,14 +33,10 @@ func (s *stepRemoteUpload) Run(ctx context.Context, state multistep.StateBag) mu
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
config := state.Get("config").(*Config)
|
if esx5, ok := remote.(*ESX5Driver); ok {
|
||||||
checksum := config.ISOChecksum
|
|
||||||
checksumType := config.ISOChecksumType
|
|
||||||
|
|
||||||
if esx5, ok := remote.(*vmwcommon.ESX5Driver); ok {
|
|
||||||
remotePath := esx5.CachePath(path)
|
remotePath := esx5.CachePath(path)
|
||||||
|
|
||||||
if esx5.VerifyChecksum(checksumType, checksum, remotePath) {
|
if esx5.VerifyChecksum(s.ChecksumType, s.Checksum, remotePath) {
|
||||||
ui.Say("Remote cache was verified skipping remote upload...")
|
ui.Say("Remote cache was verified skipping remote upload...")
|
||||||
state.Put(s.Key, remotePath)
|
state.Put(s.Key, remotePath)
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
|
@ -49,7 +46,7 @@ func (s *stepRemoteUpload) Run(ctx context.Context, state multistep.StateBag) mu
|
||||||
|
|
||||||
ui.Say(s.Message)
|
ui.Say(s.Message)
|
||||||
log.Printf("Remote uploading: %s", path)
|
log.Printf("Remote uploading: %s", path)
|
||||||
newPath, err := remote.UploadISO(path, checksum, checksumType)
|
newPath, err := remote.UploadISO(path, s.Checksum, s.ChecksumType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error uploading file: %s", err)
|
err := fmt.Errorf("Error uploading file: %s", err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
|
@ -61,14 +58,14 @@ func (s *stepRemoteUpload) Run(ctx context.Context, state multistep.StateBag) mu
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *stepRemoteUpload) Cleanup(state multistep.StateBag) {
|
func (s *StepRemoteUpload) Cleanup(state multistep.StateBag) {
|
||||||
if !s.DoCleanup {
|
if !s.DoCleanup {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
driver := state.Get("driver").(vmwcommon.Driver)
|
driver := state.Get("driver").(Driver)
|
||||||
|
|
||||||
remote, ok := driver.(vmwcommon.RemoteDriver)
|
remote, ok := driver.(RemoteDriver)
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
|
@ -88,14 +88,18 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
|
||||||
Directories: b.config.FloppyConfig.FloppyDirectories,
|
Directories: b.config.FloppyConfig.FloppyDirectories,
|
||||||
Label: b.config.FloppyConfig.FloppyLabel,
|
Label: b.config.FloppyConfig.FloppyLabel,
|
||||||
},
|
},
|
||||||
&stepRemoteUpload{
|
&vmwcommon.StepRemoteUpload{
|
||||||
Key: "floppy_path",
|
Key: "floppy_path",
|
||||||
Message: "Uploading Floppy to remote machine...",
|
Message: "Uploading Floppy to remote machine...",
|
||||||
DoCleanup: true,
|
DoCleanup: true,
|
||||||
|
Checksum: "",
|
||||||
|
ChecksumType: "none",
|
||||||
},
|
},
|
||||||
&stepRemoteUpload{
|
&vmwcommon.StepRemoteUpload{
|
||||||
Key: "iso_path",
|
Key: "iso_path",
|
||||||
Message: "Uploading ISO to remote machine...",
|
Message: "Uploading ISO to remote machine...",
|
||||||
|
Checksum: b.config.ISOChecksum,
|
||||||
|
ChecksumType: b.config.ISOChecksumType,
|
||||||
},
|
},
|
||||||
&stepCreateDisk{},
|
&stepCreateDisk{},
|
||||||
&stepCreateVMX{},
|
&stepCreateVMX{},
|
||||||
|
|
|
@ -84,6 +84,13 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
|
||||||
Directories: b.config.FloppyConfig.FloppyDirectories,
|
Directories: b.config.FloppyConfig.FloppyDirectories,
|
||||||
Label: b.config.FloppyConfig.FloppyLabel,
|
Label: b.config.FloppyConfig.FloppyLabel,
|
||||||
},
|
},
|
||||||
|
&vmwcommon.StepRemoteUpload{
|
||||||
|
Key: "floppy_path",
|
||||||
|
Message: "Uploading Floppy to remote machine...",
|
||||||
|
DoCleanup: true,
|
||||||
|
Checksum: "",
|
||||||
|
ChecksumType: "none",
|
||||||
|
},
|
||||||
&StepCloneVMX{
|
&StepCloneVMX{
|
||||||
OutputDir: b.config.OutputDir,
|
OutputDir: b.config.OutputDir,
|
||||||
Path: b.config.SourcePath,
|
Path: b.config.SourcePath,
|
||||||
|
|
Loading…
Reference in New Issue