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
42 stars 34 forks source link

Redfish-Service-Validator didn't verify oem uri with oem schema #600

Open rick0118 opened 2 months ago

rick0118 commented 2 months ago

Hi all,

I am a newbie in Redfish. I have an OEM Redfish service, and I tried to write an OEM CSDL schema to verify it. However, the service validator did not show the OEM verification report in the HTML output. Even in the OEM property, it returns a "complex" result.

Here is my workflow:

I wrote the annotated JSON for Redfish-Schema-Creator based on the Redfish service response JSON. I used the odata-csdl-validator to verify it and then added it to the BMC web Redfish-core/schema. I was able to see the OEM schema at /redfish/v1/$metadata. Additionally, I added an OEM URI to the service root:

"Oem": {
    "@odata.id": "/redfish/v1/Oem/rick"
}

Here is my OEM service response JSON. I know @odata.type means the verify CSDL XML namespace version:

{
    "@odata.id": "/redfish/v1/Oem/rick",
    "@odata.type": "#rickCollection.v1_0_0.rickCollection",
    "Employee": "rick",
    "Members": [
        {
            "@odata.id": "/redfish/v1/Oem/rick/Virtual_Temp"
        }
    ],
    "Members@odata.count": 1,
    "Work_ID": 123
}

OEM CSDL name: rickCollection_v1.xml

<?xml version="1.0" encoding="UTF-8"?>
<!---->
<!--################################################################################-->
<!--# Redfish Schema:  rickCollection.v1_0_0                                      -->
<!--#                                                                                -->
<!--# For a detailed change log, see the README file contained in the DSP8010 bundle,-->
<!--# available at http://www.dmtf.org/standards/redfish                             -->
<!--# Copyright 2020 DMTF.                                                           -->
<!--# For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright -->
<!--################################################################################-->
<!---->
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
    <edmx:Reference Uri="http://redfish.dmtf.org/schemas/v1/Resource_v1.xml">
        <edmx:Include Namespace="Resource.v1_0_0"/>
    </edmx:Reference>
    <edmx:Reference Uri="http://docs.oasis-open.org/odata/odata/v4.0/errata03/csd01/complete/vocabularies/Org.OData.Capabilities.V1.xml">
        <edmx:Include Namespace="Org.OData.Capabilities.V1" Alias="Capabilities"/>
    </edmx:Reference>
    <edmx:Reference Uri="http://docs.oasis-open.org/odata/odata/v4.0/errata03/csd01/complete/vocabularies/Org.OData.Core.V1.xml">
        <edmx:Include Namespace="Org.OData.Core.V1" Alias="OData"/>
    </edmx:Reference>
    <edmx:Reference Uri="http://redfish.dmtf.org/schemas/v1/RedfishExtensions_v1.xml">
        <edmx:Include Namespace="RedfishExtensions.v1_0_0" Alias="Redfish"/>
    </edmx:Reference>
    <edmx:DataServices>
        <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="rickCollection">
            <Annotation Term="Redfish.OwningEntity" String="TBD"/>
            <EntityType Name="rickCollection" BaseType="Resource.v1_0_0.Resource" Abstract="true">
                <Annotation Term="OData.Description" String="Parameters for rickCollection."/>
                <Annotation Term="OData.LongDescription" String="Parameters for rickCollection."/>
                <Annotation Term="Capabilities.InsertRestrictions">
                    <Record>
                        <PropertyValue Property="Insertable" Bool="false"/>
                    </Record>
                </Annotation>
                <Annotation Term="Capabilities.UpdateRestrictions">
                    <Record>
                        <PropertyValue Property="Updatable" Bool="false"/>
                    </Record>
                </Annotation>
                <Annotation Term="Capabilities.DeleteRestrictions">
                    <Record>
                        <PropertyValue Property="Deletable" Bool="false"/>
                    </Record>
                </Annotation>
            </EntityType>
        </Schema>
        <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="rickCollection.v1_0_0">
            <Annotation Term="Redfish.OwningEntity" String="TBD"/>
            <Annotation Term="Redfish.Release" String="TBD"/>
            <EntityType Name="rickCollection" BaseType="rickCollection.rickCollection">
                <Property Name="Employee" Type="rickCollection.v1_0_0.Employee" Nullable="false">
                    <Annotation Term="OData.Permissions" EnumMember="OData.Permission/Read"/>
                    <Annotation Term="OData.Description" String="TBD"/>
                    <Annotation Term="OData.LongDescription" String="TBD"/>
                </Property>
                <Property Name="Members" Type="Collection(rickCollection.v1_0_0.Members)" Nullable="false">
                    <Annotation Term="OData.Permissions" EnumMember="OData.Permission/Read"/>
                    <Annotation Term="OData.Description" String="TBD"/>
                    <Annotation Term="OData.LongDescription" String="TBD"/>
                </Property>
                <Property Name="Work_ID" Type="Edm.Int64" Nullable="false">
                    <Annotation Term="OData.Permissions" EnumMember="OData.Permission/Read"/>
                    <Annotation Term="OData.Description" String="TBD"/>
                    <Annotation Term="OData.LongDescription" String="TBD"/>
                </Property>
            </EntityType>
            <EnumType Name="Employee">
                <Member Name="rick">
                    <Annotation Term="OData.Description" String="TBD"/>
                </Member>
                <Member Name="rose">
                    <Annotation Term="OData.Description" String="TBD"/>
                </Member>
            </EnumType>
            <ComplexType Name="Members">
                <Annotation Term="OData.Description" String="TBD"/>
                <Annotation Term="OData.LongDescription" String="TBD"/>
                <Annotation Term="OData.AdditionalProperties" Bool="false"/>
            </ComplexType>
        </Schema>
    </edmx:DataServices>
