HewlettPackard / python-redfish-utility

Python-based utility for interacting with devices supporting a Redfish Service
Other
86 stars 41 forks source link

JSON schema changed in 3.6.0.0 #94

Closed pszlazak closed 3 months ago

pszlazak commented 7 months ago

Recently I was recreating my server and updated from ilorest 3.2.2 to 4.7.0.0. My scripts used to parse JSON data stopped to work. I found issue #66 , but it does not solve my problems.

According to my checks new schema was introduced in 3.6.0.0 and it generally dropped usage of arrays in JSON. Current output:

$ ilorest serverinfo --power --json --nologo
{
  "PowerSupply Redundancy Group 1": {
    "Redundancy Health": "OK",
    "Redundancy Mode": "Failover",
    "Redundancy State": "Enabled"
  },
  "power": {
    "Power Metrics on 20 min. Intervals": {
      "Average Power": "263 W",
      "Max Consumed Power": "293 W",
      "Minimum Consumed Power": "251 W"
    },
    "Power Supply 1": {
      "Health": "OK",
      "Hotplug Capable": true,
      "Input Voltage": "227 V",
      "Input Voltage Type": "ACHighLine",
      "Last Power Output": "111 W",
      "Power Capacity": "800 W",
      "State": "Enabled",
      "iPDU Capable": false
    },
    "Power Supply 2": {
      "Health": "OK",
      "Hotplug Capable": true,
      "Input Voltage": "227 V",
      "Input Voltage Type": "ACHighLine",
      "Last Power Output": "146 W",
      "Power Capacity": "800 W",
      "State": "Enabled",
      "iPDU Capable": false
    },
    "Total Power Capacity": "1600 W",
    "Total Power Consumed": "257 W"
  }
}

Previously it was:

$ ilorest serverinfo --power --json --nologo
{
  "power": {
    "@odata.context": "/redfish/v1/$metadata#Power.Power",
    "@odata.etag": "W/\"FB09DF9B\"",
    "@odata.id": "/redfish/v1/Chassis/1/Power/",
    "@odata.type": "#Power.v1_3_0.Power",
    "Id": "Power",
    "Name": "PowerMetrics",
    "Oem": {
      "Hpe": {
        "@odata.context": "/redfish/v1/$metadata#HpePowerMetricsExt.HpePowerMetricsExt",
        "@odata.type": "#HpePowerMetricsExt.v2_4_1.HpePowerMetricsExt",
        "BrownoutRecoveryEnabled": true,
        "HasCpuPowerMetering": true,
        "HasDimmPowerMetering": true,
        "HasGpuPowerMetering": false,
        "HasPowerMetering": true,
        "HighEfficiencyMode": "Balanced",
        "Links": {
          "FastPowerMeter": {
            "@odata.id": "/redfish/v1/Chassis/1/Power/FastPowerMeter/"
          },
          "FederatedGroupCapping": {
            "@odata.id": "/redfish/v1/Chassis/1/Power/FederatedGroupCapping/"
          },
          "PowerMeter": {
            "@odata.id": "/redfish/v1/Chassis/1/Power/PowerMeter/"
          },
          "SlowPowerMeter": {
            "@odata.id": "/redfish/v1/Chassis/1/Power/SlowPowerMeter/"
          }
        },
        "MinimumSafelyAchievableCap": null,
        "MinimumSafelyAchievableCapValid": false,
        "PowerMetric": {
          "AmbTemp": 22,
          "Cap": 0,
          "CpuCapLim": 100,
          "CpuMax": 0,
          "CpuPwrSavLim": 100,
          "CpuWatts": 130,
          "DimmWatts": 19,
          "GpuWatts": 0,
          "PrMode": "max",
          "PunCap": false,
          "UnachCap": false
        },
        "SNMPPowerThresholdAlert": {
          "DurationInMin": 0,
          "ThresholdWatts": 0,
          "Trigger": "Disabled"
        }
      }
    },
    "PowerControl": [
      {
        "@odata.id": "/redfish/v1/Chassis/1/Power/#PowerControl/0",
        "MemberId": "0",
        "PowerCapacityWatts": 1600,
        "PowerConsumedWatts": 257,
        "PowerMetrics": {
          "AverageConsumedWatts": 262,
          "IntervalInMin": 20,
          "MaxConsumedWatts": 300,
          "MinConsumedWatts": 250
        }
      }
    ],
    "PowerSupplies": [
      {
        "@odata.id": "/redfish/v1/Chassis/1/Power/#PowerSupplies/0",
        "FirmwareVersion": "1.00",
        "LastPowerOutputWatts": 112,
        "LineInputVoltage": 226,
        "LineInputVoltageType": "ACHighLine",
        "Manufacturer": "DELTA",
        "MemberId": "0",
        "Model": "865414-B21",
        "Name": "HpeServerPowerSupply",
        "Oem": {
          "Hpe": {
            "@odata.context": "/redfish/v1/$metadata#HpeServerPowerSupply.HpeServerPowerSupply",
            "@odata.type": "#HpeServerPowerSupply.v2_0_0.HpeServerPowerSupply",
            "AveragePowerOutputWatts": 112,
            "BayNumber": 1,
            "HotplugCapable": true,
            "MaxPowerOutputWatts": 119,
            "Mismatched": false,
            "PowerSupplyStatus": {
              "State": "Ok"
            },
            "iPDUCapable": false
          }
        },
        "PowerCapacityWatts": 800,
        "PowerSupplyType": "AC",
        "SerialNumber": "5WBXT0B4D90034",
        "SparePartNumber": "866730-001",
        "Status": {
          "Health": "OK",
          "State": "Enabled"
        }
      },
      {
        "@odata.id": "/redfish/v1/Chassis/1/Power/#PowerSupplies/1",
        "FirmwareVersion": "1.00",
        "LastPowerOutputWatts": 145,
        "LineInputVoltage": 227,
        "LineInputVoltageType": "ACHighLine",
        "Manufacturer": "DELTA",
        "MemberId": "1",
        "Model": "865414-B21",
        "Name": "HpeServerPowerSupply",
        "Oem": {
          "Hpe": {
            "@odata.context": "/redfish/v1/$metadata#HpeServerPowerSupply.HpeServerPowerSupply",
            "@odata.type": "#HpeServerPowerSupply.v2_0_0.HpeServerPowerSupply",
            "AveragePowerOutputWatts": 145,
            "BayNumber": 2,
            "HotplugCapable": true,
            "MaxPowerOutputWatts": 154,
            "Mismatched": false,
            "PowerSupplyStatus": {
              "State": "Ok"
            },
            "iPDUCapable": false
          }
        },
        "PowerCapacityWatts": 800,
        "PowerSupplyType": "AC",
        "SerialNumber": "5WBXT0B4D9001B",
        "SparePartNumber": "866730-001",
        "Status": {
          "Health": "OK",
          "State": "Enabled"
        }
      }
    ],
    "Redundancy": [
      {
        "@odata.id": "/redfish/v1/Chassis/1/Power/#Redundancy/0",
        "MaxNumSupported": 2,
        "MemberId": "0",
        "MinNumNeeded": 2,
        "Mode": "Failover",
        "Name": "PowerSupply Redundancy Group 1",
        "RedundancySet": [
          {
            "@odata.id": "/redfish/v1/Chassis/1/Power/#PowerSupplies/0"
          },
          {
            "@odata.id": "/redfish/v1/Chassis/1/Power/#PowerSupplies/1"
          }
        ],
        "Status": {
          "Health": "OK",
          "State": "Enabled"
        }
      }
    ]
  }
}

