Add new config option to allow setting virtual machine hardware version (#65)
* Add new config option to allow setting virtual machine hardware version The vsphere-iso builder gets a new configuration option named vm_version. It allows setting the VMWare virtual machine hardware version to a non-default value. The default behavior remains unchanged. Use the latest supported hardware version that ESXi/vCenter allows. VMWare KB for supported virtual machine hardware versions. https://kb.vmware.com/s/article/1003746 * Change vm_version from string to int
This commit is contained in:
parent
9612ec5b5e
commit
40ec9efdfd
@ -53,6 +53,7 @@ type CreateConfig struct {
|
|||||||
Network string // "" for default network
|
Network string // "" for default network
|
||||||
NetworkCard string // example: vmxnet3
|
NetworkCard string // example: vmxnet3
|
||||||
USBController bool
|
USBController bool
|
||||||
|
Version int // example: 10
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) NewVM(ref *types.ManagedObjectReference) *VirtualMachine {
|
func (d *Driver) NewVM(ref *types.ManagedObjectReference) *VirtualMachine {
|
||||||
@ -396,6 +397,9 @@ func (config CreateConfig) toConfigSpec() types.VirtualMachineConfigSpec {
|
|||||||
confSpec.Name = config.Name
|
confSpec.Name = config.Name
|
||||||
confSpec.Annotation = config.Annotation
|
confSpec.Annotation = config.Annotation
|
||||||
confSpec.GuestId = config.GuestOS
|
confSpec.GuestId = config.GuestOS
|
||||||
|
if config.Version != 0 {
|
||||||
|
confSpec.Version = fmt.Sprintf("%s%d", "vmx-", config.Version)
|
||||||
|
}
|
||||||
return confSpec
|
return confSpec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ type CreateConfig struct {
|
|||||||
Network string `mapstructure:"network"`
|
Network string `mapstructure:"network"`
|
||||||
NetworkCard string `mapstructure:"network_card"`
|
NetworkCard string `mapstructure:"network_card"`
|
||||||
USBController bool `mapstructure:"usb_controller"`
|
USBController bool `mapstructure:"usb_controller"`
|
||||||
|
Version int `mapstructure:"vm_version"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CreateConfig) Prepare() []error {
|
func (c *CreateConfig) Prepare() []error {
|
||||||
@ -31,6 +32,10 @@ func (c *CreateConfig) Prepare() []error {
|
|||||||
errs = append(errs, tmp.VMConfig.Prepare()...)
|
errs = append(errs, tmp.VMConfig.Prepare()...)
|
||||||
errs = append(errs, tmp.HardwareConfig.Prepare()...)
|
errs = append(errs, tmp.HardwareConfig.Prepare()...)
|
||||||
|
|
||||||
|
if tmp.Version < 0 {
|
||||||
|
errs = append(errs, fmt.Errorf("'vm_version' cannot be a negative number"))
|
||||||
|
}
|
||||||
|
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
@ -71,6 +76,7 @@ func (s *StepCreateVM) Run(state multistep.StateBag) multistep.StepAction {
|
|||||||
Network: s.Config.Network,
|
Network: s.Config.Network,
|
||||||
NetworkCard: s.Config.NetworkCard,
|
NetworkCard: s.Config.NetworkCard,
|
||||||
USBController: s.Config.USBController,
|
USBController: s.Config.USBController,
|
||||||
|
Version: s.Config.Version,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user