HewlettPackard / POSH-HPEOneView

PowerShell language bindings library for HPE OneView.
http://hewlettpackard.github.io/POSH-HPEOneView/
125 stars 52 forks source link

Show-OVFirmwareReport does not test against provided baseline #583

Closed jdkarpin closed 2 years ago

jdkarpin commented 3 years ago

Expected Behavior


PS C:\Users\ad_jdkarpin> $Baseline

Name        : HPE Synergy Service Pack
State       : Created
Status      : OK
Version     : SY-2021.05.01
ISOFileName : Synergy_Service_Pack_SSP_2021_05_01_Z7550-97181.iso
XMLKeyName  : bp004476
BundleSize  : 6.2GB
Locations   : {Internal}

PS C:\Users\ad_jdkarpin\Desktop> Show-OVFirmwareReport -InputObject (Get-OVLogicalEnclosure) -Baseline $Baseline
PS C:\Users\ad_jdkarpin\Desktop> $ret = Show-OVFirmwareReport -InputObject (Get-OVLogicalEnclosure) -Baseline $Baseline
PS C:\Users\ad_jdkarpin\Desktop> $ret[0] | fl

Component           : fm11d-bk33-f1, interconnect 3
ComponentModel      : Virtual Connect SE 100Gb F32 Module for Synergy
ComponentType       : Firmware
Installed           : 2.1.1.1003
SerialNumber        : 7C9015003M
PartNumber          : 867796-B21
BaselineVersion     : 2.2.1.1002
BaselineName        : HPE Service Pack for ProLiant
BaselineUri         : /rest/firmware-drivers/Synergy_Service_Pack_SSP_2021_05_01_Z7550-97181
Name                : fm11d-bk33-f1
ResourceUri         : /rest/enclosures/P06011MXQ0210B4V
ApplianceConnection : fm1ov1.fm.intel.com

Actual Behavior


PS C:\Users\ad_jdkarpin> $Baseline

Name        : HPE Synergy Service Pack
State       : Created
Status      : OK
Version     : SY-2021.05.01
ISOFileName : Synergy_Service_Pack_SSP_2021_05_01_Z7550-97181.iso
XMLKeyName  : bp004476
BundleSize  : 6.2GB
Locations   : {Internal}

PS C:\Users\ad_jdkarpin\Desktop> Show-OVFirmwareReport -InputObject (Get-OVLogicalEnclosure) -Baseline $Baseline
PS C:\Users\ad_jdkarpin\Desktop> $ret = Show-OVFirmwareReport -InputObject (Get-OVLogicalEnclosure) -Baseline $Baseline
PS C:\Users\ad_jdkarpin\Desktop> $ret[0]

    Enclosure: fm11d-bk33-f1

Component                     ComponentModel                                  Installed  Baseline BaselineName
---------                     --------------                                  ---------  -------- ------------
fm11d-bk33-f1, interconnect 3 Virtual Connect SE 100Gb F32 Module for Synergy 2.1.1.1003 N/A      NoPolicySet

PS C:\Users\ad_jdkarpin\Desktop> $ret[0] | fl

Component           : fm11d-bk33-f1, interconnect 3
ComponentModel      : Virtual Connect SE 100Gb F32 Module for Synergy
ComponentType       : Firmware
Installed           : 2.1.1.1003
SerialNumber        : 7C9015003M
PartNumber          : 867796-B21
BaselineVersion     : N/A
BaselineName        : NoPolicySet
BaselineUri         :
Name                : fm11d-bk33-f1
ResourceUri         : /rest/enclosures/P06011MXQ0210B4V
ApplianceConnection : fm1ov1.fm.intel.com

Steps to reproduce

Bug is in HPEOneView.610.ps1 line 57875 in local function Ger-EnclosureFirmware. If Enclosure have FW Managed then parameter $Baseline is ignored and $BaseLinePolicy is set to $_NoBaselinePolicy.

Also Get-ServerFirmware casts $Baseline to [Object] (line 58534) which cases script to fail (on $Baseline.Clone() which doesn't exist) if correct Baseline is provided.

        if ($Enclosure.isFwManaged)
        {

            if ($null -eq $Baseline -and -not [String]::IsNullOrEmpty($Enclosure.fwBaselineUri))
            {

                Try
                {

                    $BaseLinePolicy = Send-OVRequest -Uri $Enclosure.fwBaselineUri -Hostname $Enclosure.ApplianceConnection

                }

                Catch [ResourceNotFoundException]
                {

                    "[{0}] The baseline associated with the provided enclosure cannot be found. Was it removed from the repository?" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Enclosure.name | Write-Verbose

                    $BaseLinePolicy = $_NoBaselinePolicy

                }

                Catch
                {

                    $PSCmdlet.ThrowTerminatingError($_)

                }

            }

            else
            {

                "[{0}] No baseline provided, and provided enclosure is not assigned a baseline resource." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose

                $BaseLinePolicy = $_NoBaselinePolicy

            }

        }
                    else
                    {

                        "[{0}] Baseline Name passed: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline | Write-Verbose

                        Try
                        {

                            $FirmwareBaselineName = $Baseline.Clone()

                            $_BaseLinePolicy = Get-OVBaseline -name $Baseline -ApplianceConnection $Server.ApplianceConnection.Name -ErrorAction Stop

                        }

                        Catch
                        {

                            $PSCmdlet.ThrowTerminatingError($_)

                        }

                    }

Version Information

HPE OneView PowerShell Library Version (Get-HPOVVersion or $PSLibraryVersion):

fm1ov1.fm.intel.com                 LibraryVersion
-------------------                 --------------
ApplianceVersion: 6.10.00.437859.00 6.10.2778.2020

HPE OneView Appliance Version (Get-HPOVVersion -ApplianceVer):

PS C:\Users\ad_jdkarpin\Desktop> Get-OVVersion -ApplianceVer

fm1ov1.fm.intel.com                 LibraryVersion Path
-------------------                 -------------- ----
ApplianceVersion: 6.10.00.437859.00 6.10.2778.2020 C:\Progra

Output from $PSVersionTable on your Windows Host:

PS C:\Users\ad_jdkarpin\Desktop> $PSVersionTable
>>

Name                           Value
----                           -----
PSVersion                      5.1.14409.1018
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1018
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
# Output from $PSVersionTable
ChrisLynchHPE commented 3 years ago

Apologies for the late reply here. The main issue is that there is no conditional check if $Baseline is not empty.

Also, yes, the use of .Clone() is a bug here. It should instead have been .PSObject.Copy().

ChrisLynchHPE commented 2 years ago

This is fixed in Release 6.30.3188.1900 and in PowerShell Gallery.

Please verify before this issue is closed.

ChrisLynchHPE commented 2 years ago

Closing due to no further activity. If you wish, feel free to re-open to discuss further.