As I use jq to parse outputs, I was able to quickly select needed data, e.g.

$ ilorest serverinfo --power --json --nologo | jq --raw-output '.power.PowerSupplies[].Status.Health'
OK
OK

In previous output, PSUs were available as two separate objects of PowerSupplies array.

In current output, under power we have three objects:

and additional two keys:

In short I would call current output too flat.

rajkumar14 commented 4 months ago

@pszlazak We plan to fix this, this output made as PowerSupplies array now is this OK. { "PowerSupply Redundancy Group 1": { "Redundancy Health": "OK", "Redundancy Mode": "Failover", "Redundancy State": "Enabled" }, "power": { "Power Metrics on 20 min. Intervals": { "Average Power": "127 W", "Max Consumed Power": "153 W", "Minimum Consumed Power": "126 W" }, "PowerSupplies": [ {

      "Health": "OK",
      "Hotplug Capable": true,
      "Input Voltage": "227 V",
      "Input Voltage Type": "ACHighLine",
      "Last Power Output": "69 W",
      "Power Capacity": "1600 W",
      "State": "Enabled",
      "iPDU Capable": false

  },
  {

      "Health": "OK",
      "Hotplug Capable": true,
      "Input Voltage": "227 V",
      "Input Voltage Type": "ACHighLine",
      "Last Power Output": "59 W",
      "Power Capacity": "1600 W",
      "State": "Enabled",
      "iPDU Capable": false

  }
],
"Total Power Capacity": "3200 W",
"Total Power Consumed": "128 W"

} }

rajkumar14 commented 4 months ago

You may have to change the below command:

$ ilorest serverinfo --power --json --nologo | jq --raw-output '.power.PowerSupplies[].Status.Health'

instead you can use this command

$ ilorest serverinfo --power --json --nologo | jq --raw-output '.power.PowerSupplies[].Health'

rajkumar14 commented 3 months ago

@pszlazak This is fixed in build 5.0.0.0. Please you can verify.

pszlazak commented 3 months ago

@rajkumar14 I confirm, JSON schema is corrected in 5.0.0.0. Although it differs from the old schema. Yet, with suggested command, I can get needed data:

$ ilorest serverinfo --power --json --nologo | jq --raw-output '.power.PowerSupplies[].Health'

BTW - for 5.0.0.0 I don't see Debian package created. Is it intended or just an accident?

rajeevkallur commented 3 months ago

@pszlazak , For debian, please use the pypi package from https://pypi.org/project/ilorest/

pszlazak commented 3 months ago

@rajeevkallur Yes, I noticed it's available now as pypi package. Yet Debian is PEP 668 compatible and the easiest way to install something system-wide is to have DEB package.