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

Commit 90d5c07

Browse files
authored
Merge pull request #118 from napalm-automation/develop
Release 0.6.3
2 parents 4be7234 + a8e8f78 commit 90d5c07

File tree

6 files changed

+97
-9
lines changed

6 files changed

+97
-9
lines changed

napalm_junos/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@
1414
'vpls': 'BGP_VPLS',
1515
'forwarding': 'L2P2P'
1616
}
17+
18+
OPTICS_NO_POWER = '- Inf'

napalm_junos/junos.py

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
# import stdlib
2121
import re
22+
import logging
2223
import collections
2324
from copy import deepcopy
2425

@@ -47,6 +48,8 @@
4748
# import local modules
4849
from napalm_junos.utils import junos_views
4950

51+
log = logging.getLogger(__file__)
52+
5053

5154
class JunOSDriver(NetworkDriver):
5255
"""JunOSDriver class - inherits NetworkDriver from napalm_base."""
@@ -428,8 +431,15 @@ def get_bgp_neighbors(self):
428431
def get_lldp_neighbors(self):
429432
"""Return LLDP neighbors details."""
430433
lldp = junos_views.junos_lldp_table(self.device)
431-
lldp.get()
432-
434+
try:
435+
lldp.get()
436+
except RpcError as rpcerr:
437+
# this assumes the library runs in an environment
438+
# able to handle logs
439+
# otherwise, the user just won't see this happening
440+
log.error('Unable to retrieve the LLDP neighbors information:')
441+
log.error(rpcerr.message)
442+
return {}
433443
result = lldp.items()
434444

435445
neighbors = {}
@@ -445,7 +455,15 @@ def get_lldp_neighbors_detail(self, interface=''):
445455
lldp_neighbors = {}
446456

447457
lldp_table = junos_views.junos_lldp_neighbors_detail_table(self.device)
448-
lldp_table.get()
458+
try:
459+
lldp_table.get()
460+
except RpcError as rpcerr:
461+
# this assumes the library runs in an environment
462+
# able to handle logs
463+
# otherwise, the user just won't see this happening
464+
log.error('Unable to retrieve the LLDP neighbors information:')
465+
log.error(rpcerr.message)
466+
return {}
449467
interfaces = lldp_table.get().keys()
450468

451469
old_junos = napalm_base.helpers.convert(
@@ -907,19 +925,25 @@ def get_interfaces_ip(self):
907925
'inet6': u'ipv6'
908926
# can add more mappings
909927
}
928+
_FAMILY_MAX_PREFIXLEN = {
929+
'inet': 32,
930+
'inet6': 128
931+
}
910932

