vmware / photon

Minimal Linux container host
https://vmware.github.io/photon
Other
3.05k stars 697 forks source link

PowerCLI fails to install on Photon Arm #1056

Open lamw opened 4 years ago

lamw commented 4 years ago

With ESXi-Arm Fling now available. I wanted to have PowerCLI running within Photon OS 3.0 AARCH64. The steps below is what I used to successfully install Powershell Arm, but when attempting to install the PowerCLI Module, it throws an error.

FYI - This works perfectly fine when using Ubuntu 20.04 AARCH64

tdnf -y update
tdnf -y install icu libunwind wget tar
wget https://github.com/PowerShell/PowerShell/releases/download/v7.0.3/powershell-7.0.3-linux-arm64.tar.gz
mkdir ~/powershell
tar -xvf ./powershell-7.0.3-linux-arm64.tar.gz -C ~/powershell
ln -s ~/powershell/pwsh /usr/bin/pwsh
pwsh
Install-Module VMware.PowerCLI

Install-Package: /root/powershell/Modules/PowerShellGet/PSModule.psm1:9709
Line |
9709 |  … talledPackages = PackageManagement\Install-Package @PSBoundParameters
     |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | No match was found for the specified search criteria and module name 'VMware.PowerCLI'. Try Get-PSRepository to see all available registered module repositories.
dcasota commented 4 years ago

@lamw pwsh7.03 uses the latest dotnet-runtime. Hence, update-module pwsh7.0 to 7.03 on photon produces some issues on x86, too. ARM BoM in mind, does pwsh7.0.0 & PowerCLI12.0 install successfully?

lamw commented 4 years ago

@dcasota Powershell 7.0.3 installs and runs fine. Its when I attempt to install PowerCLI (see command output above) where the error occurs.

These exact instructions work when using Ubuntu 20.0.4

dcasota commented 4 years ago

(edited 12.10.2020) @lamw When running on Photon OS 2.0, two workarounds are necessary to be saved in profile /opt/microsoft ~/powershell/profile.ps1. Here's the code (edited):

OUTPUT=`~/powershell/pwsh -c "find-module VMware.PowerCLI"`
if ! (echo $OUTPUT | grep -q "PSGallery"); then
    cat <<EOFProfile > ~/powershell/profile.ps1
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
\$env:DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0     
EOFProfile
fi

Without those, it's the identical error message, not on exactly same line exception though. Each time pwsh7.0.3 is started the saved profile with the workarounds is loaded.

The source snippets are from: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-5.1&redirectedfrom=MSDN Show variables of $PROFILE: $PROFILE | Get-Member -Type NoteProperty

Workaround 1: https://github.com/PowerShell/PowerShellGet/issues/447#issuecomment-476968923 Change to TLS1.2 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Workaround #2 https://github.com/PowerShell/PowerShell/issues/9495#issuecomment-515592672 $env:DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0

Powershell 7.0.3 its PackageManagement 1.4.7 has "Update security protocol to use TLS 1.2" as release comment, hence TLS 1.2 seems to have become mandatory.

Using a setup photon-3.0-1ca1d7be-aarch64.iso with Ubuntu 20.04.1 LTS sd card on ESXi-ARM on a Raspberry Pi4 Model B, a tested feedback these days should be possible as well (I'm struggling actually with the 7" touch screen, don't ask :-/ ). the workaround is a temporary option.

image

dcasota commented 2 years ago

@ssahani Has something changed for powershell on Photon OS aarch64? There seems to be no package anymore, see pwsh. dotnet-runtime is missing, btw.

Side installation works, I've used this test setup Pwsh7.3.0-preview.1OnPhotonOS.sh.zip, but powershell command history does not work (maybe a powershell issue on aarch64?). In addition, install-module -name VMware.PowerCLIthrows some (debug) log warnings. [...]

Path: /root/.local/share/powershell/Modules/VMware.VimAutomation.Sdk/12.5.0.19093564/netcoreapp3.1/ParameterCompleter.ps1
Jan 23 23:23:51 photon-f72a20e6dbfc powershell[930]: pwsh Warning: 0 :
Jan 23 23:23:51 photon-f72a20e6dbfc powershell[930]: Unable to load settings file : /root/.local/share/VMware/PowerCLI/PowerCLI_Settings.xml. Error: System.IO.DirectoryNotFoundException: Could not find a part of the path '/root/.local/share/VMware/PowerCLI/PowerCLI_Settings.xml'.
                                                        at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
                                                        at Interop.CheckIo(Error error, String path, Boolean isDirectory, Func`2 errorRewriter)
                                                        at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
                                                        at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
                                                        at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
                                                        at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
                                                        at VMware.VimAutomation.ViCore.Util10.Settings.FileSettingsStore.LoadFileSettings(SettingsStore settings)
                                                        at VMware.VimAutomation.ViCore.Util10.Settings.FileSettingsStore.LoadSettings()
Jan 23 23:23:51 photon-f72a20e6dbfc powershell[930]: pwsh Warning: 0 :
ssahani commented 2 years ago

/cc @YustasSwamp