def validate_different_intervals(operation_list): """ Check that the same operations (e.g. monitor) have different interval. list operation_list contains dictionaries with attributes of operation return see resource operation in pcs/lib/exchange_formats.md """ duplication_map = defaultdict(lambda: defaultdict(list)) for operation in operation_list: interval = operation.get( "interval", get_default_interval(operation["name"]) ) seconds = timeout_to_seconds(interval) duplication_map[operation["name"]][seconds].append(interval) duplications = defaultdict(list) for name, interval_map in duplication_map.items(): for timeout in sorted(interval_map.values()): if len(timeout) > 1: duplications[name].append(timeout) if duplications: return [reports.resource_operation_interval_duplication( dict(duplications) )] return []
def validate_different_intervals(operation_list): """ Check that the same operations (e.g. monitor) have different interval. list operation_list contains dictionaries with attributes of operation return see resource operation in pcs/lib/exchange_formats.md """ duplication_map = defaultdict(lambda: defaultdict(list)) for operation in operation_list: interval = operation.get("interval", get_default_interval(operation["name"])) seconds = timeout_to_seconds(interval) duplication_map[operation["name"]][seconds].append(interval) duplications = defaultdict(list) for name, interval_map in duplication_map.items(): for timeout in sorted(interval_map.values()): if len(timeout) > 1: duplications[name].append(timeout) if duplications: return [ ReportItem.error( reports.messages.ResourceOperationIntervalDuplication( dict(duplications))) ] return []