HewlettPackard / POSH-HPEOneView

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

ConvertTo-OVPowerShellscript : mpSettings from ServerProfile(Template) are added on a single line + missing parameter in New-OVServerProfileIloPolicy #634

Open odesaphy opened 1 year ago

odesaphy commented 1 year ago

Actual Behavior

Get-OvServerProfileTemplate | ConvertTo-OVPowerShellscript generate mpSettings on a single line Missing IloHostname in call to New-OVServerProfileIloPolicy (when -ManageIloHostname is set)

Part of generated script

# -------------- Attributes for iLO settings
$mpConsistency                      = "Exact"
# ------------------- iLO Attribute: Local Accounts # ---------- iLO User: _iloAmplifier Pack $user1userName                      = "_iloAmplifier Pack" $user1displayName                   = "iLO Amplifier Pack" $user1Password                      = Read-Host -Prompt "user1 password" -AsSecureString $user1loginPriv                     = $True $user1                              = New-OVIloLocalUserAccount -Username $user1userName -Password $user1Password -DisplayName $user1displayName -Login $user1loginPriv $mpLocalAccounts                    = $user1 # ------------------- iLO Attribute: Host Name $mpHostName                         = "{serverProfileName}" # ------------------- iLO Settings Policy $iloSettings                        = New-OVServerProfileIloPolicy -ManageLocalAccounts -LocalAccounts $mpLocalAccounts -ManageIloHostname $mpHostName
# -------------- Attributes for advanced settings
New-OVServerProfileTemplate -Name $name -ServerHardwareType $sht -EnclosureGroup $eg -Affinity $affinity -ManageConnections $True -ConnectionsConsistencyChecking $cnConsistency  -Connections $connections -LocalStorage  -StorageController $controllers -LocalStorageConsistencyChecking $lsConsistency  -ManageBoot:$manageboot -BootMode $biosBootMode -BootOrder $bootOrder -BootModeConsistencyChecking $bmConsistency -Bios -BiosSettings $biosSettings -BiosConsistencyChecking $biosConsistency  -ManageIloSettings $True -IloSettingsConsistencyChecking $mpConsistency -IloSettings $iloSettings -HideUnusedFlexNics $true

Proposed Solution - Single Line Issue

From

$mpSettingsCode       = Generate-mpSettings-Script -Setting $settings
[void]$scriptCode.Add($mpSettingsCode)

To (Using AddRange for adding multilne $mpSettingsCode to $scriptCode)

$mpSettingsCode       = Generate-mpSettings-Script -Setting $settings
[void]$scriptCode.AddRange($mpSettingsCode)

Proposed Solution - New-OVServerProfileIloPolicy

From

'HostName'
  {
    [void]$mpSettingsCode.Add('# ------------------- iLO Attribute: Host Name')
    [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'mpHostName' -Value ('"{0}"' -f $s.args.HostName)))
    $mpSettingsArray    += ' -ManageIloHostname $mpHostName'
  }

To (Missing -IloHostname parameter)

  {
    [void]$mpSettingsCode.Add('# ------------------- iLO Attribute: Host Name')
    [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'mpHostName' -Value ('"{0}"' -f $s.args.HostName)))
    $mpSettingsArray    += ' -ManageIloHostname -IloHostname $mpHostName'
  }

Version Information

HPE OneView PowerShell Library Version : 6.60.3332.3428 HPE OneView Appliance Version : 6.60.00.455762.00 Output from $PSVersionTable on your Windows Host:

# Output from $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.19041.2364
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.2364
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
ChrisLynchHPE commented 1 year ago

The missing -IloHostname parameter will be fixed.

However, I am unable to reproduce the first issue where attribute variables are printed to the screen as a single line. I tried this on the current 6.60 through 8.00 libraries. It tried to reproduce this in both PowerShell 5.1 and PowerShell 7.3. Are you able to consistently reproduce this?