Skip to content
This repository has been archived by the owner on Feb 10, 2018. It is now read-only.

Commit

Permalink
Merge pull request #124 from napalm-automation/develop
Browse files Browse the repository at this point in the history
Release 0.6.4
  • Loading branch information
mirceaulinic committed Feb 8, 2017
2 parents 90d5c07 + 4570592 commit db9af62
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
2 changes: 0 additions & 2 deletions napalm_junos/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@
'vpls': 'BGP_VPLS',
'forwarding': 'L2P2P'
}

OPTICS_NO_POWER = '- Inf'
45 changes: 28 additions & 17 deletions napalm_junos/junos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,8 @@ def traceroute(self,
destination,
source=C.TRACEROUTE_SOURCE,
ttl=C.TRACEROUTE_TTL,
timeout=C.TRACEROUTE_TIMEOUT):
timeout=C.TRACEROUTE_TIMEOUT,
vrf=C.TRACEROUTE_VRF):
"""Execute traceroute and return results."""
traceroute_result = {}

Expand All @@ -1229,19 +1230,23 @@ def traceroute(self,
source_str = ''
maxttl_str = ''
wait_str = ''
vrf_str = ''

if source:
source_str = 'source {source}'.format(source=source)
source_str = ' source {source}'.format(source=source)
if ttl:
maxttl_str = 'ttl {ttl}'.format(ttl=ttl)
maxttl_str = ' ttl {ttl}'.format(ttl=ttl)
if timeout:
wait_str = 'wait {timeout}'.format(timeout=timeout)
wait_str = ' wait {timeout}'.format(timeout=timeout)
if vrf:
vrf_str = ' routing-instance {vrf}'.format(vrf=vrf)

traceroute_command = 'traceroute {destination} {source} {maxttl} {wait}'.format(
traceroute_command = 'traceroute {destination}{source}{maxttl}{wait}{vrf}'.format(
destination=destination,
source=source_str,
maxttl=maxttl_str,
wait=wait_str
wait=wait_str,
vrf=vrf_str
)

traceroute_rpc = E('command', traceroute_command)
Expand Down Expand Up @@ -1281,7 +1286,7 @@ def traceroute(self,
return traceroute_result

def ping(self, destination, source=C.PING_SOURCE, ttl=C.PING_TTL,
timeout=C.PING_TIMEOUT, size=C.PING_SIZE, count=C.PING_COUNT):
timeout=C.PING_TIMEOUT, size=C.PING_SIZE, count=C.PING_COUNT, vrf=C.PING_VRF):

ping_dict = {}

Expand All @@ -1290,25 +1295,29 @@ def ping(self, destination, source=C.PING_SOURCE, ttl=C.PING_TTL,
timeout_str = ''
size_str = ''
count_str = ''
vrf_str = ''

if source:
source_str = 'source {source}'.format(source=source)
source_str = ' source {source}'.format(source=source)
if ttl:
maxttl_str = 'ttl {ttl}'.format(ttl=ttl)
maxttl_str = ' ttl {ttl}'.format(ttl=ttl)
if timeout:
timeout_str = 'wait {timeout}'.format(timeout=timeout)
timeout_str = ' wait {timeout}'.format(timeout=timeout)
if size:
size_str = 'size {size}'.format(size=size)
size_str = ' size {size}'.format(size=size)
if count:
count_str = 'count {count}'.format(count=count)
count_str = ' count {count}'.format(count=count)
if vrf:
vrf_str = ' routing-instance {vrf}'.format(vrf=vrf)

ping_command = 'ping {destination} {source} {ttl} {timeout} {size} {count}'.format(
ping_command = 'ping {destination}{source}{ttl}{timeout}{size}{count}{vrf}'.format(
destination=destination,
source=source_str,
ttl=maxttl_str,
timeout=timeout_str,
size=size_str,
count=count_str
count=count_str,
vrf=vrf_str
)

ping_rpc = E('command', ping_command)
Expand Down Expand Up @@ -1442,7 +1451,8 @@ def get_optics(self):
'input_power': {
'instant': (
float(optics['input_power'])
if optics['input_power'] not in [None, C.OPTICS_NO_POWER]
if optics['input_power'] not in
[None, C.OPTICS_NULL_LEVEL]
else 0.0),
'avg': 0.0,
'max': 0.0,
Expand All @@ -1451,7 +1461,8 @@ def get_optics(self):
'output_power': {
'instant': (
float(optics['output_power'])
if optics['output_power'] not in [None, C.OPTICS_NO_POWER]
if optics['output_power'] not in
[None, C.OPTICS_NULL_LEVEL]
else 0.0),
'avg': 0.0,
'max': 0.0,
Expand All @@ -1461,7 +1472,7 @@ def get_optics(self):
'instant': (
float(optics['laser_bias_current'])
if optics['laser_bias_current'] not in
[None, C.OPTICS_NO_POWER]
[None, C.OPTICS_NULL_LEVEL]
else 0.0),
'avg': 0.0,
'max': 0.0,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name="napalm-junos",
version="0.6.3",
version="0.6.4",
packages=find_packages(),
author="David Barroso, Mircea Ulinic",
author_email="dbarrosop@dravetech.com, mircea@cloudflare.com",
Expand Down

0 comments on commit db9af62

Please sign in to comment.