</edmx:Edmx>

After that, I ran the Redfish-Service-Validator, but the Redfish Conformance Test Report did not include my OEM Redfish service. However, it did perform the JSON schema validation tests.

*** /redfish/v1/JsonSchemas/rickCollection
INFO -     Type (JsonSchemaFile.v1_0_2.JsonSchemaFile), GET SUCCESS (time: 0:00:00.316447)
INFO -     PASS

Can someone help me understand what might be going wrong?

mraineri commented 2 months ago

So the Oem property is defined to be a structured object. You won't be able to stick a URI in directly like that. The validator (and other tools) are expecting the Oem property to be constructed like this:

{
    "Oem": {
        "CompanyIdentifier": {
            // OEM properties
        }
    }
}

For your usage, you'll need to define the contents of the inner object. I suppose it'll look something like this:

{
    "Oem": {
        "CompanyIdentifier": {
            "@odata.type": "#RickServiceRoot.v1_0_0.RickServiceRoot",
            "RickLink": {
                "@odata.id": "/redfish/v1/Oem/rick
            }
        }
    }
}

To make the schema file for "#RickServiceRoot.v1_0_0.RickServiceRoot", you can use this example as a template: https://github.com/DMTF/Redfish-Publications/blob/main/mockups/public-oem-examples/Contoso.com/ContosoServiceRoot_v1.xml

rick0118 commented 2 months ago

Thank you! That definitely clears things up.

I referred to the URL you provided and some forum articles:

ContosoServiceRoot.json ContosoServiceRoot_v1.xml

relative redfishforum with same warning

I get the warning about Couldn't get schema for object (?), skipping OemObject RichCompany : 'RichCompanyServiceRoot'

To clarify further, I added an OEM object, RichCompanyServiceRoot, to the Redfish v1 service root. The OEM service root extends the original service root:

.
.
.
"Name": "Root Service",
    "Oem": {
        "RichCompany": {
            "@odata.type": "#RichCompanyServiceRoot.v1_0_0.RichCompanyServiceRoot",
            "RickLink": {
                "@odata.id": "/redfish/v1/Oem/rick"
            }
        }
    }
.
.
.

Below is my RichCompanyServiceRoot_v1.xml. I expect it to successfully parse my OEM object and add @odata.id to the path that needs to be verified, but I encountered issues and need your generous help.

First, define the necessary XML as references:

