Skip to content

Commit

Permalink
bump to 0.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dmulyalin committed Dec 4, 2022
1 parent cb51b20 commit c0f8cfd
Show file tree
Hide file tree
Showing 8 changed files with 290 additions and 264 deletions.
3 changes: 1 addition & 2 deletions nornir_salt/plugins/functions/HostsKeepalive.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ def HostsKeepalive(nr):
)
# enlist connection plugins that does not maintain connection open
elif any(
i in str(type(conn_obj)).lower()
for i in ["http", "puresnmp", "netbox"]
i in str(type(conn_obj)).lower() for i in ["http", "puresnmp"]
):
is_alive = True
else:
Expand Down
4 changes: 3 additions & 1 deletion nornir_salt/plugins/inventory/DictInventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ class DictInventory:
:param defaults: dictionary with defaults data
"""

def __init__(self, hosts: Dict = None, groups: Dict = None, defaults: Dict = None) -> None:
def __init__(
self, hosts: Dict = None, groups: Dict = None, defaults: Dict = None
) -> None:
self.hosts = hosts or {}
self.groups = groups or {}
self.defaults = defaults or {}
Expand Down
23 changes: 11 additions & 12 deletions nornir_salt/plugins/processors/TestsProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ class TestsProcessor:
:param jinja_kwargs: (dict) Dictionary of arguments for ``jinja2.Template`` object,
default is ``{"trim_blocks": True, "lstrip_blocks": True}``
:param subset: (list or str) list or string with comma separated glob patterns to
match tests' names to execute. Patterns are not case-sensitive. Uses ``fnmatch``
match tests' names to execute. Patterns are not case-sensitive. Uses ``fnmatch``
Python built-in function to do glob patterns matching
:param tests_data: (dict) dictionary of parameters to supply for test suite templates rendering
"""
Expand All @@ -1018,10 +1018,12 @@ def __init__(
self.tests_data = tests_data or {}
self.build_per_host_tests = build_per_host_tests
self.render_tests = render_tests
self.subset = [
i.strip() for i in subset.split(",")
] if isinstance(subset, str) else (subset or [])

self.subset = (
[i.strip() for i in subset.split(",")]
if isinstance(subset, str)
else (subset or [])
)

# do preliminary tests suite validation
if build_per_host_tests:
_ = modelTestsProcessorTests(tests=self.tests)
Expand Down Expand Up @@ -1051,7 +1053,7 @@ def _render(self, template, data: dict = None, load: bool = False):
ret = [self._render(i, data) for i in template]
else:
ret = template

# process rendered string further
if isinstance(ret, str):
# check if test rendering produced empty string
Expand Down Expand Up @@ -1128,10 +1130,7 @@ def task_started(self, task: Task) -> None:
t = tests_.pop()
# filter tests by using subset list
if self.subset and not any(
map(
lambda m: fnmatch.fnmatch(t["name"], m),
self.subset
)
map(lambda m: fnmatch.fnmatch(t["name"], m), self.subset)
):
continue
# filter tests by using Fx filters
Expand All @@ -1158,7 +1157,7 @@ def task_started(self, task: Task) -> None:

def task_instance_started(self, task: Task, host: Host) -> None:
pass

def task_instance_completed(
self, task: Task, host: Host, result: MultiResult
) -> None:
Expand All @@ -1171,7 +1170,7 @@ def task_instance_completed(
return

test_results = []

try:
# decide on tests content
if self.build_per_host_tests:
Expand Down
2 changes: 1 addition & 1 deletion nornir_salt/plugins/tasks/netmiko_send_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def netmiko_send_commands(

# increase read timeout to 30 from default 10 seconds
kwargs.setdefault("read_timeout", 30)

commands = cli_form_commands(
task=task,
commands=commands,
Expand Down
1 change: 1 addition & 0 deletions nornir_salt/plugins/tasks/tcp_ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

log = logging.getLogger(__name__)


def tcp_ping(
task: Task, ports: List[int] = None, timeout: int = 1, host: Optional[str] = None
) -> Result:
Expand Down
12 changes: 5 additions & 7 deletions nornir_salt/utils/pydantic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,10 @@ def check_commands_given(cls, values):

class modelTestsProcessorTests(BaseModel):
tests: Union[
List[List[StrictStr]],
List[Dict],
List[StrictStr],
Dict[StrictStr, List[Dict]]
List[List[StrictStr]], List[Dict], List[StrictStr], Dict[StrictStr, List[Dict]]
]



class modelTestsProcessorSuite(BaseModel):
"""Model for TestsProcessor tests suite"""

Expand All @@ -574,6 +572,6 @@ class modelTestsProcessorSuite(BaseModel):
conlist(StrictStr, min_items=3, max_items=4),
StrictStr,
]
]
]
],
],
]

0 comments on commit c0f8cfd

Please sign in to comment.