Skip to content

Commit

Permalink
add uefi support
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxtof committed Aug 31, 2023
1 parent 40a52c9 commit d0e28b3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
25 changes: 22 additions & 3 deletions machine/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ import (
)

const (
defaultVMMem = 2048
defaultVCPUs = 2
defaultCores = 1
defaultVMMem = 2048
defaultVCPUs = 2
defaultCores = 1
defaultBootType = "legacy"
)

// NutanixDriver driver structure
Expand Down Expand Up @@ -55,6 +56,7 @@ type NutanixDriver struct {
CloudInit string
SerialPort bool
Project string
BootType string
}

// NewDriver create new instance
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
},
}
}

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit d0e28b3

Please sign in to comment.