Skip to content

Commit

Permalink
Fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
wvandeun committed Jun 11, 2018
1 parent e133d42 commit 508adcf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion napalm_asa/_MC_INCOMPATIBLE_ENDPOINTS.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
MC_INCOMPATIBLE_ENDPOINTS=(
MC_INCOMPATIBLE_ENDPOINTS = (
'/monitoring/serialnumber',
)
51 changes: 26 additions & 25 deletions napalm_asa/asa.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
)
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)


class RespFetcherHttps:
"""Response fetcher."""

Expand Down Expand Up @@ -144,7 +145,7 @@ def __init__(self,
self._context = None
self.port = optional_args.get('port', 443)
self.timeout = timeout
# delay factor is used for delaying api rest calls that show
# delay factor is used for delaying api rest calls that show
# problematic behaviour when being followed by a subsequent call
# that follows to fast
self.delay = optional_args.get('delay', .5)
Expand All @@ -167,7 +168,7 @@ def _delete_token(self):

def _send_request(self, endpoint, data=None):
"""Send request method."""

if self._use_context_in_request(endpoint):
endpoint = "{}?context={}".format(endpoint, self._context)
if data is None:
Expand Down Expand Up @@ -220,7 +221,7 @@ def _get_interfaces_details(self, interfaces):
@property
def context(self):
return self._context

@context.setter
def context(self, value):
self._check_context_exists(value)
Expand All @@ -234,7 +235,7 @@ def _get_contexts(self):
self.multicontext = False
return
self.multicontext = True
self.contexts = [ c['name'] for c in resp['items']]
self.contexts = [c['name'] for c in resp['items']]
self.contexts.append('system')

def _use_context_in_request(self, endpoint):
Expand Down Expand Up @@ -340,10 +341,10 @@ def get_interfaces(self):
for if_name in interfaces:
ifs.append(if_name)

# This is a nasty solution for an issue seen with ASA's
# using the /api/interfaces/physical endpoint. If you call
# that endpoint and then send another request to quickly
# (?), then the ASA closes the HTTPS connection without
# This is a nasty solution for an issue seen with ASA's
# using the /api/interfaces/physical endpoint. If you call
# that endpoint and then send another request to quickly
# (?), then the ASA closes the HTTPS connection without
# sending a reponse

if self.multicontext:
Expand All @@ -357,7 +358,7 @@ def get_interfaces(self):

return interfaces

def _check_context_exists(self,context):
def _check_context_exists(self, context):
if context:
if not self.multicontext:
e = "Device is not in multicontext mode"
Expand All @@ -368,12 +369,12 @@ def _check_context_exists(self,context):

def get_config(self, retrieve='all'):
"""Get config."""

config = {
'startup': '',
'running': '',
'candidate': ''
}
'startup': '',
'running': '',
'candidate': ''
}

commands = []
startup_cmd = "show startup-config"
Expand Down Expand Up @@ -411,7 +412,7 @@ def get_interfaces_ip(self):
network = ip + '/' + mask
prefix_length = IPNetwork(network).prefixlen
interfaces[int_info['hardwareID']]['ipv4'] = \
{ip: {'prefix_length': prefix_length}}
{ip: {'prefix_length': prefix_length}}

if len(int_info['ipv6Info']['ipv6Addresses']) > 0:
if int_info['hardwareID'] not in interfaces:
Expand All @@ -422,7 +423,7 @@ def get_interfaces_ip(self):
ip = ipv6['address']['value']
prefix_length = ipv6['prefixLength']
interfaces[int_info['hardwareID']]['ipv6'][ip] = \
{'prefix_length': prefix_length}
{'prefix_length': prefix_length}

return interfaces

Expand All @@ -437,15 +438,15 @@ def get_arp_table(self):
regex = re.compile(r'.{2}')
mac = ":".join(re.findall(regex, mac))
arp_table.append(
{
'interface': item['interface'],
'ip': item['ipAddress'],
'mac': mac,
'age': 0.0
}
)

return arp_table
{
'interface': item['interface'],
'ip': item['ipAddress'],
'mac': mac,
'age': 0.0
}
)

return arp_table

def is_alive(self):
"""Check if connection is still valid."""
Expand Down

0 comments on commit 508adcf

Please sign in to comment.