@@ -767,6 +767,15 @@ def checkInteropURI(r_obj, profile_entry):
767767 my_id , my_uri = r_obj .jsondata .get ('Id' ), r_obj .uri
768768 return compareRedfishURI (profile_entry , my_uri )
769769
770+ # Expected Type, Key
771+ entry_type_table = {
772+ 'ChassisType' : ("Chassis" , "ChassisType" ),
773+ 'DriveProtocol' : ("Drive" , "Protocol" ),
774+ 'MemoryType' : ("Memory" , "MemoryType" ),
775+ 'PortProtocol' : ("Port" , "PortProtocol" ),
776+ 'ProcessorType' : ("Processor" , "ProcessorType" ),
777+ }
778+
770779
771780def validateInteropResource (propResourceObj , interop_profile , rf_payload ):
772781 """
@@ -783,11 +792,12 @@ def validateInteropResource(propResourceObj, interop_profile, rf_payload):
783792 for use_case in interop_profile ['UseCases' ]:
784793 entry_title = use_case .get ("UseCaseTitle" , "NoName" ).replace (' ' , '_' )
785794 entry_type = use_case .get ("UseCaseType" , "Normal" )
795+ my_parent = propResourceObj .parent
786796 my_logger .debug ('UseCase {} {}' .format (entry_title , entry_type ))
787797
788798 # Check if we have a valid UseCase
789- if 'URIs' not in use_case and 'UseCaseKeyProperty' not in use_case and entry_type != 'AbsentResource' :
790- my_logger .error ('UseCase does not have URIs or UseCaseKeyProperty ...' )
799+ if ( 'URIs' not in use_case ) and ( 'UseCaseKeyProperty' not in use_case ) and ( entry_type not in [ 'AbsentResource' ] + list ( entry_type_table . keys ())) :
800+ my_logger .error ('UseCase does not have URIs or valid UseCase ...' )
791801
792802 if entry_type == 'AbsentResource' :
793803 my_status = rf_payload .get ('Status' )
@@ -797,6 +807,28 @@ def validateInteropResource(propResourceObj, interop_profile, rf_payload):
797807 use_case_applies = False
798808 if 'URIs' in use_case :
799809 use_case_applies = use_case_applies and checkInteropURI (propResourceObj , use_case ['URIs' ])
810+
811+ elif entry_type in entry_type_table :
812+ target_type_found = False
813+ target_type , entry_key = entry_type_table [entry_type ]
814+ entry_comparison , entry_values = use_case ['UseCaseComparison' ], use_case ['UseCaseKeyValues' ]
815+
816+ # Iterate until we find our target type, if not found then use case cannot apply
817+ while my_parent is not None and not target_type_found :
818+ parent_type = getType (my_parent .jsondata .get ('@odata.type' , 'NoType' ))
819+ target_type_found = parent_type == target_type
820+ if not target_type_found :
821+ my_parent = my_parent .parent
822+
823+ if target_type_found :
824+ target_payload = my_parent .jsondata
825+ target_value = target_payload .get (entry_key )
826+
827+ _ , use_case_applies = checkComparison (target_payload .get (entry_key , REDFISH_ABSENT ), entry_comparison , entry_values )
828+ else :
829+ my_logger .verbose1 ('Type {} was not found in parent typechain' .format (target_type ))
830+ use_case_applies = False
831+
800832
801833 elif 'UseCaseKeyProperty' in use_case :
802834 entry_key , entry_comparison , entry_values = use_case ['UseCaseKeyProperty' ], use_case ['UseCaseComparison' ], use_case ['UseCaseKeyValues' ]
0 commit comments