/usr/lib/python2.7/dist-packages/jnpr/junos/facts/chassis.py is in python-junos-eznc 2.0.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | from jnpr.junos.exception import ConnectNotMasterError
def facts_chassis(junos, facts):
"""
The following facts are assigned:
facts['2RE'] : designates if the device can support two RE, not that it has them
facts['RE_hw_mi'] : designates if the device is multi-instance-routing-engine
facts['model'] : product model
facts['serialnumber'] : serial number
NOTES:
(1) if in a 2RE system, this routine will only load the information
from the first chassis item.
(2) hostname, domain, and fqdn are retrieved from configuration data;
inherited configs are checked.
"""
try:
rsp = junos.rpc.get_chassis_inventory()
if rsp.tag == 'error':
raise RuntimeError()
except:
# this means that the RPC caused a trap. this should generally
# never happen, but we'll trap it cleanly for now
facts['2RE'] = False
facts['model'] = ''
facts['serialnumber'] = ''
return
if rsp.tag == 'output':
# this means that there was an error; due to the
# fact that this connection is not on the master
# @@@ need to validate on VC-member
raise ConnectNotMasterError(junos)
if rsp.tag == 'multi-routing-engine-results':
facts['2RE'] = True
facts['RE_hw_mi'] = True
x_ch = rsp.xpath('.//chassis-inventory')[0].find('chassis')
else:
facts['2RE'] = False
x_ch = rsp.find('chassis')
facts['model'] = x_ch.findtext('description')
try:
facts['serialnumber'] = x_ch.find('serial-number').text
except:
# if the toplevel chassis does not have a serial-number, then
# check the Backplane chassis-module
facts['serialnumber'] = x_ch.xpath(
'chassis-module[name="Backplane" or name="Midplane"]/serial-number')[0].text
|