<?xml version="1.0" encoding="UTF-8"?>
<!---->
<!--################################################################################       -->
<!--# Contoso Schema:  RichCompanyServiceRoot.v1_0_0                                       -->
<!--#                                                                                      -->
<!--# Copyright 2014-2021 DMTF.                                                            -->
<!--# For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright -->
<!--################################################################################       -->
<!---->
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">

  <edmx:Reference Uri="http://docs.oasis-open.org/odata/odata/v4.0/errata03/csd01/complete/vocabularies/Org.OData.Core.V1.xml">
    <edmx:Include Namespace="Org.OData.Core.V1" Alias="OData"/>
  </edmx:Reference>
  <edmx:Reference Uri="http://redfish.dmtf.org/schemas/v1/RedfishExtensions_v1.xml">
    <edmx:Include Namespace="RedfishExtensions.v1_0_0" Alias="Redfish"/>
  </edmx:Reference>
  <edmx:Reference Uri="http://redfish.dmtf.org/schemas/v1/Resource_v1.xml">
    <edmx:Include Namespace="Resource"/>
  </edmx:Reference>
  <edmx:Reference Uri="http://redfish.dmtf.org/schemas/v1/ServiceRoot_v1.xml">
    <edmx:Include Namespace="ServiceRoot.v1_13_0"/>
  </edmx:Reference>
  <edmx:Reference Uri="http://127.0.0.1/rickCollection_v1.xml"> 
    <edmx:Include Namespace="rickCollection"/>
  </edmx:Reference>
  <edmx:DataServices>

    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="RichCompanyServiceRoot">
      <Annotation Term="Redfish.OwningEntity" String="RichCompany"/>
      <Annotation Term="OData.Description" String="RichCompany extensions to the standard service root."/>
    </Schema>

    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="RichCompanyServiceRoot.v1_0_0">
      <Annotation Term="Redfish.OwningEntity" String="RichCompany"/>

      <EntityContainer Name="ServiceContainer" Extends="ServiceRoot.v1_15_0.ServiceRoot">
        <Singleton Name="RickLink" Type="rickCollection.rickCollection"/>
      </EntityContainer>

      <ComplexType Name="ServiceRoot" BaseType="Resource.OemObject">
        <NavigationProperty Name="RickLink" Type="rickCollection.rickCollection" Nullable="false">
          <Annotation Term="OData.Permissions" EnumMember="OData.Permission/Read"/>
          <Annotation Term="OData.Description" String="Link to the rickCollection service."/>
          <Annotation Term="OData.LongDescription" String="This property shall contain the link to a resource of type rickCollection."/>
          <Annotation Term="OData.AutoExpandReferences"/>
        </NavigationProperty>
      </ComplexType>
    </Schema>

  </edmx:DataServices>
</edmx:Edmx>

I am unsure if the following definitions are correct. When I use

<EntityContainer Name="ServiceContainer" Extends="ServiceRoot.v1_15_0.ServiceRoot">
<ComplexType Name="ServiceRoot" BaseType="Resource.OemObject">

I also tested other methods, but the results were similar:

<EntityContainer Name="ServiceContainer" Extends="RichCompanyServiceRoot.v1_0_0.ServiceContainer">
<ComplexType Name="ServiceRoot" BaseType="RichCompanyServiceRoot.v1_0_0.ServiceRoot">

I get the warning below. Expecting your reply and thank you very much.

Couldn't get schema for object (?), skipping OemObject RichCompany : 'RichCompanyServiceRoot'
         Type (ServiceRoot.v1_15_0.ServiceRoot), GET SUCCESS (time: 0:00:00.208736)

Additionally, I noticed that my collectionlimit setting for LogEntry 10 is not being properly enforced. The tool continues to validate even when the limit is exceeded. I have confirmed that I have upgraded to the latest version 2.4.8 of the tool.

mraineri commented 2 months ago

Additionally, I noticed that my collectionlimit setting for LogEntry 10 is not being properly enforced. The tool continues to validate even when the limit is exceeded. I have confirmed that I have upgraded to the latest version 2.4.8 of the tool.

Please file a separate issue for this. I'd likely lose track of this otherwise.

Below is my RichCompanyServiceRoot_v1.xml.

On first review, the syntax for this looks good to me. The EntityContainer portion isn't very relevant. There are some technicalities where it might be needed in a pure OData environment, but for the purposes of making a Redfish extension and having the Redfish tools work, it's not necessary. The service validator won't inspect EntityContainer.

