From 5e1e4ec7016e38fe69f5892d2da00d30bc0c9288 Mon Sep 17 00:00:00 2001 From: William Brooks Date: Fri, 21 Feb 2020 01:07:58 -0600 Subject: [PATCH] fmt && generate --- builder/hyperv/common/config.go | 4 ++-- builder/hyperv/common/step_mount_dvddrive.go | 4 ++-- builder/hyperv/iso/builder.go | 4 ++-- builder/hyperv/iso/builder.hcl2spec.go | 4 ++-- builder/hyperv/vmcx/builder.go | 4 ++-- builder/hyperv/vmcx/builder.hcl2spec.go | 4 ++-- common/powershell/hyperv/hyperv.go | 22 +++++++++---------- .../common/_CommonConfig-not-required.html.md | 20 ++++++++++++----- 8 files changed, 36 insertions(+), 30 deletions(-) diff --git a/builder/hyperv/common/config.go b/builder/hyperv/common/config.go index 949266454..c97d0ffcd 100644 --- a/builder/hyperv/common/config.go +++ b/builder/hyperv/common/config.go @@ -150,9 +150,9 @@ type CommonConfig struct { Headless bool `mapstructure:"headless" required:"false"` // When configured, determines the device or device type that is given preferential // treatment when choosing a boot device. - // + // // For Generation 1: - // - `IDE` + // - `IDE` // - `CD` *or* `DVD` // - `Floppy` // - `NET` diff --git a/builder/hyperv/common/step_mount_dvddrive.go b/builder/hyperv/common/step_mount_dvddrive.go index faa2a49c7..f0eeaba61 100644 --- a/builder/hyperv/common/step_mount_dvddrive.go +++ b/builder/hyperv/common/step_mount_dvddrive.go @@ -12,8 +12,8 @@ import ( ) type StepMountDvdDrive struct { - Generation uint - FirstBootDevice string + Generation uint + FirstBootDevice string } func (s *StepMountDvdDrive) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { diff --git a/builder/hyperv/iso/builder.go b/builder/hyperv/iso/builder.go index 5735cbbfe..31905e01f 100644 --- a/builder/hyperv/iso/builder.go +++ b/builder/hyperv/iso/builder.go @@ -242,8 +242,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &hypervcommon.StepEnableIntegrationService{}, &hypervcommon.StepMountDvdDrive{ - Generation: b.config.Generation, - FirstBootDevice: b.config.FirstBootDevice, + Generation: b.config.Generation, + FirstBootDevice: b.config.FirstBootDevice, }, &hypervcommon.StepMountFloppydrive{ Generation: b.config.Generation, diff --git a/builder/hyperv/iso/builder.hcl2spec.go b/builder/hyperv/iso/builder.hcl2spec.go index 5753a3f41..a7f2b18aa 100644 --- a/builder/hyperv/iso/builder.hcl2spec.go +++ b/builder/hyperv/iso/builder.hcl2spec.go @@ -97,7 +97,7 @@ type FlatConfig struct { SkipCompaction *bool `mapstructure:"skip_compaction" required:"false" cty:"skip_compaction"` SkipExport *bool `mapstructure:"skip_export" required:"false" cty:"skip_export"` Headless *bool `mapstructure:"headless" required:"false" cty:"headless"` - LegacyGen1BootOrder *bool `mapstructure:"legacy_gen1_boot_order" required:"false" cty:"legacy_gen1_boot_order"` + FirstBootDevice *string `mapstructure:"first_boot_device" required:"false" cty:"first_boot_device"` ShutdownCommand *string `mapstructure:"shutdown_command" required:"false" cty:"shutdown_command"` ShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"` DiskSize *uint `mapstructure:"disk_size" required:"false" cty:"disk_size"` @@ -206,7 +206,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "skip_compaction": &hcldec.AttrSpec{Name: "skip_compaction", Type: cty.Bool, Required: false}, "skip_export": &hcldec.AttrSpec{Name: "skip_export", Type: cty.Bool, Required: false}, "headless": &hcldec.AttrSpec{Name: "headless", Type: cty.Bool, Required: false}, - "legacy_gen1_boot_order": &hcldec.AttrSpec{Name: "legacy_gen1_boot_order", Type: cty.Bool, Required: false}, + "first_boot_device": &hcldec.AttrSpec{Name: "first_boot_device", Type: cty.String, Required: false}, "shutdown_command": &hcldec.AttrSpec{Name: "shutdown_command", Type: cty.String, Required: false}, "shutdown_timeout": &hcldec.AttrSpec{Name: "shutdown_timeout", Type: cty.String, Required: false}, "disk_size": &hcldec.AttrSpec{Name: "disk_size", Type: cty.Number, Required: false}, diff --git a/builder/hyperv/vmcx/builder.go b/builder/hyperv/vmcx/builder.go index 6eed0a3c3..17a878142 100644 --- a/builder/hyperv/vmcx/builder.go +++ b/builder/hyperv/vmcx/builder.go @@ -282,8 +282,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &hypervcommon.StepEnableIntegrationService{}, &hypervcommon.StepMountDvdDrive{ - Generation: b.config.Generation, - FirstBootDevice: b.config.FirstBootDevice, + Generation: b.config.Generation, + FirstBootDevice: b.config.FirstBootDevice, }, &hypervcommon.StepMountFloppydrive{ Generation: b.config.Generation, diff --git a/builder/hyperv/vmcx/builder.hcl2spec.go b/builder/hyperv/vmcx/builder.hcl2spec.go index e2c028e73..113cd677e 100644 --- a/builder/hyperv/vmcx/builder.hcl2spec.go +++ b/builder/hyperv/vmcx/builder.hcl2spec.go @@ -97,7 +97,7 @@ type FlatConfig struct { SkipCompaction *bool `mapstructure:"skip_compaction" required:"false" cty:"skip_compaction"` SkipExport *bool `mapstructure:"skip_export" required:"false" cty:"skip_export"` Headless *bool `mapstructure:"headless" required:"false" cty:"headless"` - LegacyGen1BootOrder *bool `mapstructure:"legacy_gen1_boot_order" required:"false" cty:"legacy_gen1_boot_order"` + FirstBootDevice *string `mapstructure:"first_boot_device" required:"false" cty:"first_boot_device"` ShutdownCommand *string `mapstructure:"shutdown_command" required:"false" cty:"shutdown_command"` ShutdownTimeout *string `mapstructure:"shutdown_timeout" required:"false" cty:"shutdown_timeout"` CloneFromVMCXPath *string `mapstructure:"clone_from_vmcx_path" cty:"clone_from_vmcx_path"` @@ -208,7 +208,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "skip_compaction": &hcldec.AttrSpec{Name: "skip_compaction", Type: cty.Bool, Required: false}, "skip_export": &hcldec.AttrSpec{Name: "skip_export", Type: cty.Bool, Required: false}, "headless": &hcldec.AttrSpec{Name: "headless", Type: cty.Bool, Required: false}, - "legacy_gen1_boot_order": &hcldec.AttrSpec{Name: "legacy_gen1_boot_order", Type: cty.Bool, Required: false}, + "first_boot_device": &hcldec.AttrSpec{Name: "first_boot_device", Type: cty.String, Required: false}, "shutdown_command": &hcldec.AttrSpec{Name: "shutdown_command", Type: cty.String, Required: false}, "shutdown_timeout": &hcldec.AttrSpec{Name: "shutdown_timeout", Type: cty.String, Required: false}, "clone_from_vmcx_path": &hcldec.AttrSpec{Name: "clone_from_vmcx_path", Type: cty.String, Required: false}, diff --git a/common/powershell/hyperv/hyperv.go b/common/powershell/hyperv/hyperv.go index bebc4119f..3ace245a3 100644 --- a/common/powershell/hyperv/hyperv.go +++ b/common/powershell/hyperv/hyperv.go @@ -188,7 +188,7 @@ func SetFirstBootDeviceGen1(vmName string, controllerType string) error { // controllerType must be 'NET', 'DVD', 'IDE' or 'FLOPPY' (case sensitive) // The 'NET' value is always replaced with 'LegacyNetworkAdapter' - if (controllerType == "NET") { + if controllerType == "NET" { controllerType = "LegacyNetworkAdapter" } @@ -205,18 +205,16 @@ param([string] $vmName, [string] $controllerType) func SetFirstBootDeviceGen2(vmName string, controllerType string, controllerNumber uint, controllerLocation uint) error { + // script := ` + // param([string]$vmName,[int]$controllerNumber,[int]$controllerLocation) + // $vmDvdDrive = Hyper-V\Get-VMDvdDrive -VMName $vmName -ControllerNumber $controllerNumber -ControllerLocation $controllerLocation + // if (!$vmDvdDrive) {throw 'unable to find dvd drive'} + // Hyper-V\Set-VMFirmware -VMName $vmName -FirstBootDevice $vmDvdDrive -ErrorAction SilentlyContinue + // ` - -// script := ` -// param([string]$vmName,[int]$controllerNumber,[int]$controllerLocation) -// $vmDvdDrive = Hyper-V\Get-VMDvdDrive -VMName $vmName -ControllerNumber $controllerNumber -ControllerLocation $controllerLocation -// if (!$vmDvdDrive) {throw 'unable to find dvd drive'} -// Hyper-V\Set-VMFirmware -VMName $vmName -FirstBootDevice $vmDvdDrive -ErrorAction SilentlyContinue -// ` - -// script := ` -// param([string] $vmName, [string] $controllerType, ) -//` + // script := ` + // param([string] $vmName, [string] $controllerType, ) + //` return nil } diff --git a/website/source/partials/builder/hyperv/common/_CommonConfig-not-required.html.md b/website/source/partials/builder/hyperv/common/_CommonConfig-not-required.html.md index e1ebf434b..74f9914c5 100644 --- a/website/source/partials/builder/hyperv/common/_CommonConfig-not-required.html.md +++ b/website/source/partials/builder/hyperv/common/_CommonConfig-not-required.html.md @@ -110,10 +110,18 @@ built. When this value is set to true, the machine will start without a console. -- `legacy_gen1_boot_order` (bool) - Over time the Hyper-V builder has been modified to change the original - boot order that is used when an ISO is mounted. Hyper-V's default is to - boot from the CD first, the original Hyper-V builder included code to - codify this setting when the primary ISO is mounted, that code was eventually - modified to place the IDE adapter before the the CD (only in generation 1). - Setting this value to true, forces the original method of operation. +- `first_boot_device` (string) - When configured, determines the device or device type that is given preferential + treatment when choosing a boot device. + + For Generation 1: + - `IDE` + - `CD` *or* `DVD` + - `Floppy` + - `NET` + + For Generation 2: + - `IDE:x:y` + - `SCSI:x:y` + - `CD` *or* `DVD` + - `NET` \ No newline at end of file