Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@
# IPMI FRU Device Commands
Cmd_ReadFRUData = 0x11

def get_ipmitool_raw_output(args):
"""
Returns a list the elements of which are the individual bytes of
ipmitool raw <cmd> command output.
"""
result_bytes = list()
result = ""
command = "ipmitool raw {}".format(args)
try:
proc = subprocess.Popen(command.split(), stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
if not proc.returncode:
result = stdout.rstrip('\n')
except:
pass

for i in result.split():
result_bytes.append(int(i, 16))

return result_bytes

class IpmiSensor(object):

# Sensor Threshold types and their respective bit masks
Expand All @@ -39,29 +62,6 @@ def __init__(self, sensor_id, is_discrete=False):
self.id = sensor_id
self.is_discrete = is_discrete

def _get_ipmitool_raw_output(self, args):
"""
Returns a list the elements of which are the individual bytes of
ipmitool raw <cmd> command output.
"""
result_bytes = list()
result = ""
command = "ipmitool raw {}".format(args)
try:
proc = subprocess.Popen(command.split(), stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
if not proc.returncode:
result = stdout.decode('utf-8').rstrip('\n')
except:
pass

for i in result.split():
result_bytes.append(int(i, 16))

return result_bytes

def _get_converted_sensor_reading(self, raw_value):
"""
Returns a 2 element tuple(bool, int) in which first element
Expand All @@ -72,7 +72,7 @@ def _get_converted_sensor_reading(self, raw_value):
cmd_args = "{} {} {} {}".format(NetFn_SensorEvent,
Cmd_GetSensorReadingFactors,
self.id, raw_value)
factors = self._get_ipmitool_raw_output(cmd_args)
factors = get_ipmitool_raw_output(cmd_args)

if len(factors) != 7:
return False, 0
Expand Down Expand Up @@ -107,7 +107,7 @@ def get_reading(self):
# Get Sensor Reading
cmd_args = "{} {} {}".format(NetFn_SensorEvent, Cmd_GetSensorReading,
self.id)
output = self._get_ipmitool_raw_output(cmd_args)
output = get_ipmitool_raw_output(cmd_args)
if len(output) != 4:
return False, 0

Expand Down Expand Up @@ -154,7 +154,7 @@ def get_threshold(self, threshold_type):
# Get Sensor Threshold
cmd_args = "{} {} {}".format(NetFn_SensorEvent, Cmd_GetSensorThreshold,
self.id)
thresholds = self._get_ipmitool_raw_output(cmd_args)
thresholds = get_ipmitool_raw_output(cmd_args)
if len(thresholds) != 7:
return False, 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ z9332f/scripts/platform_sensors.py usr/local/bin
z9332f/scripts/sensors usr/bin
z9332f/cfg/z9332f-modules.conf etc/modules-load.d
z9332f/systemd/platform-modules-z9332f.service etc/systemd/system
z9332f/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-dellemc_z9332f_d1508-r0
z9332f/modules/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-dellemc_z9332f_d1508-r0
common/platform_reboot usr/share/sonic/device/x86_64-dellemc_z9332f_d1508-r0
common/pcisysfs.py usr/bin
common/fw-updater usr/local/bin
common/onie_mode_set usr/local/bin
11 changes: 11 additions & 0 deletions platform/broadcom/sonic-platform-modules-dell/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ override_dh_auto_build:
python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
cd $(MOD_SRC_DIR); \
elif [ $$mod = "z9332f" ]; then \
cp $(COMMON_DIR)/ipmihelper.py $(MOD_SRC_DIR)/$${mod}/sonic_platform/ipmihelper.py; \
cd $(MOD_SRC_DIR)/$${mod}; \
python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
cd $(MOD_SRC_DIR); \
fi; \
echo "making man page alias $$mod -> $$mod APIs";\
make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \
Expand Down Expand Up @@ -97,6 +103,11 @@ override_dh_clean:
rm -f $(MOD_SRC_DIR)/$${mod}/modules/*.whl; \
rm -rf $(MOD_SRC_DIR)/$${mod}/build; \
rm -rf $(MOD_SRC_DIR)/$${mod}/build/*.egg-info; \
elif [ $$mod = "z9332f" ]; then \
rm -f $(MOD_SRC_DIR)/$${mod}/sonic_platform/ipmihelper.py; \
rm -f $(MOD_SRC_DIR)/$${mod}/modules/*.whl; \
rm -rf $(MOD_SRC_DIR)/$${mod}/build; \
rm -rf $(MOD_SRC_DIR)/$${mod}/build/*.egg-info; \
fi; \
make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules clean; \
done); \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(self):

for port_num in range(self.PORT_START, self.PORTS_IN_BLOCK):
# sfp get uses zero-indexing, but port numbers start from 1
presence = self.get_sfp(port_num-1).get_presence()
presence = self.get_sfp(port_num).get_presence()
self._global_port_pres_dict[port_num] = '1' if presence else '0'

def __del__(self):
Expand All @@ -99,7 +99,7 @@ def get_change_event(self, timeout=0):
while True:
time.sleep(0.5)
for port_num in range(self.PORT_START, (self.PORT_END + 1)):
presence = self.get_sfp(port_num-1).get_presence()
presence = self.get_sfp(port_num).get_presence()
if(presence and self._global_port_pres_dict[port_num] == '0'):
self._global_port_pres_dict[port_num] = '1'
port_dict[port_num] = '1'
Expand Down Expand Up @@ -134,10 +134,10 @@ def get_sfp(self, index):

try:
# The index will start from 0
sfp = self._sfp_list[index]
sfp = self._sfp_list[index-1]
except IndexError:
sys.stderr.write("SFP index {} out of range (0-{})\n".format(
index, len(self._sfp_list)-1))
index, len(self._sfp_list)))
return sfp

def get_name(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python

########################################################################
# DellEMC S5232F
# DellEMC Z9332F
#
# Module contains an implementation of SONiC Platform Base API and
# provides the Fan-Drawers' information available in the platform.
Expand All @@ -14,7 +14,7 @@
except ImportError as e:
raise ImportError(str(e) + "- required module not found")

S5232F_FANS_PER_FANTRAY = 2
Z9332F_FANS_PER_FANTRAY = 2


class FanDrawer(FanDrawerBase):
Expand All @@ -25,7 +25,7 @@ def __init__(self, fantray_index):
FanDrawerBase.__init__(self)
# FanTray is 1-based in DellEMC platforms
self.fantrayindex = fantray_index + 1
for i in range(S5232F_FANS_PER_FANTRAY):
for i in range(Z9332F_FANS_PER_FANTRAY):
self._fan_list.append(Fan(fantray_index, i))

def get_name(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,29 @@ platform_firmware_versions() {
ver=`/usr/sbin/i2cget -y 4 0x31 0x0`
echo "Switch CPLD 2: $((ver))" >> $FIRMWARE_VERSION_FILE
}

install_python_api_package() {
device="/usr/share/sonic/device"
platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)

rv=$(pip install $device/$platform/sonic_platform-1.0-py2-none-any.whl)
rv=$(pip3 install $device/$platform/sonic_platform-1.0-py3-none-any.whl)
}

remove_python_api_package() {
rv=$(pip show sonic-platform > /dev/null 2>/dev/null)
if [ $? -eq 0 ]; then
rv=$(pip uninstall -y sonic-platform > /dev/null 2>/dev/null)
fi

rv=$(pip3 show sonic-platform > /dev/null 2>/dev/null)
if [ $? -eq 0 ]; then
rv=$(pip3 uninstall -y sonic-platform > /dev/null 2>/dev/null)
fi
}



init_devnum

if [ "$1" == "init" ]; then
Expand All @@ -160,6 +183,7 @@ if [ "$1" == "init" ]; then
switch_board_qsfp "new_device"
switch_board_sfp "new_device"
switch_board_led_default
install_python_api_package
# /usr/bin/qsfp_irq_enable.py
platform_firmware_versions

Expand All @@ -174,6 +198,7 @@ elif [ "$1" == "deinit" ]; then
modprobe -r cls-i2c-ocore
modprobe -r cls-switchboard
modprobe -r mc24lc64t
remove_python_api_package
else
echo "z9332f_platform : Invalid option !"
fi
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__all__ = ["platform", "chassis", "sfp", "eeprom", "component", "psu", "thermal", "fan", "fan_drawer"]
from sonic_platform import *
Loading