Only attach dvd drive if there is one

Fix debug messages for cloning

Add hyperv-vmcx as a builder from command line
This commit is contained in:
Taliesin Sisson 2017-03-12 23:51:59 +00:00 committed by Vijaya Bhaskar Reddy Kondreddi
parent 429e1bc3ad
commit 452fcbd9a1
5 changed files with 34 additions and 14 deletions

View File

@ -28,7 +28,7 @@ type StepCloneVM struct {
func (s *StepCloneVM) Run(state multistep.StateBag) multistep.StepAction {
driver := state.Get("driver").(Driver)
ui := state.Get("ui").(packer.Ui)
ui.Say("Creating virtual machine...")
ui.Say("Cloning virtual machine...")
path := state.Get("packerTempDir").(string)

View File

@ -2,9 +2,9 @@ package common
import (
"fmt"
"log"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep"
"log"
)
type StepMountDvdDrive struct {
@ -17,7 +17,15 @@ func (s *StepMountDvdDrive) Run(state multistep.StateBag) multistep.StepAction {
errorMsg := "Error mounting dvd drive: %s"
vmName := state.Get("vmName").(string)
isoPath := state.Get("iso_path").(string)
// Determine if we even have a dvd disk to attach
var isoPath string
if isoPathRaw, ok := state.GetOk("iso_path"); ok {
isoPath = isoPathRaw.(string)
} else {
log.Println("No dvd disk, not attaching.")
return multistep.ActionContinue
}
// should be able to mount up to 60 additional iso images using SCSI
// but Windows would only allow a max of 22 due to available drive letters

View File

@ -348,15 +348,23 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
Force: b.config.PackerForce,
Path: b.config.OutputDir,
},
&common.StepDownload{
Checksum: b.config.ISOChecksum,
ChecksumType: b.config.ISOChecksumType,
Description: "ISO",
ResultKey: "iso_path",
Url: b.config.ISOUrls,
Extension: b.config.TargetExtension,
TargetPath: b.config.TargetPath,
},
}
if b.config.RawSingleISOUrl != "" || len(b.config.ISOUrls) > 0 {
steps = append(steps,
&common.StepDownload{
Checksum: b.config.ISOChecksum,
ChecksumType: b.config.ISOChecksumType,
Description: "ISO",
ResultKey: "iso_path",
Url: b.config.ISOUrls,
Extension: b.config.TargetExtension,
TargetPath: b.config.TargetPath,
},
)
}
steps = append(steps,
&common.StepCreateFloppy{
Files: b.config.FloppyFiles,
},
@ -449,7 +457,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
},
// the clean up actions for each step will be executed reverse order
}
)
// Run the steps.
if b.config.PackerDebug {

View File

@ -92,8 +92,12 @@ var Builders = map[string]packer.Builder{
"file": new(filebuilder.Builder),
"googlecompute": new(googlecomputebuilder.Builder),
"hyperv-iso": new(hypervisobuilder.Builder),
<<<<<<< HEAD
"lxc": new(lxcbuilder.Builder),
"lxd": new(lxdbuilder.Builder),
=======
"hyperv-vmcx": new(hypervvmcxbuilder.Builder),
>>>>>>> Only attach dvd drive if there is one
"null": new(nullbuilder.Builder),
"oneandone": new(oneandonebuilder.Builder),
"openstack": new(openstackbuilder.Builder),

View File

@ -248,7 +248,7 @@ if ((Get-Command Set-Vm).Parameters["AutomaticCheckpointsEnabled"]) {
func CloneVirtualMachine(cloneFromVmName string, cloneFromSnapshotName string, cloneAllSnapshots bool, vmName string, path string, ram int64, switchName string) error {
var script = `
param([string]$CloneFromVMName, [string]$CloneFromSnapshotName, [string]CloneAllSnapshotsString, [string]$vmName, [string]$path, [long]$memoryStartupBytes, [string]$switchName)
param([string]$CloneFromVMName, [string]$CloneFromSnapshotName, [string]$CloneAllSnapshotsString, [string]$vmName, [string]$path, [long]$memoryStartupBytes, [string]$switchName)
$CloneAllSnapshots = [System.Boolean]::Parse($CloneAllSnapshotsString)