HewlettPackard / POSH-HPEOneView

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

Get-OVServerProfileTemplate | ConvertTo-OVPowerShellScript: Missing parameter $netName #561

Closed ChristianCarHPE closed 2 years ago

ChristianCarHPE commented 3 years ago

Expected Behavior

Getting Server Profile Template information, converting it to PowerShell commands and reimporting it by using the automatically generated PowerShell code. Using following command to generate the PowerShell code:

Get-OVServerProfileTemplate -name $inputArray[$i] | ConvertTo-OVPowerShellScript | Out-File $path

Actual Behavior

PowerShell Code for reimporting the Server Profile Templates works fine but you are not able to use the generated code to reimporting the Server Profile Template due the parameter $netName is missing in the generated code. Example automatically generated code snippet:

 -------------- Attributes for connection "1"
$connID                             = 1
$connName                           = "wer324"
$connType                           = "Ethernet"
$ThisNetwork                        = Get-OVNetwork -Type Ethernet -Name $netName
$portID                             = "Mezz 3:1-b"
$requestedMbps                      = 2500
$Conn1                              = New-OVServerProfileConnection -ConnectionID $connID -Name $connName -ConnectionType $connType -Network $ThisNetwork -PortId $portID -RequestedBW $requestedMbps
$connections                        = $Conn1

Line "$ThisNetwork = Get-OVNetwork -Type Ethernet -Name $netName" will not work and will produce an error because parameter "$netName" is empty (and is not filled anywehere in the automatically generated code).

Steps to reproduce

1) generate manually a simple Server Profile Template with at least one managed connection 2) run "Get-OVServerProfileTemplate | ConvertTo-OVPowerShellScript" to generate PowerShell code for this Server Profile Template 3) Try to reimport the Server Profile Template by using the automatically generated PowerShell code 4) You will get an error that will state that the parameter "$netName" is empty 5) optional: by manually add a code line like '$netname = "testnetwork"' into the automatically generated code will make the code runable.

Example execution with error message:

PS C:\Users\ccar\desktop\export_import_OV_settings\export> # -------------- Attributes for ServerProfileTemplate "test"
$name                               = "test"
$description                        = "13e213"
$spdescription                      = "34324125"
$shtName                            = "SY 480 Gen10 3"
$sht                                = Get-OVServerHardwareType -Name $shtName
$egName                             = "EG-Synergy-Local"
$eg                                 = Get-OVEnclosureGroup -Name $egName
$affinity                           = "Bay"
# -------------- Connections section
$cnConsistency                      = "Minimum"
# -------------- Attributes for connection "1"
$connID                             = 1
$connName                           = "wer324"
$connType                           = "Ethernet"
$ThisNetwork                        = Get-OVNetwork -Type Ethernet -Name $netName
$portID                             = "Mezz 3:1-b"
$requestedMbps                      = 2500
$Conn1                              = New-OVServerProfileConnection -ConnectionID $connID -Name $connName -ConnectionType $connType -Network $ThisNetwork -PortId $portID -RequestedBW $requestedMbps
$connections                        = $Conn1
# -------------- Attributes for Boot Mode settings
$manageboot                         = $True
$biosBootMode                       = "UEFIOptimized"
# -------------- Attributes for boot order settings
$bootOrder                          = "HardDisk"
$bmConsistency                      = "Exact"
# -------------- Attributes for BIOS settings
$biosSettings                       = @(
    @{id = 'MinProcIdlePower'; value = 'NoCStates'},
    @{id = 'WorkloadProfile'; value = 'Virtualization-MaxPerformance'},
    @{id = 'IntelUpiPowerManagement'; value = 'Disabled'},
    @{id = 'MinProcIdlePkgState'; value = 'NoState'},
    @{id = 'EnergyPerfBias'; value = 'MaxPerf'},
    @{id = 'UncoreFreqScaling'; value = 'Maximum'},
    @{id = 'PowerRegulator'; value = 'StaticHighPerf'},
    @{id = 'SubNumaClustering'; value = 'Enabled'},
    @{id = 'CollabPowerControl'; value = 'Disabled'},
    @{id = 'PostDiscoveryMode'; value = 'ForceFastDiscovery'},
    @{id = 'EnergyEfficientTurbo'; value = 'Disabled'},
    @{id = 'NumaGroupSizeOpt'; value = 'Clustered'}
)
$biosConsistency                    = "Exact"
# -------------- Attributes for advanced settings
New-OVServerProfileTemplate -Name $name -Description $description -ServerProfileDescription $spdescription  -ServerHardwareType $sht -EnclosureGroup $eg -Affinity $affinity -ManageConnections $True -ConnectionsConsistencyChecking $cnConsistency  -Connections $connections -ManageBoot:$manageboot -BootMode $biosBootMode -BootOrder $bootOrder -BootModeConsistencyChecking $bmConsistency -Bios -BiosSettings $biosSettings -BiosConsistencyChecking $biosConsistency  -HideUnusedFlexNics $true

Get-OVNetwork : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At line:16 char:74
+ ...                         = Get-OVNetwork -Type Ethernet -Name $netName
+                                                                  ~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-OVNetwork], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Get-OVNetwork

New-OVServerProfileConnection : Cannot validate argument on parameter 'Network'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At line:19 char:142
+ ... ame $connName -ConnectionType $connType -Network $ThisNetwork -PortId ...
+                                                      ~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [New-OVServerProfileConnection], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,New-OVServerProfileConnection

New-OVServerProfileTemplate : Cannot validate argument on parameter 'Connections'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At line:44 char:260
+ ... ConsistencyChecking $cnConsistency  -Connections $connections -Manage ...
+                                                      ~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [New-OVServerProfileTemplate], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,New-OVServerProfileTemplate

Version Information

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

10.10.111.1                         10.10.50.1                          LibraryVersion Path                                                     
-----------                         ----------                          -------------- ----                                                     
ApplianceVersion: 5.40.00.423953.00 ApplianceVersion: 5.40.00.424900.00 5.40.2689.2416 C:\Program Files\WindowsPowerShell\Modules\hpeoneview.540

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

see above. Both appliance are running OneView 5.40

Output from $PSVersionTable on your Windows Host:

PS C:\Users\ccar\desktop\export_import_OV_settings\export> $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   
ChrisLynchHPE commented 2 years ago

This issue was addressed in the following releases of the impacted libraries, and in the 6.00 library release.

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