From 95d973258c379172477c38692d96b83ab142acee Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Mon, 25 Mar 2013 13:58:09 +0000 Subject: [PATCH] Have upflag try to use powershell when available instead of exes. Have xCAT powershell client attempt without a certificate when no client certificate specified git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@15652 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/windows.pm | 27 ++++++++++++++----- .../xcat/netboot/windows/nextdestiny.ps1 | 2 ++ .../share/xcat/netboot/windows/xCAT.psm1 | 13 ++++++++- 3 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 xCAT-server/share/xcat/netboot/windows/nextdestiny.ps1 diff --git a/xCAT-server/lib/xcat/plugins/windows.pm b/xCAT-server/lib/xcat/plugins/windows.pm index e64d8bdc0..6c154f6b4 100644 --- a/xCAT-server/lib/xcat/plugins/windows.pm +++ b/xCAT-server/lib/xcat/plugins/windows.pm @@ -340,13 +340,19 @@ sub mkinstall #Call the Template class to do substitution to produce an unattend.xml file in the autoinst dir my $tmperr; - unless (-r "$installroot/utils/windows/fixupunattend.vbs" and stat("$::XCATROOT/share/xcat/netboot/windows/fixupunattend.vbs")->mtime < stat("$installroot/utils/windows/fixupunattend.vbs")) { - mkpath("$installroot/utils/windows/"); - copy("$::XCATROOT/share/xcat/netboot/windows/fixupunattend.vbs","$installroot/utils/windows/fixupunattend.vbs"); - } - unless (-r "$installroot/utils/windows/detectefi.exe" and stat("$::XCATROOT/share/xcat/netboot/windows/detectefi.exe")->mtime < stat("$installroot/utils/windows/detectefi.exe")) { - mkpath("$installroot/utils/windows/"); - copy("$::XCATROOT/share/xcat/netboot/windows/detectefi.exe","$installroot/utils/windows/detectefi.exe"); + my @utilfiles = ( + "fixupunattend.vbs", + "detectefi.exe", + "xCAT.psd1", + "xCAT.psm1", + "xCAT.format.ps1xml", + "nextdestiny.ps1", + ); + foreach my $utilfile (@utilfiles) { + unless (-r "$installroot/utils/windows/$utilfile" and stat("$::XCATROOT/share/xcat/netboot/windows/$utilfile")->mtime < stat("$installroot/utils/windows/$utilfile")) { + mkpath("$installroot/utils/windows/"); + copy("$::XCATROOT/share/xcat/netboot/windows/$utilfile","$installroot/utils/windows/$utilfile"); + } } if (-r "$tmplfile") { @@ -438,6 +444,7 @@ sub mkinstall print $shandle 'reg copy HKLM\system\CurrentControlSet\services\TCPIP6\parameters HKLM\csystem\ControlSet001\services\TCPIP6\parameters /f'."\r\n"; print $shandle 'reg copy HKLM\system\CurrentControlSet\services\TCPIP6\parameters HKLM\csystem\ControlSet002\services\TCPIP6\parameters /f'."\r\n"; print $shandle 'reg unload HKLM\csystem'."\r\n"; + print $shandle "If EXIST X:\\Windows\\system32\\WindowsPowerShell GOTO PSH\r\n"; print $shandle "IF %PROCESSOR_ARCHITECTURE%==AMD64 GOTO x64\r\n"; print $shandle "IF %PROCESSOR_ARCHITECTURE%==x64 GOTO x64\r\n"; print $shandle "IF %PROCESSOR_ARCHITECTURE%==x86 GOTO x86\r\n"; @@ -446,6 +453,12 @@ sub mkinstall print $shandle "GOTO END\r\n"; print $shandle ":x64\r\n"; print $shandle "%instdrv%\\postscripts\\upflagx64 %XCATD% 3002 next\r\n"; + print $shandle "GOTO END\r\n"; + print $shandle ":PSH\n"; + print $shandle "mkdir x:\\windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\xCAT\r\n"; + print $shandle "copy %instdrv%\\utils\\windows\\xCAT.* x:\\windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\xCAT\r\n"; + print $shandle "powershell set-executionpolicy bypass CurrentUser\r\n"; + print $shandle "powershell %instdrv%\\utils\\windows\\nextdestiny.ps1\r\n"; print $shandle ":END\r\n"; close($shandle); if ($vpdhash->{$node}) { diff --git a/xCAT-server/share/xcat/netboot/windows/nextdestiny.ps1 b/xCAT-server/share/xcat/netboot/windows/nextdestiny.ps1 new file mode 100644 index 000000000..68c11ff30 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/windows/nextdestiny.ps1 @@ -0,0 +1,2 @@ +$command=@{'command'='nextdestiny'} +Send-xCATCommand $command diff --git a/xCAT-server/share/xcat/netboot/windows/xCAT.psm1 b/xCAT-server/share/xcat/netboot/windows/xCAT.psm1 index 27bf82d73..8a234f47d 100644 --- a/xCAT-server/share/xcat/netboot/windows/xCAT.psm1 +++ b/xCAT-server/share/xcat/netboot/windows/xCAT.psm1 @@ -109,7 +109,18 @@ Function Connect-xCAT { $verifycallback = Get-Content Function:\VerifyxCATCert $certselect = Get-Content Function:\SelectxCATClientCert $script:xcatstream = $script:xcatconnection.GetStream() - $script:securexCATStream = New-Object System.Net.Security.SSLStream($script:xcatstream,$false,$verifycallback,$certselect) + $haveclientcert=0 + if (Test-Path HKCU:\Software\xCAT) { + $xcreg=Get-ItemProperty HKCU:\Software\xCAT + if ($xcreg.usercertthumb) { + $haveclientcert=1 + } + } + if ($haveclientcert) { + $script:securexCATStream = New-Object System.Net.Security.SSLStream($script:xcatstream,$false,$verifycallback,$certselect) + } else { + $script:securexCATStream = New-Object System.Net.Security.SSLStream($script:xcatstream,$false,$verifycallback) + } $script:securexCATStream.AuthenticateAsClient($mgtServerAltName) $script:xcatwriter = New-Object System.IO.StreamWriter($script:securexCATStream) $script:xcatreader = New-Object System.IO.StreamReader($script:securexCATStream)