DMTF / Redfish-Service-Validator

The Redfish Service Validator is a Python3 tool for checking conformance of any "device" with a Redfish service interface against Redfish CSDL schema
Other
38 stars 33 forks source link

Incorrect error "NetworkSuppliedServers not defined in Complex NTP ManagerNetworkProtocol" #529

Closed blakehilliard closed 1 year ago

blakehilliard commented 1 year ago

The tool gives me this error, but "NetworkSuppliedServers" is in the schema. Notice that it says "1_2_0" as the schema version, even though the one in odata.type is 1_9_1. It seems to be validating against a very old version of ManagerNetworkProtocol for some reason?

This is likely the same root cause as https://github.com/DMTF/Redfish/issues/5311

ERROR - NetworkSuppliedServers not defined in Complex NTP ManagerNetworkProtocol.v1_2_0.NTPProtocol (check version, spelling and casing)
{
    "@odata.etag": "\"a5e398f753e816234363776dbf34d787\"",
    "@odata.id": "/redfish/v1/Managers/RMC/NetworkProtocol",
    "@odata.type": "#ManagerNetworkProtocol.v1_9_1.ManagerNetworkProtocol",
    "FQDN": "sph-030-rmc.chf.rdlabs.hpecorp.net",
    "HTTP": {
        "Port": 80,
        "ProtocolEnabled": true
    },
    "HTTPS": {
        "Certificates": {
            "@odata.id": "/redfish/v1/Managers/RMC/NetworkProtocol/HTTPS/Certificates"
        },
        "Port": 443,
        "ProtocolEnabled": true
    },
    "HostName": "sph-030-rmc",
    "IPMI": {
        "Port": 623,
        "ProtocolEnabled": false
    },
    "Id": "NetworkProtocol",
    "NTP": {
        "NTPServers": [
            null
        ],
        "NetworkSuppliedServers": [
            "16.110.135.123"
        ],
        "Port": 123,
        "ProtocolEnabled": true
    },
    "Name": "RMC Network Protocol",
    "SSH": {
        "Port": 22,
        "ProtocolEnabled": true
    },
    "Status": {
        "State": "Enabled"
    }
}
tomasg2012 commented 1 year ago

The schema is logical, but the tool is acting particular about type casting to a higher version.

      <EntityType Name="ManagerNetworkProtocol" BaseType="ManagerNetworkProtocol.v1_1_1.ManagerNetworkProtocol">
        <Property Name="NTP" Type="ManagerNetworkProtocol.v1_2_0.NTPProtocol" Nullable="false">
          <Annotation Term="OData.Description" String="The settings for this manager's NTP protocol support."/>
          <Annotation Term="OData.LongDescription" String="This object shall contain the NTP protocol settings for the manager."/>
        </Property>
      .........
      </EntityType>

      <ComplexType Name="NTPProtocol" BaseType="ManagerNetworkProtocol.v1_0_0.Protocol">
        <Annotation Term="OData.AdditionalProperties" Bool="false"/>
        <Property Name="NTPServers" Type="Collection(Edm.String)">
          <Annotation Term="OData.Permissions" EnumMember="OData.Permission/ReadWrite"/>
          <Annotation Term="OData.Description" String="Indicates to which NTP servers this manager is subscribed."/>
          <Annotation Term="OData.LongDescription" String="This property shall contain all the NTP servers for which this manager is using to obtain time."/>
        </Property>
      </ComplexType>

In catalog.py, the following code only casts if our namespace is the lowest or undefined, or specified by '@odata.type':

if my_ns in [my_ns_unversioned, my_ns_unversioned + '.v1_0_0', '.'.join([my_ns_unversioned, min_version])] or my_odata_type:

Since the Property in particular NTP's typechain starts at v1_2_0, but the actual lowest version is v1_0_0.Protocol, the tool falsely assumes it should not be cast.

The tool should maybe just cast if there's any higher type that's valid within sub_obj.parent.Type (which would be ManagerNetworkProtocol.v1_9_1), but I'm unsure if that's accomplished by simply removing this line. This should probably be given a series of corner cases, or if there's any fallback in Redfish schema, or some precedent in odata to define this behavior since @odata.type is assumed... @mraineri , @jautor