Skip to content

Commit

Permalink
[run-int-tests]
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekzyla committed Jun 25, 2024
1 parent 5b4e624 commit 3b30579
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 24 deletions.
2 changes: 1 addition & 1 deletion integration_tests/test_poller_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 13 additions & 6 deletions splunk_connect_for_snmp/common/collection_manager.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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 = {}
Expand Down
39 changes: 22 additions & 17 deletions splunk_connect_for_snmp/common/collections_schemas.py
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -59,7 +58,7 @@
},
"required": ["type", "field", "patterns"],
"additionalProperties": False,
}
},
},
"required": ["condition", "varBinds", "frequency"],
"additionalProperties": False,
Expand All @@ -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 = {
Expand Down

0 comments on commit 3b30579

Please sign in to comment.