From b6e477aca0d8867c102c492576e48bed4231a92e Mon Sep 17 00:00:00 2001 From: "Alexander \"Ace\" Olofsson" <ace@haxalot.com> Date: Thu, 14 Jun 2018 15:46:06 +0200 Subject: [PATCH] Add an unattend processorArchitecture method --- app/models/concerns/foreman_wds/host_extensions.rb | 6 +++++- app/models/wds_server.rb | 5 +++++ app/views/foreman_wds/unattend_2016.xml.erb | 14 +++++++------- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/models/concerns/foreman_wds/host_extensions.rb b/app/models/concerns/foreman_wds/host_extensions.rb index 7742fbb..b0a5220 100644 --- a/app/models/concerns/foreman_wds/host_extensions.rb +++ b/app/models/concerns/foreman_wds/host_extensions.rb @@ -65,6 +65,10 @@ module ForemanWds wds_facet || build_wds_facet end + def unattend_arch + WdsServer.wdsify_processor_architecture(architecture) + end + def unattend_pass(password, suffix = nil) if suffix.nil? suffix = password @@ -105,5 +109,5 @@ module ForemanWds end class ::Host::Managed::Jail < Safemode::Jail - allow :unattend_pass, :wds_facet, :wds_server, :wds_install_image_file, :wds_install_image_group, :wds_install_image_name + allow :unattend_arch, :unattend_pass, :wds_facet, :wds_server, :wds_install_image_file, :wds_install_image_group, :wds_install_image_name end diff --git a/app/models/wds_server.rb b/app/models/wds_server.rb index 98e330d..a0c4a4d 100644 --- a/app/models/wds_server.rb +++ b/app/models/wds_server.rb @@ -136,6 +136,11 @@ class WdsServer < ApplicationRecord ForemanWds::WdsImage::WDS_ARCH_NAMES[wds_arch] end + def self.wdsify_processor_architecture(architecture) + wds_arch = ForemanWds::WdsImage::WDS_IMAGE_ARCHES.find_index { |arch| arch =~ architecture.name } + ForemanWds::WdsImage::WDS_ARCH_NAMES[wds_arch] + end + def test_connection connection.run_wql('SELECT * FROM Win32_UTCTime').key? :win32_utc_time rescue StandardError diff --git a/app/views/foreman_wds/unattend_2016.xml.erb b/app/views/foreman_wds/unattend_2016.xml.erb index 6bbdd47..56c4a2b 100644 --- a/app/views/foreman_wds/unattend_2016.xml.erb +++ b/app/views/foreman_wds/unattend_2016.xml.erb @@ -31,7 +31,7 @@ end <?xml version="1.0" encoding="utf-8"?> <unattend xmlns="urn:schemas-microsoft-com:unattend"> <settings pass="windowsPE"> - <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="<%= @host.unattend_arch %>" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <SetupUILanguage> <UILanguage>en-US</UILanguage> </SetupUILanguage> @@ -39,7 +39,7 @@ end <SystemLocale>en-US</SystemLocale> <UserLocale>en-US</UserLocale> </component> - <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <component name="Microsoft-Windows-Setup" processorArchitecture="<%= @host.unattend_arch %>" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <WindowsDeploymentServices> <Login> <Credentials> @@ -73,7 +73,7 @@ end </settings> <settings pass="specialize"> <%- if realm -%> - <component name="Microsoft-Windows-UnattendedJoin" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <component name="Microsoft-Windows-UnattendedJoin" processorArchitecture="<%= @host.unattend_arch %>" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Identification> <JoinDomain><%= realm[:domain] %></JoinDomain> <%- if realm[:type] == :machine -%> @@ -92,13 +92,13 @@ end </Identification> </component> <%- end -%> - <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="<%= @host.unattend_arch %>" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ComputerName><%= @host.shortname %></ComputerName> <RegisteredOrganization><%= registration[:organization] %></RegisteredOrganization> <RegisteredOwner><%= registration[:owner] %></RegisteredOwner> <TimeZone><%= timezone %></TimeZone> </component> - <component name="Microsoft-Windows-TCPIP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <component name="Microsoft-Windows-TCPIP" processorArchitecture="<%= @host.unattend_arch %>" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Interfaces> <%- iface = @host.primary_interface # @host.managed_interfaces.each.with_index do |iface, i| -%> <Interface wcm:action="add"> @@ -132,7 +132,7 @@ end </Interface> </Interfaces> </component> - <component name="Microsoft-Windows-DNS-Client" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <component name="Microsoft-Windows-DNS-Client" processorArchitecture="<%= @host.unattend_arch %>" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <DNSSuffixSearchOrder> <DomainName wcm:action="add" wcm:keyValue="1"><%= @host.domain %></DomainName> </DNSSuffixSearchOrder> @@ -150,7 +150,7 @@ end </component> </settings> <settings pass="oobeSystem"> - <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="<%= @host.unattend_arch %>" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <OOBE> <HideEULAPage>true</HideEULAPage> <HideLocalAccountScreen>true</HideLocalAccountScreen> -- GitLab