diff --git a/integration_tests/test_poller_integration.py b/integration_tests/test_poller_integration.py index 26cd48d18..d1d9a3b30 100644 --- a/integration_tests/test_poller_integration.py +++ b/integration_tests/test_poller_integration.py @@ -1314,7 +1314,7 @@ def setup_misconfigured_profiles(request): yaml_escape_list(sq("IP-MIB"), sq("icmpOutDestUnreachs"), 0), yaml_escape_list(sq("IP-MIB"), sq("icmpOutEchoReps"), 0), ], - } + }, } update_profiles(profiles) diff --git a/splunk_connect_for_snmp/common/collection_manager.py b/splunk_connect_for_snmp/common/collection_manager.py index acea6828a..2159d412e 100644 --- a/splunk_connect_for_snmp/common/collection_manager.py +++ b/splunk_connect_for_snmp/common/collection_manager.py @@ -1,13 +1,16 @@ import os from abc import abstractmethod from contextlib import suppress -from jsonschema import validate, ValidationError import yaml from celery.utils.log import get_task_logger +from jsonschema import ValidationError, validate +from splunk_connect_for_snmp.common.collections_schemas import ( + get_all_group_schemas, + get_all_profile_schemas, +) from splunk_connect_for_snmp.common.hummanbool import human_bool -from splunk_connect_for_snmp.common.collections_schemas import get_all_profile_schemas, get_all_group_schemas with suppress(ImportError, OSError): from dotenv import load_dotenv @@ -95,8 +98,10 @@ def validate_elements(elements: dict): invalid_groups.append(group_name) for group in invalid_groups: del elements[group] - logger.warning(f"The following groups have invalid configuration: {invalid_groups}. Please check " - f"indentation and key words spelling inside these groups configuration.") + logger.warning( + f"The following groups have invalid configuration: {invalid_groups}. Please check " + f"indentation and key words spelling inside these groups configuration." + ) def gather_elements(self): groups = {} @@ -137,8 +142,10 @@ def validate_elements(elements: dict): invalid_profiles.append(profile_name) for profile in invalid_profiles: del elements[profile] - logger.warning(f"The following profiles have invalid configuration: {invalid_profiles}. Please check " - f"indentation and key words spelling inside these profiles configuration.") + logger.warning( + f"The following profiles have invalid configuration: {invalid_profiles}. Please check " + f"indentation and key words spelling inside these profiles configuration." + ) def gather_elements(self): active_profiles = {} diff --git a/splunk_connect_for_snmp/common/collections_schemas.py b/splunk_connect_for_snmp/common/collections_schemas.py index ec53f5350..bd5dda9f6 100644 --- a/splunk_connect_for_snmp/common/collections_schemas.py +++ b/splunk_connect_for_snmp/common/collections_schemas.py @@ -1,4 +1,7 @@ -varbinds_type = {"type": "array", "items": {"type": "array", "items": {"type": ["integer", "string"]}}} +varbinds_type = { + "type": "array", + "items": {"type": "array", "items": {"type": ["integer", "string"]}}, +} standard_profile_schema = { "type": "object", @@ -16,12 +19,10 @@ "varBinds": varbinds_type, "condition": { "type": "object", - "properties": { - "type": {"type": "string", "enum": ["walk"]} - }, + "properties": {"type": {"type": "string", "enum": ["walk"]}}, "required": ["type"], "additionalProperties": False, - } + }, }, "required": ["condition", "varBinds"], "additionalProperties": False, @@ -34,12 +35,10 @@ "varBinds": varbinds_type, "condition": { "type": "object", - "properties": { - "type": {"type": "string", "enum": ["base"]} - }, + "properties": {"type": {"type": "string", "enum": ["base"]}}, "required": ["type"], "additionalProperties": False, - } + }, }, "required": ["condition", "varBinds", "frequency"], "additionalProperties": False, @@ -59,7 +58,7 @@ }, "required": ["type", "field", "patterns"], "additionalProperties": False, - } + }, }, "required": ["condition", "varBinds", "frequency"], "additionalProperties": False, @@ -76,25 +75,31 @@ "type": "object", "properties": { "field": {"type": "string"}, - "operation": {"type": "string", "enum": ["lt", "gt", "regex", "in", "equals"]}, + "operation": { + "type": "string", + "enum": ["lt", "gt", "regex", "in", "equals"], + }, "value": {"type": ["number", "string", "array"]}, "negate_operation": {"type": ["boolean", "string"]}, }, "required": ["field", "operation", "value"], "additionalProperties": False, - } - } + }, + }, }, "required": ["conditions", "varBinds", "frequency"], "additionalProperties": False, } - - def get_all_profile_schemas(): - return [standard_profile_schema, walk_profile_schema, base_profile_schema, smart_profile_schema, - conditional_profile_schema] + return [ + standard_profile_schema, + walk_profile_schema, + base_profile_schema, + smart_profile_schema, + conditional_profile_schema, + ] group_schema = {