Unsolved
6 Posts
0
2396
February 18th, 2020 07:00
REST API - Powershell Script for firmware updates
Hi,
I tried to adapt this script
To perform firmware updates against an existing Catalog (not the online catalog because we need to control what firmware versions get installed in production).
The scenario is this:
- variables passed to the script: hostname and catalog name
- the script queries the OME appliance for the Device ID of the host and for the Catalog ID and Repository ID, then creates a baseline for that host, checks the compliance, creates the update job, then deletes the baseline and exit
It works OK until attempting to create the update job.
It seems to be a problem with the jSON conversion of the payload. In the original script, line 669
I get this error
Invalid value for property: Data must not be an object or array. .
However, if i comment the -depth parameter i get
Invalid value for property: TargetType must not be an array or primitive value.
Here is the body with -Depth 6
{
"JobName": "Update Firmware-Test",
"JobDescription": "Firmware Update Job",
"Schedule": "",
"State": "Enabled",
"JobType": {
"Id": 5,
"Name": "Update_Task"
},
"Params": [
{
"Key": "complianceReportId",
"Value": "55"
},
{
"Key": "repositoryId",
"Value": "31"
},
{
"Key": "catalogId",
"Value": "41"
},
{
"Key": "operationName",
"Value": "INSTALL_FIRMWARE"
},
{
"Key": "complianceUpdate",
"Value": "true"
},
{
"Key": "signVerify",
"Value": "true"
},
{
"Key": "stagingValue",
"Value": "true"
}
],
"Targets": [
{
"TargetType": {
"Id": 1000,
"Name": "DEVICE"
},
"Data": [
"DCIM:INSTALLED#308_C_Enclosure.Internal.0-1:RAID.Slot.6-1",
"DCIM:INSTALLED#802__OSCollector.Embedded.1",
"DCIM:INSTALLED#721__FC.Slot.3-2",
"DCIM:INSTALLED#721__FC.Slot.2-1",
"DCIM:INSTALLED#802__ServiceModule.Embedded.1",
"DCIM:INSTALLED#802__DriverPack.Embedded.1:LC.Embedded.1",
"DCIM:INSTALLED#721__FC.Slot.2-2",
"DCIM:INSTALLED#802__Diagnostics.Embedded.1:LC.Embedded.1",
"DCIM:INSTALLED#721__FC.Slot.3-1",
"DCIM:INSTALLED#701__NIC.Integrated.1-3-1",
"DCIM:INSTALLED#304_C_Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1",
"DCIM:INSTALLED#iDRAC.Embedded.1-1#IDRACinfo",
"DCIM:INSTALLED#701__NIC.Integrated.1-4-1",
"DCIM:INSTALLED#701__NIC.Integrated.1-2-1",
"DCIM:INSTALLED#301_C_RAID.Slot.6-1",
"DCIM:INSTALLED#701__NIC.Integrated.1-1-1",
"DCIM:INSTALLED#741__BIOS.Setup.1-1",
"DCIM:INSTALLED#304_C_Disk.Bay.1:Enclosure.Internal.0-1:RAID.Slot.6-1"
],
"Id": 243584
}
]
}
And here is the body without the -depth parameter (i believe the default value is 2)
{
"JobName": "Update Firmware-Test",
"JobDescription": "Firmware Update Job",
"Schedule": "",
"State": "Enabled",
"JobType": {
"Id": 5,
"Name": "Update_Task"
},
"Params": [
{
"Key": "complianceReportId",
"Value": "55"
},
{
"Key": "repositoryId",
"Value": "31"
},
{
"Key": "catalogId",
"Value": "41"
},
{
"Key": "operationName",
"Value": "INSTALL_FIRMWARE"
},
{
"Key": "complianceUpdate",
"Value": "true"
},
{
"Key": "signVerify",
"Value": "true"
},
{
"Key": "stagingValue",
"Value": "true"
}
],
"Targets": [
{
"TargetType": "System.Collections.Hashtable",
"Data": "DCIM:INSTALLED#308_C_Enclosure.Internal.0-1:RAID.Slot.6-1 DCIM:INSTALLED#802__OSCollector.Embedded.1 DCIM:INSTALLED#721__FC.Slot.3-2 DCIM:INSTALLED#721__FC.Slot.2-1 DCIM:INSTALLED#802__ServiceModule.Em
bedded.1 DCIM:INSTALLED#802__DriverPack.Embedded.1:LC.Embedded.1 DCIM:INSTALLED#721__FC.Slot.2-2 DCIM:INSTALLED#802__Diagnostics.Embedded.1:LC.Embedded.1 DCIM:INSTALLED#721__FC.Slot.3-1 DCIM:INSTALLED#701__NIC.Integrated.1-3-1 DCIM:INS
TALLED#304_C_Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1 DCIM:INSTALLED#iDRAC.Embedded.1-1#IDRACinfo DCIM:INSTALLED#701__NIC.Integrated.1-4-1 DCIM:INSTALLED#701__NIC.Integrated.1-2-1 DCIM:INSTALLED#301_C_RAID.Slot.6-1 DCIM:INSTALLE
D#701__NIC.Integrated.1-1-1 DCIM:INSTALLED#741__BIOS.Setup.1-1 DCIM:INSTALLED#304_C_Disk.Bay.1:Enclosure.Internal.0-1:RAID.Slot.6-1",
"Id": 243584
}
]
}
I would really appreciate any hint to correct this.
Thank you!



ut_fleet
1 Rookie
•
21 Posts
0
February 24th, 2020 10:00
We are doing something similar (with Python instead of PS). Looking at your payload, we format our "Targets" section differently. We loop through the compliance report, creating a dictionary for each target (device):
We then populate the "Data" key's value with a monolithic string of semi-colon delimited components to update. Each target dictionary gets appended to a list, "target_list". Then for the JSON it is just:
Andi1234567
6 Posts
0
February 24th, 2020 23:00
Hi!
Seems the PS script from github is not formatting the JSON string correctly
Can you paste a complete payload here? (removing sensitive information of course)
Thank you!