[DellEMC]: Platform modules Python3 compliance and other changes (#5609)

- Make DellEMC platform modules Python3 compliant.
- Change return type of PSU Platform APIs in DellEMC Z9264, S5232 and Thermal Platform APIs in S5232 to 'float'.
- Remove multiple copies of pcisysfs.py.
- PEP8 style changes for utility scripts.
- Build and install Python3 version of sonic_platform package.
- Fix minor Platform API issues.
This commit is contained in:
Arun Saravanan Balachandran 2020-10-17 19:31:55 +00:00 committed by GitHub
parent b57272f137
commit bcc6c64335
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
69 changed files with 992 additions and 1347 deletions

View File

@ -11,8 +11,8 @@
try:
from sonic_eeprom import eeprom_tlvinfo
except ImportError, e:
raise ImportError (str(e) + "- required module not found")
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
class board(eeprom_tlvinfo.TlvInfoDecoder):

View File

@ -11,8 +11,8 @@
try:
from sonic_eeprom import eeprom_tlvinfo
except ImportError, e:
raise ImportError (str(e) + "- required module not found")
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
class board(eeprom_tlvinfo.TlvInfoDecoder):

View File

@ -13,8 +13,8 @@
try:
import os.path
from sonic_eeprom import eeprom_tlvinfo
except ImportError, e:
raise ImportError (str(e) + "- required module not found")
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
class board(eeprom_tlvinfo.TlvInfoDecoder):

View File

@ -13,8 +13,8 @@
try:
import os.path
from sonic_eeprom import eeprom_tlvinfo
except ImportError, e:
raise ImportError (str(e) + "- required module not found")
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
class board(eeprom_tlvinfo.TlvInfoDecoder):

View File

@ -12,8 +12,8 @@
try:
import os.path
from sonic_eeprom import eeprom_tlvinfo
except ImportError, e:
raise ImportError (str(e) + "- required module not found")
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
class board(eeprom_tlvinfo.TlvInfoDecoder):

View File

@ -11,8 +11,8 @@
try:
from sonic_eeprom import eeprom_tlvinfo
except ImportError, e:
raise ImportError (str(e) + "- required module not found")
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
class board(eeprom_tlvinfo.TlvInfoDecoder):

View File

@ -1,15 +1,14 @@
#!/usr/bin/python
#!/usr/bin/python3
# dell staging fw updater script
import os
import sys
import subprocess
import argparse
onie_boot_folder = '/mnt/onie-boot/onie/tools/bin/onie-fwpkg'
onie_fwpkg_tool = '/mnt/onie-boot/onie/tools/bin/onie-fwpkg'
onie_boot_folder = '/mnt/onie-boot/onie/tools/bin/onie-fwpkg'
onie_fwpkg_tool = '/mnt/onie-boot/onie/tools/bin/onie-fwpkg'
ONIE_BOOT_MODE_CMD = '/mnt/onie-boot/onie/tools/bin/onie-boot-mode'
HOST_GRUB_DIR = '/host'
HOST_GRUB_CFG = HOST_GRUB_DIR + '/grub/grub.cfg'
@ -19,8 +18,6 @@ HOST_PLATFORM_INFO = HOST_GRUB_DIR + '/platform'
dell_reload_tool = '/usr/local/bin/reboot'
def set_onie_mode(option):
"""Select the ONIE boot mode, and set the next_entry to point to ONIE"""
_set_env_option('next_entry', 'ONIE')
@ -30,12 +27,12 @@ def set_onie_fw_update_env():
"""Select the ONIE boot mode, and set the next_entry to point to ONIE"""
if not os.path.exists(onie_boot_folder):
os.makedirs(onie_boot_folder)
os.makedirs(onie_boot_folder)
try:
subprocess.check_call(['mount','/dev/disk/by-label/ONIE-BOOT','/mnt/onie-boot'])
subprocess.check_call(['mount', '/dev/disk/by-label/ONIE-BOOT', '/mnt/onie-boot'])
except:
print "onie-boot not able to mount"
print("onie-boot not able to mount")
def _set_env_option(option, value):
"""Set an option in the GRUB environment block. Pass None to value to
@ -53,32 +50,32 @@ def _set_env_option(option, value):
def dell_firmware_update_staging(image_name):
try:
p = subprocess.Popen([onie_fwpkg_tool,"purge"],stdout=subprocess.PIPE,stdin=subprocess.PIPE)
p = subprocess.Popen([onie_fwpkg_tool, "purge"], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
p.communicate("y")
except:
print "onie-fwpkg command not found for purging old fw updates"
print("onie-fwpkg command not found for purging old fw updates")
try:
subprocess.check_call([onie_fwpkg_tool,"add", str(image_name)])
subprocess.check_call([onie_fwpkg_tool, "add", str(image_name)])
except:
print "onie-fwpkg is not found to stage fw updates"
print("onie-fwpkg is not found to stage fw updates")
try:
set_onie_mode("update")
except:
print "dell-image command not found"
print("dell-image command not found")
try:
subprocess.check_call([dell_reload_tool])
except:
print "reload command not found"
print("reload command not found")
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Dell HOST Firmware updates')
opts = parser.add_mutually_exclusive_group(required=True)
opts.add_argument('-u', '--update', nargs=1, metavar='IMAGE',
help='update specified image')
help='update specified image')
args = parser.parse_args()
@ -88,4 +85,3 @@ if __name__ == '__main__':
if args.update:
set_onie_fw_update_env()
dell_firmware_update_staging(args.update[0])

View File

@ -1,45 +1,45 @@
#!/usr/bin/python
#Script to read/write the io based registers
#!/usr/bin/python3
# Script to read/write the io based registers
import sys
import os
import getopt
import struct
io_resource='/dev/port'
io_resource = '/dev/port'
def usage():
''' This is the Usage Method '''
print 'Utility for IO read/write'
print '\t\t io_rd_wr.py --get --offset <offset>'
print '\t\t io_rd_wr.py --set --val <val> --offset <offset>'
print('Utility for IO read/write')
print('\t\t io_rd_wr.py --get --offset <offset>')
print('\t\t io_rd_wr.py --set --val <val> --offset <offset>')
sys.exit(1)
def io_reg_read(io_resource,offset):
fd=os.open(io_resource, os.O_RDONLY)
if(fd<0):
print 'file open failed %s"%io_resource'
def io_reg_read(io_resource, offset):
fd = os.open(io_resource, os.O_RDONLY)
if(fd < 0):
print('file open failed %s' % io_resource)
return
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
print 'lseek failed on %s'%io_resource
print('lseek failed on %s' % io_resource)
return
buf=os.read(fd,1)
reg_val1=ord(buf)
print 'reg value %x'%reg_val1
buf = os.read(fd, 1)
reg_val1 = ord(buf)
print('reg value %x' % reg_val1)
os.close(fd)
def io_reg_write(io_resource,offset,val):
fd=os.open(io_resource,os.O_RDWR)
if(fd<0):
print 'file open failed %s"%io_resource'
def io_reg_write(io_resource, offset, val):
fd = os.open(io_resource, os.O_RDWR)
if(fd < 0):
print('file open failed %s' % io_resource)
return
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
print 'lseek failed on %s'%io_resource
print('lseek failed on %s' % io_resource)
return
ret=os.write(fd,struct.pack('B',val))
ret = os.write(fd, struct.pack('B', val))
if(ret != 1):
print 'write failed %d'%ret
print('write failed %d' % ret)
return
os.close(fd)
@ -51,19 +51,17 @@ def main(argv):
opts = ''
val = ''
choice = ''
resouce = ''
offset = ''
try:
opts, args = getopt.getopt(argv, "hgs:" , \
["val=","offset=","help", "get", "set"])
opts, args = getopt.getopt(argv, "hgs:",
["val=", "offset=", "help", "get", "set"])
except getopt.GetoptError:
usage()
for opt,arg in opts:
for opt, arg in opts:
if opt in ('-h','--help'):
if opt in ('-h', '--help'):
choice = 'help'
elif opt in ('-g', '--get'):
@ -72,22 +70,21 @@ def main(argv):
elif opt in ('-s', '--set'):
choice = 'set'
elif opt == '--offset':
offset = int(arg,16)
elif opt == '--offset':
offset = int(arg, 16)
elif opt == '--val':
val = int(arg,16)
elif opt == '--val':
val = int(arg, 16)
if choice == 'get' and offset != '':
io_reg_read(io_resource,offset)
io_reg_read(io_resource, offset)
elif choice == 'set' and offset != '' and val != '':
io_reg_write(io_resource,offset,val)
io_reg_write(io_resource, offset, val)
else:
usage()
#Calling the main method
# Calling the main method
if __name__ == "__main__":
main(sys.argv[1:])

View File

@ -1,4 +1,4 @@
#! /usr/bin/python
#!/usr/bin/python3
########################################################################
# DellEMC
@ -53,7 +53,7 @@ class IpmiSensor(object):
stdout = proc.communicate()[0]
proc.wait()
if not proc.returncode:
result = stdout.rstrip('\n')
result = stdout.decode('utf-8').rstrip('\n')
except:
pass
@ -144,10 +144,10 @@ class IpmiSensor(object):
if self.is_discrete:
raise TypeError("Threshold is not applicable for Discrete Sensor")
if threshold_type not in self.THRESHOLD_BIT_MASK.keys():
if threshold_type not in list(self.THRESHOLD_BIT_MASK.keys()):
raise ValueError("Invalid threshold type {} provided. Valid types "
"are {}".format(threshold_type,
self.THRESHOLD_BIT_MASK.keys()))
list(self.THRESHOLD_BIT_MASK.keys())))
bit_mask = self.THRESHOLD_BIT_MASK[threshold_type]
@ -179,7 +179,7 @@ class IpmiFru(object):
stdout = proc.communicate()[0]
proc.wait()
if not proc.returncode:
result = stdout.rstrip('\n')
result = stdout.decode('utf-8').rstrip('\n')
except:
pass
@ -193,7 +193,7 @@ class IpmiFru(object):
if not fru_output:
return "NA"
info_req = re.search(r"%s\s*:(.*)"%info, fru_output)
info_req = re.search(r"%s\s*:(.*)" % info, fru_output)
if not info_req:
return "NA"
@ -223,7 +223,6 @@ class IpmiFru(object):
"""
return self._get_from_fru('Board Product')
def get_fru_data(self, offset, count=1):
"""
Reads and returns the FRU data at the provided offset.
@ -253,7 +252,7 @@ class IpmiFru(object):
stdout = proc.communicate()[0]
proc.wait()
if not proc.returncode:
result = stdout.rstrip('\n')
result = stdout.decode('utf-8').rstrip('\n')
except:
is_valid = False

View File

@ -1,45 +1,45 @@
#!/usr/bin/python
#Script to read/write the nvram
#!/usr/bin/python3
# Script to read/write the nvram
import sys
import os
import getopt
import struct
nvram_resource='/dev/nvram'
nvram_resource = '/dev/nvram'
def usage():
''' This is the Usage Method '''
print 'Utility for NVRAM read/write'
print '\t\t nvram_rd_wr.py --get --offset <offset>'
print '\t\t nvram_rd_wr.py --set --val <val> --offset <offset>'
print('Utility for NVRAM read/write')
print('\t\t nvram_rd_wr.py --get --offset <offset>')
print('\t\t nvram_rd_wr.py --set --val <val> --offset <offset>')
sys.exit(1)
def nvram_reg_read(nvram_resource,offset):
fd=os.open(nvram_resource, os.O_RDONLY)
if(fd<0):
print 'file open failed %s"%nvram_resource'
def nvram_reg_read(nvram_resource, offset):
fd = os.open(nvram_resource, os.O_RDONLY)
if(fd < 0):
print('file open failed %s' % nvram_resource)
return
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
print 'lseek failed on %s'%nvram_resource
print('lseek failed on %s' % nvram_resource)
return
buf=os.read(fd,1)
reg_val1=ord(buf)
print 'value %x'%reg_val1
buf = os.read(fd, 1)
reg_val1 = ord(buf)
print('value %x' % reg_val1)
os.close(fd)
def nvram_reg_write(nvram_resource,offset,val):
fd=os.open(nvram_resource,os.O_RDWR)
if(fd<0):
print 'file open failed %s"%nvram_resource'
def nvram_reg_write(nvram_resource, offset, val):
fd = os.open(nvram_resource, os.O_RDWR)
if(fd < 0):
print('file open failed %s' % nvram_resource)
return
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
print 'lseek failed on %s'%nvram_resource
print('lseek failed on %s' % nvram_resource)
return
ret=os.write(fd,struct.pack('B',val))
ret = os.write(fd, struct.pack('B', val))
if(ret != 1):
print 'write failed %d'%ret
print('write failed %d' % ret)
return
os.close(fd)
@ -51,23 +51,21 @@ def main(argv):
opts = ''
val = ''
choice = ''
resouce = ''
offset = ''
try:
opts, args = getopt.getopt(argv, "hgs:" , \
["val=","offset=","help", "get", "set"])
opts, args = getopt.getopt(argv, "hgs:",
["val=", "offset=", "help", "get", "set"])
except getopt.GetoptError:
usage()
if not os.path.exists(nvram_resource):
print 'NVRAM is not initialized'
print('NVRAM is not initialized')
sys.exit(1)
for opt,arg in opts:
for opt, arg in opts:
if opt in ('-h','--help'):
if opt in ('-h', '--help'):
choice = 'help'
elif opt in ('-g', '--get'):
@ -76,22 +74,21 @@ def main(argv):
elif opt in ('-s', '--set'):
choice = 'set'
elif opt == '--offset':
offset = int(arg,16) - 0xE
elif opt == '--offset':
offset = int(arg, 16) - 0xE
elif opt == '--val':
val = int(arg,16)
elif opt == '--val':
val = int(arg, 16)
if choice == 'get' and offset != '':
nvram_reg_read(nvram_resource,offset)
nvram_reg_read(nvram_resource, offset)
elif choice == 'set' and offset != '' and val != '':
nvram_reg_write(nvram_resource,offset,val)
nvram_reg_write(nvram_resource, offset, val)
else:
usage()
#Calling the main method
# Calling the main method
if __name__ == "__main__":
main(sys.argv[1:])

View File

@ -0,0 +1,105 @@
#!/usr/bin/python3
# Copyright (c) 2015 Dell Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
# LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS
# FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
#
# See the Apache Version 2.0 License for specific language governing
# permissions and limitations under the License.
import struct
import sys
import getopt
from os import *
from mmap import *
def usage():
''' This is the Usage Method '''
print('\t\t pcisysfs.py --get --offset <offset> --res <resource>')
print('\t\t pcisysfs.py --set --val <val> --offset <offset> --res <resource>')
sys.exit(1)
def pci_mem_read(mm, offset):
mm.seek(offset)
read_data_stream = mm.read(4)
print("")
reg_val = struct.unpack('I', read_data_stream)
print("reg_val read:%x" % reg_val)
return reg_val
def pci_mem_write(mm, offset, data):
mm.seek(offset)
print("data to write:%x" % data)
mm.write(struct.pack('I', data))
def pci_set_value(resource, val, offset):
fd = open(resource, O_RDWR)
mm = mmap(fd, 0)
pci_mem_write(mm, offset, val)
mm.close()
close(fd)
def pci_get_value(resource, offset):
fd = open(resource, O_RDWR)
mm = mmap(fd, 0)
pci_mem_read(mm, offset)
mm.close()
close(fd)
def main(argv):
''' The main function will read the user input from the
command line argument and process the request '''
opts = ''
val = ''
choice = ''
resource = ''
offset = ''
try:
opts, args = getopt.getopt(argv, "hgsv:",
["val=", "res=", "offset=", "help", "get", "set"])
except getopt.GetoptError:
usage()
for opt, arg in opts:
if opt in ('-h', '--help'):
choice = 'help'
elif opt in ('-g', '--get'):
choice = 'get'
elif opt in ('-s', '--set'):
choice = 'set'
elif opt == '--res':
resource = arg
elif opt == '--val':
val = int(arg, 16)
elif opt == '--offset':
offset = int(arg, 16)
if choice == 'set' and val != '' and offset != '' and resource != '':
pci_set_value(resource, val, offset)
elif choice == 'get' and offset != '' and resource != '':
pci_get_value(resource, offset)
else:
usage()
# Calling the main method
if __name__ == "__main__":
main(sys.argv[1:])

View File

@ -1,5 +1,4 @@
#!/usr/bin/python
import sys
#!/usr/bin/python3
import os
import struct
@ -9,17 +8,16 @@ PORT_RES = '/dev/port'
def portio_reg_write(resource, offset, val):
fd = os.open(resource, os.O_RDWR)
if(fd < 0):
print 'file open failed %s" % resource'
print('file open failed %s' % resource)
return
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
print 'lseek failed on %s' % resource
print('lseek failed on %s' % resource)
return
ret = os.write(fd, struct.pack('B', val))
if(ret != 1):
print 'write failed %d' % ret
print('write failed %d' % ret)
return
os.close(fd)
if __name__ == "__main__":
portio_reg_write(PORT_RES, 0xcf9, 0xe)

View File

@ -2,11 +2,12 @@ s5232f/scripts/s5232f_platform.sh usr/local/bin
s5232f/scripts/check_qsfp.sh usr/local/bin
s5232f/scripts/platform_sensors.py usr/local/bin
s5232f/scripts/sensors usr/bin
s5232f/scripts/pcisysfs.py usr/bin
s5232f/scripts/qsfp_irq_enable.py usr/bin
s5232f/cfg/s5232f-modules.conf etc/modules-load.d
s5232f/systemd/platform-modules-s5232f.service etc/systemd/system
s5232f/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-dellemc_s5232f_c3538-r0
s5232f/modules/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-dellemc_s5232f_c3538-r0
common/platform_reboot usr/share/sonic/device/x86_64-dellemc_s5232f_c3538-r0
common/fw-updater usr/local/bin
common/onie_mode_set usr/local/bin
common/pcisysfs.py usr/bin

View File

@ -2,10 +2,10 @@ s5248f/scripts/s5248f_platform.sh usr/local/bin
s5248f/scripts/check_qsfp.sh usr/local/bin
s5248f/scripts/platform_sensors.py usr/local/bin
s5248f/scripts/sensors usr/bin
s5248f/scripts/pcisysfs.py usr/bin
s5248f/scripts/qsfp_irq_enable.py usr/bin
s5248f/cfg/s5248f-modules.conf etc/modules-load.d
s5248f/systemd/platform-modules-s5248f.service etc/systemd/system
common/platform_reboot usr/share/sonic/device/x86_64-dellemc_s5248f_c3538-r0
common/fw-updater usr/local/bin
common/onie_mode_set usr/local/bin
common/pcisysfs.py usr/bin

View File

@ -6,3 +6,4 @@ s6000/systemd/platform-modules-s6000.service etc/systemd/system
s6000/systemd/fancontrol.service etc/systemd/system
common/io_rd_wr.py usr/local/bin
s6000/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-dell_s6000_s1220-r0
s6000/modules/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-dell_s6000_s1220-r0

View File

@ -15,6 +15,7 @@ s6100/scripts/override.conf /etc/systemd/system/systemd-reboot.service.d
common/dell_lpc_mon.sh usr/local/bin
s6100/scripts/platform_sensors.py usr/local/bin
s6100/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-dell_s6100_c2538-r0
s6100/modules/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-dell_s6100_c2538-r0
s6100/scripts/platform_watchdog_enable.sh usr/local/bin
s6100/scripts/platform_watchdog_disable.sh usr/local/bin
s6100/scripts/sensors usr/bin

View File

@ -8,6 +8,7 @@ z9100/scripts/override.conf /etc/systemd/system/systemd-reboot.service.d
z9100/scripts/platform_sensors.py usr/local/bin
z9100/scripts/sensors usr/bin
z9100/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-dell_z9100_c2538-r0
z9100/modules/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-dell_z9100_c2538-r0
z9100/cfg/z9100-modules.conf etc/modules-load.d
z9100/systemd/platform-modules-z9100.service etc/systemd/system
z9100/systemd/z9100-lpc-monitor.service etc/systemd/system

View File

@ -2,11 +2,12 @@ z9264f/scripts/z9264f_platform.sh usr/local/bin
z9264f/scripts/check_qsfp.sh usr/local/bin
z9264f/scripts/platform_sensors.py usr/local/bin
z9264f/scripts/sensors usr/bin
z9264f/scripts/pcisysfs.py usr/bin
z9264f/scripts/port_irq_enable.py usr/bin
z9264f/cfg/z9264f-modules.conf etc/modules-load.d
z9264f/systemd/platform-modules-z9264f.service etc/systemd/system
z9264f/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-dellemc_z9264f_c3538-r0
z9264f/modules/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-dellemc_z9264f_c3538-r0
common/platform_reboot usr/share/sonic/device/x86_64-dellemc_z9264f_c3538-r0
common/fw-updater usr/local/bin
common/onie_mode_set usr/local/bin
common/pcisysfs.py usr/bin

View File

@ -1,7 +1,7 @@
z9332f/scripts/z9332f_platform.sh usr/local/bin
z9332f/scripts/platform_sensors.py usr/local/bin
z9332f/scripts/sensors usr/bin
z9332f/scripts/pcisysfs.py usr/bin
z9332f/cfg/z9332f-modules.conf etc/modules-load.d
z9332f/systemd/platform-modules-z9332f.service etc/systemd/system
common/platform_reboot usr/share/sonic/device/x86_64-dellemc_z9332f_d1508-r0
common/pcisysfs.py usr/bin

View File

@ -19,26 +19,31 @@ override_dh_auto_build:
cp $(COMMON_DIR)/dell_ich.c $(MOD_SRC_DIR)/$${mod}/modules/dell_ich.c; \
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); \
elif [ $$mod = "z9100" ]; then \
cp $(COMMON_DIR)/dell_pmc.c $(MOD_SRC_DIR)/$${mod}/modules/dell_mailbox.c; \
cp $(COMMON_DIR)/dell_ich.c $(MOD_SRC_DIR)/$${mod}/modules/dell_ich.c; \
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); \
elif [ $$mod = "s6000" ]; then \
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); \
elif [ $$mod = "z9264f" ]; 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); \
elif [ $$mod = "s5232f" ]; 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";\

View File

@ -1,102 +0,0 @@
#!/usr/bin/python
# Copyright (c) 2015 Dell Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
# LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS
# FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
#
# See the Apache Version 2.0 License for specific language governing
# permissions and limitations under the License.
import struct
import sys
import getopt
from os import *
from mmap import *
def usage():
''' This is the Usage Method '''
print '\t\t pcisysfs.py --get --offset <offset> --res <resource>'
print '\t\t pcisysfs.py --set --val <val> --offset <offset> --res <resource>'
sys.exit(1)
def pci_mem_read(mm,offset):
mm.seek(offset)
read_data_stream=mm.read(4)
print ""
reg_val=struct.unpack('I',read_data_stream)
print "reg_val read:%x"%reg_val
return reg_val
def pci_mem_write(mm,offset,data):
mm.seek(offset)
print "data to write:%x"%data
mm.write(struct.pack('I',data))
def pci_set_value(resource,val,offset):
fd=open(resource,O_RDWR)
mm=mmap(fd,0)
pci_mem_write(mm,offset,val)
def pci_get_value(resource,offset):
fd=open(resource,O_RDWR)
mm=mmap(fd,0)
pci_mem_read(mm,offset)
def main(argv):
''' The main function will read the user input from the
command line argument and process the request '''
opts = ''
val = ''
choice = ''
resource = ''
offset = ''
try:
opts, args = getopt.getopt(argv, "hgsv:" , \
["val=","res=","offset=","help", "get", "set"])
except getopt.GetoptError:
usage()
for opt,arg in opts:
if opt in ('-h','--help'):
choice = 'help'
elif opt in ('-g', '--get'):
choice = 'get'
elif opt in ('-s', '--set'):
choice = 'set'
elif opt == '--res':
resource = arg
elif opt == '--val':
val = int(arg,16)
elif opt == '--offset':
offset = int(arg,16)
if choice == 'set' and val != '' and offset !='' and resource !='':
pci_set_value(resource,val,offset)
elif choice == 'get' and offset != '' and resource !='':
pci_get_value(resource,offset)
else:
usage()
#Calling the main method
if __name__ == "__main__":
main(sys.argv[1:])

View File

@ -1,9 +1,9 @@
#!/usr/bin/python
#!/usr/bin/python3
# On S5232F, the BaseBoard Management Controller is an
# autonomous subsystem provides monitoring and management
# facility independent of the host CPU. IPMI standard
# protocol is used with ipmitool to fetch sensor details.
# Current script support X00 board only. X01 support will
# Current script support X00 board only. X01 support will
# be added soon. This provies support for the
# following objects:
# * Onboard temperature sensors
@ -11,11 +11,9 @@
# * PSU
import os
import sys
import logging
import subprocess
import commands
S5232F_MAX_FAN_TRAYS = 4
S5232F_MAX_PSUS = 2
@ -41,7 +39,7 @@ def ipmi_sensor_dump():
status = 1
global ipmi_sdr_list
ipmi_cmd = IPMI_SENSOR_DATA
status, ipmi_sdr_list = commands.getstatusoutput(ipmi_cmd)
status, ipmi_sdr_list = subprocess.getstatusoutput(ipmi_cmd)
if status:
logging.error('Failed to execute: ' + ipmi_sdr_list)
@ -50,9 +48,9 @@ def ipmi_sensor_dump():
# Fetch a Fan Status
def get_fan_status(fan_id):
ret_status, ipmi_cmd_ret = commands.getstatusoutput(IPMI_FAN_PRESENCE.format(fan_id))
ret_status, ipmi_cmd_ret = subprocess.getstatusoutput(IPMI_FAN_PRESENCE.format(fan_id))
if ret_status:
logging.error('Failed to execute : %s'%IPMI_FAN_PRESENCE.format(fan_id))
logging.error('Failed to execute : %s' % IPMI_FAN_PRESENCE.format(fan_id))
sys.exit(0)
return(' ' + ipmi_cmd_ret.splitlines()[5].strip(' ').strip('[]'))
@ -67,7 +65,7 @@ def get_pmc_register(reg_name):
output = item.strip()
if output is None:
print('\nFailed to fetch: ' + reg_name + ' sensor ')
print('\nFailed to fetch: ' + reg_name + ' sensor ')
sys.exit(0)
output = output.split('|')[1]
@ -75,16 +73,16 @@ def get_pmc_register(reg_name):
logging.basicConfig(level=logging.DEBUG)
return output
#Fetch FRU Data for given fruid
# Fetch FRU Data for given fruid
def get_psu_airflow(psu_id):
fru_id = 'PSU' + str(psu_id) + '_fru'
ret_status, ipmi_cmd_ret = commands.getstatusoutput(IPMI_FRU)
ret_status, ipmi_cmd_ret = subprocess.getstatusoutput(IPMI_FRU)
if ret_status:
logging.error('Failed to execute ipmitool: '+ IPMI_FRU)
logging.error('Failed to execute ipmitool: ' + IPMI_FRU)
sys.exit(0)
found_fru = False
for line in ipmi_cmd_ret.splitlines():
if line.startswith('FRU Device Description') and fru_id in line.split(':')[1] :
if line.startswith('FRU Device Description') and fru_id in line.split(':')[1]:
found_fru = True
if found_fru and line.startswith(' Board Product '):
return ' B2F' if 'PS/IO' in line else ' F2B'
@ -92,13 +90,11 @@ def get_psu_airflow(psu_id):
# Fetch FRU on given offset
def fetch_raw_fru(dev_id, offset):
ret_status, ipmi_cmd_ret = commands.getstatusoutput(IPMI_RAW_STORAGE_READ.format(dev_id))
ret_status, ipmi_cmd_ret = subprocess.getstatusoutput(IPMI_RAW_STORAGE_READ.format(dev_id))
if ret_status:
logging.error('Failed to execute ipmitool :' + IPMI_RAW_STORAGE_READ.format(dev_id))
sys.exit(0)
return int((ipmi_cmd_ret.splitlines()[offset/16]).split(' ')[(offset%16+1)])
return int((ipmi_cmd_ret.splitlines()[offset//16]).split(' ')[(offset%16+1)])
def get_fan_airflow(fan_id):
@ -106,24 +102,22 @@ def get_fan_airflow(fan_id):
return Airflow_Direction[fetch_raw_fru(fan_id+2, 0x46)]
# Print the information for temperature sensors
def print_temperature_sensors():
print("\nOnboard Temperature Sensors:")
print ' PT_Left_temp: ',\
(get_pmc_register('PT_Left_temp'))
print ' PT_Mid_temp: ',\
(get_pmc_register('PT_Mid_temp'))
print ' PT_Right_temp: ',\
(get_pmc_register('PT_Right_temp'))
print ' Broadcom Temp: ',\
(get_pmc_register('NPU_Near_temp'))
print ' Inlet Airflow Temp: ',\
(get_pmc_register('ILET_AF_temp'))
print ' CPU Temp: ',\
(get_pmc_register('CPU_temp'))
print(' PT_Left_temp: ',
get_pmc_register('PT_Left_temp'))
print(' PT_Mid_temp: ',
get_pmc_register('PT_Mid_temp'))
print(' PT_Right_temp: ',
get_pmc_register('PT_Right_temp'))
print(' Broadcom Temp: ',
get_pmc_register('NPU_Near_temp'))
print(' Inlet Airflow Temp: ',
get_pmc_register('ILET_AF_temp'))
print(' CPU Temp: ',
get_pmc_register('CPU_temp'))
ipmi_sensor_dump()
@ -136,65 +130,65 @@ def print_fan_tray(tray):
Fan_Status = [' Normal', ' Abnormal']
print ' Fan Tray ' + str(tray) + ':'
print(' Fan Tray ' + str(tray) + ':')
if (tray == 1):
fan1_status = int(get_pmc_register('FAN1_Front_stat'), 16)
fan2_status = int(get_pmc_register('FAN1_Rear_stat'), 16)
print ' Fan1 Speed: ',\
get_pmc_register('FAN1_Front_rpm')
print ' Fan2 Speed: ',\
get_pmc_register('FAN1_Rear_rpm')
print ' Fan1 State: ',\
Fan_Status[fan1_status]
print ' Fan2 State: ',\
Fan_Status[fan2_status]
print(' Fan1 Speed: ',
get_pmc_register('FAN1_Front_rpm'))
print(' Fan2 Speed: ',
get_pmc_register('FAN1_Rear_rpm'))
print(' Fan1 State: ',
Fan_Status[fan1_status])
print(' Fan2 State: ',
Fan_Status[fan2_status])
elif (tray == 2):
fan1_status = int(get_pmc_register('FAN2_Front_stat'), 16)
fan2_status = int(get_pmc_register('FAN2_Rear_stat'), 16)
print ' Fan1 Speed: ',\
get_pmc_register('FAN2_Front_rpm')
print ' Fan2 Speed: ',\
get_pmc_register('FAN2_Rear_rpm')
print ' Fan1 State: ',\
Fan_Status[fan1_status]
print ' Fan2 State: ',\
Fan_Status[fan2_status]
print(' Fan1 Speed: ',
get_pmc_register('FAN2_Front_rpm'))
print(' Fan2 Speed: ',
get_pmc_register('FAN2_Rear_rpm'))
print(' Fan1 State: ',
Fan_Status[fan1_status])
print(' Fan2 State: ',
Fan_Status[fan2_status])
elif (tray == 3):
fan1_status = int(get_pmc_register('FAN3_Front_stat'), 16)
fan2_status = int(get_pmc_register('FAN3_Rear_stat'), 16)
print ' Fan1 Speed: ',\
get_pmc_register('FAN3_Front_rpm')
print ' Fan2 Speed: ',\
get_pmc_register('FAN3_Rear_rpm')
print ' Fan1 State: ',\
Fan_Status[fan1_status]
print ' Fan2 State: ',\
Fan_Status[fan2_status]
print(' Fan1 Speed: ',
get_pmc_register('FAN3_Front_rpm'))
print(' Fan2 Speed: ',
get_pmc_register('FAN3_Rear_rpm'))
print(' Fan1 State: ',
Fan_Status[fan1_status])
print(' Fan2 State: ',
Fan_Status[fan2_status])
elif (tray == 4):
fan1_status = int(get_pmc_register('FAN4_Front_stat'), 16)
fan2_status = int(get_pmc_register('FAN4_Rear_stat'), 16)
print ' Fan1 Speed: ',\
get_pmc_register('FAN4_Front_rpm')
print ' Fan2 Speed: ',\
get_pmc_register('FAN4_Rear_rpm')
print ' Fan1 State: ',\
Fan_Status[fan1_status]
print ' Fan2 State: ',\
Fan_Status[fan2_status]
print ' Airflow: ',\
get_fan_airflow(tray)
print(' Fan1 Speed: ',
get_pmc_register('FAN4_Front_rpm'))
print(' Fan2 Speed: ',
get_pmc_register('FAN4_Rear_rpm'))
print(' Fan1 State: ',
Fan_Status[fan1_status])
print(' Fan2 State: ',
Fan_Status[fan2_status])
print(' Airflow: ',
get_fan_airflow(tray))
print('\nFan Trays:')
@ -203,7 +197,7 @@ for tray in range(1, S5232F_MAX_FAN_TRAYS + 1):
if (get_fan_status(tray) == ' Present'):
print_fan_tray(tray)
else:
print ' Fan Tray {}: NOT PRESENT'.format(str(tray))
print(' Fan Tray {}: NOT PRESENT'.format(str(tray)))
def get_psu_presence(index):
"""
@ -215,9 +209,9 @@ for tray in range(1, S5232F_MAX_FAN_TRAYS + 1):
ret_status = 1
if index == 1:
ret_status, ipmi_cmd_ret = commands.getstatusoutput(IPMI_PSU1_DATA_DOCKER)
ret_status, ipmi_cmd_ret = subprocess.getstatusoutput(IPMI_PSU1_DATA_DOCKER)
elif index == 2:
ret_status, ipmi_cmd_ret = commands.getstatusoutput(IPMI_PSU2_DATA_DOCKER)
ret_status, ipmi_cmd_ret = subprocess.getstatusoutput(IPMI_PSU2_DATA_DOCKER)
if ret_status:
logging.error('Failed to execute ipmitool :' + IPMI_PSU1_DATA_DOCKER)
@ -238,9 +232,9 @@ for tray in range(1, S5232F_MAX_FAN_TRAYS + 1):
ipmi_cmd_ret = 'f'
if index == 1:
ret_status, ipmi_cmd_ret = commands.getstatusoutput(IPMI_PSU1_DATA_DOCKER)
ret_status, ipmi_cmd_ret = subprocess.getstatusoutput(IPMI_PSU1_DATA_DOCKER)
elif index == 2:
ret_status, ipmi_cmd_ret = commands.getstatusoutput(IPMI_PSU2_DATA_DOCKER)
ret_status, ipmi_cmd_ret = subprocess.getstatusoutput(IPMI_PSU2_DATA_DOCKER)
if ret_status:
logging.error('Failed to execute ipmitool : ' + IPMI_PSU2_DATA_DOCKER)
@ -271,68 +265,67 @@ def print_psu(psu):
# psu1_fan_status = int(get_pmc_register('PSU1_status'),16)
print ' PSU1:'
print ' FAN Normal Temperature: ',\
get_pmc_register('PSU1_temp')
print ' FAN AirFlow Temperature: ',\
get_pmc_register('PSU1_AF_temp')
print ' FAN RPM: ',\
get_pmc_register('PSU1_rpm')
print(' PSU1:')
print(' FAN Normal Temperature: ',
get_pmc_register('PSU1_temp'))
print(' FAN AirFlow Temperature: ',
get_pmc_register('PSU1_AF_temp'))
print(' FAN RPM: ',
get_pmc_register('PSU1_rpm'))
# print ' FAN Status: ', Psu_Fan_Status[psu1_fan_status]
# PSU input & output monitors
print ' Input Voltage: ',\
get_pmc_register('PSU1_In_volt')
print ' Output Voltage: ',\
get_pmc_register('PSU1_Out_volt')
print ' Input Power: ',\
get_pmc_register('PSU1_In_watt')
print ' Output Power: ',\
get_pmc_register('PSU1_Out_watt')
print ' Input Current: ',\
get_pmc_register('PSU1_In_amp')
print ' Output Current: ',\
get_pmc_register('PSU1_Out_amp')
print(' Input Voltage: ',
get_pmc_register('PSU1_In_volt'))
print(' Output Voltage: ',
get_pmc_register('PSU1_Out_volt'))
print(' Input Power: ',
get_pmc_register('PSU1_In_watt'))
print(' Output Power: ',
get_pmc_register('PSU1_Out_watt'))
print(' Input Current: ',
get_pmc_register('PSU1_In_amp'))
print(' Output Current: ',
get_pmc_register('PSU1_Out_amp'))
else:
# psu2_fan_status = int(get_pmc_register('PSU1_status'),16)
print ' PSU2:'
print ' FAN Normal Temperature: ',\
get_pmc_register('PSU2_temp')
print ' FAN AirFlow Temperature: ',\
get_pmc_register('PSU2_AF_temp')
print ' FAN RPM: ',\
get_pmc_register('PSU2_rpm')
print(' PSU2:')
print(' FAN Normal Temperature: ',
get_pmc_register('PSU2_temp'))
print(' FAN AirFlow Temperature: ',
get_pmc_register('PSU2_AF_temp'))
print(' FAN RPM: ',
get_pmc_register('PSU2_rpm'))
# print ' FAN Status: ', Psu_Fan_Status[psu2_fan_status]
# PSU input & output monitors
print ' Input Voltage: ',\
get_pmc_register('PSU2_In_volt')
print ' Output Voltage: ',\
get_pmc_register('PSU2_Out_volt')
print ' Input Power: ',\
get_pmc_register('PSU2_In_watt')
print ' Output Power: ',\
get_pmc_register('PSU2_Out_watt')
print ' Input Current: ',\
get_pmc_register('PSU2_In_amp')
print ' Output Current: ',\
get_pmc_register('PSU2_Out_amp')
print ' Airflow: ',\
get_psu_airflow(psu)
print(' Input Voltage: ',
get_pmc_register('PSU2_In_volt'))
print(' Output Voltage: ',
get_pmc_register('PSU2_Out_volt'))
print(' Input Power: ',
get_pmc_register('PSU2_In_watt'))
print(' Output Power: ',
get_pmc_register('PSU2_Out_watt'))
print(' Input Current: ',
get_pmc_register('PSU2_In_amp'))
print(' Output Current: ',
get_pmc_register('PSU2_Out_amp'))
print(' Airflow: ',
get_psu_airflow(psu))
print('\nPSUs:')
for psu in range(1, S5232F_MAX_PSUS + 1):
#psu_presence = PSU_PRESENCE.format(psu)
if not get_psu_presence(psu):
print ' PSU{}: NOT PRESENT'.format(psu)
elif not get_psu_status(psu) :
print ' PSU{}: NOT OK'.format(psu)
print(' PSU{}: NOT PRESENT'.format(psu))
elif not get_psu_status(psu):
print(' PSU{}: NOT OK'.format(psu))
else:
print_psu(psu)
print '\n Total Power: ',\
get_pmc_register('PSU_Total_watt')
print('\n Total Power: ',
get_pmc_register('PSU_Total_watt'))

View File

@ -1,32 +1,31 @@
#!/usr/bin/python
#!/usr/bin/python3
try:
import struct
import sys
from os import *
from mmap import *
import struct
from os import *
from mmap import *
except ImportError as e:
raise ImportError("%s - required module no found" % str(e))
raise ImportError("%s - required module no found" % str(e))
BASE_RES_PATH = "/sys/bus/pci/devices/0000:04:00.0/resource0"
PORT_START = 0
PORT_END = 32
PORT_END = 32
def pci_mem_write(mm, offset, data):
mm.seek(offset)
mm.write(struct.pack('I', data))
mm.seek(offset)
mm.write(struct.pack('I', data))
def pci_set_value(resource, val, offset):
fd = open(resource, O_RDWR)
mm = mmap(fd, 0)
val = pci_mem_write(mm, offset, val)
mm.close()
close(fd)
return val
fd = open(resource, O_RDWR)
mm = mmap(fd, 0)
val = pci_mem_write(mm, offset, val)
mm.close()
close(fd)
return val
for port_num in range(PORT_START, PORT_END+1):
port_offset = 0x400c + ((port_num) * 16)
pci_set_value(BASE_RES_PATH, 0x30, port_offset)
port_offset = 0x400c + ((port_num) * 16)
pci_set_value(BASE_RES_PATH, 0x30, port_offset)

View File

@ -104,14 +104,14 @@ switch_board_modsel() {
do
port_addr=$(( 16384 + ((i - 1) * 16)))
hex=$( printf "0x%x" $port_addr )
python /usr/bin/pcisysfs.py --set --offset $hex --val 0x10 --res $resource > /dev/null 2>&1
/usr/bin/pcisysfs.py --set --offset $hex --val 0x10 --res $resource > /dev/null 2>&1
done
}
#This enables the led control for CPU and default states
switch_board_led_default() {
resource="/sys/bus/pci/devices/0000:04:00.0/resource0"
python /usr/bin/pcisysfs.py --set --offset 0x24 --val 0x194 --res $resource > /dev/null 2>&1
/usr/bin/pcisysfs.py --set --offset 0x24 --val 0x194 --res $resource > /dev/null 2>&1
}
# Readout firmware version of the system and
@ -161,6 +161,7 @@ install_python_api_package() {
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() {
@ -168,6 +169,11 @@ remove_python_api_package() {
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
@ -186,7 +192,7 @@ if [ "$1" == "init" ]; then
switch_board_modsel
switch_board_led_default
install_python_api_package
python /usr/bin/qsfp_irq_enable.py
/usr/bin/qsfp_irq_enable.py
platform_firmware_versions
elif [ "$1" == "deinit" ]; then

View File

@ -8,9 +8,10 @@
#
#############################################################################
from __future__ import division
try:
import sys
from __future__ import division
import sys
from sonic_platform_base.chassis_base import ChassisBase
from sonic_platform.sfp import Sfp
from sonic_platform.eeprom import Eeprom
@ -46,7 +47,7 @@ class Chassis(ChassisBase):
self.PORT_START = 1
self.PORT_END = 34
self.PORTS_IN_BLOCK = (self.PORT_END + 1)
_sfp_port = range(33, self.PORT_END + 1)
_sfp_port = list(range(33, self.PORT_END + 1))
eeprom_base = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"
for index in range(self.PORT_START, self.PORTS_IN_BLOCK):
@ -112,7 +113,7 @@ class Chassis(ChassisBase):
if elapsed_time_ms > timeout:
break
time.sleep(sleep_time)
sleep(sleep_time)
return True, change_dict
def get_sfp(self, index):
@ -188,14 +189,6 @@ class Chassis(ChassisBase):
"""
return self._eeprom.base_mac_addr('')
def get_serial_number(self):
"""
Retrieves the hardware serial number for the chassis
Returns:
A string containing the hardware serial number for this chassis.
"""
return self._eeprom.serial_number_str()
def get_system_eeprom_info(self):
"""
Retrieves the full content of system EEPROM information for the chassis

View File

@ -13,22 +13,22 @@ try:
import subprocess
from sonic_platform_base.component_base import ComponentBase
import sonic_platform.hwaccess as hwaccess
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
def get_bios_version():
return subprocess.check_output(['dmidecode', '-s', 'system-version']).strip()
return subprocess.check_output(['dmidecode', '-s', 'system-version']).decode('utf-8').strip()
def get_fpga_version():
val = hwaccess.pci_get_value('/sys/bus/pci/devices/0000:04:00.0/resource0', 0)
return '{}.{}'.format((val >> 8) & 0xff, val & 0xff)
def get_bmc_version():
return subprocess.check_output(
['cat', '/sys/class/ipmi/ipmi0/device/bmc/firmware_revision']
).strip()
).decode('utf-8').strip()
def get_cpld_version(bus, i2caddr):
return '{}.{}'.format(hwaccess.i2c_get(bus, i2caddr, 1),
@ -60,8 +60,7 @@ class Component(ComponentBase):
],
['BMC',
'Platform management controller for on-board temperature ',
'monitoring, in-chassis power, Fan and LED control',
'Platform management controller for on-board temperature monitoring, in-chassis power, Fan and LED control',
get_bmc_version
],

View File

@ -12,7 +12,7 @@ try:
import os.path
from sonic_eeprom import eeprom_tlvinfo
import binascii
except ImportError, e:
except ImportError as e:
raise ImportError(str(e) + "- required module not found")

View File

@ -168,7 +168,7 @@ class Fan(FanBase):
if not is_valid or self.max_speed == 0:
speed = 0
else:
speed = (100 * fan_speed)/self.max_speed
speed = (100 * fan_speed)//self.max_speed
return speed
def get_speed_rpm(self):

View File

@ -111,7 +111,7 @@ class Psu(PsuBase):
if not is_valid:
voltage = 0
return "{:.1f}".format(voltage)
return float(voltage)
def get_current(self):
"""
@ -125,7 +125,7 @@ class Psu(PsuBase):
if not is_valid:
current = 0
return "{:.1f}".format(current)
return float(current)
def get_power(self):
"""
@ -139,7 +139,7 @@ class Psu(PsuBase):
if not is_valid:
power = 0
return "{:.1f}".format(power)
return float(power)
def get_powergood_status(self):
"""

View File

@ -94,7 +94,7 @@ class Thermal(ThermalBase):
if not is_valid:
temperature = 0
return "{:.3f}".format(temperature)
return float(temperature)
def get_high_threshold(self):
"""
@ -109,7 +109,7 @@ class Thermal(ThermalBase):
if not is_valid:
high_threshold = 0
return "{:.3f}".format(high_threshold)
return float(high_threshold)
def get_low_threshold(self):
"""
@ -124,7 +124,7 @@ class Thermal(ThermalBase):
if not is_valid:
low_threshold = 0
return "{:.3f}".format(low_threshold)
return float(low_threshold)
def set_high_threshold(self, temperature):
"""

View File

@ -1,102 +0,0 @@
#!/usr/bin/python
# Copyright (c) 2015 Dell Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
# LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS
# FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
#
# See the Apache Version 2.0 License for specific language governing
# permissions and limitations under the License.
import struct
import sys
import getopt
from os import *
from mmap import *
def usage():
''' This is the Usage Method '''
print '\t\t pcisysfs.py --get --offset <offset> --res <resource>'
print '\t\t pcisysfs.py --set --val <val> --offset <offset> --res <resource>'
sys.exit(1)
def pci_mem_read(mm,offset):
mm.seek(offset)
read_data_stream=mm.read(4)
print ""
reg_val=struct.unpack('I',read_data_stream)
print "reg_val read:%x"%reg_val
return reg_val
def pci_mem_write(mm,offset,data):
mm.seek(offset)
print "data to write:%x"%data
mm.write(struct.pack('I',data))
def pci_set_value(resource,val,offset):
fd=open(resource,O_RDWR)
mm=mmap(fd,0)
pci_mem_write(mm,offset,val)
def pci_get_value(resource,offset):
fd=open(resource,O_RDWR)
mm=mmap(fd,0)
pci_mem_read(mm,offset)
def main(argv):
''' The main function will read the user input from the
command line argument and process the request '''
opts = ''
val = ''
choice = ''
resource = ''
offset = ''
try:
opts, args = getopt.getopt(argv, "hgsv:" , \
["val=","res=","offset=","help", "get", "set"])
except getopt.GetoptError:
usage()
for opt,arg in opts:
if opt in ('-h','--help'):
choice = 'help'
elif opt in ('-g', '--get'):
choice = 'get'
elif opt in ('-s', '--set'):
choice = 'set'
elif opt == '--res':
resource = arg
elif opt == '--val':
val = int(arg,16)
elif opt == '--offset':
offset = int(arg,16)
if choice == 'set' and val != '' and offset !='' and resource !='':
pci_set_value(resource,val,offset)
elif choice == 'get' and offset != '' and resource !='':
pci_get_value(resource,offset)
else:
usage()
#Calling the main method
if __name__ == "__main__":
main(sys.argv[1:])

View File

@ -1,9 +1,9 @@
#!/usr/bin/python
#!/usr/bin/python3
# On S5248F, the BaseBoard Management Controller is an
# autonomous subsystem provides monitoring and management
# facility independent of the host CPU. IPMI standard
# protocol is used with ipmitool to fetch sensor details.
# Current script support X00 board only. X01 support will
# Current script support X00 board only. X01 support will
# be added soon. This provies support for the
# following objects:
# * Onboard temperature sensors
@ -11,11 +11,9 @@
# * PSU
import os
import sys
import logging
import subprocess
import commands
S5248F_MAX_FAN_TRAYS = 4
S5248F_MAX_PSUS = 2
@ -39,7 +37,7 @@ def ipmi_sensor_dump():
status = 1
global ipmi_sdr_list
ipmi_cmd = IPMI_SENSOR_DATA
status, ipmi_sdr_list = commands.getstatusoutput(ipmi_cmd)
status, ipmi_sdr_list = subprocess.getstatusoutput(ipmi_cmd)
if status:
logging.error('Failed to execute:' + ipmi_sdr_list)
@ -56,7 +54,7 @@ def get_pmc_register(reg_name):
output = item.strip()
if output is None:
print('\nFailed to fetch: ' + reg_name + ' sensor ')
print('\nFailed to fetch: ' + reg_name + ' sensor ')
sys.exit(0)
output = output.split('|')[1]
@ -72,18 +70,18 @@ def print_temperature_sensors():
print("\nOnboard Temperature Sensors:")
print ' PT_Left_temp: ',\
(get_pmc_register('PT_Left_temp'))
print ' PT_Mid_temp: ',\
(get_pmc_register('PT_Mid_temp'))
print ' PT_Right_temp: ',\
(get_pmc_register('PT_Right_temp'))
print ' Broadcom Temp: ',\
(get_pmc_register('NPU_Near_temp'))
print ' Inlet Airflow Temp: ',\
(get_pmc_register('ILET_AF_temp'))
print ' CPU Temp: ',\
(get_pmc_register('CPU_temp'))
print(' PT_Left_temp: ',
get_pmc_register('PT_Left_temp'))
print(' PT_Mid_temp: ',
get_pmc_register('PT_Mid_temp'))
print(' PT_Right_temp: ',
get_pmc_register('PT_Right_temp'))
print(' Broadcom Temp: ',
get_pmc_register('NPU_Near_temp'))
print(' Inlet Airflow Temp: ',
get_pmc_register('ILET_AF_temp'))
print(' CPU Temp: ',
get_pmc_register('CPU_temp'))
ipmi_sensor_dump()
@ -97,63 +95,63 @@ def print_fan_tray(tray):
Fan_Status = [' Normal', ' Abnormal']
Airflow_Direction = ['B2F', 'F2B']
print ' Fan Tray ' + str(tray) + ':'
print(' Fan Tray ' + str(tray) + ':')
if (tray == 1):
fan1_status = int(get_pmc_register('FAN1_Front_stat'), 16)
fan2_status = int(get_pmc_register('FAN1_Rear_stat'), 16)
print ' Fan1 Speed: ',\
get_pmc_register('FAN1_Front_rpm')
print ' Fan2 Speed: ',\
get_pmc_register('FAN1_Rear_rpm')
print ' Fan1 State: ',\
Fan_Status[fan1_status]
print ' Fan2 State: ',\
Fan_Status[fan2_status]
print(' Fan1 Speed: ',
get_pmc_register('FAN1_Front_rpm'))
print(' Fan2 Speed: ',
get_pmc_register('FAN1_Rear_rpm'))
print(' Fan1 State: ',
Fan_Status[fan1_status])
print(' Fan2 State: ',
Fan_Status[fan2_status])
elif (tray == 2):
fan1_status = int(get_pmc_register('FAN2_Front_stat'), 16)
fan2_status = int(get_pmc_register('FAN2_Rear_stat'), 16)
print ' Fan1 Speed: ',\
get_pmc_register('FAN2_Front_rpm')
print ' Fan2 Speed: ',\
get_pmc_register('FAN2_Rear_rpm')
print ' Fan1 State: ',\
Fan_Status[fan1_status]
print ' Fan2 State: ',\
Fan_Status[fan2_status]
print(' Fan1 Speed: ',
get_pmc_register('FAN2_Front_rpm'))
print(' Fan2 Speed: ',
get_pmc_register('FAN2_Rear_rpm'))
print(' Fan1 State: ',
Fan_Status[fan1_status])
print(' Fan2 State: ',
Fan_Status[fan2_status])
elif (tray == 3):
fan1_status = int(get_pmc_register('FAN3_Front_stat'), 16)
fan2_status = int(get_pmc_register('FAN3_Rear_stat'), 16)
print ' Fan1 Speed: ',\
get_pmc_register('FAN3_Front_rpm')
print ' Fan2 Speed: ',\
get_pmc_register('FAN3_Rear_rpm')
print ' Fan1 State: ',\
Fan_Status[fan1_status]
print ' Fan2 State: ',\
Fan_Status[fan2_status]
print(' Fan1 Speed: ',
get_pmc_register('FAN3_Front_rpm'))
print(' Fan2 Speed: ',
get_pmc_register('FAN3_Rear_rpm'))
print(' Fan1 State: ',
Fan_Status[fan1_status])
print(' Fan2 State: ',
Fan_Status[fan2_status])
elif (tray == 4):
fan1_status = int(get_pmc_register('FAN4_Front_stat'), 16)
fan2_status = int(get_pmc_register('FAN4_Rear_stat'), 16)
print ' Fan1 Speed: ',\
get_pmc_register('FAN4_Front_rpm')
print ' Fan2 Speed: ',\
get_pmc_register('FAN4_Rear_rpm')
print ' Fan1 State: ',\
Fan_Status[fan1_status]
print ' Fan2 State: ',\
Fan_Status[fan2_status]
print(' Fan1 Speed: ',
get_pmc_register('FAN4_Front_rpm'))
print(' Fan2 Speed: ',
get_pmc_register('FAN4_Rear_rpm'))
print(' Fan1 State: ',
Fan_Status[fan1_status])
print(' Fan2 State: ',
Fan_Status[fan2_status])
print('\nFan Trays:')
@ -163,7 +161,7 @@ for tray in range(1, S5248F_MAX_FAN_TRAYS + 1):
if (get_pmc_register(fan_presence)):
print_fan_tray(tray)
else:
print '\n Fan Tray ' + str(tray + 1) + ': Not present'
print('\n Fan Tray ' + str(tray + 1) + ': Not present')
def get_psu_presence(index):
"""
@ -176,9 +174,9 @@ for tray in range(1, S5248F_MAX_FAN_TRAYS + 1):
ret_status = 1
if index == 1:
status, ipmi_cmd_ret = commands.getstatusoutput(IPMI_PSU1_DATA_DOCKER)
status, ipmi_cmd_ret = subprocess.getstatusoutput(IPMI_PSU1_DATA_DOCKER)
elif index == 2:
ret_status, ipmi_cmd_ret = commands.getstatusoutput(IPMI_PSU2_DATA_DOCKER)
ret_status, ipmi_cmd_ret = subprocess.getstatusoutput(IPMI_PSU2_DATA_DOCKER)
#if ret_status:
# print ipmi_cmd_ret
@ -214,54 +212,54 @@ def print_psu(psu):
# psu1_fan_status = int(get_pmc_register('PSU1_status'),16)
print ' PSU1:'
print ' FAN Normal Temperature: ',\
get_pmc_register('PSU1_temp')
print ' FAN AirFlow Temperature: ',\
get_pmc_register('PSU1_AF_temp')
print ' FAN RPM: ',\
get_pmc_register('PSU1_rpm')
print(' PSU1:')
print(' FAN Normal Temperature: ',
get_pmc_register('PSU1_temp'))
print(' FAN AirFlow Temperature: ',
get_pmc_register('PSU1_AF_temp'))
print(' FAN RPM: ',
get_pmc_register('PSU1_rpm'))
# print ' FAN Status: ', Psu_Fan_Status[psu1_fan_status]
# PSU input & output monitors
print ' Input Voltage: ',\
get_pmc_register('PSU1_In_volt')
print ' Output Voltage: ',\
get_pmc_register('PSU1_Out_volt')
print ' Input Power: ',\
get_pmc_register('PSU1_In_watt')
print ' Output Power: ',\
get_pmc_register('PSU1_Out_watt')
print ' Input Current: ',\
get_pmc_register('PSU1_In_amp')
print ' Output Current: ',\
get_pmc_register('PSU1_Out_amp')
print(' Input Voltage: ',
get_pmc_register('PSU1_In_volt'))
print(' Output Voltage: ',
get_pmc_register('PSU1_Out_volt'))
print(' Input Power: ',
get_pmc_register('PSU1_In_watt'))
print(' Output Power: ',
get_pmc_register('PSU1_Out_watt'))
print(' Input Current: ',
get_pmc_register('PSU1_In_amp'))
print(' Output Current: ',
get_pmc_register('PSU1_Out_amp'))
else:
# psu2_fan_status = int(get_pmc_register('PSU1_status'),16)
print ' PSU2:'
print ' FAN Normal Temperature: ',\
get_pmc_register('PSU2_temp')
print ' FAN AirFlow Temperature: ',\
get_pmc_register('PSU2_AF_temp')
print ' FAN RPM: ',\
get_pmc_register('PSU2_rpm')
print(' PSU2:')
print(' FAN Normal Temperature: ',
get_pmc_register('PSU2_temp'))
print(' FAN AirFlow Temperature: ',
get_pmc_register('PSU2_AF_temp'))
print(' FAN RPM: ',
get_pmc_register('PSU2_rpm'))
# print ' FAN Status: ', Psu_Fan_Status[psu2_fan_status]
# PSU input & output monitors
print ' Input Voltage: ',\
get_pmc_register('PSU2_In_volt')
print ' Output Voltage: ',\
get_pmc_register('PSU2_Out_volt')
print ' Input Power: ',\
get_pmc_register('PSU2_In_watt')
print ' Output Power: ',\
get_pmc_register('PSU2_Out_watt')
print ' Input Current: ',\
get_pmc_register('PSU2_In_amp')
print ' Output Current: ',\
get_pmc_register('PSU2_Out_amp')
print(' Input Voltage: ',
get_pmc_register('PSU2_In_volt'))
print(' Output Voltage: ',
get_pmc_register('PSU2_Out_volt'))
print(' Input Power: ',
get_pmc_register('PSU2_In_watt'))
print(' Output Power: ',
get_pmc_register('PSU2_Out_watt'))
print(' Input Current: ',
get_pmc_register('PSU2_In_amp'))
print(' Output Current: ',
get_pmc_register('PSU2_Out_amp'))
print('\nPSUs:')
@ -270,8 +268,7 @@ for psu in range(1, S5248F_MAX_PSUS + 1):
if (get_psu_presence(psu)):
print_psu(psu)
else:
print '\n PSU ', psu, 'Not present'
print '\n Total Power: ',\
get_pmc_register('PSU_Total_watt')
print('\n PSU ', psu, 'Not present')
print('\n Total Power: ',
get_pmc_register('PSU_Total_watt'))

View File

@ -82,7 +82,7 @@ switch_board_modsel() {
do
port_addr=$(( 16384 + ((i - 1) * 16)))
hex=$( printf "0x%x" $port_addr )
python /usr/bin/pcisysfs.py --set --offset $hex --val 0x10 --res $resource > /dev/null 2>&1
/usr/bin/pcisysfs.py --set --offset $hex --val 0x10 --res $resource > /dev/null 2>&1
done
}
@ -129,7 +129,7 @@ platform_firmware_versions() {
#This enables the led control for CPU and default states
switch_board_led_default() {
resource="/sys/bus/pci/devices/0000:04:00.0/resource0"
python /usr/bin/pcisysfs.py --set --offset 0x24 --val 0x194 --res $resource > /dev/null 2>&1
/usr/bin/pcisysfs.py --set --offset 0x24 --val 0x194 --res $resource > /dev/null 2>&1
}
init_devnum
@ -145,7 +145,7 @@ if [ "$1" == "init" ]; then
switch_board_qsfp "new_device"
switch_board_modsel
switch_board_led_default
#python /usr/bin/qsfp_irq_enable.py
#/usr/bin/qsfp_irq_enable.py
platform_firmware_versions
elif [ "$1" == "deinit" ]; then

View File

@ -76,17 +76,21 @@ switch_board_qsfp_lpmode() {
install_python_api_package() {
device="/usr/share/sonic/device"
platform=${PLATFORM:-`/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`}
platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)
if [ -e $device/$platform/sonic_platform-1.0-py2-none-any.whl ]; then
rv=$(pip install $device/$platform/sonic_platform-1.0-py2-none-any.whl)
fi
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)
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
}

View File

@ -10,9 +10,7 @@
try:
import os
import time
import datetime
import struct
import subprocess
from sonic_platform_base.chassis_base import ChassisBase
from sonic_platform.sfp import Sfp
from sonic_platform.eeprom import Eeprom, EepromS6000
@ -190,16 +188,6 @@ class Chassis(ChassisBase):
"""
return self._eeprom.get_base_mac()
def get_serial_number(self):
"""
Retrieves the hardware serial number for the chassis
Returns:
A string containing the hardware serial number for this
chassis.
"""
return self._eeprom.get_serial_number()
def get_system_eeprom_info(self):
"""
Retrieves the full content of system EEPROM information for the

View File

@ -61,7 +61,7 @@ class Component(ComponentBase):
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
result = stdout.rstrip('\n')
result = stdout.decode('utf-8').rstrip('\n')
except OSError:
result = None

View File

@ -200,7 +200,7 @@ class Eeprom(TlvInfoDecoder):
for field in self.format:
field_end = field_start + field[2]
if field[0] == field_name:
return (True, self.eeprom_data[field_start:field_end])
return (True, self.eeprom_data[field_start:field_end].decode('utf-8'))
field_start = field_end
return (False, None)
@ -222,9 +222,9 @@ class Eeprom(TlvInfoDecoder):
Returns the airflow fan type.
"""
if self.is_psu_eeprom:
return int(self.psu_type.encode('hex'), 16)
return int(binascii.hexlify(self.psu_type.encode('utf-8')), 16)
else:
return int(self.fan_type.encode('hex'), 16)
return int(binascii.hexlify(self.fan_type.encode('utf-8')), 16)
# System EEPROM specific methods
def get_base_mac(self):
@ -323,13 +323,13 @@ class EepromS6000(EepromDecoder):
"""
Decode and print out the contents of the EEPROM.
"""
print " Field Name Len Value"
print "-------------------- --- --------------------"
for blk_code in self._BLK_INFO.keys():
print(" Field Name Len Value")
print("-------------------- --- --------------------")
for blk_code in list(self._BLK_INFO.keys()):
blk_start = self._BLK_INFO[blk_code]["offset"]
blk_end = blk_start + self._BLK_INFO[blk_code]["size"]
if not self._is_valid_block(e[blk_start:blk_end], blk_code):
print "Invalid Block starting at EEPROM offset %d" % (blk_start)
print("Invalid Block starting at EEPROM offset %d" % (blk_start))
return
offset = blk_start + self._BLK_HDR_LEN
@ -342,11 +342,11 @@ class EepromS6000(EepromDecoder):
data = ":".join([binascii.b2a_hex(T) for T in e[offset:offset+f[1]]]).upper()
else:
data = e[offset:offset+f[1]]
print "{:<20s} {:>3d} {:<s}".format(f[0], f[1], data)
print("{:<20s} {:>3d} {:<s}".format(f[0], f[1], data))
offset += f[1]
if not self._is_valid_block_checksum(e[blk_start:blk_end]):
print "(*** block checksum invalid)"
print("(*** block checksum invalid)")
def read_eeprom(self):
"""
@ -363,23 +363,23 @@ class EepromS6000(EepromDecoder):
if db_state != '1':
return -1
print " Field Name Len Value"
print "-------------------- --- --------------------"
for blk_code in self._BLK_INFO.keys():
print(" Field Name Len Value")
print("-------------------- --- --------------------")
for blk_code in list(self._BLK_INFO.keys()):
blk_name = self._BLK_INFO[blk_code]["name"]
blk_start = self._BLK_INFO[blk_code]["offset"]
is_valid = client.hget('EEPROM_INFO|{}'.format(blk_name), 'Valid')
if is_valid == '0':
print "Invalid Block starting at EEPROM offset %d" % (blk_start)
print("Invalid Block starting at EEPROM offset %d" % (blk_start))
break
for f in self._BLK_INFO[blk_code]["format"]:
data = client.hget('EEPROM_INFO|{}'.format(f[0]), 'Value')
print "{:<20s} {:>3d} {:<s}".format(f[0], f[1], data)
print("{:<20s} {:>3d} {:<s}".format(f[0], f[1], data))
is_checksum_valid = client.hget('EEPROM_INFO|{}'.format(blk_name), 'Checksum_Valid')
if is_checksum_valid == '0':
print "(*** block checksum invalid)"
print("(*** block checksum invalid)")
return 0
@ -388,13 +388,13 @@ class EepromS6000(EepromDecoder):
Decode the contents of the EEPROM and update the contents to database
"""
client = redis.Redis(db=STATE_DB_INDEX)
for blk_code in self._BLK_INFO.keys():
for blk_code in list(self._BLK_INFO.keys()):
blk_name = self._BLK_INFO[blk_code]["name"]
blk_start = self._BLK_INFO[blk_code]["offset"]
blk_end = blk_start + self._BLK_INFO[blk_code]["size"]
if not self._is_valid_block(e[blk_start:blk_end], blk_code):
client.hset('EEPROM_INFO|{}'.format(blk_name), 'Valid', '0')
print "Invalid Block starting at EEPROM offset %d" % (blk_start)
print("Invalid Block starting at EEPROM offset %d" % (blk_start))
break
else:
client.hset('EEPROM_INFO|{}'.format(blk_name), 'Valid', '1')

View File

@ -87,7 +87,7 @@ class Fan(FanBase):
cpld_reg_file = self.CPLD_DIR + reg_name
if (not os.path.isfile(cpld_reg_file)):
print "open error"
print("open error")
return rv
try:
@ -251,7 +251,7 @@ class Fan(FanBase):
fan_speed = self._get_i2c_register(self.get_fan_speed_reg)
if (fan_speed != 'ERR') and self.get_presence():
speed_in_rpm = int(fan_speed, 10)
speed = (100 * speed_in_rpm)/self.max_fan_speed
speed = (100 * speed_in_rpm)//self.max_fan_speed
else:
speed = 0

View File

@ -168,7 +168,7 @@ class Psu(PsuBase):
status = False
psu_status = self._get_cpld_register(self.psu_status_reg)
if (psu_status != 'ERR'):
psu_status = (int(psu_status, 16) >> ((2 - self.index) * 4)) & 0xF
psu_status = (int(psu_status, 16) >> int((2 - self.index) * 4)) & 0xF
if (~psu_status & 0b1000) and (~psu_status & 0b0100):
status = True

View File

@ -241,7 +241,7 @@ class Sfp(SfpBase):
vendor_sn = vendor_sn_data['data']['Vendor SN']['value']
else:
return transceiver_info_dict
# Fill The Dictionary and return
transceiver_info_dict['type'] = identifier
transceiver_info_dict['hardware_rev'] = vendor_rev
@ -259,7 +259,7 @@ class Sfp(SfpBase):
compliance_code_dict)
transceiver_info_dict['vendor_date'] = vendor_date
transceiver_info_dict['vendor_oui'] = vendor_oui
transceiver_info_dict['type_abbrv_name']=type_abbrv_name
transceiver_info_dict['type_abbrv_name'] = type_abbrv_name
return transceiver_info_dict

View File

@ -1,4 +1,4 @@
#! /usr/bin/python
#!/usr/bin/python3
import struct
import sys
@ -7,35 +7,37 @@ from os import *
from mmap import *
def usage():
''' This is the Usage Method '''
''' This is the Usage Method '''
print '\t\t pcisysfs.py --get --offset <offset> --res <resource>'
print '\t\t pcisysfs.py --set --val <val> --offset <offset> --res <resource>'
sys.exit(1)
print('\t\t pcisysfs.py --get --offset <offset> --res <resource>')
print('\t\t pcisysfs.py --set --val <val> --offset <offset> --res <resource>')
sys.exit(1)
def pci_mem_read(mm,offset):
def pci_mem_read(mm, offset):
mm.seek(offset)
read_data_stream=mm.read(4)
print ""
reg_val=struct.unpack('I',read_data_stream)
print "reg_val read:%x"%reg_val
read_data_stream = mm.read(4)
print("")
reg_val = struct.unpack('I', read_data_stream)
print("reg_val read:%x" % reg_val)
return reg_val
def pci_mem_write(mm,offset,data):
def pci_mem_write(mm, offset, data):
mm.seek(offset)
#print "data to write:%x"%data
mm.write(struct.pack('I',data))
#print("data to write:%x" % data)
mm.write(struct.pack('I', data))
def pci_set_value(resource,val,offset):
fd=open(resource,O_RDWR)
mm=mmap(fd,0)
pci_mem_write(mm,offset,val)
def pci_set_value(resource, val, offset):
fd = open(resource, O_RDWR)
mm = mmap(fd, 0)
pci_mem_write(mm, offset, val)
mm.close()
close(fd)
def pci_get_value(resource,offset):
fd=open(resource,O_RDWR)
mm=mmap(fd,0)
pci_mem_read(mm,offset)
def pci_get_value(resource, offset):
fd = open(resource, O_RDWR)
mm = mmap(fd, 0)
pci_mem_read(mm, offset)
mm.close()
close(fd)
def main(argv):
@ -50,15 +52,15 @@ def main(argv):
offset = ''
try:
opts, args = getopt.getopt(argv, "hgsv:" , \
["val=","res=","offset=","help", "get", "set"])
opts, args = getopt.getopt(argv, "hgsv:",
["val=", "res=", "offset=", "help", "get", "set"])
except getopt.GetoptError:
usage()
for opt,arg in opts:
for opt, arg in opts:
if opt in ('-h','--help'):
if opt in ('-h', '--help'):
choice = 'help'
elif opt in ('-g', '--get'):
@ -67,25 +69,24 @@ def main(argv):
elif opt in ('-s', '--set'):
choice = 'set'
elif opt == '--res':
elif opt == '--res':
resource = arg
elif opt == '--val':
val = int(arg,16)
elif opt == '--val':
val = int(arg, 16)
elif opt == '--offset':
offset = int(arg,16)
elif opt == '--offset':
offset = int(arg, 16)
if choice == 'set' and val != '' and offset !='' and resource !='':
pci_set_value(resource,val,offset)
if choice == 'set' and val != '' and offset != '' and resource != '':
pci_set_value(resource, val, offset)
elif choice == 'get' and offset != '' and resource !='':
pci_get_value(resource,offset)
elif choice == 'get' and offset != '' and resource != '':
pci_get_value(resource, offset)
else:
usage()
#Calling the main method
# Calling the main method
if __name__ == "__main__":
main(sys.argv[1:])
main(sys.argv[1:])

View File

@ -1,5 +1,4 @@
#!/usr/bin/python
import sys
#!/usr/bin/python3
import os
import subprocess
import struct
@ -20,14 +19,14 @@ def ssd_hdparm_upgrade():
def portio_reg_write(resource, offset, val):
fd = os.open(resource, os.O_RDWR)
if(fd < 0):
print 'file open failed %s" % resource'
print('file open failed %s" % resource')
return
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
print 'lseek failed on %s' % resource
print('lseek failed on %s' % resource)
return
ret = os.write(fd, struct.pack('B', val))
if(ret != 1):
print 'write failed %d' % ret
print('write failed %d' % ret)
return
os.close(fd)
@ -35,4 +34,3 @@ if __name__ == "__main__":
log_software_reboot()
ssd_hdparm_upgrade()
portio_reg_write(PORT_RES, 0xcf9, 0xe)

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# On S6100, the Platform Management Controller runs the
# thermal algorithm. It provides a mailbox for the Host
@ -9,7 +9,6 @@
# * PSU
#
import os
import sys
import logging
S6100_MAX_FAN_TRAYS = 4
@ -29,7 +28,7 @@ def get_pmc_register(reg_name):
mb_reg_file = MAILBOX_DIR+'/'+reg_name
if (not os.path.isfile(mb_reg_file)):
print mb_reg_file, 'not found !'
print(mb_reg_file, 'not found !')
return retval
try:
@ -45,8 +44,8 @@ def get_pmc_register(reg_name):
logging.basicConfig(level=logging.DEBUG)
if (os.path.isdir(MAILBOX_DIR)):
print 'dell-s6100-lpc'
print 'Adapter: S6100 Platform Management Controller'
print('dell-s6100-lpc')
print('Adapter: S6100 Platform Management Controller')
else:
logging.error('S6100 Platform Management Controller module not loaded !')
# sys.exit(0)
@ -56,20 +55,20 @@ else:
def print_temperature_sensors():
print("\nOnboard Temperature Sensors:")
print ' CPU: ',\
int(get_pmc_register('temp1_input'))/1000, 'C'
print ' BCM56960 (PSU side): ',\
int(get_pmc_register('temp2_input'))/1000, 'C'
print ' System Outlet 1 (switch board): ',\
int(get_pmc_register('temp3_input'))/1000, 'C'
print ' BCM56960 (IO side): ',\
int(get_pmc_register('temp4_input'))/1000, 'C'
print ' System Outlet 2 (CPU board): ',\
int(get_pmc_register('temp9_input'))/1000, 'C'
print ' System Inlet Left (IO side): ',\
int(get_pmc_register('temp10_input'))/1000, 'C'
print ' System Inlet Right (IO side): ',\
int(get_pmc_register('temp11_input'))/1000, 'C'
print(' CPU: ',
int(get_pmc_register('temp1_input'))/1000, 'C')
print(' BCM56960 (PSU side): ',
int(get_pmc_register('temp2_input'))/1000, 'C')
print(' System Outlet 1 (switch board): ',
int(get_pmc_register('temp3_input'))/1000, 'C')
print(' BCM56960 (IO side): ',
int(get_pmc_register('temp4_input'))/1000, 'C')
print(' System Outlet 2 (CPU board): ',
int(get_pmc_register('temp9_input'))/1000, 'C')
print(' System Inlet Left (IO side): ',
int(get_pmc_register('temp10_input'))/1000, 'C')
print(' System Inlet Right (IO side): ',
int(get_pmc_register('temp11_input'))/1000, 'C')
iom_status = get_pmc_register('iom_presence')
iom_status = int(iom_status, 16)
@ -84,9 +83,9 @@ def print_temperature_sensors():
for iom in range(0, S6100_MAX_IOMS):
if (~iom_presence & (1 << iom)):
iom_sensor_indx = iom + 5
print ' IOM ' + str(iom + 1) + ':\t\t\t ',\
int(get_pmc_register('temp'+str(iom_sensor_indx) +
'_input'))/1000, 'C'
print(' IOM ' + str(iom + 1) + ':\t\t\t ',
int(get_pmc_register('temp' + str(iom_sensor_indx) +
'_input'))/1000, 'C')
# Save the IOM Status for later use
if (~iom_status & (1 << iom)):
@ -95,7 +94,7 @@ def print_temperature_sensors():
iom_status_list.append('OFF')
else:
iom_status_list.append('Not present')
print ' IOM ' + str(iom + 1) + ':\t\t\t ', 'Not present'
print(' IOM ' + str(iom + 1) + ':\t\t\t ', 'Not present')
else:
logging.error('Unable to check IOM presence')
@ -108,56 +107,56 @@ print_temperature_sensors()
def print_voltage_sensors():
print("\nOnboard Voltage Sensors:")
print ' CPU XP3R3V_EARLY ',\
float(get_pmc_register('in1_input'))/1000, 'V'
print ' CPU XP5R0V_CP ',\
float(get_pmc_register('in2_input'))/1000, 'V'
print ' CPU XP3R3V_STD ',\
float(get_pmc_register('in3_input'))/1000, 'V'
print ' CPU XP3R3V_CP ',\
float(get_pmc_register('in4_input'))/1000, 'V'
print ' CPU XP0R75V_VTT_A ',\
float(get_pmc_register('in5_input'))/1000, 'V'
print ' CPU XPPR75V_VTT_B ',\
float(get_pmc_register('in6_input'))/1000, 'V'
print ' CPU XP1R07V_CPU ',\
float(get_pmc_register('in7_input'))/1000, 'V'
print ' CPU XP1R0V_CPU ',\
float(get_pmc_register('in8_input'))/1000, 'V'
print ' CPU XP12R0V ',\
float(get_pmc_register('in9_input'))/1000, 'V'
print ' CPU VDDR_CPU_2 ',\
float(get_pmc_register('in10_input'))/1000, 'V'
print ' CPU VDDR_CPU_1 ',\
float(get_pmc_register('in11_input'))/1000, 'V'
print ' CPU XP1R5V_CLK ',\
float(get_pmc_register('in12_input'))/1000, 'V'
print ' CPU XP1R8V_CPU ',\
float(get_pmc_register('in13_input'))/1000, 'V'
print ' CPU XP1R0V_CPU_VNN ',\
float(get_pmc_register('in14_input'))/1000, 'V'
print ' CPU XP1R0V_CPU_VCC ',\
float(get_pmc_register('in15_input'))/1000, 'V'
print ' CPU XP1R5V_EARLY ',\
float(get_pmc_register('in16_input'))/1000, 'V'
print ' SW XP3R3V_MON ',\
float(get_pmc_register('in17_input'))/1000, 'V'
print ' SW XP1R25V_MON ',\
float(get_pmc_register('in19_input'))/1000, 'V'
print ' SW XP1R2V_MON ',\
float(get_pmc_register('in20_input'))/1000, 'V'
print ' SW XP1R0V_SW_MON ',\
float(get_pmc_register('in21_input'))/1000, 'V'
print ' SW XP1R0V_ROV_SW_MON ',\
float(get_pmc_register('in22_input'))/1000, 'V'
print ' SW XR1R0V_BCM84752_MON ',\
float(get_pmc_register('in23_input'))/1000, 'V'
print ' SW XP5V_MB_MON ',\
float(get_pmc_register('in24_input'))/1000, 'V'
print ' SW XP3R3V_FPGA_MON ',\
float(get_pmc_register('in26_input'))/1000, 'V'
print ' SW XP3R3V_EARLY_MON ',\
float(get_pmc_register('in27_input'))/1000, 'V'
print(' CPU XP3R3V_EARLY ',
float(get_pmc_register('in1_input'))/1000, 'V')
print(' CPU XP5R0V_CP ',
float(get_pmc_register('in2_input'))/1000, 'V')
print(' CPU XP3R3V_STD ',
float(get_pmc_register('in3_input'))/1000, 'V')
print(' CPU XP3R3V_CP ',
float(get_pmc_register('in4_input'))/1000, 'V')
print(' CPU XP0R75V_VTT_A ',
float(get_pmc_register('in5_input'))/1000, 'V')
print(' CPU XPPR75V_VTT_B ',
float(get_pmc_register('in6_input'))/1000, 'V')
print(' CPU XP1R07V_CPU ',
float(get_pmc_register('in7_input'))/1000, 'V')
print(' CPU XP1R0V_CPU ',
float(get_pmc_register('in8_input'))/1000, 'V')
print(' CPU XP12R0V ',
float(get_pmc_register('in9_input'))/1000, 'V')
print(' CPU VDDR_CPU_2 ',
float(get_pmc_register('in10_input'))/1000, 'V')
print(' CPU VDDR_CPU_1 ',
float(get_pmc_register('in11_input'))/1000, 'V')
print(' CPU XP1R5V_CLK ',
float(get_pmc_register('in12_input'))/1000, 'V')
print(' CPU XP1R8V_CPU ',
float(get_pmc_register('in13_input'))/1000, 'V')
print(' CPU XP1R0V_CPU_VNN ',
float(get_pmc_register('in14_input'))/1000, 'V')
print(' CPU XP1R0V_CPU_VCC ',
float(get_pmc_register('in15_input'))/1000, 'V')
print(' CPU XP1R5V_EARLY ',
float(get_pmc_register('in16_input'))/1000, 'V')
print(' SW XP3R3V_MON ',
float(get_pmc_register('in17_input'))/1000, 'V')
print(' SW XP1R25V_MON ',
float(get_pmc_register('in19_input'))/1000, 'V')
print(' SW XP1R2V_MON ',
float(get_pmc_register('in20_input'))/1000, 'V')
print(' SW XP1R0V_SW_MON ',
float(get_pmc_register('in21_input'))/1000, 'V')
print(' SW XP1R0V_ROV_SW_MON ',
float(get_pmc_register('in22_input'))/1000, 'V')
print(' SW XR1R0V_BCM84752_MON ',
float(get_pmc_register('in23_input'))/1000, 'V')
print(' SW XP5V_MB_MON ',
float(get_pmc_register('in24_input'))/1000, 'V')
print(' SW XP3R3V_FPGA_MON ',
float(get_pmc_register('in26_input'))/1000, 'V')
print(' SW XP3R3V_EARLY_MON ',
float(get_pmc_register('in27_input'))/1000, 'V')
print_voltage_sensors()
@ -169,40 +168,40 @@ def print_fan_tray(tray):
Fan_Status = ['Normal', 'Abnormal']
Airflow_Direction = ['B2F', 'F2B']
print ' Fan Tray ' + str(tray) + ':'
print(' Fan Tray ' + str(tray) + ':')
if (tray == 1):
fan1_speed = get_pmc_register('fan1_input')
fan1_speed = int(get_pmc_register('fan1_input'))
air_flow_reg = int(get_pmc_register('fan1_airflow'), 16)
fan1_status = 0 if fan1_speed >= 1000 else 1
print ' Fan Speed: ', fan1_speed, 'RPM'
print ' Fan State: ', Fan_Status[fan1_status]
print ' Air Flow: ', Airflow_Direction[air_flow_reg]
print(' Fan Speed: ', fan1_speed, 'RPM')
print(' Fan State: ', Fan_Status[fan1_status])
print(' Air Flow: ', Airflow_Direction[air_flow_reg])
elif (tray == 2):
fan1_speed = get_pmc_register('fan3_input')
fan1_speed = int(get_pmc_register('fan3_input'))
air_flow_reg = int(get_pmc_register('fan3_airflow'), 16)
fan1_status = 0 if fan1_speed >= 1000 else 1
print ' Fan Speed: ', fan1_speed, 'RPM'
print ' Fan State: ', Fan_Status[fan1_status]
print ' Air Flow: ', Airflow_Direction[air_flow_reg]
print(' Fan Speed: ', fan1_speed, 'RPM')
print(' Fan State: ', Fan_Status[fan1_status])
print(' Air Flow: ', Airflow_Direction[air_flow_reg])
elif (tray == 3):
fan1_speed = get_pmc_register('fan5_input')
fan1_speed = int(get_pmc_register('fan5_input'))
air_flow_reg = int(get_pmc_register('fan5_airflow'), 16)
fan1_status = 0 if fan1_speed >= 1000 else 1
print ' Fan Speed: ', fan1_speed, 'RPM'
print ' Fan State: ', Fan_Status[fan1_status]
print ' Air Flow: ', Airflow_Direction[air_flow_reg]
print(' Fan Speed: ', fan1_speed, 'RPM')
print(' Fan State: ', Fan_Status[fan1_status])
print(' Air Flow: ', Airflow_Direction[air_flow_reg])
elif (tray == 4):
fan1_speed = get_pmc_register('fan7_input')
fan1_speed = int(get_pmc_register('fan7_input'))
air_flow_reg = int(get_pmc_register('fan7_airflow'), 16)
fan1_status = 0 if fan1_speed >= 1000 else 1
print ' Fan Speed: ', fan1_speed, 'RPM'
print ' Fan State: ', Fan_Status[fan1_status]
print ' Air Flow: ', Airflow_Direction[air_flow_reg]
print(' Fan Speed: ', fan1_speed, 'RPM')
print(' Fan State: ', Fan_Status[fan1_status])
print(' Air Flow: ', Airflow_Direction[air_flow_reg])
print('\nFan Trays:')
fan_tray_presence = get_pmc_register('fan_tray_presence')
@ -214,7 +213,7 @@ if (fan_tray_presence != 'ERR'):
if (fan_tray_presence & (1 << tray)):
print_fan_tray(tray + 1)
else:
print '\n Fan Tray ' + str(tray + 1) + ': Not present'
print('\n Fan Tray ' + str(tray + 1) + ': Not present')
else:
logging.error('Unable to read FAN presence')
@ -233,7 +232,7 @@ def print_psu(psu):
Psu_Fan_Status = ['Normal', 'Abnormal']
Psu_Fan_Airflow = ['B2F', 'F2B']
print ' PSU ' + str(psu) + ':'
print(' PSU ' + str(psu) + ':')
if (psu == 1):
psu_status = int(get_pmc_register('psu1_presence'), 16)
else:
@ -244,12 +243,12 @@ def print_psu(psu):
psu_type = (psu_status & (1 << PSU_STATUS_TYPE_BIT)) >>\
PSU_STATUS_TYPE_BIT
print ' Input: ', Psu_Input_Type[psu_input_type]
print ' Type: ', Psu_Type[psu_type]
print(' Input: ', Psu_Input_Type[psu_input_type])
print(' Type: ', Psu_Type[psu_type])
# PSU FAN details
if (psu == 1):
print ' FAN Speed: ', get_pmc_register('fan11_input'), 'RPM'
print(' FAN Speed: ', get_pmc_register('fan11_input'), 'RPM')
psu_fan_airflow = int(get_pmc_register('fan11_airflow'))
psu_fan_status = int(get_pmc_register('fan11_alarm'))
psu_fan_present = int(get_pmc_register('fan11_fault'))
@ -262,7 +261,7 @@ def print_psu(psu):
if (input_power != 0):
psu_fan_temp = int(get_pmc_register('temp14_input'))/1000
else:
print ' FAN Speed: ', get_pmc_register('fan12_input'), 'RPM'
print(' FAN Speed: ', get_pmc_register('fan12_input'), 'RPM')
psu_fan_airflow = int(get_pmc_register('fan12_airflow'))
psu_fan_status = int(get_pmc_register('fan12_alarm'))
psu_fan_present = int(get_pmc_register('fan12_fault'))
@ -274,28 +273,28 @@ def print_psu(psu):
output_power = float(get_pmc_register('power4_input')) / 1000000
if (input_power != 0):
psu_fan_temp = int(get_pmc_register('temp15_input'))/1000
print ' FAN: ', Psu_Fan_Presence[psu_fan_present]
print ' FAN Status: ', Psu_Fan_Status[psu_fan_status]
print ' FAN AIRFLOW: ', Psu_Fan_Airflow[psu_fan_airflow]
print(' FAN: ', Psu_Fan_Presence[psu_fan_present])
print(' FAN Status: ', Psu_Fan_Status[psu_fan_status])
print(' FAN AIRFLOW: ', Psu_Fan_Airflow[psu_fan_airflow])
# PSU input & output monitors
print ' Input Voltage: %6.2f' % (input_voltage), 'V'
print(' Input Voltage: %6.2f' % (input_voltage), 'V')
print ' Output Voltage: %6.2f' % (output_voltage), 'V'
print(' Output Voltage: %6.2f' % (output_voltage), 'V')
print ' Input Current: %6.2f' % (input_current), 'A'
print(' Input Current: %6.2f' % (input_current), 'A')
print ' Output Current: %6.2f' % (output_current), 'A'
print(' Output Current: %6.2f' % (output_current), 'A')
print ' Input Power: %6.2f' % (input_power), 'W'
print(' Input Power: %6.2f' % (input_power), 'W')
print ' Output Power: %6.2f' % (output_power), 'W'
print(' Output Power: %6.2f' % (output_power), 'W')
# PSU firmware gives spurious temperature reading without input power
if (input_power != 0):
print ' Temperature: ', psu_fan_temp, 'C'
print(' Temperature: ', psu_fan_temp, 'C')
else:
print ' Temperature: ', 'NA'
print(' Temperature: ', 'NA')
print('\nPSUs:')
for psu in range(1, S6100_MAX_PSUS + 1):
@ -310,15 +309,15 @@ for psu in range(1, S6100_MAX_PSUS + 1):
if (~psu_status & 0b1):
print_psu(psu)
else:
print '\n PSU ', psu, 'Not present'
print('\n PSU ', psu, 'Not present')
else:
logging.error('Unable to check PSU presence')
print '\n Total Power: ', get_pmc_register('current_total_power'), 'W'
print('\n Total Power: ', get_pmc_register('current_total_power'), 'W')
print('\nIO Modules:')
for iom in range(1, S6100_MAX_IOMS+1):
print ' IOM ' + str(iom) + ' :' + iom_status_list[iom - 1]
print(' IOM ' + str(iom) + ' :' + iom_status_list[iom - 1])
print '\n'
print('\n')

View File

@ -7,6 +7,7 @@ install_python_api_package() {
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() {
@ -14,6 +15,11 @@ remove_python_api_package() {
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
}

View File

@ -23,6 +23,7 @@ setup(
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.7',
'Topic :: Utilities',
],
keywords='sonic SONiC platform PLATFORM',

View File

@ -10,7 +10,6 @@
try:
import os
from sonic_platform_base.platform_base import PlatformBase
from sonic_platform_base.chassis_base import ChassisBase
from sonic_platform.sfp import Sfp
from sonic_platform.psu import Psu
@ -19,7 +18,7 @@ try:
from sonic_platform.thermal import Thermal
from sonic_platform.component import Component
from sonic_platform.watchdog import Watchdog
from eeprom import Eeprom
from sonic_platform.eeprom import Eeprom
import time
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
@ -182,16 +181,6 @@ class Chassis(ChassisBase):
"""
return self._eeprom.base_mac_addr()
def get_serial_number(self):
"""
Retrieves the hardware serial number for the chassis
Returns:
A string containing the hardware serial number for this
chassis.
"""
return self._eeprom.serial_number_str()
def get_system_eeprom_info(self):
"""
Retrieves the full content of system EEPROM information for the chassis

View File

@ -79,7 +79,7 @@ class Component(ComponentBase):
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
result = stdout.rstrip('\n')
result = stdout.decode('utf-8').rstrip('\n')
except OSError:
result = None

View File

@ -12,8 +12,8 @@
try:
from sonic_eeprom import eeprom_tlvinfo
import binascii
except ImportError, e:
raise ImportError (str(e) + "- required module not found")
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
class Eeprom(eeprom_tlvinfo.TlvInfoDecoder):

View File

@ -186,7 +186,7 @@ class Fan(FanBase):
fan_speed = self._get_pmc_register(self.get_fan_speed_reg)
if (fan_speed != 'ERR') and self.get_presence():
speed_in_rpm = int(fan_speed, 10)
speed = (100 * speed_in_rpm)/self.max_fan_speed
speed = (100 * speed_in_rpm)//self.max_fan_speed
else:
speed = 0

View File

@ -172,15 +172,6 @@ class Module(ModuleBase):
# In S6100, individual modules doesn't have MAC address
return '00:00:00:00:00:00'
def get_serial_number(self):
"""
Retrieves the hardware serial number for the module
Returns:
A string containing the hardware serial number for this module.
"""
return self._eeprom.serial_number_str()
def get_system_eeprom_info(self):
"""
Retrieves the full content of system EEPROM information for the module

View File

@ -1,5 +1,4 @@
#!/usr/bin/python
import sys
#!/usr/bin/python3
import os
import struct
@ -9,17 +8,16 @@ PORT_RES = '/dev/port'
def portio_reg_write(resource, offset, val):
fd = os.open(resource, os.O_RDWR)
if(fd < 0):
print 'file open failed %s" % resource'
print('file open failed %s" % resource')
return
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
print 'lseek failed on %s' % resource
print('lseek failed on %s' % resource)
return
ret = os.write(fd, struct.pack('B', val))
if(ret != 1):
print 'write failed %d' % ret
print('write failed %d' % ret)
return
os.close(fd)
if __name__ == "__main__":
portio_reg_write(PORT_RES, 0xcf9, 0xe)

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
#
# On Z9100, the Platform Management Controller runs the
# thermal algorithm. It provides a mailbox for the Host
@ -28,7 +28,7 @@ def get_pmc_register(reg_name):
mb_reg_file = MAILBOX_DIR+'/'+reg_name
if (not os.path.isfile(mb_reg_file)):
print mb_reg_file, 'not found !'
print(mb_reg_file, 'not found !')
return retval
try:
@ -44,8 +44,8 @@ def get_pmc_register(reg_name):
logging.basicConfig(level=logging.DEBUG)
if (os.path.isdir(MAILBOX_DIR)):
print 'dell-z9100-lpc'
print 'Adapter: Z9100 Platform Management Controller'
print('dell-z9100-lpc')
print('Adapter: Z9100 Platform Management Controller')
else:
logging.error('Z9100 Platform Management Controller module not loaded !')
# sys.exit(0)
@ -55,18 +55,18 @@ else:
def print_temperature_sensors():
print("\nOnboard Temperature Sensors:")
print ' CPU: ',\
int(get_pmc_register('temp1_input'))/1000, 'C'
print ' BCM56960 (PSU side): ',\
int(get_pmc_register('temp2_input'))/1000, 'C'
print ' System Outlet 1 (switch board): ',\
int(get_pmc_register('temp3_input'))/1000, 'C'
print ' BCM56960 (IO side): ',\
int(get_pmc_register('temp4_input'))/1000, 'C'
print ' System Outlet 2 (CPU board): ',\
int(get_pmc_register('temp9_input'))/1000, 'C'
print ' System Inlet Left (IO side): ',\
int(get_pmc_register('temp6_input'))/1000, 'C'
print(' CPU: ',
int(get_pmc_register('temp1_input'))/1000, 'C')
print(' BCM56960 (PSU side): ',
int(get_pmc_register('temp2_input'))/1000, 'C')
print(' System Outlet 1 (switch board): ',
int(get_pmc_register('temp3_input'))/1000, 'C')
print(' BCM56960 (IO side): ',
int(get_pmc_register('temp4_input'))/1000, 'C')
print(' System Outlet 2 (CPU board): ',
int(get_pmc_register('temp9_input'))/1000, 'C')
print(' System Inlet Left (IO side): ',
int(get_pmc_register('temp6_input'))/1000, 'C')
print_temperature_sensors()
@ -77,63 +77,62 @@ print_temperature_sensors()
def print_voltage_sensors():
print("\nOnboard Voltage Sensors:")
print ' CPU XP3R3V_EARLY ',\
float(get_pmc_register('in1_input'))/1000, 'V'
print '\n CPU XP5R0V_CP ',\
float(get_pmc_register('in2_input'))/1000, 'V'
print ' CPU XP3R3V_STD ',\
float(get_pmc_register('in3_input'))/1000, 'V'
print ' CPU XP3R3V_CP ',\
float(get_pmc_register('in4_input'))/1000, 'V'
print ' CPU XP0R75V_VTT_A ',\
float(get_pmc_register('in5_input'))/1000, 'V'
print ' CPU XPPR75V_VTT_B ',\
float(get_pmc_register('in6_input'))/1000, 'V'
print ' CPU XP1R07V_CPU ',\
float(get_pmc_register('in7_input'))/1000, 'V'
print ' CPU XP1R0V_CPU ',\
float(get_pmc_register('in8_input'))/1000, 'V'
print ' CPU XP12R0V ',\
float(get_pmc_register('in9_input'))/1000, 'V'
print ' CPU VDDR_CPU_2 ',\
float(get_pmc_register('in10_input'))/1000, 'V'
print ' CPU VDDR_CPU_1 ',\
float(get_pmc_register('in11_input'))/1000, 'V'
print ' CPU XP1R5V_CLK ',\
float(get_pmc_register('in12_input'))/1000, 'V'
print ' CPU XP1R8V_CPU ',\
float(get_pmc_register('in13_input'))/1000, 'V'
print ' CPU XP1R0V_CPU_VNN ',\
float(get_pmc_register('in14_input'))/1000, 'V'
print ' CPU XP1R0V_CPU_VCC ',\
float(get_pmc_register('in15_input'))/1000, 'V'
print ' CPU XP1R5V_EARLY ',\
float(get_pmc_register('in16_input'))/1000, 'V'
print ' SW XP3R3V_MON ',\
float(get_pmc_register('in17_input'))/1000, 'V'
print ' SW XP1R8V_MON ',\
float(get_pmc_register('in19_input'))/1000, 'V'
print ' SW XP1R2V_MON ',\
float(get_pmc_register('in20_input'))/1000, 'V'
print ' SW XP1R0V_SW_MON ',\
float(get_pmc_register('in21_input'))/1000, 'V'
print ' SW XP1R0V_ROV_SW_MON ',\
float(get_pmc_register('in22_input'))/1000, 'V'
print ' SW XR1R0V_BCM84752_MON ',\
float(get_pmc_register('in23_input'))/1000, 'V'
print ' SW XP5V_MB_MON ',\
float(get_pmc_register('in24_input'))/1000, 'V'
print ' SW XP1R8V_FPGA_MON ',\
float(get_pmc_register('in25_input'))/1000, 'V'
print ' SW XP3R3V_FPGA_MON ',\
float(get_pmc_register('in26_input'))/1000, 'V'
print ' SW XP3R3V_EARLY_MON ',\
float(get_pmc_register('in27_input'))/1000, 'V'
print ' SW XP1R0V_ ',\
float(get_pmc_register('curr21_input'))/10000, 'A'
print ' SW XP1R0V_ROV ',\
float(get_pmc_register('curr22_input'))/10000, 'A'
print(' CPU XP3R3V_EARLY ',
float(get_pmc_register('in1_input'))/1000, 'V')
print('\n CPU XP5R0V_CP ',
float(get_pmc_register('in2_input'))/1000, 'V')
print(' CPU XP3R3V_STD ',
float(get_pmc_register('in3_input'))/1000, 'V')
print(' CPU XP3R3V_CP ',
float(get_pmc_register('in4_input'))/1000, 'V')
print(' CPU XP0R75V_VTT_A ',
float(get_pmc_register('in5_input'))/1000, 'V')
print(' CPU XPPR75V_VTT_B ',
float(get_pmc_register('in6_input'))/1000, 'V')
print(' CPU XP1R07V_CPU ',
float(get_pmc_register('in7_input'))/1000, 'V')
print(' CPU XP1R0V_CPU ',
float(get_pmc_register('in8_input'))/1000, 'V')
print(' CPU XP12R0V ',
float(get_pmc_register('in9_input'))/1000, 'V')
print(' CPU VDDR_CPU_2 ',
float(get_pmc_register('in10_input'))/1000, 'V')
print(' CPU VDDR_CPU_1 ',
float(get_pmc_register('in11_input'))/1000, 'V')
print(' CPU XP1R5V_CLK ',
float(get_pmc_register('in12_input'))/1000, 'V')
print(' CPU XP1R8V_CPU ',
float(get_pmc_register('in13_input'))/1000, 'V')
print(' CPU XP1R0V_CPU_VNN ',
float(get_pmc_register('in14_input'))/1000, 'V')
print(' CPU XP1R0V_CPU_VCC ',
float(get_pmc_register('in15_input'))/1000, 'V')
print(' CPU XP1R5V_EARLY ',
float(get_pmc_register('in16_input'))/1000, 'V')
print(' SW XP3R3V_MON ',
float(get_pmc_register('in17_input'))/1000, 'V')
print(' SW XP1R8V_MON ',
float(get_pmc_register('in19_input'))/1000, 'V')
print(' SW XP1R2V_MON ',
float(get_pmc_register('in20_input'))/1000, 'V')
print(' SW XP1R0V_SW_MON ',
float(get_pmc_register('in21_input'))/1000, 'V')
print(' SW XP1R0V_ROV_SW_MON ',
float(get_pmc_register('in22_input'))/1000, 'V')
print(' SW XR1R0V_BCM84752_MON ',
float(get_pmc_register('in23_input'))/1000, 'V')
print(' SW XP5V_MB_MON ',
float(get_pmc_register('in24_input'))/1000, 'V')
print(' SW XP1R8V_FPGA_MON ',
float(get_pmc_register('in25_input'))/1000, 'V')
print(' SW XP3R3V_FPGA_MON ',
float(get_pmc_register('in26_input'))/1000, 'V')
print(' SW XP3R3V_EARLY_MON ',
float(get_pmc_register('in27_input'))/1000, 'V')
print(' SW XP1R0V_ ',
float(get_pmc_register('curr21_input'))/10000, 'A')
print(' SW XP1R0V_ROV ',
float(get_pmc_register('curr22_input'))/10000, 'A')
print_voltage_sensors()
@ -146,68 +145,68 @@ def print_fan_tray(tray):
Fan_Status = ['Normal', 'Abnormal']
Airflow_Direction = ['B2F', 'F2B']
print ' Fan Tray ' + str(tray) + ':'
print(' Fan Tray ' + str(tray) + ':')
if (tray == 1):
fan1_speed = get_pmc_register('fan1_input')
fan2_speed = get_pmc_register('fan2_input')
air_flow_reg = int(get_pmc_register('fan1_airflow'), 16)
fan1_speed = int(get_pmc_register('fan1_input'))
fan2_speed = int(get_pmc_register('fan2_input'))
air_flow_reg = int(get_pmc_register('fan1_airflow'), 16)
fan1_status = 0 if fan1_speed >= 1000 else 1
fan2_status = 0 if fan2_speed >= 1000 else 1
print ' Fan1 Speed: ', fan1_speed, 'RPM'
print ' Fan2 Speed: ', fan2_speed, 'RPM'
print ' Fan1 State: ', Fan_Status[fan1_status]
print ' Fan2 State: ', Fan_Status[fan2_status]
print ' Air Flow: ', Airflow_Direction[air_flow_reg]
print(' Fan1 Speed: ', fan1_speed, 'RPM')
print(' Fan2 Speed: ', fan2_speed, 'RPM')
print(' Fan1 State: ', Fan_Status[fan1_status])
print(' Fan2 State: ', Fan_Status[fan2_status])
print(' Air Flow: ', Airflow_Direction[air_flow_reg])
elif (tray == 2):
fan1_speed = get_pmc_register('fan3_input')
fan2_speed = get_pmc_register('fan4_input')
air_flow_reg = int(get_pmc_register('fan3_airflow'), 16)
fan1_speed = int(get_pmc_register('fan3_input'))
fan2_speed = int(get_pmc_register('fan4_input'))
air_flow_reg = int(get_pmc_register('fan3_airflow'), 16)
fan1_status = 0 if fan1_speed >= 1000 else 1
fan2_status = 0 if fan2_speed >= 1000 else 1
print ' Fan1 Speed: ', fan1_speed, 'RPM'
print ' Fan2 Speed: ', fan2_speed, 'RPM'
print ' Fan1 State: ', Fan_Status[fan1_status]
print ' Fan2 State: ', Fan_Status[fan2_status]
print ' Air Flow: ', Airflow_Direction[air_flow_reg]
print(' Fan1 Speed: ', fan1_speed, 'RPM')
print(' Fan2 Speed: ', fan2_speed, 'RPM')
print(' Fan1 State: ', Fan_Status[fan1_status])
print(' Fan2 State: ', Fan_Status[fan2_status])
print(' Air Flow: ', Airflow_Direction[air_flow_reg])
elif (tray == 3):
fan1_speed = get_pmc_register('fan5_input')
fan2_speed = get_pmc_register('fan6_input')
air_flow_reg = int(get_pmc_register('fan5_airflow'), 16)
fan1_speed = int(get_pmc_register('fan5_input'))
fan2_speed = int(get_pmc_register('fan6_input'))
air_flow_reg = int(get_pmc_register('fan5_airflow'), 16)
fan1_status = 0 if fan1_speed >= 1000 else 1
fan2_status = 0 if fan2_speed >= 1000 else 1
print ' Fan1 Speed: ', fan1_speed, 'RPM'
print ' Fan2 Speed: ', fan2_speed, 'RPM'
print ' Fan1 State: ', Fan_Status[fan1_status]
print ' Fan2 State: ', Fan_Status[fan2_status]
print ' Air Flow: ', Airflow_Direction[air_flow_reg]
print(' Fan1 Speed: ', fan1_speed, 'RPM')
print(' Fan2 Speed: ', fan2_speed, 'RPM')
print(' Fan1 State: ', Fan_Status[fan1_status])
print(' Fan2 State: ', Fan_Status[fan2_status])
print(' Air Flow: ', Airflow_Direction[air_flow_reg])
elif (tray == 4):
fan1_speed = get_pmc_register('fan7_input')
fan2_speed = get_pmc_register('fan8_input')
air_flow_reg = int(get_pmc_register('fan7_airflow'), 16)
fan1_speed = int(get_pmc_register('fan7_input'))
fan2_speed = int(get_pmc_register('fan8_input'))
air_flow_reg = int(get_pmc_register('fan7_airflow'), 16)
fan1_status = 0 if fan1_speed >= 1000 else 1
fan2_status = 0 if fan2_speed >= 1000 else 1
print ' Fan1 Speed: ', fan1_speed, 'RPM'
print ' Fan2 Speed: ', fan2_speed, 'RPM'
print ' Fan1 State: ', Fan_Status[fan1_status]
print ' Fan2 State: ', Fan_Status[fan2_status]
print ' Air Flow: ', Airflow_Direction[air_flow_reg]
print(' Fan1 Speed: ', fan1_speed, 'RPM')
print(' Fan2 Speed: ', fan2_speed, 'RPM')
print(' Fan1 State: ', Fan_Status[fan1_status])
print(' Fan2 State: ', Fan_Status[fan2_status])
print(' Air Flow: ', Airflow_Direction[air_flow_reg])
elif (tray == 5):
fan1_speed = get_pmc_register('fan9_input')
fan2_speed = get_pmc_register('fan10_input')
air_flow_reg = int(get_pmc_register('fan9_airflow'), 16)
fan1_speed = int(get_pmc_register('fan9_input'))
fan2_speed = int(get_pmc_register('fan10_input'))
air_flow_reg = int(get_pmc_register('fan9_airflow'), 16)
fan1_status = 0 if fan1_speed >= 1000 else 1
fan2_status = 0 if fan2_speed >= 1000 else 1
print ' Fan1 Speed: ', fan1_speed, 'RPM'
print ' Fan2 Speed: ', fan2_speed, 'RPM'
print ' Fan1 State: ', Fan_Status[fan1_status]
print ' Fan2 State: ', Fan_Status[fan2_status]
print ' Air Flow: ', Airflow_Direction[air_flow_reg]
print(' Fan1 Speed: ', fan1_speed, 'RPM')
print(' Fan2 Speed: ', fan2_speed, 'RPM')
print(' Fan1 State: ', Fan_Status[fan1_status])
print(' Fan2 State: ', Fan_Status[fan2_status])
print(' Air Flow: ', Airflow_Direction[air_flow_reg])
print('\nFan Trays:')
@ -220,7 +219,7 @@ if (fan_tray_presence != 'ERR'):
if (fan_tray_presence & (1 << tray)):
print_fan_tray(tray + 1)
else:
print '\n Fan Tray ' + str(tray + 1) + ': Not present'
print('\n Fan Tray ' + str(tray + 1) + ': Not present')
else:
logging.error('Unable to read FAN presence')
@ -238,9 +237,8 @@ def print_psu(psu):
Psu_Fan_Presence = ['Present', 'Absent']
Psu_Fan_Status = ['Normal', 'Abnormal']
Psu_Fan_Airflow = ['B2F', 'F2B']
print ' PSU ' + str(psu) + ':'
print(' PSU ' + str(psu) + ':')
if (psu == 1):
psu_status = int(get_pmc_register('psu1_presence'), 16)
else:
@ -251,12 +249,12 @@ def print_psu(psu):
psu_type = (psu_status & (1 << PSU_STATUS_TYPE_BIT)) >>\
PSU_STATUS_TYPE_BIT
print ' Input: ', Psu_Input_Type[psu_input_type]
print ' Type: ', Psu_Type[psu_type]
print(' Input: ', Psu_Input_Type[psu_input_type])
print(' Type: ', Psu_Type[psu_type])
# PSU FAN details
if (psu == 1):
print ' FAN Speed: ', get_pmc_register('fan11_input'), 'RPM'
print(' FAN Speed: ', get_pmc_register('fan11_input'), 'RPM')
psu_fan_airflow = int(get_pmc_register('fan11_airflow'))
psu_fan_status = int(get_pmc_register('fan11_alarm'))
psu_fan_present = int(get_pmc_register('fan11_fault'))
@ -266,10 +264,10 @@ def print_psu(psu):
output_current = float(get_pmc_register('curr602_input')) / 1000
input_power = float(get_pmc_register('power1_input')) / 1000000
output_power = float(get_pmc_register('power2_input')) / 1000000
if (input_power != 0):
psu_fan_temp = int(get_pmc_register('temp14_input'))/1000
if (input_power != 0):
psu_fan_temp = int(get_pmc_register('temp14_input'))/1000
else:
print ' FAN Speed: ', get_pmc_register('fan12_input'), 'RPM'
print(' FAN Speed: ', get_pmc_register('fan12_input'), 'RPM')
psu_fan_airflow = int(get_pmc_register('fan12_airflow'))
psu_fan_status = int(get_pmc_register('fan12_alarm'))
psu_fan_present = int(get_pmc_register('fan12_fault'))
@ -279,31 +277,31 @@ def print_psu(psu):
output_current = float(get_pmc_register('curr702_input')) / 1000
input_power = float(get_pmc_register('power3_input')) / 1000000
output_power = float(get_pmc_register('power4_input')) / 1000000
if (input_power != 0):
psu_fan_temp = int(get_pmc_register('temp15_input'))/1000
if (input_power != 0):
psu_fan_temp = int(get_pmc_register('temp15_input'))/1000
print ' FAN: ', Psu_Fan_Presence[psu_fan_present]
print ' FAN Status: ', Psu_Fan_Status[psu_fan_status]
print ' FAN AIRFLOW: ', Psu_Fan_Airflow[psu_fan_airflow]
print(' FAN: ', Psu_Fan_Presence[psu_fan_present])
print(' FAN Status: ', Psu_Fan_Status[psu_fan_status])
print(' FAN AIRFLOW: ', Psu_Fan_Airflow[psu_fan_airflow])
# PSU input & output monitors
print ' Input Voltage: %6.2f' % (input_voltage), 'V'
print(' Input Voltage: %6.2f' % (input_voltage), 'V')
print ' Output Voltage: %6.2f' % (output_voltage), 'V'
print(' Output Voltage: %6.2f' % (output_voltage), 'V')
print ' Input Current: %6.2f' % (input_current), 'A'
print(' Input Current: %6.2f' % (input_current), 'A')
print ' Output Current: %6.2f' % (output_current), 'A'
print(' Output Current: %6.2f' % (output_current), 'A')
print ' Input Power: %6.2f' % (input_power), 'W'
print(' Input Power: %6.2f' % (input_power), 'W')
print ' Output Power: %6.2f' % (output_power), 'W'
print(' Output Power: %6.2f' % (output_power), 'W')
# PSU firmware gives spurious temperature reading without input power
if (input_power != 0):
print ' Temperature: ', psu_fan_temp, 'C'
print(' Temperature: ', psu_fan_temp, 'C')
else:
print ' Temperature: ', 'NA'
print(' Temperature: ', 'NA')
print('\nPSUs:')
for psu in range(1, Z9100_MAX_PSUS + 1):
@ -319,8 +317,8 @@ for psu in range(1, Z9100_MAX_PSUS + 1):
if (~psu_status & 0b1):
print_psu(psu)
else:
print '\n PSU ', psu, 'Not present'
print('\n PSU ', psu, 'Not present')
else:
logging.error('Unable to check PSU presence')
print '\n Total Power: ', get_pmc_register('current_total_power'), 'W'
print('\n Total Power: ', get_pmc_register('current_total_power'), 'W')

View File

@ -205,6 +205,7 @@ install_python_api_package() {
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() {
@ -212,6 +213,11 @@ remove_python_api_package() {
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

View File

@ -18,7 +18,7 @@ try:
from sonic_platform.psu import Psu
from sonic_platform.thermal import Thermal
from sonic_platform.component import Component
from eeprom import Eeprom
from sonic_platform.eeprom import Eeprom
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
@ -232,15 +232,6 @@ class Chassis(ChassisBase):
"""
return self._eeprom.base_mac_addr()
def get_serial_number(self):
"""
Retrieves the hardware serial number for the chassis
Returns:
A string containing the hardware serial number for this chassis.
"""
return self._eeprom.serial_number_str()
def get_system_eeprom_info(self):
"""
Retrieves the full content of system EEPROM information for the chassis

View File

@ -67,7 +67,7 @@ class Component(ComponentBase):
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
result = stdout.rstrip('\n')
result = stdout.decode('utf-8').rstrip('\n')
except OSError:
result = None

View File

@ -12,7 +12,7 @@
try:
from sonic_eeprom import eeprom_tlvinfo
import binascii
except ImportError, e:
except ImportError as e:
raise ImportError(str(e) + "- required module not found")

View File

@ -185,7 +185,7 @@ class Fan(FanBase):
fan_speed = self._get_pmc_register(self.get_fan_speed_reg)
if (fan_speed != 'ERR') and self.get_presence():
speed_in_rpm = int(fan_speed, 10)
speed = (100 * speed_in_rpm)/self.max_fan_speed
speed = (100 * speed_in_rpm)//self.max_fan_speed
else:
speed = 0

View File

@ -258,7 +258,7 @@ class Sfp(SfpBase):
compliance_code_dict)
transceiver_info_dict['vendor_date'] = vendor_date
transceiver_info_dict['vendor_oui'] = vendor_oui
transceiver_info_dict['type_abbrv_name']=type_abbrv_name
transceiver_info_dict['type_abbrv_name'] = type_abbrv_name
return transceiver_info_dict

View File

@ -1,102 +0,0 @@
#!/usr/bin/python
# Copyright (c) 2015 Dell Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
# LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS
# FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
#
# See the Apache Version 2.0 License for specific language governing
# permissions and limitations under the License.
import struct
import sys
import getopt
from os import *
from mmap import *
def usage():
''' This is the Usage Method '''
print '\t\t pcisysfs.py --get --offset <offset> --res <resource>'
print '\t\t pcisysfs.py --set --val <val> --offset <offset> --res <resource>'
sys.exit(1)
def pci_mem_read(mm,offset):
mm.seek(offset)
read_data_stream=mm.read(4)
print ""
reg_val=struct.unpack('I',read_data_stream)
print "reg_val read:%x"%reg_val
return reg_val
def pci_mem_write(mm,offset,data):
mm.seek(offset)
print "data to write:%x"%data
mm.write(struct.pack('I',data))
def pci_set_value(resource,val,offset):
fd=open(resource,O_RDWR)
mm=mmap(fd,0)
pci_mem_write(mm,offset,val)
def pci_get_value(resource,offset):
fd=open(resource,O_RDWR)
mm=mmap(fd,0)
pci_mem_read(mm,offset)
def main(argv):
''' The main function will read the user input from the
command line argument and process the request '''
opts = ''
val = ''
choice = ''
resource = ''
offset = ''
try:
opts, args = getopt.getopt(argv, "hgsv:" , \
["val=","res=","offset=","help", "get", "set"])
except getopt.GetoptError:
usage()
for opt,arg in opts:
if opt in ('-h','--help'):
choice = 'help'
elif opt in ('-g', '--get'):
choice = 'get'
elif opt in ('-s', '--set'):
choice = 'set'
elif opt == '--res':
resource = arg
elif opt == '--val':
val = int(arg,16)
elif opt == '--offset':
offset = int(arg,16)
if choice == 'set' and val != '' and offset !='' and resource !='':
pci_set_value(resource,val,offset)
elif choice == 'get' and offset != '' and resource !='':
pci_get_value(resource,offset)
else:
usage()
#Calling the main method
if __name__ == "__main__":
main(sys.argv[1:])

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# On Z9264f, the BaseBoard Management Controller is an
# autonomous subsystem provides monitoring and management
# facility independent of the host CPU. IPMI standard
@ -11,11 +11,9 @@
# * PSU
import os
import sys
import logging
import subprocess
import commands
Z9264F_MAX_FAN_TRAYS = 4
Z9264F_MAX_PSUS = 2
@ -36,7 +34,7 @@ def ipmi_sensor_dump():
status = 1
global ipmi_sdr_list
ipmi_cmd = IPMI_SENSOR_DATA
status, ipmi_sdr_list = commands.getstatusoutput(ipmi_cmd)
status, ipmi_sdr_list = subprocess.getstatusoutput(ipmi_cmd)
if status:
logging.error('Failed to execute:' + ipmi_sdr_list)
@ -68,24 +66,24 @@ def print_temperature_sensors():
print("\nOnboard Temperature Sensors:")
print ' PT_Left_temp: ',\
(get_pmc_register('PT_Left_temp'))
print ' PT_Mid_temp: ',\
(get_pmc_register('PT_Mid_temp'))
print ' PT_Right_temp: ',\
(get_pmc_register('PT_Right_temp'))
print ' Broadcom Temp: ',\
(get_pmc_register('TC_Near_temp'))
print ' Inlet Airflow Temp: ',\
(get_pmc_register('ILET_AF_temp'))
print ' CPU Temp: ',\
(get_pmc_register('CPU_Near_temp'))
print ' CPU Near Temp: ',\
(get_pmc_register('CPU_temp'))
print ' PSU FAN AirFlow Temperature 1: ',\
(get_pmc_register('PSU1_AF_temp'))
print ' PSU FAN AirFlow Temperature 2: ',\
(get_pmc_register('PSU2_AF_temp'))
print(' PT_Left_temp: ',
get_pmc_register('PT_Left_temp'))
print(' PT_Mid_temp: ',
get_pmc_register('PT_Mid_temp'))
print(' PT_Right_temp: ',
get_pmc_register('PT_Right_temp'))
print(' Broadcom Temp: ',
get_pmc_register('TC_Near_temp'))
print(' Inlet Airflow Temp: ',
get_pmc_register('ILET_AF_temp'))
print(' CPU Temp: ',
get_pmc_register('CPU_Near_temp'))
print(' CPU Near Temp: ',
get_pmc_register('CPU_temp'))
print(' PSU FAN AirFlow Temperature 1: ',
get_pmc_register('PSU1_AF_temp'))
print(' PSU FAN AirFlow Temperature 2: ',
get_pmc_register('PSU2_AF_temp'))
ipmi_sensor_dump()
@ -99,7 +97,7 @@ def print_fan_tray(tray):
Fan_Status = [' Normal', ' Abnormal', ' no reading']
Airflow_Direction = ['B2F', 'F2B']
print ' Fan Tray ' + str(tray) + ':'
print(' Fan Tray ' + str(tray) + ':')
if (tray == 1):
@ -114,14 +112,14 @@ def print_fan_tray(tray):
fan1_status = 2
fan2_status = 2
print ' Fan1 Speed: ',\
get_pmc_register('FAN1_Front_rpm')
print ' Fan2 Speed: ',\
get_pmc_register('FAN1_Rear_rpm')
print ' Fan1 State: ',\
Fan_Status[fan1_status]
print ' Fan2 State: ',\
Fan_Status[fan2_status]
print(' Fan1 Speed: ',
get_pmc_register('FAN1_Front_rpm'))
print(' Fan2 Speed: ',
get_pmc_register('FAN1_Rear_rpm'))
print(' Fan1 State: ',
Fan_Status[fan1_status])
print(' Fan2 State: ',
Fan_Status[fan2_status])
elif (tray == 2):
@ -136,14 +134,14 @@ def print_fan_tray(tray):
fan1_status = 2
fan2_status = 2
print ' Fan1 Speed: ',\
get_pmc_register('FAN2_Front_rpm')
print ' Fan2 Speed: ',\
get_pmc_register('FAN2_Rear_rpm')
print ' Fan1 State: ',\
Fan_Status[fan1_status]
print ' Fan2 State: ',\
Fan_Status[fan2_status]
print(' Fan1 Speed: ',
get_pmc_register('FAN2_Front_rpm'))
print(' Fan2 Speed: ',
get_pmc_register('FAN2_Rear_rpm'))
print(' Fan1 State: ',
Fan_Status[fan1_status])
print(' Fan2 State: ',
Fan_Status[fan2_status])
elif (tray == 3):
@ -158,14 +156,14 @@ def print_fan_tray(tray):
fan1_status = 2
fan2_status = 2
print ' Fan1 Speed: ',\
get_pmc_register('FAN3_Front_rpm')
print ' Fan2 Speed: ',\
get_pmc_register('FAN3_Rear_rpm')
print ' Fan1 State: ',\
Fan_Status[fan1_status]
print ' Fan2 State: ',\
Fan_Status[fan2_status]
print(' Fan1 Speed: ',
get_pmc_register('FAN3_Front_rpm'))
print(' Fan2 Speed: ',
get_pmc_register('FAN3_Rear_rpm'))
print(' Fan1 State: ',
Fan_Status[fan1_status])
print(' Fan2 State: ',
Fan_Status[fan2_status])
elif (tray == 4):
@ -180,14 +178,14 @@ def print_fan_tray(tray):
fan1_status = 2
fan2_status = 2
print ' Fan1 Speed: ',\
get_pmc_register('FAN4_Front_rpm')
print ' Fan2 Speed: ',\
get_pmc_register('FAN4_Rear_rpm')
print ' Fan1 State: ',\
Fan_Status[fan1_status]
print ' Fan2 State: ',\
Fan_Status[fan2_status]
print(' Fan1 Speed: ',
get_pmc_register('FAN4_Front_rpm'))
print(' Fan2 Speed: ',
get_pmc_register('FAN4_Rear_rpm'))
print(' Fan1 State: ',
Fan_Status[fan1_status])
print(' Fan2 State: ',
Fan_Status[fan2_status])
print('\nFan Trays:')
@ -197,7 +195,7 @@ for tray in range(1, Z9264F_MAX_FAN_TRAYS + 1):
if (get_pmc_register(fan_presence)):
print_fan_tray(tray)
else:
print '\n Fan Tray ' + str(tray + 1) + ': Not present'
print('\n Fan Tray ' + str(tray + 1) + ': Not present')
# Print the information for PSU1, PSU2
@ -206,51 +204,51 @@ def print_psu(psu):
# PSU FAN details
if (psu == 1):
print ' PSU1:'
print ' FAN Normal Temperature: ',\
get_pmc_register('PSU1_Normal_temp')
print ' Chassis Temperature: ',\
get_pmc_register('PSU1_Chass_temp')
print ' System Temperature: ',\
get_pmc_register('PSU1_Sys_temp')
print ' FAN RPM: ',\
get_pmc_register('PSU1_rpm')
print ' Input Voltage: ',\
get_pmc_register('PSU1_In_volt')
print ' Output Voltage: ',\
get_pmc_register('PSU1_Out_volt')
print ' Input Power: ',\
get_pmc_register('PSU1_In_watt')
print ' Output Power: ',\
get_pmc_register('PSU1_Out_watt')
print ' Input Current: ',\
get_pmc_register('PSU1_In_amp')
print ' Output Current: ',\
get_pmc_register('PSU1_Out_amp')
print(' PSU1:')
print(' FAN Normal Temperature: ',
get_pmc_register('PSU1_Normal_temp'))
print(' Chassis Temperature: ',
get_pmc_register('PSU1_Chass_temp'))
print(' System Temperature: ',
get_pmc_register('PSU1_Sys_temp'))
print(' FAN RPM: ',
get_pmc_register('PSU1_rpm'))
print(' Input Voltage: ',
get_pmc_register('PSU1_In_volt'))
print(' Output Voltage: ',
get_pmc_register('PSU1_Out_volt'))
print(' Input Power: ',
get_pmc_register('PSU1_In_watt'))
print(' Output Power: ',
get_pmc_register('PSU1_Out_watt'))
print(' Input Current: ',
get_pmc_register('PSU1_In_amp'))
print(' Output Current: ',
get_pmc_register('PSU1_Out_amp'))
else:
print ' PSU2:'
print ' FAN Normal Temperature: ',\
get_pmc_register('PSU2_Normal_temp')
print ' Chassis Temperature: ',\
get_pmc_register('PSU2_Chass_temp')
print ' System Temperature: ',\
get_pmc_register('PSU2_Sys_temp')
print ' FAN RPM: ',\
get_pmc_register('PSU2_rpm')
print ' Input Voltage: ',\
get_pmc_register('PSU2_In_volt')
print ' Output Voltage: ',\
get_pmc_register('PSU2_Out_volt')
print ' Input Power: ',\
get_pmc_register('PSU2_In_watt')
print ' Output Power: ',\
get_pmc_register('PSU2_Out_watt')
print ' Input Current: ',\
get_pmc_register('PSU2_In_amp')
print ' Output Current: ',\
get_pmc_register('PSU2_Out_amp')
print(' PSU2:')
print(' FAN Normal Temperature: ',
get_pmc_register('PSU2_Normal_temp'))
print(' Chassis Temperature: ',
get_pmc_register('PSU2_Chass_temp'))
print(' System Temperature: ',
get_pmc_register('PSU2_Sys_temp'))
print(' FAN RPM: ',
get_pmc_register('PSU2_rpm'))
print(' Input Voltage: ',
get_pmc_register('PSU2_In_volt'))
print(' Output Voltage: ',
get_pmc_register('PSU2_Out_volt'))
print(' Input Power: ',
get_pmc_register('PSU2_In_watt'))
print(' Output Power: ',
get_pmc_register('PSU2_Out_watt'))
print(' Input Current: ',
get_pmc_register('PSU2_In_amp'))
print(' Output Current: ',
get_pmc_register('PSU2_Out_amp'))
print('\nPSUs:')
@ -259,7 +257,7 @@ for psu in range(1, Z9264F_MAX_PSUS + 1):
if (get_pmc_register(psu_presence)):
print_psu(psu)
else:
print '\n PSU ', psu, 'Not present'
print('\n PSU ', psu, 'Not present')
print '\n Total Power: ',\
get_pmc_register('PSU_Total_watt')
print('\n Total Power: ',
get_pmc_register('PSU_Total_watt'))

View File

@ -1,13 +1,12 @@
#!/usr/bin/python
#!/usr/bin/python3
try:
import struct
import sys
from os import *
from mmap import *
import struct
from os import *
from mmap import *
except ImportError as e:
raise ImportError("%s - required module no found" % str(e))
raise ImportError("%s - required module no found" % str(e))
BASE_RES_PATH = "/sys/bus/pci/devices/0000:04:00.0/resource0"
PORT_START = 0
@ -15,19 +14,19 @@ PORT_END = 64
def pci_mem_write(mm, offset, data):
mm.seek(offset)
mm.write(struct.pack('I', data))
mm.seek(offset)
mm.write(struct.pack('I', data))
def pci_set_value(resource, val, offset):
fd = open(resource, O_RDWR)
mm = mmap(fd, 0)
val = pci_mem_write(mm, offset, val)
mm.close()
close(fd)
return val
fd = open(resource, O_RDWR)
mm = mmap(fd, 0)
val = pci_mem_write(mm, offset, val)
mm.close()
close(fd)
return val
#Enabled interrupt for qsfp and sfp
# Enabled interrupt for qsfp and sfp
for port_num in range(PORT_START, PORT_END+1):
port_offset = 0x400c + ((port_num) * 16)
pci_set_value(BASE_RES_PATH, 0x31, port_offset)
port_offset = 0x400c + ((port_num) * 16)
pci_set_value(BASE_RES_PATH, 0x31, port_offset)

View File

@ -105,20 +105,20 @@ switch_board_modsel() {
do
port_addr=$(( 16384 + ((i - 1) * 16)))
hex=$( printf "0x%x" $port_addr )
python /usr/bin/pcisysfs.py --set --offset $hex --val 0x10 --res $resource > /dev/null 2>&1
/usr/bin/pcisysfs.py --set --offset $hex --val 0x10 --res $resource > /dev/null 2>&1
done
# Disabling low power mode for last two 10G ports
# From last 6th bit: Disable - 0; Enable - 1
reg_offset=$(python /usr/bin/pcisysfs.py --get --offset 0x4400 --res $resource | cut -d':' -f 2)
reg_offset=$(/usr/bin/pcisysfs.py --get --offset 0x4400 --res $resource | cut -d':' -f 2)
reg_offset=$( printf '0x%s' $reg_offset)
reg_offset=$( printf '0x%x' $(( $reg_offset & 0xbf )) )
python /usr/bin/pcisysfs.py --set --offset 0x4400 --val $reg_offset --res $resource > /dev/null 2>&1
/usr/bin/pcisysfs.py --set --offset 0x4400 --val $reg_offset --res $resource > /dev/null 2>&1
reg_offset=$(python /usr/bin/pcisysfs.py --get --offset 0x4410 --res $resource | cut -d':' -f 2)
reg_offset=$(/usr/bin/pcisysfs.py --get --offset 0x4410 --res $resource | cut -d':' -f 2)
reg_offset=$( printf '0x%s' $reg_offset)
reg_offset=$( printf '0x%x' $(( $reg_offset & 0xbf )) )
python /usr/bin/pcisysfs.py --set --offset 0x4410 --val $reg_offset --res $resource > /dev/null 2>&1
/usr/bin/pcisysfs.py --set --offset 0x4410 --val $reg_offset --res $resource > /dev/null 2>&1
}
# Copy led_proc_init.soc file according to the HWSKU
@ -142,6 +142,7 @@ install_python_api_package() {
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() {
@ -149,6 +150,11 @@ remove_python_api_package() {
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
}
# Readout firmware version of the system and
@ -225,7 +231,7 @@ if [ "$1" == "init" ]; then
switch_board_modsel
init_switch_port_led
install_python_api_package
python /usr/bin/port_irq_enable.py
/usr/bin/port_irq_enable.py
platform_firmware_versions

View File

@ -11,6 +11,7 @@
try:
import os
import select
import sys
from sonic_platform_base.chassis_base import ChassisBase
from sonic_platform.sfp import Sfp
from sonic_platform.eeprom import Eeprom
@ -49,7 +50,7 @@ class Chassis(ChassisBase):
self.PORT_START = 1
self.PORT_END = 66
PORTS_IN_BLOCK = (self.PORT_END + 1)
_sfp_port = range(65, self.PORT_END + 1)
_sfp_port = list(range(65, self.PORT_END + 1))
eeprom_base = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"
for index in range(self.PORT_START, PORTS_IN_BLOCK):
@ -98,7 +99,7 @@ class Chassis(ChassisBase):
def _get_register(self, reg_file):
retval = 'ERR'
if (not os.path.isfile(reg_file)):
print reg_file, 'not found !'
print(reg_file, 'not found !')
return retval
try:
@ -258,14 +259,6 @@ class Chassis(ChassisBase):
"""
return self._eeprom.base_mac_addr()
def get_serial_number(self):
"""
Retrieves the hardware serial number for the chassis
Returns:
A string containing the hardware serial number for this chassis.
"""
return self._eeprom.serial_number_str()
def get_system_eeprom_info(self):
"""
Retrieves the full content of system EEPROM information for the chassis

View File

@ -13,7 +13,7 @@ try:
import os.path
from sonic_eeprom import eeprom_tlvinfo
import binascii
except ImportError, e:
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
@ -26,8 +26,8 @@ class Eeprom(eeprom_tlvinfo.TlvInfoDecoder):
if os.path.exists(f):
self.eeprom_path = f
break
if self.eeprom_path is None:
return
if self.eeprom_path is None:
return
super(Eeprom, self).__init__(self.eeprom_path, 0, '', True)
self.eeprom_tlv_dict = dict()
try:

View File

@ -170,5 +170,5 @@ class Fan(FanBase):
if not is_valid or self.max_speed == 0:
speed = 0
else:
speed = (100 * fan_speed)/self.max_speed
speed = (100 * fan_speed)//self.max_speed
return speed

View File

@ -111,7 +111,7 @@ class Psu(PsuBase):
if not is_valid:
voltage = 0
return "{:.1f}".format(voltage)
return float(voltage)
def get_current(self):
"""
@ -125,7 +125,7 @@ class Psu(PsuBase):
if not is_valid:
current = 0
return "{:.1f}".format(current)
return float(current)
def get_power(self):
"""
@ -139,7 +139,7 @@ class Psu(PsuBase):
if not is_valid:
power = 0
return "{:.1f}".format(power)
return float(power)
def get_powergood_status(self):
"""

View File

@ -1,102 +0,0 @@
#!/usr/bin/python
# Copyright (c) 2015 Dell Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
# LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS
# FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
#
# See the Apache Version 2.0 License for specific language governing
# permissions and limitations under the License.
import struct
import sys
import getopt
from os import *
from mmap import *
def usage():
''' This is the Usage Method '''
print '\t\t pcisysfs.py --get --offset <offset> --res <resource>'
print '\t\t pcisysfs.py --set --val <val> --offset <offset> --res <resource>'
sys.exit(1)
def pci_mem_read(mm,offset):
mm.seek(offset)
read_data_stream=mm.read(4)
print ""
reg_val=struct.unpack('I',read_data_stream)
print "reg_val read:%x"%reg_val
return reg_val
def pci_mem_write(mm,offset,data):
mm.seek(offset)
print "data to write:%x"%data
mm.write(struct.pack('I',data))
def pci_set_value(resource,val,offset):
fd=open(resource,O_RDWR)
mm=mmap(fd,0)
pci_mem_write(mm,offset,val)
def pci_get_value(resource,offset):
fd=open(resource,O_RDWR)
mm=mmap(fd,0)
pci_mem_read(mm,offset)
def main(argv):
''' The main function will read the user input from the
command line argument and process the request '''
opts = ''
val = ''
choice = ''
resource = ''
offset = ''
try:
opts, args = getopt.getopt(argv, "hgsv:" , \
["val=","res=","offset=","help", "get", "set"])
except getopt.GetoptError:
usage()
for opt,arg in opts:
if opt in ('-h','--help'):
choice = 'help'
elif opt in ('-g', '--get'):
choice = 'get'
elif opt in ('-s', '--set'):
choice = 'set'
elif opt == '--res':
resource = arg
elif opt == '--val':
val = int(arg,16)
elif opt == '--offset':
offset = int(arg,16)
if choice == 'set' and val != '' and offset !='' and resource !='':
pci_set_value(resource,val,offset)
elif choice == 'get' and offset != '' and resource !='':
pci_get_value(resource,offset)
else:
usage()
#Calling the main method
if __name__ == "__main__":
main(sys.argv[1:])

View File

@ -1,9 +1,9 @@
#!/usr/bin/python
#!/usr/bin/python3
# On Z9332F, the BaseBoard Management Controller is an
# autonomous subsystem provides monitoring and management
# facility independent of the host CPU. IPMI standard
# protocol is used with ipmitool to fetch sensor details.
# Current script support X00 board only. X01 support will
# Current script support X00 board only. X01 support will
# be added soon. This provies support for the
# following objects:
# * Onboard temperature sensors
@ -11,11 +11,9 @@
# * PSU
import os
import sys
import logging
import subprocess
import commands
Z9332F_MAX_FAN_TRAYS = 7
Z9332F_MAX_PSUS = 2
@ -40,7 +38,7 @@ def ipmi_sensor_dump():
status = 1
global ipmi_sdr_list
ipmi_cmd = IPMI_SENSOR_DATA
status, ipmi_sdr_list = commands.getstatusoutput(ipmi_cmd)
status, ipmi_sdr_list = subprocess.getstatusoutput(ipmi_cmd)
if status:
logging.error('Failed to execute:' + ipmi_sdr_list)
@ -57,7 +55,7 @@ def get_pmc_register(reg_name):
output = item.strip()
if output is None:
print('\nFailed to fetch: ' + reg_name + ' sensor ')
print('\nFailed to fetch: ' + reg_name + ' sensor ')
sys.exit(0)
output = output.split('|')[1]
@ -75,7 +73,7 @@ def print_temperature_sensors():
for x in (('TEMP_FAN_U52', 'Fan U52'),
('TEMP_FAN_U17', 'Fan U17'),
('TEMP_SW_U52', 'SW U52'),
('TEMP_SW_U52', 'SW U52'),
('TEMP_SW_U16', 'SW U16'),
('TEMP_BB_U3', 'Baseboard U3'),
('TEMP_CPU', 'Near CPU'),
@ -88,7 +86,7 @@ def print_temperature_sensors():
('SW_U14_Temp', 'SW U14'),
('SW_U4403_Temp', 'SW U4403')
):
print ' {0:32}{1}'.format(x[1] + ':', get_pmc_register(x[0]))
print(' {0:32}{1}'.format(x[1] + ':', get_pmc_register(x[0])))
ipmi_sensor_dump()
@ -102,14 +100,14 @@ def print_fan_tray(tray):
Fan_Status = [' Normal', ' Abnormal']
Airflow_Direction = ['B2F', 'F2B']
print ' Fan Tray ' + str(tray) + ':'
print(' Fan Tray ' + str(tray) + ':')
print ' Fan1 Speed: ',\
get_pmc_register('Fan{}_Front'.format(tray))
print ' Fan2 Speed: ',\
get_pmc_register('Fan{}_Rear'.format(tray))
print ' Fan State: ',\
Fan_Status[int(get_pmc_register('Fan{}_Status'.format(tray)), 16)]
print(' Fan1 Speed: ',
get_pmc_register('Fan{}_Front'.format(tray)))
print(' Fan2 Speed: ',
get_pmc_register('Fan{}_Rear'.format(tray)))
print(' Fan State: ',
Fan_Status[int(get_pmc_register('Fan{}_Status'.format(tray)), 16)])
print('\nFan Trays:')
@ -119,7 +117,7 @@ for tray in range(1, Z9332F_MAX_FAN_TRAYS + 1):
if (get_pmc_register(fan_presence)):
print_fan_tray(tray)
else:
print '\n Fan Tray ' + str(tray + 1) + ': Not present'
print('\n Fan Tray ' + str(tray + 1) + ': Not present')
def get_psu_presence(index):
"""
@ -132,9 +130,9 @@ for tray in range(1, Z9332F_MAX_FAN_TRAYS + 1):
ret_status = 1
if index == 1:
status, ipmi_cmd_ret = commands.getstatusoutput(IPMI_PSU1_DATA_DOCKER)
status, ipmi_cmd_ret = subprocess.getstatusoutput(IPMI_PSU1_DATA_DOCKER)
elif index == 2:
ret_status, ipmi_cmd_ret = commands.getstatusoutput(IPMI_PSU2_DATA_DOCKER)
ret_status, ipmi_cmd_ret = subprocess.getstatusoutput(IPMI_PSU2_DATA_DOCKER)
#if ret_status:
# print ipmi_cmd_ret
@ -144,7 +142,7 @@ for tray in range(1, Z9332F_MAX_FAN_TRAYS + 1):
psu_status = ipmi_cmd_ret
if psu_status == '1':
status = 1
status = 1
return status
@ -165,28 +163,28 @@ def print_psu(psu):
# print ' Input: ', Psu_Input_Type[psu_input_type]
# print ' Type: ', Psu_Type[psu_type]
print ' PSU{}:'.format(psu)
print ' Inlet Temperature: ',\
get_pmc_register('PSU{}_Temp1'.format(psu))
print ' Hotspot Temperature: ',\
get_pmc_register('PSU{}_Temp2'.format(psu))
print ' FAN RPM: ',\
get_pmc_register('PSU{}_Fan'.format(psu))
print(' PSU{}:'.format(psu))
print(' Inlet Temperature: ',
get_pmc_register('PSU{}_Temp1'.format(psu)))
print(' Hotspot Temperature: ',
get_pmc_register('PSU{}_Temp2'.format(psu)))
print(' FAN RPM: ',
get_pmc_register('PSU{}_Fan'.format(psu)))
# print ' FAN Status: ', Psu_Fan_Status[psu1_fan_status]
# PSU input & output monitors
print ' Input Voltage: ',\
get_pmc_register('PSU{}_VIn'.format(psu))
print ' Output Voltage: ',\
get_pmc_register('PSU{}_VOut'.format(psu))
print ' Input Power: ',\
get_pmc_register('PSU{}_PIn'.format(psu))
print ' Output Power: ',\
get_pmc_register('PSU{}_POut'.format(psu))
print ' Input Current: ',\
get_pmc_register('PSU{}_CIn'.format(psu))
print ' Output Current: ',\
get_pmc_register('PSU{}_COut'.format(psu))
print(' Input Voltage: ',
get_pmc_register('PSU{}_VIn'.format(psu)))
print(' Output Voltage: ',
get_pmc_register('PSU{}_VOut'.format(psu)))
print(' Input Power: ',
get_pmc_register('PSU{}_PIn'.format(psu)))
print(' Output Power: ',
get_pmc_register('PSU{}_POut'.format(psu)))
print(' Input Current: ',
get_pmc_register('PSU{}_CIn'.format(psu)))
print(' Output Current: ',
get_pmc_register('PSU{}_COut'.format(psu)))
print('\nPSUs:')
@ -195,4 +193,4 @@ for psu in range(1, Z9332F_MAX_PSUS + 1):
if (get_psu_presence(psu)):
print_psu(psu)
else:
print '\n PSU ', psu, 'Not present'
print('\n PSU ', psu, 'Not present')

View File

@ -105,7 +105,7 @@ switch_board_modsel() {
do
port_addr=$(( 16384 + ((i - 1) * 16)))
hex=$( printf "0x%x" $port_addr )
python /usr/bin/pcisysfs.py --set --offset $hex --val 0x10 --res $resource > /dev/null 2>&1
/usr/bin/pcisysfs.py --set --offset $hex --val 0x10 --res $resource > /dev/null 2>&1
done
}
@ -160,7 +160,7 @@ if [ "$1" == "init" ]; then
switch_board_qsfp "new_device"
switch_board_sfp "new_device"
switch_board_led_default
# python /usr/bin/qsfp_irq_enable.py
# /usr/bin/qsfp_irq_enable.py
platform_firmware_versions
elif [ "$1" == "deinit" ]; then