|
Post by jyundt on Jun 28, 2022 21:12:55 GMT
What is the correct syntax for conditionally marking properties as "Mandatory"? I was following the example page 25 of DSP0272 (1.5.0) to conditionally set IndicatorLED to "Mandatory" but this doesn't seem to be working. Specifically, I have several servers that have two chassis: the server/chassis (ChassisType: Rackmount) and a backplane (ChassisType: Enclosure). The backplane does not have an IndicatorLED property (as expected), but when I'm trying to test a failure scenario by intentionally including Enclosures in my conditional, the Enclosure still passes the IndicatorLED test. Example profile that should fail because the Enclosure does not have an IndicatorLED: { "SchemaDefinition": "RedfishInteroperabilityProfile.v1_5_0", "ProfileName": "conditional", "ProfileVersion": "0.0.1", "Purpose": "condtional testing", "ContactInfo": "[email protected]", "OwningEntity": "DigitalOcean - Hardware Engineering", "Resources": { "Chassis": { "ReadRequirement": "Mandatory", "PropertyRequirements": { "ChassisType": { "Comparison": "Equal", "Values": [ "Enclosure", "RackMount", "StorageEnclosure" ] }, "IndicatorLED": { "ReadRequirement": "Recommended", "ConditionalRequirement": [ { "Purpose": "IndicatorLED is only required for specific Chassis types", "ReadRequirement": "Mandatory", "CompareType": "AnyOf", "CompareProperty": "ChassisType", "CompareValues": [ "RackMount", "Enclosure" ] } ] } } } }, "Registries": {} }
Test report: 
|
|
|
Post by jautor on Jun 29, 2022 0:01:58 GMT
You'll be happy and sad with this answer... You have a typo, that property name is "ConditionalRequirements" (plural). The validator is simply not seeing your requirement and since the base requirement is 'Recommended' it is passing in all cases.
But a good time to mention that the DSP0272 DSP8013 (EDIT: that's the spec, not the ZIP) bundle includes a JSON schema for the Profile document itself that you can use with your favorite JSON schema validator to check your document before testing with the Validator. Now, the bad news is that for the current version of the Profile schema, this error would not have been caught because we're lacking the "additionalProperties" attribute that deep in the object hierarchy. But we have that as an open issue and this is a good reminder to go address that!
Looking at your definition, though, if you fix that typo, you should get the results you're expecting.
Jeff
|
|
|
Post by jautor on Jun 29, 2022 0:35:10 GMT
jyundt I'm going to do some more testing to make sure I'm not breaking anything, but using the RedfishInteroperabilityProfile.v1_5_0 as the source, I added: "additionalProperties": false at the proper JSON schema levels on lines (numbered as you add them from the top) 191, 225, 423 to catch those cases. Testing that against your schema it catches the error, and once fixed, still validates. Please review and let me know if you see any issues with those additions. Jeff
|
|
|
Post by jyundt on Jun 29, 2022 10:19:03 GMT
jautor Ah, thank you for catching that typo! And thank you very much for the tip on DSP8013 / the Interop profile bundle for use with a JSON schema validator, that is exactly what I was looking for!
|
|
|
Post by jyundt on Jul 5, 2022 19:46:05 GMT
jautor I'm back with a semi-similar question. What is the correct syntax for a conditional to check based on the presence/absence of a property _and_ the value of another property? In this case, I want IndicatorLED or LocationIndicatorActive to be Mandatory, but only if ChassisType=RackMount. I was trying this, but this doesn't seem to be correct: { "SchemaDefinition": "RedfishInteroperabilityProfile.v1_5_0", "ProfileName": "drive_conditional", "ProfileVersion": "0.0.1", "Resources": { "Chassis": { "MinVersion": "1.18.0", "ReadRequirement": "Mandatory", "PropertyRequirements": { "ChassisType": { "Comparison": "Equal", "Values": [ "Enclosure", "RackMount", "StorageEnclosure" ] }, "IndicatorLED": { "ReadRequirement": "Recommended", "ConditionalRequirements": [ { "CompareProperty": "LocationIndicatorActive", "CompareType": "Absent", "ReadRequirement": "Mandatory" }, { "ReadRequirement": "Mandatory", "CompareType": "AnyOf", "CompareProperty": "ChassisType", "CompareValues": [ "RackMount" ] } ] }, "LocationIndicatorActive": { "ReadRequirement": "Recommended", "ConditionalRequirements": [ { "CompareProperty": "IndicatorLED", "CompareType": "Absent", "ReadRequirement": "Mandatory" }, { "ReadRequirement": "Mandatory", "CompareType": "AnyOf", "CompareProperty": "ChassisType", "CompareValues": [ "RackMount" ] } ] } } } } }
|
|
|
Post by jautor on Jul 7, 2022 4:09:19 GMT
I'm afraid you've reached the limit of what the profile can support - each ConditionalRequirement is independent, you're trying to do an "AND" across two conditional requirements.
I'll have to think a bit about if there would be something we could add that would allow the combination, but it may become too complicated. Perhaps since you're trying to work through a deprecated property that is replaced by a new one, there's something we can add to address those cases more directly...
Jeff
|
|
|
Post by jyundt on Jul 7, 2022 14:33:34 GMT
Ah got it, thanks for the sanity check, I was slightly worried that this would be the case.
I'm also open to suggestions if there is a better way to handle this scenario of "deprecates / replaces" properties (with one conditional).
|
|
|
Post by jautor on Jul 7, 2022 18:31:21 GMT
Ah got it, thanks for the sanity check, I was slightly worried that this would be the case. I'm also open to suggestions if there is a better way to handle this scenario of "deprecates / replaces" properties (with one conditional). Yeah, I'm noodling on a proposal to add support for specifically handling deprecated or "replaced with a better way" properties as a way to handle these cases without adding the complexity of multi-variable conditionals. Stay tuned on that, but any suggestions welcome! Jeff
|
|