stmcginnis / gofish

Gofish is a Golang client library for DMTF Redfish and SNIA Swordfish interaction.
BSD 3-Clause "New" or "Revised" License
211 stars 113 forks source link

Is chassis.Drives() unfinished? #143

Closed sosodev closed 3 years ago

sosodev commented 3 years ago

chassis.Drives() seems to always return an empty drives slice. Also, it looks like creating the chassis itself hits what looks like a leftover debugging print.

stmcginnis commented 3 years ago

Oops, thanks for pointing out that print statement. Definitely a leftover mistake. :)

The call is fully implemented, but not all Redfish implementations actually return associated drives for their Chassis objects. There are ComputerSystem and I think one or two other objects that can also have associated drives that I need to implement yet. I haven't been able to compare a wide variety of implementations, but I think some report the drives in some places but not others.

sosodev commented 3 years ago

Hmm. It doesn't seem to work for me.

chassis.Drives() returns an empty slice for the following chassis entity which links its drives

{
  "@odata.type": "#Chassis.v1_9_1.Chassis",
  "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane",
  "Id": "NVMeSSD.0.Group.0.StorageBackplane",
  "Name": "Backplane",
  "ChassisType": "Enclosure",
  "Model": "Backplane",
  "SerialNumber": "",
  "PartNumber": "",
  "Links": {
    "ManagedBy": [
      {
        "@odata.id": "/redfish/v1/Managers/1"
      }
    ],
    "Storage": [
      {
        "@odata.id": "/redfish/v1/Systems/1/Storage/NVMeSSD"
      }
    ],
    "Drives": [
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.0"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.1"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.2"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.3"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.4"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.5"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.6"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.7"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.8"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.9"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.10"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.11"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.12"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.13"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.14"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.15"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.16"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.17"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.18"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.19"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.20"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.21"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.22"
      },
      {
        "@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.23"
      }
    ]
  },
  "Oem": {}
}
stmcginnis commented 3 years ago

Ah, looks like this has morphed a bit over time.

http://redfish.dmtf.org/schemas/v1/Chassis.v1_15_0.json

In version v1.2.0 of the spec, Drives were added to the Chassis.Links property. But in v1.14.0 of the spec, Chassis.Drives was added as a direct property. So this is complete for any implementations v1.14.0 and later.

I think we can handle this in the library. The Drives() call can be updated to check both places for references to drives and extract whichever is present. Should be easy enough (famous last words). ;)

stmcginnis commented 3 years ago

Thanks for the json output by the way, that helps a lot!

sosodev commented 3 years ago

No problem. :) Thanks for taking another look at this