CiscoDevNet / intersight-powershell

Cisco Intersight PowerShell
Apache License 2.0
16 stars 4 forks source link

Initialize-IntersightBootLocalCdd and Initialize-IntersightBootUefiShell do not implement ClassId and ObjectType #136

Closed tgrabrian closed 2 months ago

tgrabrian commented 10 months ago

Describe the bug Neither Initialize-IntersightBootLocalCdd nor Initialize-IntersightBootUefiShell implement their respective ClassId and ObjectType properties, causing their usage with the New-IntersightBootPrecisionPolicy BootDevices parameter to fail. These are the only two Intialize-IntersightBoot* functions to behave like this.

To Reproduce

PS C:\Example> $LocalCddBoot = Initialize-IntersightBootLocalCdd -Enabled $true -Name "Local-CDD"
PS C:\Example> New-IntersightBootPrecisionPolicy -Organization $OrgRef -Name "test1" -BootDevices @($LocalCddBoot)  # Not working
New-IntersightBootPrecisionPolicy: Error calling CreateBootPrecisionPolicy: {"code":"InvalidRequest","message":"Cannot execute the request. The JSON document is malformed.","messageId":"barcelona_request_malformed_json","traceId":"YYCHLAoj6Fi-LJGsHVlkaxgWDBTqWywseftJXGZG5-YMT7WxGNMxXg==","cause":{"code":"InternalServerError","message":"Cannot execute the request due to an error. Retry later.","messageId":"barcelona_request_internal_error","traceId":"YYCHLAoj6Fi-LJGsHVlkaxgWDBTqWywseftJXGZG5-YMT7WxGNMxXg=="}}
PS C:\Example> $LocalCddBoot  # Not working (note 0 ClassId/ObjectType)
AdditionalProperties : {}
ClassId              : 0
ObjectType           : 0
Enabled              : True
Name                 : Local-CDD
PS C:\Example> $UefiShellBoot = Initialize-IntersightBootUefiShell -Enabled $true -Name "UEFI-Shell"
PS C:\Example> New-IntersightBootPrecisionPolicy -Organization $OrgRef -Name "test2" -BootDevices @($UefiShellBoot)  # Not working
New-IntersightBootPrecisionPolicy: Error calling CreateBootPrecisionPolicy: {"code":"InvalidRequest","message":"Cannot execute the request. The JSON document is malformed.","messageId":"barcelona_request_malformed_json","traceId":"qAjtvjtjl3rIRbM9FKGpShY-5BvHlbNteHiVZuZJ8_gKhmva8nQQJA==","cause":{"code":"InternalServerError","message":"Cannot execute the request due to an error. Retry later.","messageId":"barcelona_request_internal_error","traceId":"qAjtvjtjl3rIRbM9FKGpShY-5BvHlbNteHiVZuZJ8_gKhmva8nQQJA=="}}
PS C:\Example> $UefiShellBoot  # Not working (note 0 ClassId/ObjectType)
AdditionalProperties : {}
ClassId              : 0
ObjectType           : 0
Enabled              : True
Name                 : UEFI-Shell

Version used Version 1.0.11.14968 of Intersight.PowerShell (SaaS connection)

Expected behavior ClassId and ObjectType to be pre-defined using the Intersight-Initialize* functions and for related calls to New-IntersightBootPrecisionPolicy to succeed. Example using NVMe policy:

PS C:\Example> $NvmeBoot = Initialize-IntersightBootNvme -Enabled $true -Name "NVMe"
PS C:\Example> New-IntersightBootPrecisionPolicy -Organization $OrgRef -Name "test3" -BootDevices @($NvmeBoot)  # Working
ClassId               : BootPrecisionPolicy
ObjectType            : BootPrecisionPolicy
...
PS C:\Example> $NvmeBoot  # Working (note populated ClassId/ObjectType)
ClassId              : BootNvme
ObjectType           : BootNvme
Bootloader           :
AdditionalProperties : {}
Enabled              : True
Name                 : NVMe

Additional context This can be worked around by manually specifying the ClassId and ObjectType, though they need to be discovered by capturing the API calls in a web browser. However, this behavior of not having the ClassId and ObjectType pre-defined by these two Initialize-IntersightBoot* functions deviates from the behavior of all of the rest.

# Workarounds
$LocalCddBoot = Initialize-IntersightBootLocalCdd -Enabled $true -Name "Local-CDD" -ClassId "BootLocalCdd" -ObjectType "BootLocalCdd"
$UefiShellBoot = Initialize-IntersightBootUefiShell -Enabled $true -Name "UEFI-Shell" -ClassId "BootUefiShell" -ObjectType "BootUefiShell"
New-IntersightBootPrecisionPolicy -Organization $OrgRef -Name "test4" -BootDevices @($LocalCddBoot, $UefiShellBoot)  # Working with workaround
ClassId               : BootPrecisionPolicy
ObjectType            : BootPrecisionPolicy
Ghufz commented 2 months ago

This issue has been fixed in the version 1.0.11.18369