Skip to content

add secure boot (#181) #235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .web-docs/components/builder/nutanix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ These parameters allow to define information about platform and temporary VM use
- `memory_mb` (number) - Size of vRAM for temporary VM (in megabytes).
- `cd_files` (array of strings) - A list of files to place onto a CD that is attached when the VM is booted. This can include either files or directories; any directories will be copied onto the CD recursively, preserving directory structure hierarchy.
- `cd_label` (string) - Label of this CD Drive.
- `boot_type` (string) - Type of boot used on the temporary VM ("legacy" or "uefi", default is "legacy").
- `boot_type` (string) - Type of boot used on the temporary VM ("legacy", "uefi" or "secure_boot", default is "legacy").
- `boot_priority` (string) - Priority of boot device ("cdrom" or "disk", default is "cdrom").
- `ip_wait_timeout` (duration string | ex: "0h42m0s") - Amount of time to wait for VM's IP, similar to 'ssh_timeout'. Defaults to 15m (15 minutes). See the Golang [ParseDuration](https://golang.org/pkg/time/#ParseDuration) documentation for full details.
- `vm_categories` ([]Category) - Assign Categories to the vm.
Expand Down
10 changes: 9 additions & 1 deletion builder/nutanix/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const (
// NutanixIdentifierBootTypeUEFI is a resource identifier identifying the UEFI boot type for virtual machines.
NutanixIdentifierBootTypeUEFI string = "uefi"

// NutanixIdentifierBootTypeSecure is a resource identifier identifying the secure boot type for virtual machines.
NutanixIdentifierBootTypeSecure string = "secure_boot"

// NutanixIdentifierBootPriorityDisk is a resource identifier identifying the boot priority as disk for virtual machines.
NutanixIdentifierBootPriorityDisk string = "disk"

Expand Down Expand Up @@ -146,7 +149,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
c.ClusterConfig.Port = 9440
}

if c.BootType != NutanixIdentifierBootTypeLegacy && c.BootType != NutanixIdentifierBootTypeUEFI {
if c.BootType != NutanixIdentifierBootTypeLegacy && c.BootType != NutanixIdentifierBootTypeUEFI && c.BootType != NutanixIdentifierBootTypeSecure {
log.Println("No correct VM Boot Type configured, defaulting to 'legacy'")
c.BootType = string(NutanixIdentifierBootTypeLegacy)
}
Expand All @@ -156,6 +159,11 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("UEFI does not support boot priority"))
}

if c.BootType == NutanixIdentifierBootTypeSecure && c.BootPriority != "" {
log.Println("Boot Priority is not supported for secure boot type")
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("secure boot does not support boot priority"))
}

if c.BootPriority != NutanixIdentifierBootPriorityDisk && c.BootPriority != NutanixIdentifierBootPriorityCDROM {
log.Println("No correct VM Boot Priority configured, defaulting to 'cdrom'")
c.BootPriority = string(NutanixIdentifierBootPriorityCDROM)
Expand Down
8 changes: 8 additions & 0 deletions builder/nutanix/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,14 @@ func (d *NutanixDriver) CreateRequest(ctx context.Context, vm VmConfig, state mu
req.Spec.Resources.BootConfig = &v3.VMBootConfig{
BootType: &bootType,
}
} else if vm.BootType == NutanixIdentifierBootTypeSecure {
bootType := strings.ToUpper(NutanixIdentifierBootTypeSecure)

req.Spec.Resources.BootConfig = &v3.VMBootConfig{
BootType: &bootType,
}
// Force machine type to "Q35", which is required for Secure Boot
req.Spec.Resources.MachineType = StringPtr("Q35")
} else {
bootType := strings.ToUpper(NutanixIdentifierBootTypeLegacy)

Expand Down
Loading