diff --git a/rancher2/schema_machine_config_v2_harvester.go b/rancher2/schema_machine_config_v2_harvester.go index 66833a7ed..8a9446986 100644 --- a/rancher2/schema_machine_config_v2_harvester.go +++ b/rancher2/schema_machine_config_v2_harvester.go @@ -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 diff --git a/rancher2/schema_node_template_harvester.go b/rancher2/schema_node_template_harvester.go index 81d30366a..ee94f0348 100644 --- a/rancher2/schema_node_template_harvester.go +++ b/rancher2/schema_node_template_harvester.go @@ -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 @@ -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 diff --git a/rancher2/structure_machine_config_v2_harvester.go b/rancher2/structure_machine_config_v2_harvester.go index 180658525..032403bf0 100644 --- a/rancher2/structure_machine_config_v2_harvester.go +++ b/rancher2/structure_machine_config_v2_harvester.go @@ -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 { @@ -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} } @@ -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 } diff --git a/rancher2/structure_node_template_harvester.go b/rancher2/structure_node_template_harvester.go index 7d4aae242..1203c6f50 100644 --- a/rancher2/structure_node_template_harvester.go +++ b/rancher2/structure_node_template_harvester.go @@ -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} } @@ -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 }