911933
for interface_details in interface_table_items:
912934
ip_network = interface_details[0]
913935
ip_address = ip_network.split('/')[0]
914936
address = napalm_base.helpers.convert(
915937
napalm_base.helpers.ip, ip_address, ip_address)
916-
prefix = napalm_base.helpers.convert(int, ip_network.split('/')[-1], 0)
917938
try:
918939
interface_details_dict = dict(interface_details[1])
919940
family_raw = interface_details_dict.get('family')
920941
interface = py23_compat.text_type(interface_details_dict.get('interface'))
921942
except ValueError:
922943
continue
944+
prefix = napalm_base.helpers.convert(int,
945+
ip_network.split('/')[-1],
946+
_FAMILY_MAX_PREFIXLEN.get(family_raw))
923947
family = _FAMILY_VMAP_.get(family_raw)
924948
if not family or not interface:
925949
continue
@@ -1418,7 +1442,7 @@ def get_optics(self):
14181442
'input_power': {
14191443
'instant': (
14201444
float(optics['input_power'])
1421-
if optics['input_power'] != '- Inf'
1445+
if optics['input_power'] not in [None, C.OPTICS_NO_POWER]
14221446
else 0.0),
14231447
'avg': 0.0,
14241448
'max': 0.0,
@@ -1427,7 +1451,7 @@ def get_optics(self):
14271451
'output_power': {
14281452
'instant': (
14291453
float(optics['output_power'])
1430-
if optics['output_power'] != '- Inf'
1454+
if optics['output_power'] not in [None, C.OPTICS_NO_POWER]
14311455
else 0.0),
14321456
'avg': 0.0,
14331457
'max': 0.0,
@@ -1436,7 +1460,8 @@ def get_optics(self):
14361460
'laser_bias_current': {
14371461
'instant': (
14381462
float(optics['laser_bias_current'])
1439-
if optics['laser_bias_current'] != '- Inf'
1463+
if optics['laser_bias_current'] not in
1464+
[None, C.OPTICS_NO_POWER]
14401465
else 0.0),
14411466
'avg': 0.0,
14421467
'max': 0.0,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
setup(
1414
name="napalm-junos",
15-
version="0.6.2",
15+
version="0.6.3",
1616
packages=find_packages(),
1717
author="David Barroso, Mircea Ulinic",
1818
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"irb.17": {"ipv4": {"172.17.17.1": {"prefix_length": 32}, "172.17.19.1": {"prefix_length": 24}}, "ipv6": {"2400::1": {"prefix_length": 64}, "fe80::1": {"prefix_length": 128}}}}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<interface-information style="terse">
2+
<physical-interface>
3+
<name>irb</name>
4+
<admin-status format="Enabled">up</admin-status>
5+
<oper-status>up</oper-status>
6+
<local-index>134</local-index>
7+
<snmp-index>505</snmp-index>
8+
<if-type>Ethernet</if-type>
9+
<link-level-type>Ethernet</link-level-type>
10+
<mtu>1514</mtu>
11+
<if-device-flags>
12+
<ifdf-present/>
13+
<ifdf-running/>
14+
</if-device-flags>
15+
<ifd-specific-config-flags>
16+
</ifd-specific-config-flags>
17+
<if-config-flags>
18+
<iff-snmp-traps/>
19+
</if-config-flags>
20+
<link-type>Full-Duplex</link-type>
21+
<if-media-flags>
22+
<ifmf-none/>
23+
</if-media-flags>
24+
<current-physical-address format="MAC de:ad:be:ef:de:ad">de:ad:be:ef:de:ad</current-physical-address>
25+
<hardware-physical-address format="MAC de:ad:be:ef:de:ad">de:ad:be:ef:de:ad</hardware-physical-address>
26+
<interface-flapped seconds="0">Never</interface-flapped>
27+
<traffic-statistics style="brief">
28+
<input-packets>0</input-packets>
29+
<output-packets>0</output-packets>
30+
</traffic-statistics>
31+
<logical-interface>
32+
<name>irb.17</name>
33+
<admin-status>up</admin-status>
34+
<oper-status>up</oper-status>
35+
<filter-information>
36+
</filter-information>
37+
<address-family>
38+
<address-family-name>inet</address-family-name>
39+
<interface-address>
40+
<ifa-local emit="emit">172.17.17.1/32</ifa-local>
41+
</interface-address>
42+
<interface-address>
43+
<ifa-local emit="emit">172.17.19.1/24</ifa-local>
44+
</interface-address>
45+
</address-family>
46+
<address-family>
47+
<address-family-name>inet6</address-family-name>
48+
<interface-address>
49+
<ifa-local emit="emit">2400::1/64</ifa-local>
50+
</interface-address>
51+
<interface-address>
52+
<ifa-local emit="emit">fe80::1/128</ifa-local>
53+
</interface-address>
54+
</address-family>
55+
<address-family>
56+
<address-family-name>multiservice</address-family-name>
57+
</address-family>
58+
</logical-interface>
59+
</physical-interface>
60+
</interface-information>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{".local..0": {"ipv4": {"10.48.71.102": {"prefix_length": 0}}}, ".local..1": {"ipv4": {"128.0.0.16": {"prefix_length": 0}, "128.0.0.32": {"prefix_length": 0}, "128.0.0.1": {"prefix_length": 0}}}, "xe-0/1/2.3": {"ipv4": {"192.169.1.1": {"prefix_length": 0}}}, "xe-0/1/2.2": {"ipv4": {"192.169.1.1": {"prefix_length": 0}}}, "lo0.2": {"ipv4": {"10.255.254.1": {"prefix_length": 0}}}, ".local..6": {"ipv4": {"10.3.1.1": {"prefix_length": 0}, "192.168.0.1": {"prefix_length": 0}, "10.255.255.1": {"prefix_length": 0}, "192.169.1.1": {"prefix_length": 0}}}, ".local..7": {"ipv4": {"10.255.254.1": {"prefix_length": 0}, "10.2.1.1": {"prefix_length": 0}, "192.168.0.1": {"prefix_length": 0}, "192.169.1.1": {"prefix_length": 0}}, "ipv6": {"fe80::56e0:3200:280:68b3": {"prefix_length": 0}, "::ffff:192.168.0.1": {"prefix_length": 0}}}, "bme0.32768": {"ipv4": {"128.0.0.16": {"prefix_length": 0}, "128.0.0.32": {"prefix_length": 0}, "128.0.0.1": {"prefix_length": 0}}}, ".local..2": {"ipv4": {"127.0.0.1": {"prefix_length": 0}}}, "xe-0/1/0.2": {"ipv4": {"192.168.0.1": {"prefix_length": 0}}, "ipv6": {"fe80::56e0:3200:280:68b3": {"prefix_length": 0}, "::ffff:192.168.0.1": {"prefix_length": 0}}}, "xe-0/1/0.3": {"ipv4": {"192.168.0.1": {"prefix_length": 0}}}, "me0.0": {"ipv4": {"10.48.71.102": {"prefix_length": 0}}}, "lo0.16384": {"ipv4": {"127.0.0.1": {"prefix_length": 0}}}, ".local..3": {"ipv4": {"128.0.0.127": {"prefix_length": 0}}}, "jsrv.1": {"ipv4": {"128.0.0.127": {"prefix_length": 0}}}, "vlan.3": {"ipv4": {"10.3.1.1": {"prefix_length": 0}}}, "vlan.2": {"ipv4": {"10.2.1.1": {"prefix_length": 0}}}, "lo0.3": {"ipv4": {"10.255.255.1": {"prefix_length": 0}}}}
1+
{"lo0.2": {"ipv4": {"10.255.254.1": {"prefix_length": 32}}}, "lo0.3": {"ipv4": {"10.255.255.1": {"prefix_length": 32}}}, "jsrv.1": {"ipv4": {"128.0.0.127": {"prefix_length": 32}}}, ".local..6": {"ipv4": {"10.3.1.1": {"prefix_length": 32}, "192.168.0.1": {"prefix_length": 32}, "10.255.255.1": {"prefix_length": 32}, "192.169.1.1": {"prefix_length": 32}}}, "xe-0/1/2.3": {"ipv4": {"192.169.1.1": {"prefix_length": 32}}}, "xe-0/1/2.2": {"ipv4": {"192.169.1.1": {"prefix_length": 32}}}, "vlan.3": {"ipv4": {"10.3.1.1": {"prefix_length": 32}}}, "vlan.2": {"ipv4": {"10.2.1.1": {"prefix_length": 32}}}, ".local..0": {"ipv4": {"10.48.71.102": {"prefix_length": 32}}}, ".local..1": {"ipv4": {"128.0.0.32": {"prefix_length": 32}, "128.0.0.1": {"prefix_length": 32}, "128.0.0.16": {"prefix_length": 32}}}, ".local..2": {"ipv4": {"127.0.0.1": {"prefix_length": 32}}}, ".local..3": {"ipv4": {"128.0.0.127": {"prefix_length": 32}}}, "me0.0": {"ipv4": {"10.48.71.102": {"prefix_length": 32}}}, "bme0.32768": {"ipv4": {"128.0.0.32": {"prefix_length": 32}, "128.0.0.1": {"prefix_length": 32}, "128.0.0.16": {"prefix_length": 32}}}, ".local..7": {"ipv6": {"fe80::56e0:3200:280:68b3": {"prefix_length": 128}, "::ffff:192.168.0.1": {"prefix_length": 128}}, "ipv4": {"10.2.1.1": {"prefix_length": 32}, "192.168.0.1": {"prefix_length": 32}, "10.255.254.1": {"prefix_length": 32}, "192.169.1.1": {"prefix_length": 32}}}, "xe-0/1/0.3": {"ipv4": {"192.168.0.1": {"prefix_length": 32}}}, "xe-0/1/0.2": {"ipv6": {"fe80::56e0:3200:280:68b3": {"prefix_length": 128}, "::ffff:192.168.0.1": {"prefix_length": 128}}, "ipv4": {"192.168.0.1": {"prefix_length": 32}}}, "lo0.16384": {"ipv4": {"127.0.0.1": {"prefix_length": 32}}}}

0 commit comments

Comments
 (0)