Skip to content

Commit

Permalink
"style guide" changes
Browse files Browse the repository at this point in the history
These changes are made to fulfil the Style Guidelines of Python.
  • Loading branch information
hupebln authored and hupebln committed May 30, 2022
1 parent eecb90c commit 5c75280
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 27 deletions.
14 changes: 8 additions & 6 deletions napalm_arubaoss/ArubaOS.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
"""ArubaOS-Switch Napalm driver."""
import logging
import urllib3

from napalm_arubaoss.helper.base import Connection
from napalm.base.base import NetworkDriver

from napalm_arubaoss.helper import (
backup_config,
commit_config,
compare_config,
confirm_commit,
get_mac_address_table,
get_facts,
get_arp_table,
get_config,
get_facts,
get_interfaces,
get_interfaces_ip,
get_lldp_neighbors,
get_lldp_neighbors_detail,
get_ntp_stats,
get_mac_address_table,
get_ntp_servers,
get_ntp_stats,
get_route_to,
has_pending_commit,
is_alive,
Expand All @@ -27,8 +27,10 @@
rollback,
traceroute,
)
from napalm_arubaoss.helper.base import Connection

import urllib3

from napalm.base.base import NetworkDriver

logger = logging.getLogger("arubaoss")
logger.setLevel(logging.INFO)
Expand Down
2 changes: 1 addition & 1 deletion napalm_arubaoss/helper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
from napalm_arubaoss.helper.traceroute import traceroute
from napalm_arubaoss.helper.utils import (
backup_config,
mac_reformat,
commit_candidate,
config_batch,
mac_reformat,
read_candidate,
str_to_b64,
transaction_status,
Expand Down
4 changes: 2 additions & 2 deletions napalm_arubaoss/helper/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import base64
import logging

from json import JSONDecodeError

from napalm.base.exceptions import ConnectAuthError, NapalmException

from requests import Session
from requests.models import Response
from napalm.base.exceptions import ConnectAuthError, NapalmException


logger = logging.getLogger("arubaoss.helper.base")
Expand Down
4 changes: 2 additions & 2 deletions napalm_arubaoss/helper/commit_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

from napalm.base.exceptions import CommitError

from napalm_arubaoss.helper.utils import backup_config, commit_candidate
from napalm_arubaoss.helper.get_config import get_config
from napalm_arubaoss.helper.load_replace_candidate import load_replace_candidate
from napalm_arubaoss.helper.has_pending_commit import has_pending_commit
from napalm_arubaoss.helper.load_replace_candidate import load_replace_candidate
from napalm_arubaoss.helper.utils import backup_config, commit_candidate

logger = logging.getLogger("arubaoss.helper.commit_config")

Expand Down
3 changes: 1 addition & 2 deletions napalm_arubaoss/helper/compare_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Backups and commit the configuration, and handles commit confirm."""

import logging

from time import sleep

from napalm.base.exceptions import CommandErrorException
Expand Down Expand Up @@ -65,4 +64,4 @@ def compare_config(self):
add_list="\n".join(diff_object.get("diff_add_list"))
)

return out
return out
3 changes: 2 additions & 1 deletion napalm_arubaoss/helper/get_arp_table.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Backups and commit the configuration, and handles commit confirm."""

from napalm.base.helpers import textfsm_extractor
import logging

from napalm.base.helpers import textfsm_extractor

from napalm_arubaoss.helper.utils import mac_reformat

logger = logging.getLogger("arubaoss.helper.get_arp_table")
Expand Down
3 changes: 2 additions & 1 deletion napalm_arubaoss/helper/get_interfaces_ip.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Get IP interface IP addresses."""

from netaddr import IPNetwork
import logging

from netaddr import IPNetwork

logger = logging.getLogger("arubaoss.helper.get_interfaces_ip")


Expand Down
4 changes: 3 additions & 1 deletion napalm_arubaoss/helper/get_route_to.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"""Get route to destination."""

import logging

from napalm.base.helpers import textfsm_extractor

from netaddr import IPNetwork
import logging


logger = logging.getLogger("arubaoss.helper.get_route_to")
Expand Down
3 changes: 2 additions & 1 deletion napalm_arubaoss/helper/is_alive.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Check if device connection is alive."""

from napalm.base.exceptions import ConnectionClosedException
import logging

from napalm.base.exceptions import ConnectionClosedException

logger = logging.getLogger("arubaoss.helper.is_alive")


Expand Down
5 changes: 3 additions & 2 deletions napalm_arubaoss/helper/load_merge_candidate.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Merge candidate configuration with the running one."""

from napalm.base.exceptions import MergeConfigException
import logging

from napalm_arubaoss.helper.utils import read_candidate, config_batch, backup_config
from napalm.base.exceptions import MergeConfigException

from napalm_arubaoss.helper.utils import backup_config, config_batch, read_candidate

logger = logging.getLogger("arubaoss.helper.load_merge_candidate")

Expand Down
6 changes: 3 additions & 3 deletions napalm_arubaoss/helper/load_replace_candidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import logging

from napalm_arubaoss.helper.utils import str_to_b64, read_candidate
from napalm_arubaoss.helper.is_alive import is_alive
from napalm.base.exceptions import ReplaceConfigException, ConnectionClosedException
from napalm.base.exceptions import ConnectionClosedException, ReplaceConfigException

from napalm_arubaoss.helper.utils import read_candidate, str_to_b64

logger = logging.getLogger("arubaoss.helper.load_replace_candidate")

Expand Down
2 changes: 1 addition & 1 deletion napalm_arubaoss/helper/rollback.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import logging

from napalm_arubaoss.helper.utils import commit_candidate
from napalm_arubaoss.helper.compare_config import compare_config
from napalm_arubaoss.helper.utils import commit_candidate

logger = logging.getLogger("arubaoss.helper.rollback")

Expand Down
2 changes: 1 addition & 1 deletion napalm_arubaoss/helper/traceroute.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Execute traceroute on the device and returns a dictionary with the result."""

import socket
import logging
import socket

logger = logging.getLogger("arubaoss.helper.traceroute")

Expand Down
6 changes: 3 additions & 3 deletions napalm_arubaoss/helper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import base64
import logging
from time import sleep
from itertools import zip_longest
from time import sleep

from napalm.base.exceptions import CommandTimeoutException, CommitError

logger = logging.getLogger("arubaoss.helper.utils")
Expand Down Expand Up @@ -163,7 +164,6 @@ def commit_candidate(self, config):
raise CommitError(f"{cmd_post.json().get('failure_reason', 'failure during cfg_restore but no failure_reason')}")



def mac_reformat(mac):
"""
Reformat the MAC addresses to standard notation.
Expand All @@ -173,4 +173,4 @@ def mac_reformat(mac):
"""
t = iter(mac.replace("-", ""))

return ":".join(a + b for a, b in zip_longest(t, t, fillvalue=""))
return ":".join(a + b for a, b in zip_longest(t, t, fillvalue=""))

0 comments on commit 5c75280

Please sign in to comment.