Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 16, 2024
1 parent 6f70203 commit 65f19f4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
38 changes: 23 additions & 15 deletions plugins/cliconf/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@
NetworkConfig,
dumps,
)
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import (
to_list,
)
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import to_list
from ansible_collections.ansible.netcommon.plugins.plugin_utils.cliconf_base import (
CliconfBase,
enable_mode,
Expand All @@ -169,7 +167,7 @@ def get_config(self, source="running", flags=None, format=None):

if format:
raise ValueError(
"'format' value %s is not supported for get_config" % format
"'format' value %s is not supported for get_config" % format,
)

if not flags:
Expand Down Expand Up @@ -261,7 +259,9 @@ def get_diff(
# running configuration
have_src, have_banners = self._extract_banners(running)
running_obj = NetworkConfig(
indent=1, contents=have_src, ignore_lines=diff_ignore_lines
indent=1,
contents=have_src,
ignore_lines=diff_ignore_lines,
)
configdiffobjs = candidate_obj.difference(
running_obj,
Expand All @@ -274,9 +274,7 @@ def get_diff(
configdiffobjs = candidate_obj.items
have_banners = {}

diff["config_diff"] = (
dumps(configdiffobjs, "commands") if configdiffobjs else ""
)
diff["config_diff"] = dumps(configdiffobjs, "commands") if configdiffobjs else ""
banners = self._diff_banners(want_banners, have_banners)
diff["banner_diff"] = banners if banners else {}
return diff
Expand All @@ -289,7 +287,7 @@ def configure(self):
:return: None
"""
if self.get_option("commit_confirm_timeout") or self.get_option(
"commit_confirm_immediate"
"commit_confirm_immediate",
):
commit_timeout = (
self.get_option("commit_confirm_timeout")
Expand All @@ -298,7 +296,7 @@ def configure(self):
) # add default timeout not default: 1 to support above or operation

persistent_command_timeout = self._connection.get_option(
"persistent_command_timeout"
"persistent_command_timeout",
)
# check archive state
archive_state = self.send_command("show archive")
Expand Down Expand Up @@ -340,7 +338,11 @@ def edit_config(
resp = {}
operations = self.get_device_operations()
self.check_edit_config_capability(
operations, candidate, commit, replace, comment
operations,
candidate,
commit,
replace,
comment,
)

if err_responses:
Expand Down Expand Up @@ -396,7 +398,11 @@ def edit_macro(self, candidate=None, commit=True, replace=None, comment=None):
resp = {}
operations = self.get_device_operations()
self.check_edit_config_capability(
operations, candidate, commit, replace, comment
operations,
candidate,
commit,
replace,
comment,
)

results = []
Expand Down Expand Up @@ -575,7 +581,7 @@ def run_commands(self, commands=None, check_rc=True):
output = cmd.pop("output", None)
if output:
raise ValueError(
"'output' value %s is not supported for run_commands" % output
"'output' value %s is not supported for run_commands" % output,
)

try:
Expand Down Expand Up @@ -623,10 +629,12 @@ def set_cli_prompt_context(self):
)

if re.search(
r"config.*\)#", to_text(out, errors="surrogate_then_replace").strip()
r"config.*\)#",
to_text(out, errors="surrogate_then_replace").strip(),
):
self._connection.queue_message(
"vvvv", "wrong context, sending end to device"
"vvvv",
"wrong context, sending end to device",
)
self._connection.send_command("end")

Expand Down
5 changes: 2 additions & 3 deletions plugins/module_utils/network/ios/config/vlans/vlans.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@
dict_merge,
)

from ansible_collections.cisco.ios.plugins.module_utils.network.ios.facts.facts import (
Facts,
)
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.facts.facts import Facts
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.rm_templates.vlans import (
VlansTemplate,
)


err_responses = [r"You must disable"]


Expand Down
8 changes: 2 additions & 6 deletions plugins/terminal/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
from ansible.errors import AnsibleConnectionFailure
from ansible.module_utils._text import to_bytes, to_text
from ansible.utils.display import Display
from ansible_collections.ansible.netcommon.plugins.plugin_utils.terminal_base import (
TerminalBase,
)
from ansible_collections.ansible.netcommon.plugins.plugin_utils.terminal_base import TerminalBase


display = Display()
Expand Down Expand Up @@ -97,9 +95,7 @@ def on_open_shell(self):
try:
self._exec_cli_command(b"screen-length 0") # support to SD-WAN mode
_is_sdWan = True
except (
AnsibleConnectionFailure
): # fails as length required for handling prompt
except AnsibleConnectionFailure: # fails as length required for handling prompt
raise AnsibleConnectionFailure("unable to set terminal parameters")
try:
if _is_sdWan:
Expand Down

0 comments on commit 65f19f4

Please sign in to comment.