@@ -106,14 +106,50 @@ def validateComparisonAnyOfAllOf(profile_entry, property_path="Unspecified"):
106106 return all_msgs
107107
108108
109+ def validateRequirementResource (profile_entry , rf_payload_item = None , parent_object_tuple = None ):
110+ """
111+ Validates Requirement profile_entry for Resources
112+
113+ Has different resolutions than when validating at a per Property level
114+ """
115+ resource_exists = (rf_payload_item != REDFISH_ABSENT )
116+ my_logger .debug ('Testing Resource ReadRequirement \n \t expected:' + str (profile_entry ) + ', exists: ' + str (resource_exists ))
117+
118+ original_profile_entry = profile_entry
119+
120+ if profile_entry == "IfPopulated" :
121+ profile_entry = "Recommended"
122+
123+ paramPass = profile_entry != "Mandatory" or \
124+ profile_entry == "Mandatory" and resource_exists
125+
126+ if profile_entry == "IfImplemented" :
127+ if not resource_exists :
128+ paramPass = testResultEnum .NA
129+ else :
130+ my_logger .debug ('\t Item cannot be tested for Implementation' )
131+
132+ if profile_entry == "Recommended" and not resource_exists :
133+ my_logger .info ('\t Item is recommended but does not exist' )
134+ if config ['WarnRecommended' ]:
135+ my_logger .warning ('\t Item is recommended but does not exist, escalating to WARN' )
136+ paramPass = testResultEnum .WARN
137+ else :
138+ paramPass = testResultEnum .NA
139+
140+ my_logger .debug ('\t pass ' + str (paramPass ))
141+ return msgInterop ('ReadRequirement' , original_profile_entry , 'Must Exist' if profile_entry == "Mandatory" else 'Any' , 'Exists' if resource_exists else 'DNE' , paramPass ),\
142+ paramPass
143+
144+
109145def validateRequirement (profile_entry , rf_payload_item = None , conditional = False , parent_object_tuple = None ):
110146 """
111147 Validates Requirement profile_entry
112148
113149 By default, only the first parameter is necessary and will always Pass if none given
114150 """
115- propDoesNotExist = (rf_payload_item = = REDFISH_ABSENT )
116- my_logger .debug ('Testing ReadRequirement \n \t expected:' + str (profile_entry ) + ', exists: ' + str (not propDoesNotExist ))
151+ prop_exists = (rf_payload_item ! = REDFISH_ABSENT )
152+ my_logger .debug ('Testing ReadRequirement \n \t expected:' + str (profile_entry ) + ', exists: ' + str (prop_exists ))
117153 # If we're not mandatory, pass automatically, else fail
118154 # However, we have other entries "IfImplemented" and "Conditional"
119155 # note: Mandatory is default!! if present in the profile. Make sure this is made sure.
@@ -133,16 +169,16 @@ def validateRequirement(profile_entry, rf_payload_item=None, conditional=False,
133169 if profile_entry == "Conditional" and conditional :
134170 profile_entry = "Mandatory"
135171
136- paramPass = not profile_entry = = "Mandatory" or \
137- profile_entry == "Mandatory" and not propDoesNotExist
172+ paramPass = profile_entry ! = "Mandatory" or \
173+ profile_entry == "Mandatory" and prop_exists
138174
139175 if profile_entry == "IfImplemented" :
140- if propDoesNotExist :
176+ if not prop_exists :
141177 paramPass = testResultEnum .NA
142178 else :
143179 my_logger .debug ('\t Item cannot be tested for Implementation' )
144180
145- if profile_entry == "Recommended" and propDoesNotExist :
181+ if profile_entry == "Recommended" and not prop_exists :
146182 my_logger .info ('\t Item is recommended but does not exist' )
147183 if config ['WarnRecommended' ]:
148184 my_logger .warning ('\t Item is recommended but does not exist, escalating to WARN' )
@@ -151,7 +187,7 @@ def validateRequirement(profile_entry, rf_payload_item=None, conditional=False,
151187 paramPass = testResultEnum .NA
152188
153189 my_logger .debug ('\t pass ' + str (paramPass ))
154- return msgInterop ('ReadRequirement' , original_profile_entry , 'Must Exist' if profile_entry == "Mandatory" else 'Any' , 'Exists' if not propDoesNotExist else 'DNE' , paramPass ),\
190+ return msgInterop ('ReadRequirement' , original_profile_entry , 'Must Exist' if profile_entry == "Mandatory" else 'Any' , 'Exists' if prop_exists else 'DNE' , paramPass ),\
155191 paramPass
156192
157193
@@ -327,19 +363,6 @@ def checkComparison(val, compareType, target):
327363 paramPass
328364
329365
330- def validateMembers (members , profile_entry , annotation ):
331- """
332- Validate an profile_entry of Members and its count annotation
333- """
334- my_logger .debug ('Testing members \n \t ' + str ((members , profile_entry , annotation )))
335- if not validateRequirement ('Mandatory' , members ):
336- return False
337- if "MinCount" in profile_entry :
338- mincount , mincountpass = validateMinCount (members , profile_entry ["MinCount" ], annotation )
339- mincount .name = 'MembersMinCount'
340- return mincount , mincountpass
341-
342-
343366def validateMinVersion (version , profile_entry ):
344367 """
345368 Checks for the minimum version of a resource's type
0 commit comments