From d0e28b3beb235ffb5cb19ea456c94612ff6ef4b7 Mon Sep 17 00:00:00 2001 From: Christophe Jauffret Date: Thu, 31 Aug 2023 17:53:31 +0200 Subject: [PATCH] add uefi support --- README.md | 1 + machine/driver/driver.go | 25 ++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a643403..5c2696f 100755 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ If you want to use Nutanix Node Driver, you need add it in order to start using | `nutanix-password` | The password of the nutanix management account | yes | | | `nutanix-insecure` | Set to true to force SSL insecure connection | no | false | | `nutanix-cluster` | The name of the cluster where deploy the VM (case sensitive) | yes | | +| `nutanix-boot-type` | The boot type of the VM (legacy or uefi) | no | legacy | | `nutanix-vm-mem` | The amount of RAM of the newly created VM (MB) | no | 2 GB | | `nutanix-vm-cpus` | The number of cpus in the newly created VM (core) | no | 2 | | `nutanix-vm-cores` | The number of cores per vCPU | no | 1 | diff --git a/machine/driver/driver.go b/machine/driver/driver.go index 5debd1e..7327e23 100755 --- a/machine/driver/driver.go +++ b/machine/driver/driver.go @@ -24,9 +24,10 @@ import ( ) const ( - defaultVMMem = 2048 - defaultVCPUs = 2 - defaultCores = 1 + defaultVMMem = 2048 + defaultVCPUs = 2 + defaultCores = 1 + defaultBootType = "legacy" ) // NutanixDriver driver structure @@ -55,6 +56,7 @@ type NutanixDriver struct { CloudInit string SerialPort bool Project string + BootType string } // NewDriver create new instance @@ -99,6 +101,11 @@ func (d *NutanixDriver) Create() error { res.NumSockets = utils.Int64Ptr(int64(d.VMVCPUs)) res.NumVcpusPerSocket = utils.Int64Ptr(int64(d.VMCores)) + // Configure BootType + log.Infof("Set BootType to %s", d.BootType) + res.BootConfig = &v3.VMBootConfig{} + res.BootConfig.BootType = utils.StringPtr(strings.ToUpper(d.BootType)) + // Configure CPU Passthrough if d.VMCPUPassthrough { res.EnableCPUPassthrough = utils.BoolPtr(d.VMCPUPassthrough) @@ -621,6 +628,12 @@ func (d *NutanixDriver) GetCreateFlags() []mcnflag.Flag { Usage: "The name of the project to assign the VM", Value: "", }, + mcnflag.StringFlag{ + EnvVar: "NUTANIX_BOOT_TYPE", + Name: "nutanix-boot-type", + Usage: "The boot type of the VM (legacy or uefi)", + Value: defaultBootType, + }, } } @@ -775,6 +788,12 @@ func (d *NutanixDriver) SetConfigFromFlags(opts drivers.DriverOptions) error { d.CloudInit = opts.String("nutanix-cloud-init") d.SerialPort = opts.Bool("nutanix-vm-serial-port") d.Project = opts.String("nutanix-project") + + d.BootType = opts.String("nutanix-boot-type") + if d.BootType != "uefi" && d.BootType != "legacy" { + return fmt.Errorf("nutanix-boot-type %s is invalid", d.BootType) + } + return nil }