Skip to content

feat: add enableEFI and enableSecureBoot #1281

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 1 commit into
base: master
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
12 changes: 12 additions & 0 deletions rancher2/schema_machine_config_v2_harvester.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ func machineConfigV2HarvesterFields() map[string]*schema.Schema {
Optional: true,
Description: "NetworkData content of cloud-init, base64 is supported",
},
"enable_efi": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Enable EFI mode",
},
"enable_secure_boot": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Enable secure boot, only available when enable_efi is true",
},
}

return s
Expand Down
44 changes: 29 additions & 15 deletions rancher2/schema_node_template_harvester.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,23 @@ const (
//Types

type harvesterConfig struct {
VMNamespace string `json:"vmNamespace,omitempty" yaml:"vmNamespace,omitempty"`
VMAffinity string `json:"vmAffinity,omitempty" yaml:"vmAffinity,omitempty"`
CPUCount string `json:"cpuCount,omitempty" yaml:"cpuCount,omitempty"`
MemorySize string `json:"memorySize,omitempty" yaml:"memorySize,omitempty"`
DiskSize string `json:"diskSize,omitempty" yaml:"diskSize,omitempty"`
DiskBus string `json:"diskBus,omitempty" yaml:"diskBus,omitempty"`
ImageName string `json:"imageName,omitempty" yaml:"imageName,omitempty"`
DiskInfo string `json:"diskInfo,omitempty" yaml:"diskInfo,omitempty"`
SSHUser string `json:"sshUser,omitempty" yaml:"sshUser,omitempty"`
SSHPassword string `json:"sshPassword,omitempty" yaml:"sshPassword,omitempty"`
NetworkName string `json:"networkName,omitempty" yaml:"networkName,omitempty"`
NetworkModel string `json:"networkModel,omitempty" yaml:"networkModel,omitempty"`
NetworkInfo string `json:"networkInfo,omitempty" yaml:"networkInfo,omitempty"`
UserData string `json:"userData,omitempty" yaml:"userData,omitempty"`
NetworkData string `json:"networkData,omitempty" yaml:"networkData,omitempty"`
VMNamespace string `json:"vmNamespace,omitempty" yaml:"vmNamespace,omitempty"`
VMAffinity string `json:"vmAffinity,omitempty" yaml:"vmAffinity,omitempty"`
CPUCount string `json:"cpuCount,omitempty" yaml:"cpuCount,omitempty"`
MemorySize string `json:"memorySize,omitempty" yaml:"memorySize,omitempty"`
DiskSize string `json:"diskSize,omitempty" yaml:"diskSize,omitempty"`
DiskBus string `json:"diskBus,omitempty" yaml:"diskBus,omitempty"`
ImageName string `json:"imageName,omitempty" yaml:"imageName,omitempty"`
DiskInfo string `json:"diskInfo,omitempty" yaml:"diskInfo,omitempty"`
SSHUser string `json:"sshUser,omitempty" yaml:"sshUser,omitempty"`
SSHPassword string `json:"sshPassword,omitempty" yaml:"sshPassword,omitempty"`
NetworkName string `json:"networkName,omitempty" yaml:"networkName,omitempty"`
NetworkModel string `json:"networkModel,omitempty" yaml:"networkModel,omitempty"`
NetworkInfo string `json:"networkInfo,omitempty" yaml:"networkInfo,omitempty"`
UserData string `json:"userData,omitempty" yaml:"userData,omitempty"`
NetworkData string `json:"networkData,omitempty" yaml:"networkData,omitempty"`
EnableEFI bool `json:"enableEfi,omitempty" yaml:"enableEfi,omitempty"`
EnableSecureBoot bool `json:"enableSecureBoot,omitempty" yaml:"enableSecureBoot,omitempty"`
}

//Schemas
Expand Down Expand Up @@ -157,6 +159,18 @@ func harvesterConfigFields() map[string]*schema.Schema {
Optional: true,
Description: "NetworkData content of cloud-init, base64 is supported",
},
"enable_efi": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Enable EFI mode",
},
"enable_secure_boot": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Enable secure boot, only available when enable_efi is true",
},
}

return s
Expand Down
18 changes: 18 additions & 0 deletions rancher2/structure_machine_config_v2_harvester.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ type machineConfigV2Harvester struct {
NetworkInfo string `json:"networkInfo,omitempty" yaml:"networkInfo,omitempty"`
UserData string `json:"userData,omitempty" yaml:"userData,omitempty"`
NetworkData string `json:"networkData,omitempty" yaml:"networkData,omitempty"`
EnableEFI bool `json:"enableEfi,omitempty" yaml:"enableEfi,omitempty"`
EnableSecureBoot bool `json:"enableSecureBoot,omitempty" yaml:"enableSecureBoot,omitempty"`
}

type MachineConfigV2Harvester struct {
Expand Down Expand Up @@ -108,6 +110,14 @@ func flattenMachineConfigV2Harvester(in *MachineConfigV2Harvester) []interface{}
obj["network_data"] = in.NetworkData
}

if in.EnableEFI {
obj["enable_efi"] = in.EnableEFI
}

if in.EnableSecureBoot {
obj["enable_secure_boot"] = in.EnableSecureBoot
}

return []interface{}{obj}
}

Expand Down Expand Up @@ -189,5 +199,13 @@ func expandMachineConfigV2Harvester(p []interface{}, source *MachineConfigV2) *M
obj.NetworkData = v
}

if v, ok := in["enable_efi"].(bool); ok && v {
obj.EnableEFI = v
}

if v, ok := in["enable_secure_boot"].(bool); ok && v {
obj.EnableSecureBoot = v
}

return obj
}
16 changes: 16 additions & 0 deletions rancher2/structure_node_template_harvester.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ func flattenHarvesterConfig(in *harvesterConfig) []interface{} {
obj["network_data"] = in.NetworkData
}

if in.EnableEFI {
obj["enable_efi"] = in.EnableEFI
}

if in.EnableSecureBoot {
obj["enable_secure_boot"] = in.EnableSecureBoot
}

return []interface{}{obj}
}

Expand Down Expand Up @@ -140,5 +148,13 @@ func expandHarvestercloudConfig(p []interface{}) *harvesterConfig {
obj.NetworkData = v
}

if v, ok := in["enable_efi"].(bool); ok && v {
obj.EnableEFI = v
}

if v, ok := in["enable_secure_boot"].(bool); ok && v {
obj.EnableSecureBoot = v
}

return obj
}