I get the warning below. (Couldn't get schema for object (?), skipping OemObject RichCompany : 'RichCompanyServiceRoot')

Can you check the contents of the "SchemaFiles/metadata" directory to see if RichCompanyServiceRoot_v1.xml was downloaded and cached? Depending on the starting state, the tool might not download schema files.

Can you also run with --debugging and provide the txt file that's generated in the logs directory?

rick0118 commented 2 months ago

first, Thank you for taking the time to read and reply to this question.

In the log, I see that it has downloaded RichCompanyServiceRoot from /redfish/v1/schema/RichCompanyServiceRoot_v1.xml, but a warning appears as follows:

WARNING - Couldn't get schema for object (?), skipping OemObject RichCompany : 'RichCompanyServiceRoot'

Additionally, I just added the following to ServiceRoot_v1.xml, also I know we have oem property format from Resource_v1.xml but it still cannot successfully recognize my OEM schema:

<edmx:Reference Uri="http://127.0.0.1/RichCompanyServiceRoot_v1.xml">
    <edmx:Include Namespace="RichCompanyServiceRoot.v1_0_0"/>
  </edmx:Reference>

my screenshot on report image image

my oem object format, I think that is meet redfish spec

"Oem": {
        "RichCompany": {
            "@odata.type": "#RichCompanyServiceRoot.v1_0_0.RichCompanyServiceRoot",
            "RickLink": {
                "@odata.id": "/redfish/v1/Oem/rick"
            }
        }
    }

Below are my logs as well as the complete log.txt.

INFO - Redfish Service Validator, version 2.4.8
INFO - 
INFO - Target URI: https://XXXXXXXXX:2443
INFO - authtype: Basic
collectionlimit: ['LogEntry', '10']
config: ../config/example.ini
debugging: True
forceauth: False
ip: https://XXXXXXXXX:2443
logdir: ./logs
oemcheck: True
password: ******
schema_directory: ./SchemaFiles/metadata
uricheck: False
username: root
verbose: 0
INFO - Start time: 08/08/24 - 15:57:11
INFO - 
INFO - Downloading initial schemas from online
INFO - The tool will, by default, attempt to download and store XML files to relieve traffic from DMTF/service
INFO - Unpacking schema pack... https://www.dmtf.org/sites/default/files/standards/documents/DSP8010.zip
INFO - Setting up service...
INFO - Attempt 1 of /redfish/v1/
INFO - Response Time for GET to /redfish/v1/: 0.3325349750002715 seconds.
INFO - Attempt 1 of /redfish/v1/SessionService/Sessions
INFO - Response Time for GET to /redfish/v1/SessionService/Sessions: 0.679114154000672 seconds.
INFO - Attempt 1 of /redfish/v1/$metadata
INFO - Response Time for GET to /redfish/v1/$metadata: 1.5591788309993717 seconds.
INFO - Constructing metadata...
WARNING - Schema file OpenBMCAccountService_v1.xml not found in ./SchemaFiles/metadata
INFO - Attempt 1 of /redfish/v1/schema/OpenBMCAccountService_v1.xml
INFO - Response Time for GET to /redfish/v1/schema/OpenBMCAccountService_v1.xml: 0.2639589590007745 seconds.
INFO - Writing online XML to file: OpenBMCAccountService_v1.xml
WARNING - Schema file OpenBMCManager_v1.xml not found in ./SchemaFiles/metadata
INFO - Attempt 1 of /redfish/v1/schema/OpenBMCManager_v1.xml
INFO - Response Time for GET to /redfish/v1/schema/OpenBMCManager_v1.xml: 0.2729260609994526 seconds.
INFO - Writing online XML to file: OpenBMCManager_v1.xml
WARNING - Schema file RichCompanyServiceRoot_v1.xml not found in ./SchemaFiles/metadata
INFO - Attempt 1 of /redfish/v1/schema/RichCompanyServiceRoot_v1.xml
INFO - Response Time for GET to /redfish/v1/schema/RichCompanyServiceRoot_v1.xml: 0.217839025000103 seconds.
INFO - Writing online XML to file: RichCompanyServiceRoot_v1.xml
WARNING - Schema file rickCollection_v1.xml not found in ./SchemaFiles/metadata
INFO - Attempt 1 of /redfish/v1/schema/rickCollection_v1.xml
INFO - Response Time for GET to /redfish/v1/schema/rickCollection_v1.xml: 0.2924249809993853 seconds.
INFO - Writing online XML to file: rickCollection_v1.xml
WARNING - Schema file rickTemp_v1.xml not found in ./SchemaFiles/metadata
INFO - Attempt 1 of /redfish/v1/schema/rickTemp_v1.xml
INFO - Response Time for GET to /redfish/v1/schema/rickTemp_v1.xml: 0.23690154399992025 seconds.
INFO - Writing online XML to file: rickTemp_v1.xml
INFO - Attempt 1 of /redfish/v1/schema/RedfishExtensions_v1.xml
INFO - Response Time for GET to /redfish/v1/schema/RedfishExtensions_v1.xml: 0.2970805109998764 seconds.
INFO - NOT writing online XML to file: RedfishExtensions_v1.xml
INFO - Attempt 1 of /redfish/v1
INFO - Response Time for GET to /redfish/v1: 0.29463464800028305 seconds.
INFO - Redfish Version of Service: 1.17.0
INFO - Description of service: My Target System Root Service, version 1.17.0, 3e5f81ed-607e-4af0-bad2-fdabff7aa926
INFO - 
*** /redfish/v1/
INFO - Attempt 1 of /redfish/v1/
INFO - Response Time for GET to /redfish/v1/: 0.30562719000045036 seconds.
WARNING - Schema not found for NVMeDomainCollection.NVMeDomainCollection
WARNING - Schema not found for StorageSystemCollection.StorageSystemCollection
WARNING - Schema not found for StorageServiceCollection.StorageServiceCollection
WARNING - Couldn't get schema for object (?), skipping OemObject RichCompany : 'RichCompanyServiceRoot'
INFO -   Type (ServiceRoot.v1_15_0.ServiceRoot), GET SUCCESS (time: 0:00:00.306326)

ConformanceLog_08_08_2024_155711.txt


RichCompanyServiceRoot_v1.xml

<?xml version="1.0" encoding="UTF-8"?>
<!---->
<!--################################################################################       -->
<!--# Contoso Schema:  RichCompanyServiceRoot.v1_0_0                                           -->
<!--#                                                                                      -->
<!--# Copyright 2014-2021 DMTF.                                                            -->
<!--# For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright -->
<!--################################################################################       -->
<!---->
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">

  <edmx:Reference Uri="http://docs.oasis-open.org/odata/odata/v4.0/errata03/csd01/complete/vocabularies/Org.OData.Core.V1.xml">
    <edmx:Include Namespace="Org.OData.Core.V1" Alias="OData"/>
  </edmx:Reference>
  <edmx:Reference Uri="http://redfish.dmtf.org/schemas/v1/RedfishExtensions_v1.xml">
    <edmx:Include Namespace="RedfishExtensions.v1_0_0" Alias="Redfish"/>
  </edmx:Reference>
  <edmx:Reference Uri="http://redfish.dmtf.org/schemas/v1/Resource_v1.xml">
    <edmx:Include Namespace="Resource"/>
  </edmx:Reference>
  <edmx:Reference Uri="http://redfish.dmtf.org/schemas/v1/ServiceRoot_v1.xml">
    <edmx:Include Namespace="ServiceRoot.v1_13_0"/>
  </edmx:Reference>
  <edmx:Reference Uri="http://127.0.0.1/rickCollection_v1.xml"> 
    <edmx:Include Namespace="rickCollection"/>
  </edmx:Reference>

  <edmx:DataServices>

    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="RichCompanyServiceRoot">
      <Annotation Term="Redfish.OwningEntity" String="RichCompany"/>
      <Annotation Term="OData.Description" String="RichCompany extensions to the standard service root."/>
    </Schema>

    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="RichCompanyServiceRoot.v1_0_0">
      <Annotation Term="Redfish.OwningEntity" String="RichCompany"/>

      <EntityContainer Name="ServiceContainer" Extends="ServiceRoot.v1_15_0.ServiceRoot">
        <Singleton Name="RickLink" Type="rickCollection.rickCollection"/>
      </EntityContainer>

      <EntityType Name="ServiceRoot" BaseType="Resource.OemObject">
        <NavigationProperty Name="RickLink" Type="rickCollection.rickCollection" Nullable="false">
          <Annotation Term="OData.Permissions" EnumMember="OData.Permission/Read"/>
          <Annotation Term="OData.Description" String="Link to the rickCollection service."/>
          <Annotation Term="OData.LongDescription" String="This property shall contain the link to a resource of type rickCollection."/>
          <Annotation Term="OData.AutoExpandReferences"/>
        </NavigationProperty>
      </EntityType>
    </Schema>

  </edmx:DataServices>
</edmx:Edmx>