sonic-buildimage/platform/broadcom/sonic-platform-modules-juniper/qfx5200/utils
Mai Bui 2f6b34a637
[device/juniper] Mitigation for security vulnerability (#11838)
Signed-off-by: maipbui maibui@microsoft.com
Dependency: [https://github.com/sonic-net/sonic-buildimage/pull/12065](https://github.com/sonic-net/sonic-buildimage/pull/12065)
#### Why I did it
`commands` module is not secure
command injection in `getstatusoutput` being used without a static string
#### How I did it
Eliminate `commands` module, use `subprocess` module only
Convert Python 2 to Python 3
2022-11-22 10:46:12 -05:00
..
juniper_qfx5200_monitor.py [device/juniper] Mitigation for security vulnerability (#11838) 2022-11-22 10:46:12 -05:00
juniper_qfx5200_util.py [device/juniper] Mitigation for security vulnerability (#11838) 2022-11-22 10:46:12 -05:00
README
show_thresholds [device/juniper] Mitigation for security vulnerability (#11838) 2022-11-22 10:46:12 -05:00
temperature_thresholds_AFI.txt
temperature_thresholds_AFO.txt
wrapper-fast-reboot
wrapper-warm-reboot

Copyright (c) 2020, Juniper Networks, Inc.
All rights reserved.

Front panel LEDs
================
There are 4 system LEDs in the front panel. Master, System, Alarm, & Beacon.
LED controls can be found under /sys/class/leds. The sysfs interface & 
colour mappings are as follows:

For master LED: /sys/class/leds/master/brightness
  0 => off
  1 => green

For system LED: /sys/class/leds/system/brightness
  0 => off
  1 => green

For alarm LED: /sys/class/leds/alarm/brightness
  0 => off
  1 => amber
  2 => red

For beacon LED: /sys/class/leds/beacon/brightness
  0 => off
  1 => blue
  
For any of the above LEDs, max_brightness file can tell the maximum value 
accepted.

System FANs
===========
There are 5 fans and each of the fan has 2 fan modules. Overall there are 
10 fans in the system. These fans are controlled by ADT7470 driver.

Fan controls can be found in 
 /sys/bus/i2c/devices/7-002c
 /sys/bus/i2c/devices/7-002e
 /sys/bus/i2c/devices/7-002f

For example, the complete path to driver control files will be 
 /sys/bus/i2c/devices/7-002c/hwmon/hwmon12

Fan duty cycle can be controlled through 'pwm1', 'pwm2', 'pwm3', 'pwm4' sysfs files.

For example, these are the absolute paths to the control files

 /sys/bus/i2c/devices/7-002c/hwmon/hwmon*/pwm1    7-002c controls 2 fan modules
 /sys/bus/i2c/devices/7-002c/hwmon/hwmon*/pwm2
 /sys/bus/i2c/devices/7-002c/hwmon/hwmon*/pwm3
 /sys/bus/i2c/devices/7-002c/hwmon/hwmon*/pwm4

 /sys/bus/i2c/devices/7-002e/hwmon/hwmon*/pwm1    7-002e controls 2 fan modules
 /sys/bus/i2c/devices/7-002e/hwmon/hwmon*/pwm2
 /sys/bus/i2c/devices/7-002e/hwmon/hwmon*/pwm3
 /sys/bus/i2c/devices/7-002e/hwmon/hwmon*/pwm4

 /sys/bus/i2c/devices/7-002f/hwmon/hwmon*/pwm1    7-002c controls only 1 fan module
 /sys/bus/i2c/devices/7-002f/hwmon/hwmon*/pwm2

For convenience, it will be represented as 
/sys/bus/i2c/devices/7-002[c/e/f]/hwmon/hwmon*/pwm[1-4]

Fan speed is given by 
/sys/bus/i2c/devices/7-002[c/e/f]/hwmon/hwmon*/fan[1-4]_input

Fan module presence is given by 
/sys/devices/pci0000:00/0000:00:1c.0/0000:0f:00.0/refpga-tmc.15/fan[0-4]_present 
file. A value of '1' indicate that fan is present & a value of '0' otherwise.

Fan rotation direction is given by 
/sys/devices/pci0000:00/0000:00:1c.0/0000:0f:00.0/refpga-tmc.15/fan[0-4]_type
A value of '1' indicate the direction is AFO (Front to back airflow) or Airflow 
out. A value of '0' indicate that direction is AFI (Back to front airflow) or 
Airflow in.


Temperature sensors
===================
There are 10 temperature sensors. Kernel driver tmp401 is used for
reading temeperature sensors.

The readings are available in 

/sys/bus/i2c/devices/5-0048/hwmon/hwmon*/temp1_input
/sys/bus/i2c/devices/5-0049/hwmon/hwmon*/temp1_input
/sys/bus/i2c/devices/5-004a/hwmon/hwmon*/temp1_input
/sys/bus/i2c/devices/5-004b/hwmon/hwmon*/temp1_input

/sys/bus/i2c/devices/6-0048/hwmon/hwmon*/temp1_input
/sys/bus/i2c/devices/6-0049/hwmon/hwmon*/temp1_input
/sys/bus/i2c/devices/6-004a/hwmon/hwmon*/temp1_input
/sys/bus/i2c/devices/6-004b/hwmon/hwmon*/temp1_input

/sys/bus/i2c/devices/7-0048/hwmon/hwmon*/temp1_input
/sys/bus/i2c/devices/7-0049/hwmon/hwmon*/temp1_input

System PSUs
===========
There are two independent PSUs. These are controlled by TMC fpga. 

PSU presence is given by jnx-tmc-psu dirver and is available at
/sys/devices/pci0000:00/0000:00:1c.0/0000:0f:00.0/psu-tmc.15/psu*_present
A value of '1' indicate PSU is present and a value of '0' otherwise.

PSU monitoring data is provided by jnx-psu-monitor driver and is available at
/sys/bus/i2c/devices/3-0058
/sys/bus/i2c/devices/4-0058

SFPs
====
There are 32 QSFP+ modules supported in qfx5200 platform. EEPORMs will be 
mapped under /sys/bus/i2c/devices/[14-45]-0050/ sysfs directory.

FEC should be turned on for 100G SR4 & PSM4 optics and should 
be turned off for 100G LR4 optics. If the FEC mode is not set 
as per the optic type the port may not link up or work properly.
In some cases while interoperating between other NOSs & traffic
generators, FEC need to be enabled even for 100G DAC cables.

As an example, see this configuration for FEC for 100G SR4 optics in
/etc/sonic/config_db.json
                           
"Ethernet4": {
            "admin_status": "up",
            "alias": "Ethernet4",
            "fec": "rs",
            "index": "1",
            "lanes": "65,66,67,68",
            "mtu": "9100",
            "speed": "100000"
        }

Sensor details
==============
LM75 supported sensor modules will be available under 'sensors' command. 

Platform reboot
=================
Platform reboot sequences are in place for system reboot. The following
messages are displayed in the console when the system is rebooted:

    [ 6053.163363] System restart: qfx5200_cpu_reset

Platform monitoring daemon
==========================
“juniper_qfx5200_monitor.py” is the platform monitoring script. 
It implements the qfx5200 EM policy. This script will run as system service 
and monitor the temperature sensors in every 20 seconds. Based on the EM 
policy thresholds, it controls the fan rpm, manage alarm leds, and 
shutdown the box in case of any over heating.