diff --git a/redfish_service_validator/catalog.py b/redfish_service_validator/catalog.py index 6a61f4e..f7af4a2 100644 --- a/redfish_service_validator/catalog.py +++ b/redfish_service_validator/catalog.py @@ -1083,7 +1083,7 @@ def as_json(self): base.update({'Properties': {a: b.as_json() for a, b in self.properties.items()}}) return base - def getLinks(self): + def getLinks(self, collectionlimit={}): """Grab links from our Object """ links = [] @@ -1109,6 +1109,11 @@ def getLinks(self): if isinstance(item.Value, list): for num, val in enumerate(item.Value): # TODO: Along with example Excerpt and RedfishObject, replace following code with hypothetical RedfishType.getCollectionType + if item.Type.TypeName in collectionlimit: + link_limit = collectionlimit[item.Type.TypeName] + if num >= link_limit: + my_logger.verbose1('Removing link via limit: {} {}'.format(item.Type.TypeName, val)) + continue try: new_type_obj = item.Type.getCollectionType() new_link = RedfishObject(new_type_obj, item.Name, item.parent).populate(val) diff --git a/redfish_service_validator/validateRedfish.py b/redfish_service_validator/validateRedfish.py index e384219..818801f 100644 --- a/redfish_service_validator/validateRedfish.py +++ b/redfish_service_validator/validateRedfish.py @@ -547,6 +547,16 @@ def checkPropertyConformance(service, prop_name, prop, parent_name=None, parent_ appendStr = (('[' + str(cnt) + ']') if prop.IsCollection else '') sub_item = prop_name + appendStr + if propRealType == 'entity' and isinstance(prop.Type, RedfishType): + if prop.Type.TypeName in service.config['collectionlimit']: + link_limit = service.config['collectionlimit'][prop.Type.TypeName] + if cnt >= link_limit: + my_logger.verbose1('Removing link check via limit: {} {}'.format(prop.Type.TypeName, val)) + resultList[sub_item] = ( + displayValue(val, sub_item if prop.IsAutoExpanded else None), displayType(prop.Type), + 'Yes' if prop.Exists else 'No', 'NOT TESTED') + continue + excerptPass = validateExcerpt(prop, val) if isinstance(val, str): diff --git a/redfish_service_validator/validateResource.py b/redfish_service_validator/validateResource.py index 6bcfc67..dfc1a5d 100644 --- a/redfish_service_validator/validateResource.py +++ b/redfish_service_validator/validateResource.py @@ -288,7 +288,7 @@ def validateSingleURI(service, URI, uriName='', expectedType=None, expectedJson= # Get all links available - my_logger.debug(redfish_obj.getLinks()) + collection_limit = service.config['collectionlimit'] # Count of occurrences of fail, warn, invalid and deprecated in result of tests to FAILS / WARNINGS for value in messages.values(): @@ -301,7 +301,7 @@ def validateSingleURI(service, URI, uriName='', expectedType=None, expectedJson= if 'failMandatoryExist' in counts.keys(): counts['fails'] += counts['failMandatoryExist'] - return True, counts, results, redfish_obj.getLinks(), redfish_obj + return True, counts, results, redfish_obj.getLinks(collection_limit), redfish_obj def validateURITree(service, URI, uriName, expectedType=None, expectedJson=None, parent=None, all_links_traversed=None, inAnnotation=False): @@ -339,14 +339,6 @@ def validateURITree(service, URI, uriName, expectedType=None, expectedJson=None, # If successful... if validateSuccess: # Bring Registries to Front if possible - for link_type in service.config['collectionlimit']: - link_limit = service.config['collectionlimit'][link_type] - applicable_links = [link for link in gathered_links if link_type in link.Type.TypeName] - trimmed_links = applicable_links[link_limit:] - for link in trimmed_links: - link_destination = link.Value.get('@odata.id', link.Value.get('Uri')) - my_logger.verbose1('Removing link via limit: {} {}'.format(link_type, link_destination)) - all_links_traversed.add(link_destination) for link in sorted(gathered_links, key=lambda link: (link.Type.fulltype != 'Registries.Registries')): if link is None or link.Value is None: