diff --git a/app/models/compute_resources/foreman/model/libvirt.rb b/app/models/compute_resources/foreman/model/libvirt.rb index ee2cbc38fec..6999959bd75 100644 --- a/app/models/compute_resources/foreman/model/libvirt.rb +++ b/app/models/compute_resources/foreman/model/libvirt.rb @@ -14,7 +14,29 @@ def self.available? Fog::Compute.providers.include?(:libvirt) end - # Some getters/setters for the attrs Hash + def self.firmware_types + { + "efi" => N_("EFI"), + "bios" => N_("BIOS"), + }.freeze + end + + def os_firmware + attrs[:os_firmware].presence || "efi" + end + + def os_firmware=(firmware) + attrs[:os_firmware] = firmware + end + + def os_firmware_features + attrs[:os_firmware_features].presence || {} + end + + def os_firmware_features=(attrs) + attrs[:os_firmware_features].merge attrs + end + def display_type attrs[:display].presence || 'vnc' end @@ -291,7 +313,12 @@ def vm_instance_defaults :display => { :type => display_type, :listen => Setting[:libvirt_default_console_address], :password => random_password(console_password_length(display_type)), - :port => '-1' } + :port => '-1' }, + :os_firmware => 'efi', + :os_firmware_features => { + "secure-boot" => "no", + "enrolled-keys" => "no", + } ) end diff --git a/app/views/compute_resources_vms/form/libvirt/_base.html.erb b/app/views/compute_resources_vms/form/libvirt/_base.html.erb index d6378df16b1..2010503e385 100644 --- a/app/views/compute_resources_vms/form/libvirt/_base.html.erb +++ b/app/views/compute_resources_vms/form/libvirt/_base.html.erb @@ -24,3 +24,27 @@ <%= compute_specific_js(compute_resource, "nic_info") %> + +<%= select_f f, :os_firmware, + Foreman::Model::Libvirt.firmware_types, + :first, + :last, + {}, + { :label => _("Firmware"), + :label_size => "col-md-2", + :onchange => "tfm.computeResource.libvirt.firmwareSelected(this);", + } +%> +<% + feature_attrs = ActiveSupport::HashWithIndifferentAccess.new(f.object.os_firmware_features) + is_bios = f.object.os_firmware == 'bios' +%> + +