[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:
parent
b57272f137
commit
bcc6c64335
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
from sonic_eeprom import eeprom_tlvinfo
|
from sonic_eeprom import eeprom_tlvinfo
|
||||||
except ImportError, e:
|
except ImportError as e:
|
||||||
raise ImportError(str(e) + "- required module not found")
|
raise ImportError(str(e) + "- required module not found")
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
from sonic_eeprom import eeprom_tlvinfo
|
from sonic_eeprom import eeprom_tlvinfo
|
||||||
except ImportError, e:
|
except ImportError as e:
|
||||||
raise ImportError(str(e) + "- required module not found")
|
raise ImportError(str(e) + "- required module not found")
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
try:
|
try:
|
||||||
import os.path
|
import os.path
|
||||||
from sonic_eeprom import eeprom_tlvinfo
|
from sonic_eeprom import eeprom_tlvinfo
|
||||||
except ImportError, e:
|
except ImportError as e:
|
||||||
raise ImportError(str(e) + "- required module not found")
|
raise ImportError(str(e) + "- required module not found")
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
try:
|
try:
|
||||||
import os.path
|
import os.path
|
||||||
from sonic_eeprom import eeprom_tlvinfo
|
from sonic_eeprom import eeprom_tlvinfo
|
||||||
except ImportError, e:
|
except ImportError as e:
|
||||||
raise ImportError(str(e) + "- required module not found")
|
raise ImportError(str(e) + "- required module not found")
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
try:
|
try:
|
||||||
import os.path
|
import os.path
|
||||||
from sonic_eeprom import eeprom_tlvinfo
|
from sonic_eeprom import eeprom_tlvinfo
|
||||||
except ImportError, e:
|
except ImportError as e:
|
||||||
raise ImportError(str(e) + "- required module not found")
|
raise ImportError(str(e) + "- required module not found")
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
from sonic_eeprom import eeprom_tlvinfo
|
from sonic_eeprom import eeprom_tlvinfo
|
||||||
except ImportError, e:
|
except ImportError as e:
|
||||||
raise ImportError(str(e) + "- required module not found")
|
raise ImportError(str(e) + "- required module not found")
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
|
|
||||||
# dell staging fw updater script
|
# dell staging fw updater script
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
@ -19,8 +18,6 @@ HOST_PLATFORM_INFO = HOST_GRUB_DIR + '/platform'
|
|||||||
dell_reload_tool = '/usr/local/bin/reboot'
|
dell_reload_tool = '/usr/local/bin/reboot'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def set_onie_mode(option):
|
def set_onie_mode(option):
|
||||||
"""Select the ONIE boot mode, and set the next_entry to point to ONIE"""
|
"""Select the ONIE boot mode, and set the next_entry to point to ONIE"""
|
||||||
_set_env_option('next_entry', 'ONIE')
|
_set_env_option('next_entry', 'ONIE')
|
||||||
@ -35,7 +32,7 @@ def set_onie_fw_update_env():
|
|||||||
try:
|
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:
|
except:
|
||||||
print "onie-boot not able to mount"
|
print("onie-boot not able to mount")
|
||||||
|
|
||||||
def _set_env_option(option, value):
|
def _set_env_option(option, value):
|
||||||
"""Set an option in the GRUB environment block. Pass None to value to
|
"""Set an option in the GRUB environment block. Pass None to value to
|
||||||
@ -56,22 +53,22 @@ def dell_firmware_update_staging(image_name):
|
|||||||
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")
|
p.communicate("y")
|
||||||
except:
|
except:
|
||||||
print "onie-fwpkg command not found for purging old fw updates"
|
print("onie-fwpkg command not found for purging old fw updates")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.check_call([onie_fwpkg_tool, "add", str(image_name)])
|
subprocess.check_call([onie_fwpkg_tool, "add", str(image_name)])
|
||||||
except:
|
except:
|
||||||
print "onie-fwpkg is not found to stage fw updates"
|
print("onie-fwpkg is not found to stage fw updates")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
set_onie_mode("update")
|
set_onie_mode("update")
|
||||||
except:
|
except:
|
||||||
print "dell-image command not found"
|
print("dell-image command not found")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.check_call([dell_reload_tool])
|
subprocess.check_call([dell_reload_tool])
|
||||||
except:
|
except:
|
||||||
print "reload command not found"
|
print("reload command not found")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -88,4 +85,3 @@ if __name__ == '__main__':
|
|||||||
if args.update:
|
if args.update:
|
||||||
set_onie_fw_update_env()
|
set_onie_fw_update_env()
|
||||||
dell_firmware_update_staging(args.update[0])
|
dell_firmware_update_staging(args.update[0])
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
# Script to read/write the io based registers
|
# Script to read/write the io based registers
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
@ -11,35 +11,35 @@ io_resource='/dev/port'
|
|||||||
def usage():
|
def usage():
|
||||||
''' This is the Usage Method '''
|
''' This is the Usage Method '''
|
||||||
|
|
||||||
print 'Utility for IO read/write'
|
print('Utility for IO read/write')
|
||||||
print '\t\t io_rd_wr.py --get --offset <offset>'
|
print('\t\t io_rd_wr.py --get --offset <offset>')
|
||||||
print '\t\t io_rd_wr.py --set --val <val> --offset <offset>'
|
print('\t\t io_rd_wr.py --set --val <val> --offset <offset>')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def io_reg_read(io_resource, offset):
|
def io_reg_read(io_resource, offset):
|
||||||
fd = os.open(io_resource, os.O_RDONLY)
|
fd = os.open(io_resource, os.O_RDONLY)
|
||||||
if(fd < 0):
|
if(fd < 0):
|
||||||
print 'file open failed %s"%io_resource'
|
print('file open failed %s' % io_resource)
|
||||||
return
|
return
|
||||||
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
|
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
|
||||||
print 'lseek failed on %s'%io_resource
|
print('lseek failed on %s' % io_resource)
|
||||||
return
|
return
|
||||||
buf = os.read(fd, 1)
|
buf = os.read(fd, 1)
|
||||||
reg_val1 = ord(buf)
|
reg_val1 = ord(buf)
|
||||||
print 'reg value %x'%reg_val1
|
print('reg value %x' % reg_val1)
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
|
|
||||||
def io_reg_write(io_resource, offset, val):
|
def io_reg_write(io_resource, offset, val):
|
||||||
fd = os.open(io_resource, os.O_RDWR)
|
fd = os.open(io_resource, os.O_RDWR)
|
||||||
if(fd < 0):
|
if(fd < 0):
|
||||||
print 'file open failed %s"%io_resource'
|
print('file open failed %s' % io_resource)
|
||||||
return
|
return
|
||||||
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
|
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
|
||||||
print 'lseek failed on %s'%io_resource
|
print('lseek failed on %s' % io_resource)
|
||||||
return
|
return
|
||||||
ret = os.write(fd, struct.pack('B', val))
|
ret = os.write(fd, struct.pack('B', val))
|
||||||
if(ret != 1):
|
if(ret != 1):
|
||||||
print 'write failed %d'%ret
|
print('write failed %d' % ret)
|
||||||
return
|
return
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
|
|
||||||
@ -51,13 +51,11 @@ def main(argv):
|
|||||||
opts = ''
|
opts = ''
|
||||||
val = ''
|
val = ''
|
||||||
choice = ''
|
choice = ''
|
||||||
resouce = ''
|
|
||||||
offset = ''
|
offset = ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(argv, "hgs:" , \
|
opts, args = getopt.getopt(argv, "hgs:",
|
||||||
["val=", "offset=", "help", "get", "set"])
|
["val=", "offset=", "help", "get", "set"])
|
||||||
|
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
usage()
|
usage()
|
||||||
|
|
||||||
@ -90,4 +88,3 @@ def main(argv):
|
|||||||
# Calling the main method
|
# Calling the main method
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main(sys.argv[1:])
|
main(sys.argv[1:])
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#! /usr/bin/python
|
#!/usr/bin/python3
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# DellEMC
|
# DellEMC
|
||||||
@ -53,7 +53,7 @@ class IpmiSensor(object):
|
|||||||
stdout = proc.communicate()[0]
|
stdout = proc.communicate()[0]
|
||||||
proc.wait()
|
proc.wait()
|
||||||
if not proc.returncode:
|
if not proc.returncode:
|
||||||
result = stdout.rstrip('\n')
|
result = stdout.decode('utf-8').rstrip('\n')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -144,10 +144,10 @@ class IpmiSensor(object):
|
|||||||
if self.is_discrete:
|
if self.is_discrete:
|
||||||
raise TypeError("Threshold is not applicable for Discrete Sensor")
|
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 "
|
raise ValueError("Invalid threshold type {} provided. Valid types "
|
||||||
"are {}".format(threshold_type,
|
"are {}".format(threshold_type,
|
||||||
self.THRESHOLD_BIT_MASK.keys()))
|
list(self.THRESHOLD_BIT_MASK.keys())))
|
||||||
|
|
||||||
bit_mask = self.THRESHOLD_BIT_MASK[threshold_type]
|
bit_mask = self.THRESHOLD_BIT_MASK[threshold_type]
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ class IpmiFru(object):
|
|||||||
stdout = proc.communicate()[0]
|
stdout = proc.communicate()[0]
|
||||||
proc.wait()
|
proc.wait()
|
||||||
if not proc.returncode:
|
if not proc.returncode:
|
||||||
result = stdout.rstrip('\n')
|
result = stdout.decode('utf-8').rstrip('\n')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -223,7 +223,6 @@ class IpmiFru(object):
|
|||||||
"""
|
"""
|
||||||
return self._get_from_fru('Board Product')
|
return self._get_from_fru('Board Product')
|
||||||
|
|
||||||
|
|
||||||
def get_fru_data(self, offset, count=1):
|
def get_fru_data(self, offset, count=1):
|
||||||
"""
|
"""
|
||||||
Reads and returns the FRU data at the provided offset.
|
Reads and returns the FRU data at the provided offset.
|
||||||
@ -253,7 +252,7 @@ class IpmiFru(object):
|
|||||||
stdout = proc.communicate()[0]
|
stdout = proc.communicate()[0]
|
||||||
proc.wait()
|
proc.wait()
|
||||||
if not proc.returncode:
|
if not proc.returncode:
|
||||||
result = stdout.rstrip('\n')
|
result = stdout.decode('utf-8').rstrip('\n')
|
||||||
except:
|
except:
|
||||||
is_valid = False
|
is_valid = False
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
# Script to read/write the nvram
|
# Script to read/write the nvram
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
@ -11,35 +11,35 @@ nvram_resource='/dev/nvram'
|
|||||||
def usage():
|
def usage():
|
||||||
''' This is the Usage Method '''
|
''' This is the Usage Method '''
|
||||||
|
|
||||||
print 'Utility for NVRAM read/write'
|
print('Utility for NVRAM read/write')
|
||||||
print '\t\t nvram_rd_wr.py --get --offset <offset>'
|
print('\t\t nvram_rd_wr.py --get --offset <offset>')
|
||||||
print '\t\t nvram_rd_wr.py --set --val <val> --offset <offset>'
|
print('\t\t nvram_rd_wr.py --set --val <val> --offset <offset>')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def nvram_reg_read(nvram_resource, offset):
|
def nvram_reg_read(nvram_resource, offset):
|
||||||
fd = os.open(nvram_resource, os.O_RDONLY)
|
fd = os.open(nvram_resource, os.O_RDONLY)
|
||||||
if(fd < 0):
|
if(fd < 0):
|
||||||
print 'file open failed %s"%nvram_resource'
|
print('file open failed %s' % nvram_resource)
|
||||||
return
|
return
|
||||||
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
|
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
|
||||||
print 'lseek failed on %s'%nvram_resource
|
print('lseek failed on %s' % nvram_resource)
|
||||||
return
|
return
|
||||||
buf = os.read(fd, 1)
|
buf = os.read(fd, 1)
|
||||||
reg_val1 = ord(buf)
|
reg_val1 = ord(buf)
|
||||||
print 'value %x'%reg_val1
|
print('value %x' % reg_val1)
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
|
|
||||||
def nvram_reg_write(nvram_resource, offset, val):
|
def nvram_reg_write(nvram_resource, offset, val):
|
||||||
fd = os.open(nvram_resource, os.O_RDWR)
|
fd = os.open(nvram_resource, os.O_RDWR)
|
||||||
if(fd < 0):
|
if(fd < 0):
|
||||||
print 'file open failed %s"%nvram_resource'
|
print('file open failed %s' % nvram_resource)
|
||||||
return
|
return
|
||||||
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
|
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
|
||||||
print 'lseek failed on %s'%nvram_resource
|
print('lseek failed on %s' % nvram_resource)
|
||||||
return
|
return
|
||||||
ret = os.write(fd, struct.pack('B', val))
|
ret = os.write(fd, struct.pack('B', val))
|
||||||
if(ret != 1):
|
if(ret != 1):
|
||||||
print 'write failed %d'%ret
|
print('write failed %d' % ret)
|
||||||
return
|
return
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
|
|
||||||
@ -51,18 +51,16 @@ def main(argv):
|
|||||||
opts = ''
|
opts = ''
|
||||||
val = ''
|
val = ''
|
||||||
choice = ''
|
choice = ''
|
||||||
resouce = ''
|
|
||||||
offset = ''
|
offset = ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(argv, "hgs:" , \
|
opts, args = getopt.getopt(argv, "hgs:",
|
||||||
["val=", "offset=", "help", "get", "set"])
|
["val=", "offset=", "help", "get", "set"])
|
||||||
|
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
usage()
|
usage()
|
||||||
|
|
||||||
if not os.path.exists(nvram_resource):
|
if not os.path.exists(nvram_resource):
|
||||||
print 'NVRAM is not initialized'
|
print('NVRAM is not initialized')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
for opt, arg in opts:
|
for opt, arg in opts:
|
||||||
@ -94,4 +92,3 @@ def main(argv):
|
|||||||
# Calling the main method
|
# Calling the main method
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main(sys.argv[1:])
|
main(sys.argv[1:])
|
||||||
|
|
||||||
|
105
platform/broadcom/sonic-platform-modules-dell/common/pcisysfs.py
Executable file
105
platform/broadcom/sonic-platform-modules-dell/common/pcisysfs.py
Executable 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:])
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
@ -9,17 +8,16 @@ PORT_RES = '/dev/port'
|
|||||||
def portio_reg_write(resource, offset, val):
|
def portio_reg_write(resource, offset, val):
|
||||||
fd = os.open(resource, os.O_RDWR)
|
fd = os.open(resource, os.O_RDWR)
|
||||||
if(fd < 0):
|
if(fd < 0):
|
||||||
print 'file open failed %s" % resource'
|
print('file open failed %s' % resource)
|
||||||
return
|
return
|
||||||
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
|
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
|
||||||
print 'lseek failed on %s' % resource
|
print('lseek failed on %s' % resource)
|
||||||
return
|
return
|
||||||
ret = os.write(fd, struct.pack('B', val))
|
ret = os.write(fd, struct.pack('B', val))
|
||||||
if(ret != 1):
|
if(ret != 1):
|
||||||
print 'write failed %d' % ret
|
print('write failed %d' % ret)
|
||||||
return
|
return
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
portio_reg_write(PORT_RES, 0xcf9, 0xe)
|
portio_reg_write(PORT_RES, 0xcf9, 0xe)
|
||||||
|
|
||||||
|
@ -2,11 +2,12 @@ s5232f/scripts/s5232f_platform.sh usr/local/bin
|
|||||||
s5232f/scripts/check_qsfp.sh usr/local/bin
|
s5232f/scripts/check_qsfp.sh usr/local/bin
|
||||||
s5232f/scripts/platform_sensors.py usr/local/bin
|
s5232f/scripts/platform_sensors.py usr/local/bin
|
||||||
s5232f/scripts/sensors usr/bin
|
s5232f/scripts/sensors usr/bin
|
||||||
s5232f/scripts/pcisysfs.py usr/bin
|
|
||||||
s5232f/scripts/qsfp_irq_enable.py usr/bin
|
s5232f/scripts/qsfp_irq_enable.py usr/bin
|
||||||
s5232f/cfg/s5232f-modules.conf etc/modules-load.d
|
s5232f/cfg/s5232f-modules.conf etc/modules-load.d
|
||||||
s5232f/systemd/platform-modules-s5232f.service etc/systemd/system
|
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-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/platform_reboot usr/share/sonic/device/x86_64-dellemc_s5232f_c3538-r0
|
||||||
common/fw-updater usr/local/bin
|
common/fw-updater usr/local/bin
|
||||||
common/onie_mode_set usr/local/bin
|
common/onie_mode_set usr/local/bin
|
||||||
|
common/pcisysfs.py usr/bin
|
||||||
|
@ -2,10 +2,10 @@ s5248f/scripts/s5248f_platform.sh usr/local/bin
|
|||||||
s5248f/scripts/check_qsfp.sh usr/local/bin
|
s5248f/scripts/check_qsfp.sh usr/local/bin
|
||||||
s5248f/scripts/platform_sensors.py usr/local/bin
|
s5248f/scripts/platform_sensors.py usr/local/bin
|
||||||
s5248f/scripts/sensors usr/bin
|
s5248f/scripts/sensors usr/bin
|
||||||
s5248f/scripts/pcisysfs.py usr/bin
|
|
||||||
s5248f/scripts/qsfp_irq_enable.py usr/bin
|
s5248f/scripts/qsfp_irq_enable.py usr/bin
|
||||||
s5248f/cfg/s5248f-modules.conf etc/modules-load.d
|
s5248f/cfg/s5248f-modules.conf etc/modules-load.d
|
||||||
s5248f/systemd/platform-modules-s5248f.service etc/systemd/system
|
s5248f/systemd/platform-modules-s5248f.service etc/systemd/system
|
||||||
common/platform_reboot usr/share/sonic/device/x86_64-dellemc_s5248f_c3538-r0
|
common/platform_reboot usr/share/sonic/device/x86_64-dellemc_s5248f_c3538-r0
|
||||||
common/fw-updater usr/local/bin
|
common/fw-updater usr/local/bin
|
||||||
common/onie_mode_set usr/local/bin
|
common/onie_mode_set usr/local/bin
|
||||||
|
common/pcisysfs.py usr/bin
|
||||||
|
@ -6,3 +6,4 @@ s6000/systemd/platform-modules-s6000.service etc/systemd/system
|
|||||||
s6000/systemd/fancontrol.service etc/systemd/system
|
s6000/systemd/fancontrol.service etc/systemd/system
|
||||||
common/io_rd_wr.py usr/local/bin
|
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-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
|
||||||
|
@ -15,6 +15,7 @@ s6100/scripts/override.conf /etc/systemd/system/systemd-reboot.service.d
|
|||||||
common/dell_lpc_mon.sh usr/local/bin
|
common/dell_lpc_mon.sh usr/local/bin
|
||||||
s6100/scripts/platform_sensors.py 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-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_enable.sh usr/local/bin
|
||||||
s6100/scripts/platform_watchdog_disable.sh usr/local/bin
|
s6100/scripts/platform_watchdog_disable.sh usr/local/bin
|
||||||
s6100/scripts/sensors usr/bin
|
s6100/scripts/sensors usr/bin
|
||||||
|
@ -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/platform_sensors.py usr/local/bin
|
||||||
z9100/scripts/sensors usr/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-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/cfg/z9100-modules.conf etc/modules-load.d
|
||||||
z9100/systemd/platform-modules-z9100.service etc/systemd/system
|
z9100/systemd/platform-modules-z9100.service etc/systemd/system
|
||||||
z9100/systemd/z9100-lpc-monitor.service etc/systemd/system
|
z9100/systemd/z9100-lpc-monitor.service etc/systemd/system
|
||||||
|
@ -2,11 +2,12 @@ z9264f/scripts/z9264f_platform.sh usr/local/bin
|
|||||||
z9264f/scripts/check_qsfp.sh usr/local/bin
|
z9264f/scripts/check_qsfp.sh usr/local/bin
|
||||||
z9264f/scripts/platform_sensors.py usr/local/bin
|
z9264f/scripts/platform_sensors.py usr/local/bin
|
||||||
z9264f/scripts/sensors usr/bin
|
z9264f/scripts/sensors usr/bin
|
||||||
z9264f/scripts/pcisysfs.py usr/bin
|
|
||||||
z9264f/scripts/port_irq_enable.py usr/bin
|
z9264f/scripts/port_irq_enable.py usr/bin
|
||||||
z9264f/cfg/z9264f-modules.conf etc/modules-load.d
|
z9264f/cfg/z9264f-modules.conf etc/modules-load.d
|
||||||
z9264f/systemd/platform-modules-z9264f.service etc/systemd/system
|
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-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/platform_reboot usr/share/sonic/device/x86_64-dellemc_z9264f_c3538-r0
|
||||||
common/fw-updater usr/local/bin
|
common/fw-updater usr/local/bin
|
||||||
common/onie_mode_set usr/local/bin
|
common/onie_mode_set usr/local/bin
|
||||||
|
common/pcisysfs.py usr/bin
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
z9332f/scripts/z9332f_platform.sh usr/local/bin
|
z9332f/scripts/z9332f_platform.sh usr/local/bin
|
||||||
z9332f/scripts/platform_sensors.py usr/local/bin
|
z9332f/scripts/platform_sensors.py usr/local/bin
|
||||||
z9332f/scripts/sensors usr/bin
|
z9332f/scripts/sensors usr/bin
|
||||||
z9332f/scripts/pcisysfs.py usr/bin
|
|
||||||
z9332f/cfg/z9332f-modules.conf etc/modules-load.d
|
z9332f/cfg/z9332f-modules.conf etc/modules-load.d
|
||||||
z9332f/systemd/platform-modules-z9332f.service etc/systemd/system
|
z9332f/systemd/platform-modules-z9332f.service etc/systemd/system
|
||||||
common/platform_reboot usr/share/sonic/device/x86_64-dellemc_z9332f_d1508-r0
|
common/platform_reboot usr/share/sonic/device/x86_64-dellemc_z9332f_d1508-r0
|
||||||
|
common/pcisysfs.py usr/bin
|
||||||
|
@ -19,26 +19,31 @@ override_dh_auto_build:
|
|||||||
cp $(COMMON_DIR)/dell_ich.c $(MOD_SRC_DIR)/$${mod}/modules/dell_ich.c; \
|
cp $(COMMON_DIR)/dell_ich.c $(MOD_SRC_DIR)/$${mod}/modules/dell_ich.c; \
|
||||||
cd $(MOD_SRC_DIR)/$${mod}; \
|
cd $(MOD_SRC_DIR)/$${mod}; \
|
||||||
python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
|
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); \
|
cd $(MOD_SRC_DIR); \
|
||||||
elif [ $$mod = "z9100" ]; then \
|
elif [ $$mod = "z9100" ]; then \
|
||||||
cp $(COMMON_DIR)/dell_pmc.c $(MOD_SRC_DIR)/$${mod}/modules/dell_mailbox.c; \
|
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; \
|
cp $(COMMON_DIR)/dell_ich.c $(MOD_SRC_DIR)/$${mod}/modules/dell_ich.c; \
|
||||||
cd $(MOD_SRC_DIR)/$${mod}; \
|
cd $(MOD_SRC_DIR)/$${mod}; \
|
||||||
python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
|
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); \
|
cd $(MOD_SRC_DIR); \
|
||||||
elif [ $$mod = "s6000" ]; then \
|
elif [ $$mod = "s6000" ]; then \
|
||||||
cd $(MOD_SRC_DIR)/$${mod}; \
|
cd $(MOD_SRC_DIR)/$${mod}; \
|
||||||
python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
|
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); \
|
cd $(MOD_SRC_DIR); \
|
||||||
elif [ $$mod = "z9264f" ]; then \
|
elif [ $$mod = "z9264f" ]; then \
|
||||||
cp $(COMMON_DIR)/ipmihelper.py $(MOD_SRC_DIR)/$${mod}/sonic_platform/ipmihelper.py; \
|
cp $(COMMON_DIR)/ipmihelper.py $(MOD_SRC_DIR)/$${mod}/sonic_platform/ipmihelper.py; \
|
||||||
cd $(MOD_SRC_DIR)/$${mod}; \
|
cd $(MOD_SRC_DIR)/$${mod}; \
|
||||||
python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
|
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); \
|
cd $(MOD_SRC_DIR); \
|
||||||
elif [ $$mod = "s5232f" ]; then \
|
elif [ $$mod = "s5232f" ]; then \
|
||||||
cp $(COMMON_DIR)/ipmihelper.py $(MOD_SRC_DIR)/$${mod}/sonic_platform/ipmihelper.py; \
|
cp $(COMMON_DIR)/ipmihelper.py $(MOD_SRC_DIR)/$${mod}/sonic_platform/ipmihelper.py; \
|
||||||
cd $(MOD_SRC_DIR)/$${mod}; \
|
cd $(MOD_SRC_DIR)/$${mod}; \
|
||||||
python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
|
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); \
|
cd $(MOD_SRC_DIR); \
|
||||||
fi; \
|
fi; \
|
||||||
echo "making man page alias $$mod -> $$mod APIs";\
|
echo "making man page alias $$mod -> $$mod APIs";\
|
||||||
|
@ -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:])
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
# On S5232F, the BaseBoard Management Controller is an
|
# On S5232F, the BaseBoard Management Controller is an
|
||||||
# autonomous subsystem provides monitoring and management
|
# autonomous subsystem provides monitoring and management
|
||||||
# facility independent of the host CPU. IPMI standard
|
# facility independent of the host CPU. IPMI standard
|
||||||
@ -11,11 +11,9 @@
|
|||||||
# * PSU
|
# * PSU
|
||||||
|
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
import commands
|
|
||||||
|
|
||||||
S5232F_MAX_FAN_TRAYS = 4
|
S5232F_MAX_FAN_TRAYS = 4
|
||||||
S5232F_MAX_PSUS = 2
|
S5232F_MAX_PSUS = 2
|
||||||
@ -41,7 +39,7 @@ def ipmi_sensor_dump():
|
|||||||
status = 1
|
status = 1
|
||||||
global ipmi_sdr_list
|
global ipmi_sdr_list
|
||||||
ipmi_cmd = IPMI_SENSOR_DATA
|
ipmi_cmd = IPMI_SENSOR_DATA
|
||||||
status, ipmi_sdr_list = commands.getstatusoutput(ipmi_cmd)
|
status, ipmi_sdr_list = subprocess.getstatusoutput(ipmi_cmd)
|
||||||
|
|
||||||
if status:
|
if status:
|
||||||
logging.error('Failed to execute: ' + ipmi_sdr_list)
|
logging.error('Failed to execute: ' + ipmi_sdr_list)
|
||||||
@ -50,7 +48,7 @@ def ipmi_sensor_dump():
|
|||||||
# Fetch a Fan Status
|
# Fetch a Fan Status
|
||||||
|
|
||||||
def get_fan_status(fan_id):
|
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:
|
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)
|
sys.exit(0)
|
||||||
@ -78,7 +76,7 @@ def get_pmc_register(reg_name):
|
|||||||
# Fetch FRU Data for given fruid
|
# Fetch FRU Data for given fruid
|
||||||
def get_psu_airflow(psu_id):
|
def get_psu_airflow(psu_id):
|
||||||
fru_id = 'PSU' + str(psu_id) + '_fru'
|
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:
|
if ret_status:
|
||||||
logging.error('Failed to execute ipmitool: ' + IPMI_FRU)
|
logging.error('Failed to execute ipmitool: ' + IPMI_FRU)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
@ -92,13 +90,11 @@ def get_psu_airflow(psu_id):
|
|||||||
|
|
||||||
# Fetch FRU on given offset
|
# Fetch FRU on given offset
|
||||||
def fetch_raw_fru(dev_id, 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:
|
if ret_status:
|
||||||
logging.error('Failed to execute ipmitool :' + IPMI_RAW_STORAGE_READ.format(dev_id))
|
logging.error('Failed to execute ipmitool :' + IPMI_RAW_STORAGE_READ.format(dev_id))
|
||||||
sys.exit(0)
|
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):
|
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)]
|
return Airflow_Direction[fetch_raw_fru(fan_id+2, 0x46)]
|
||||||
|
|
||||||
# Print the information for temperature sensors
|
# Print the information for temperature sensors
|
||||||
|
|
||||||
|
|
||||||
def print_temperature_sensors():
|
def print_temperature_sensors():
|
||||||
|
|
||||||
print("\nOnboard Temperature Sensors:")
|
print("\nOnboard Temperature Sensors:")
|
||||||
|
|
||||||
print ' PT_Left_temp: ',\
|
print(' PT_Left_temp: ',
|
||||||
(get_pmc_register('PT_Left_temp'))
|
get_pmc_register('PT_Left_temp'))
|
||||||
print ' PT_Mid_temp: ',\
|
print(' PT_Mid_temp: ',
|
||||||
(get_pmc_register('PT_Mid_temp'))
|
get_pmc_register('PT_Mid_temp'))
|
||||||
print ' PT_Right_temp: ',\
|
print(' PT_Right_temp: ',
|
||||||
(get_pmc_register('PT_Right_temp'))
|
get_pmc_register('PT_Right_temp'))
|
||||||
print ' Broadcom Temp: ',\
|
print(' Broadcom Temp: ',
|
||||||
(get_pmc_register('NPU_Near_temp'))
|
get_pmc_register('NPU_Near_temp'))
|
||||||
print ' Inlet Airflow Temp: ',\
|
print(' Inlet Airflow Temp: ',
|
||||||
(get_pmc_register('ILET_AF_temp'))
|
get_pmc_register('ILET_AF_temp'))
|
||||||
print ' CPU Temp: ',\
|
print(' CPU Temp: ',
|
||||||
(get_pmc_register('CPU_temp'))
|
get_pmc_register('CPU_temp'))
|
||||||
|
|
||||||
ipmi_sensor_dump()
|
ipmi_sensor_dump()
|
||||||
|
|
||||||
@ -136,65 +130,65 @@ def print_fan_tray(tray):
|
|||||||
|
|
||||||
Fan_Status = [' Normal', ' Abnormal']
|
Fan_Status = [' Normal', ' Abnormal']
|
||||||
|
|
||||||
print ' Fan Tray ' + str(tray) + ':'
|
print(' Fan Tray ' + str(tray) + ':')
|
||||||
|
|
||||||
if (tray == 1):
|
if (tray == 1):
|
||||||
|
|
||||||
fan1_status = int(get_pmc_register('FAN1_Front_stat'), 16)
|
fan1_status = int(get_pmc_register('FAN1_Front_stat'), 16)
|
||||||
fan2_status = int(get_pmc_register('FAN1_Rear_stat'), 16)
|
fan2_status = int(get_pmc_register('FAN1_Rear_stat'), 16)
|
||||||
|
|
||||||
print ' Fan1 Speed: ',\
|
print(' Fan1 Speed: ',
|
||||||
get_pmc_register('FAN1_Front_rpm')
|
get_pmc_register('FAN1_Front_rpm'))
|
||||||
print ' Fan2 Speed: ',\
|
print(' Fan2 Speed: ',
|
||||||
get_pmc_register('FAN1_Rear_rpm')
|
get_pmc_register('FAN1_Rear_rpm'))
|
||||||
print ' Fan1 State: ',\
|
print(' Fan1 State: ',
|
||||||
Fan_Status[fan1_status]
|
Fan_Status[fan1_status])
|
||||||
print ' Fan2 State: ',\
|
print(' Fan2 State: ',
|
||||||
Fan_Status[fan2_status]
|
Fan_Status[fan2_status])
|
||||||
|
|
||||||
elif (tray == 2):
|
elif (tray == 2):
|
||||||
|
|
||||||
fan1_status = int(get_pmc_register('FAN2_Front_stat'), 16)
|
fan1_status = int(get_pmc_register('FAN2_Front_stat'), 16)
|
||||||
fan2_status = int(get_pmc_register('FAN2_Rear_stat'), 16)
|
fan2_status = int(get_pmc_register('FAN2_Rear_stat'), 16)
|
||||||
|
|
||||||
print ' Fan1 Speed: ',\
|
print(' Fan1 Speed: ',
|
||||||
get_pmc_register('FAN2_Front_rpm')
|
get_pmc_register('FAN2_Front_rpm'))
|
||||||
print ' Fan2 Speed: ',\
|
print(' Fan2 Speed: ',
|
||||||
get_pmc_register('FAN2_Rear_rpm')
|
get_pmc_register('FAN2_Rear_rpm'))
|
||||||
print ' Fan1 State: ',\
|
print(' Fan1 State: ',
|
||||||
Fan_Status[fan1_status]
|
Fan_Status[fan1_status])
|
||||||
print ' Fan2 State: ',\
|
print(' Fan2 State: ',
|
||||||
Fan_Status[fan2_status]
|
Fan_Status[fan2_status])
|
||||||
|
|
||||||
elif (tray == 3):
|
elif (tray == 3):
|
||||||
|
|
||||||
fan1_status = int(get_pmc_register('FAN3_Front_stat'), 16)
|
fan1_status = int(get_pmc_register('FAN3_Front_stat'), 16)
|
||||||
fan2_status = int(get_pmc_register('FAN3_Rear_stat'), 16)
|
fan2_status = int(get_pmc_register('FAN3_Rear_stat'), 16)
|
||||||
|
|
||||||
print ' Fan1 Speed: ',\
|
print(' Fan1 Speed: ',
|
||||||
get_pmc_register('FAN3_Front_rpm')
|
get_pmc_register('FAN3_Front_rpm'))
|
||||||
print ' Fan2 Speed: ',\
|
print(' Fan2 Speed: ',
|
||||||
get_pmc_register('FAN3_Rear_rpm')
|
get_pmc_register('FAN3_Rear_rpm'))
|
||||||
print ' Fan1 State: ',\
|
print(' Fan1 State: ',
|
||||||
Fan_Status[fan1_status]
|
Fan_Status[fan1_status])
|
||||||
print ' Fan2 State: ',\
|
print(' Fan2 State: ',
|
||||||
Fan_Status[fan2_status]
|
Fan_Status[fan2_status])
|
||||||
|
|
||||||
elif (tray == 4):
|
elif (tray == 4):
|
||||||
|
|
||||||
fan1_status = int(get_pmc_register('FAN4_Front_stat'), 16)
|
fan1_status = int(get_pmc_register('FAN4_Front_stat'), 16)
|
||||||
fan2_status = int(get_pmc_register('FAN4_Rear_stat'), 16)
|
fan2_status = int(get_pmc_register('FAN4_Rear_stat'), 16)
|
||||||
|
|
||||||
print ' Fan1 Speed: ',\
|
print(' Fan1 Speed: ',
|
||||||
get_pmc_register('FAN4_Front_rpm')
|
get_pmc_register('FAN4_Front_rpm'))
|
||||||
print ' Fan2 Speed: ',\
|
print(' Fan2 Speed: ',
|
||||||
get_pmc_register('FAN4_Rear_rpm')
|
get_pmc_register('FAN4_Rear_rpm'))
|
||||||
print ' Fan1 State: ',\
|
print(' Fan1 State: ',
|
||||||
Fan_Status[fan1_status]
|
Fan_Status[fan1_status])
|
||||||
print ' Fan2 State: ',\
|
print(' Fan2 State: ',
|
||||||
Fan_Status[fan2_status]
|
Fan_Status[fan2_status])
|
||||||
print ' Airflow: ',\
|
print(' Airflow: ',
|
||||||
get_fan_airflow(tray)
|
get_fan_airflow(tray))
|
||||||
|
|
||||||
|
|
||||||
print('\nFan Trays:')
|
print('\nFan Trays:')
|
||||||
@ -203,7 +197,7 @@ for tray in range(1, S5232F_MAX_FAN_TRAYS + 1):
|
|||||||
if (get_fan_status(tray) == ' Present'):
|
if (get_fan_status(tray) == ' Present'):
|
||||||
print_fan_tray(tray)
|
print_fan_tray(tray)
|
||||||
else:
|
else:
|
||||||
print ' Fan Tray {}: NOT PRESENT'.format(str(tray))
|
print(' Fan Tray {}: NOT PRESENT'.format(str(tray)))
|
||||||
|
|
||||||
def get_psu_presence(index):
|
def get_psu_presence(index):
|
||||||
"""
|
"""
|
||||||
@ -215,9 +209,9 @@ for tray in range(1, S5232F_MAX_FAN_TRAYS + 1):
|
|||||||
ret_status = 1
|
ret_status = 1
|
||||||
|
|
||||||
if index == 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:
|
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:
|
if ret_status:
|
||||||
logging.error('Failed to execute ipmitool :' + IPMI_PSU1_DATA_DOCKER)
|
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'
|
ipmi_cmd_ret = 'f'
|
||||||
|
|
||||||
if index == 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:
|
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:
|
if ret_status:
|
||||||
logging.error('Failed to execute ipmitool : ' + IPMI_PSU2_DATA_DOCKER)
|
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)
|
# psu1_fan_status = int(get_pmc_register('PSU1_status'),16)
|
||||||
|
|
||||||
print ' PSU1:'
|
print(' PSU1:')
|
||||||
print ' FAN Normal Temperature: ',\
|
print(' FAN Normal Temperature: ',
|
||||||
get_pmc_register('PSU1_temp')
|
get_pmc_register('PSU1_temp'))
|
||||||
print ' FAN AirFlow Temperature: ',\
|
print(' FAN AirFlow Temperature: ',
|
||||||
get_pmc_register('PSU1_AF_temp')
|
get_pmc_register('PSU1_AF_temp'))
|
||||||
print ' FAN RPM: ',\
|
print(' FAN RPM: ',
|
||||||
get_pmc_register('PSU1_rpm')
|
get_pmc_register('PSU1_rpm'))
|
||||||
# print ' FAN Status: ', Psu_Fan_Status[psu1_fan_status]
|
# print ' FAN Status: ', Psu_Fan_Status[psu1_fan_status]
|
||||||
|
|
||||||
# PSU input & output monitors
|
# PSU input & output monitors
|
||||||
print ' Input Voltage: ',\
|
print(' Input Voltage: ',
|
||||||
get_pmc_register('PSU1_In_volt')
|
get_pmc_register('PSU1_In_volt'))
|
||||||
print ' Output Voltage: ',\
|
print(' Output Voltage: ',
|
||||||
get_pmc_register('PSU1_Out_volt')
|
get_pmc_register('PSU1_Out_volt'))
|
||||||
print ' Input Power: ',\
|
print(' Input Power: ',
|
||||||
get_pmc_register('PSU1_In_watt')
|
get_pmc_register('PSU1_In_watt'))
|
||||||
print ' Output Power: ',\
|
print(' Output Power: ',
|
||||||
get_pmc_register('PSU1_Out_watt')
|
get_pmc_register('PSU1_Out_watt'))
|
||||||
print ' Input Current: ',\
|
print(' Input Current: ',
|
||||||
get_pmc_register('PSU1_In_amp')
|
get_pmc_register('PSU1_In_amp'))
|
||||||
print ' Output Current: ',\
|
print(' Output Current: ',
|
||||||
get_pmc_register('PSU1_Out_amp')
|
get_pmc_register('PSU1_Out_amp'))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
# psu2_fan_status = int(get_pmc_register('PSU1_status'),16)
|
# psu2_fan_status = int(get_pmc_register('PSU1_status'),16)
|
||||||
print ' PSU2:'
|
print(' PSU2:')
|
||||||
print ' FAN Normal Temperature: ',\
|
print(' FAN Normal Temperature: ',
|
||||||
get_pmc_register('PSU2_temp')
|
get_pmc_register('PSU2_temp'))
|
||||||
print ' FAN AirFlow Temperature: ',\
|
print(' FAN AirFlow Temperature: ',
|
||||||
get_pmc_register('PSU2_AF_temp')
|
get_pmc_register('PSU2_AF_temp'))
|
||||||
print ' FAN RPM: ',\
|
print(' FAN RPM: ',
|
||||||
get_pmc_register('PSU2_rpm')
|
get_pmc_register('PSU2_rpm'))
|
||||||
# print ' FAN Status: ', Psu_Fan_Status[psu2_fan_status]
|
# print ' FAN Status: ', Psu_Fan_Status[psu2_fan_status]
|
||||||
|
|
||||||
# PSU input & output monitors
|
# PSU input & output monitors
|
||||||
print ' Input Voltage: ',\
|
print(' Input Voltage: ',
|
||||||
get_pmc_register('PSU2_In_volt')
|
get_pmc_register('PSU2_In_volt'))
|
||||||
print ' Output Voltage: ',\
|
print(' Output Voltage: ',
|
||||||
get_pmc_register('PSU2_Out_volt')
|
get_pmc_register('PSU2_Out_volt'))
|
||||||
print ' Input Power: ',\
|
print(' Input Power: ',
|
||||||
get_pmc_register('PSU2_In_watt')
|
get_pmc_register('PSU2_In_watt'))
|
||||||
print ' Output Power: ',\
|
print(' Output Power: ',
|
||||||
get_pmc_register('PSU2_Out_watt')
|
get_pmc_register('PSU2_Out_watt'))
|
||||||
print ' Input Current: ',\
|
print(' Input Current: ',
|
||||||
get_pmc_register('PSU2_In_amp')
|
get_pmc_register('PSU2_In_amp'))
|
||||||
print ' Output Current: ',\
|
print(' Output Current: ',
|
||||||
get_pmc_register('PSU2_Out_amp')
|
get_pmc_register('PSU2_Out_amp'))
|
||||||
print ' Airflow: ',\
|
print(' Airflow: ',
|
||||||
get_psu_airflow(psu)
|
get_psu_airflow(psu))
|
||||||
|
|
||||||
|
|
||||||
print('\nPSUs:')
|
print('\nPSUs:')
|
||||||
for psu in range(1, S5232F_MAX_PSUS + 1):
|
for psu in range(1, S5232F_MAX_PSUS + 1):
|
||||||
#psu_presence = PSU_PRESENCE.format(psu)
|
#psu_presence = PSU_PRESENCE.format(psu)
|
||||||
if not get_psu_presence(psu):
|
if not get_psu_presence(psu):
|
||||||
print ' PSU{}: NOT PRESENT'.format(psu)
|
print(' PSU{}: NOT PRESENT'.format(psu))
|
||||||
elif not get_psu_status(psu):
|
elif not get_psu_status(psu):
|
||||||
print ' PSU{}: NOT OK'.format(psu)
|
print(' PSU{}: NOT OK'.format(psu))
|
||||||
else:
|
else:
|
||||||
print_psu(psu)
|
print_psu(psu)
|
||||||
|
|
||||||
print '\n Total Power: ',\
|
print('\n Total Power: ',
|
||||||
get_pmc_register('PSU_Total_watt')
|
get_pmc_register('PSU_Total_watt'))
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import struct
|
import struct
|
||||||
import sys
|
|
||||||
from os import *
|
from os import *
|
||||||
from mmap import *
|
from mmap import *
|
||||||
|
|
||||||
|
@ -104,14 +104,14 @@ switch_board_modsel() {
|
|||||||
do
|
do
|
||||||
port_addr=$(( 16384 + ((i - 1) * 16)))
|
port_addr=$(( 16384 + ((i - 1) * 16)))
|
||||||
hex=$( printf "0x%x" $port_addr )
|
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
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
#This enables the led control for CPU and default states
|
#This enables the led control for CPU and default states
|
||||||
switch_board_led_default() {
|
switch_board_led_default() {
|
||||||
resource="/sys/bus/pci/devices/0000:04:00.0/resource0"
|
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
|
# 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)
|
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=$(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() {
|
remove_python_api_package() {
|
||||||
@ -168,6 +169,11 @@ remove_python_api_package() {
|
|||||||
if [ $? -eq 0 ]; then
|
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
|
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
|
init_devnum
|
||||||
@ -186,7 +192,7 @@ if [ "$1" == "init" ]; then
|
|||||||
switch_board_modsel
|
switch_board_modsel
|
||||||
switch_board_led_default
|
switch_board_led_default
|
||||||
install_python_api_package
|
install_python_api_package
|
||||||
python /usr/bin/qsfp_irq_enable.py
|
/usr/bin/qsfp_irq_enable.py
|
||||||
platform_firmware_versions
|
platform_firmware_versions
|
||||||
|
|
||||||
elif [ "$1" == "deinit" ]; then
|
elif [ "$1" == "deinit" ]; then
|
||||||
|
@ -8,9 +8,10 @@
|
|||||||
#
|
#
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import sys
|
import sys
|
||||||
from __future__ import division
|
|
||||||
from sonic_platform_base.chassis_base import ChassisBase
|
from sonic_platform_base.chassis_base import ChassisBase
|
||||||
from sonic_platform.sfp import Sfp
|
from sonic_platform.sfp import Sfp
|
||||||
from sonic_platform.eeprom import Eeprom
|
from sonic_platform.eeprom import Eeprom
|
||||||
@ -46,7 +47,7 @@ class Chassis(ChassisBase):
|
|||||||
self.PORT_START = 1
|
self.PORT_START = 1
|
||||||
self.PORT_END = 34
|
self.PORT_END = 34
|
||||||
self.PORTS_IN_BLOCK = (self.PORT_END + 1)
|
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"
|
eeprom_base = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"
|
||||||
|
|
||||||
for index in range(self.PORT_START, self.PORTS_IN_BLOCK):
|
for index in range(self.PORT_START, self.PORTS_IN_BLOCK):
|
||||||
@ -112,7 +113,7 @@ class Chassis(ChassisBase):
|
|||||||
if elapsed_time_ms > timeout:
|
if elapsed_time_ms > timeout:
|
||||||
break
|
break
|
||||||
|
|
||||||
time.sleep(sleep_time)
|
sleep(sleep_time)
|
||||||
return True, change_dict
|
return True, change_dict
|
||||||
|
|
||||||
def get_sfp(self, index):
|
def get_sfp(self, index):
|
||||||
@ -188,14 +189,6 @@ class Chassis(ChassisBase):
|
|||||||
"""
|
"""
|
||||||
return self._eeprom.base_mac_addr('')
|
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):
|
def get_system_eeprom_info(self):
|
||||||
"""
|
"""
|
||||||
Retrieves the full content of system EEPROM information for the chassis
|
Retrieves the full content of system EEPROM information for the chassis
|
||||||
|
@ -19,7 +19,7 @@ except ImportError as e:
|
|||||||
|
|
||||||
|
|
||||||
def get_bios_version():
|
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():
|
def get_fpga_version():
|
||||||
val = hwaccess.pci_get_value('/sys/bus/pci/devices/0000:04:00.0/resource0', 0)
|
val = hwaccess.pci_get_value('/sys/bus/pci/devices/0000:04:00.0/resource0', 0)
|
||||||
@ -28,7 +28,7 @@ def get_fpga_version():
|
|||||||
def get_bmc_version():
|
def get_bmc_version():
|
||||||
return subprocess.check_output(
|
return subprocess.check_output(
|
||||||
['cat', '/sys/class/ipmi/ipmi0/device/bmc/firmware_revision']
|
['cat', '/sys/class/ipmi/ipmi0/device/bmc/firmware_revision']
|
||||||
).strip()
|
).decode('utf-8').strip()
|
||||||
|
|
||||||
def get_cpld_version(bus, i2caddr):
|
def get_cpld_version(bus, i2caddr):
|
||||||
return '{}.{}'.format(hwaccess.i2c_get(bus, i2caddr, 1),
|
return '{}.{}'.format(hwaccess.i2c_get(bus, i2caddr, 1),
|
||||||
@ -60,8 +60,7 @@ class Component(ComponentBase):
|
|||||||
],
|
],
|
||||||
|
|
||||||
['BMC',
|
['BMC',
|
||||||
'Platform management controller for on-board temperature ',
|
'Platform management controller for on-board temperature monitoring, in-chassis power, Fan and LED control',
|
||||||
'monitoring, in-chassis power, Fan and LED control',
|
|
||||||
get_bmc_version
|
get_bmc_version
|
||||||
],
|
],
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ try:
|
|||||||
import os.path
|
import os.path
|
||||||
from sonic_eeprom import eeprom_tlvinfo
|
from sonic_eeprom import eeprom_tlvinfo
|
||||||
import binascii
|
import binascii
|
||||||
except ImportError, e:
|
except ImportError as e:
|
||||||
raise ImportError(str(e) + "- required module not found")
|
raise ImportError(str(e) + "- required module not found")
|
||||||
|
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ class Fan(FanBase):
|
|||||||
if not is_valid or self.max_speed == 0:
|
if not is_valid or self.max_speed == 0:
|
||||||
speed = 0
|
speed = 0
|
||||||
else:
|
else:
|
||||||
speed = (100 * fan_speed)/self.max_speed
|
speed = (100 * fan_speed)//self.max_speed
|
||||||
return speed
|
return speed
|
||||||
|
|
||||||
def get_speed_rpm(self):
|
def get_speed_rpm(self):
|
||||||
|
@ -111,7 +111,7 @@ class Psu(PsuBase):
|
|||||||
if not is_valid:
|
if not is_valid:
|
||||||
voltage = 0
|
voltage = 0
|
||||||
|
|
||||||
return "{:.1f}".format(voltage)
|
return float(voltage)
|
||||||
|
|
||||||
def get_current(self):
|
def get_current(self):
|
||||||
"""
|
"""
|
||||||
@ -125,7 +125,7 @@ class Psu(PsuBase):
|
|||||||
if not is_valid:
|
if not is_valid:
|
||||||
current = 0
|
current = 0
|
||||||
|
|
||||||
return "{:.1f}".format(current)
|
return float(current)
|
||||||
|
|
||||||
def get_power(self):
|
def get_power(self):
|
||||||
"""
|
"""
|
||||||
@ -139,7 +139,7 @@ class Psu(PsuBase):
|
|||||||
if not is_valid:
|
if not is_valid:
|
||||||
power = 0
|
power = 0
|
||||||
|
|
||||||
return "{:.1f}".format(power)
|
return float(power)
|
||||||
|
|
||||||
def get_powergood_status(self):
|
def get_powergood_status(self):
|
||||||
"""
|
"""
|
||||||
|
@ -94,7 +94,7 @@ class Thermal(ThermalBase):
|
|||||||
if not is_valid:
|
if not is_valid:
|
||||||
temperature = 0
|
temperature = 0
|
||||||
|
|
||||||
return "{:.3f}".format(temperature)
|
return float(temperature)
|
||||||
|
|
||||||
def get_high_threshold(self):
|
def get_high_threshold(self):
|
||||||
"""
|
"""
|
||||||
@ -109,7 +109,7 @@ class Thermal(ThermalBase):
|
|||||||
if not is_valid:
|
if not is_valid:
|
||||||
high_threshold = 0
|
high_threshold = 0
|
||||||
|
|
||||||
return "{:.3f}".format(high_threshold)
|
return float(high_threshold)
|
||||||
|
|
||||||
def get_low_threshold(self):
|
def get_low_threshold(self):
|
||||||
"""
|
"""
|
||||||
@ -124,7 +124,7 @@ class Thermal(ThermalBase):
|
|||||||
if not is_valid:
|
if not is_valid:
|
||||||
low_threshold = 0
|
low_threshold = 0
|
||||||
|
|
||||||
return "{:.3f}".format(low_threshold)
|
return float(low_threshold)
|
||||||
|
|
||||||
def set_high_threshold(self, temperature):
|
def set_high_threshold(self, temperature):
|
||||||
"""
|
"""
|
||||||
|
@ -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:])
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
# On S5248F, the BaseBoard Management Controller is an
|
# On S5248F, the BaseBoard Management Controller is an
|
||||||
# autonomous subsystem provides monitoring and management
|
# autonomous subsystem provides monitoring and management
|
||||||
# facility independent of the host CPU. IPMI standard
|
# facility independent of the host CPU. IPMI standard
|
||||||
@ -11,11 +11,9 @@
|
|||||||
# * PSU
|
# * PSU
|
||||||
|
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
import commands
|
|
||||||
|
|
||||||
S5248F_MAX_FAN_TRAYS = 4
|
S5248F_MAX_FAN_TRAYS = 4
|
||||||
S5248F_MAX_PSUS = 2
|
S5248F_MAX_PSUS = 2
|
||||||
@ -39,7 +37,7 @@ def ipmi_sensor_dump():
|
|||||||
status = 1
|
status = 1
|
||||||
global ipmi_sdr_list
|
global ipmi_sdr_list
|
||||||
ipmi_cmd = IPMI_SENSOR_DATA
|
ipmi_cmd = IPMI_SENSOR_DATA
|
||||||
status, ipmi_sdr_list = commands.getstatusoutput(ipmi_cmd)
|
status, ipmi_sdr_list = subprocess.getstatusoutput(ipmi_cmd)
|
||||||
|
|
||||||
if status:
|
if status:
|
||||||
logging.error('Failed to execute:' + ipmi_sdr_list)
|
logging.error('Failed to execute:' + ipmi_sdr_list)
|
||||||
@ -72,18 +70,18 @@ def print_temperature_sensors():
|
|||||||
|
|
||||||
print("\nOnboard Temperature Sensors:")
|
print("\nOnboard Temperature Sensors:")
|
||||||
|
|
||||||
print ' PT_Left_temp: ',\
|
print(' PT_Left_temp: ',
|
||||||
(get_pmc_register('PT_Left_temp'))
|
get_pmc_register('PT_Left_temp'))
|
||||||
print ' PT_Mid_temp: ',\
|
print(' PT_Mid_temp: ',
|
||||||
(get_pmc_register('PT_Mid_temp'))
|
get_pmc_register('PT_Mid_temp'))
|
||||||
print ' PT_Right_temp: ',\
|
print(' PT_Right_temp: ',
|
||||||
(get_pmc_register('PT_Right_temp'))
|
get_pmc_register('PT_Right_temp'))
|
||||||
print ' Broadcom Temp: ',\
|
print(' Broadcom Temp: ',
|
||||||
(get_pmc_register('NPU_Near_temp'))
|
get_pmc_register('NPU_Near_temp'))
|
||||||
print ' Inlet Airflow Temp: ',\
|
print(' Inlet Airflow Temp: ',
|
||||||
(get_pmc_register('ILET_AF_temp'))
|
get_pmc_register('ILET_AF_temp'))
|
||||||
print ' CPU Temp: ',\
|
print(' CPU Temp: ',
|
||||||
(get_pmc_register('CPU_temp'))
|
get_pmc_register('CPU_temp'))
|
||||||
|
|
||||||
ipmi_sensor_dump()
|
ipmi_sensor_dump()
|
||||||
|
|
||||||
@ -97,63 +95,63 @@ def print_fan_tray(tray):
|
|||||||
Fan_Status = [' Normal', ' Abnormal']
|
Fan_Status = [' Normal', ' Abnormal']
|
||||||
Airflow_Direction = ['B2F', 'F2B']
|
Airflow_Direction = ['B2F', 'F2B']
|
||||||
|
|
||||||
print ' Fan Tray ' + str(tray) + ':'
|
print(' Fan Tray ' + str(tray) + ':')
|
||||||
|
|
||||||
if (tray == 1):
|
if (tray == 1):
|
||||||
|
|
||||||
fan1_status = int(get_pmc_register('FAN1_Front_stat'), 16)
|
fan1_status = int(get_pmc_register('FAN1_Front_stat'), 16)
|
||||||
fan2_status = int(get_pmc_register('FAN1_Rear_stat'), 16)
|
fan2_status = int(get_pmc_register('FAN1_Rear_stat'), 16)
|
||||||
|
|
||||||
print ' Fan1 Speed: ',\
|
print(' Fan1 Speed: ',
|
||||||
get_pmc_register('FAN1_Front_rpm')
|
get_pmc_register('FAN1_Front_rpm'))
|
||||||
print ' Fan2 Speed: ',\
|
print(' Fan2 Speed: ',
|
||||||
get_pmc_register('FAN1_Rear_rpm')
|
get_pmc_register('FAN1_Rear_rpm'))
|
||||||
print ' Fan1 State: ',\
|
print(' Fan1 State: ',
|
||||||
Fan_Status[fan1_status]
|
Fan_Status[fan1_status])
|
||||||
print ' Fan2 State: ',\
|
print(' Fan2 State: ',
|
||||||
Fan_Status[fan2_status]
|
Fan_Status[fan2_status])
|
||||||
|
|
||||||
elif (tray == 2):
|
elif (tray == 2):
|
||||||
|
|
||||||
fan1_status = int(get_pmc_register('FAN2_Front_stat'), 16)
|
fan1_status = int(get_pmc_register('FAN2_Front_stat'), 16)
|
||||||
fan2_status = int(get_pmc_register('FAN2_Rear_stat'), 16)
|
fan2_status = int(get_pmc_register('FAN2_Rear_stat'), 16)
|
||||||
|
|
||||||
print ' Fan1 Speed: ',\
|
print(' Fan1 Speed: ',
|
||||||
get_pmc_register('FAN2_Front_rpm')
|
get_pmc_register('FAN2_Front_rpm'))
|
||||||
print ' Fan2 Speed: ',\
|
print(' Fan2 Speed: ',
|
||||||
get_pmc_register('FAN2_Rear_rpm')
|
get_pmc_register('FAN2_Rear_rpm'))
|
||||||
print ' Fan1 State: ',\
|
print(' Fan1 State: ',
|
||||||
Fan_Status[fan1_status]
|
Fan_Status[fan1_status])
|
||||||
print ' Fan2 State: ',\
|
print(' Fan2 State: ',
|
||||||
Fan_Status[fan2_status]
|
Fan_Status[fan2_status])
|
||||||
|
|
||||||
elif (tray == 3):
|
elif (tray == 3):
|
||||||
|
|
||||||
fan1_status = int(get_pmc_register('FAN3_Front_stat'), 16)
|
fan1_status = int(get_pmc_register('FAN3_Front_stat'), 16)
|
||||||
fan2_status = int(get_pmc_register('FAN3_Rear_stat'), 16)
|
fan2_status = int(get_pmc_register('FAN3_Rear_stat'), 16)
|
||||||
|
|
||||||
print ' Fan1 Speed: ',\
|
print(' Fan1 Speed: ',
|
||||||
get_pmc_register('FAN3_Front_rpm')
|
get_pmc_register('FAN3_Front_rpm'))
|
||||||
print ' Fan2 Speed: ',\
|
print(' Fan2 Speed: ',
|
||||||
get_pmc_register('FAN3_Rear_rpm')
|
get_pmc_register('FAN3_Rear_rpm'))
|
||||||
print ' Fan1 State: ',\
|
print(' Fan1 State: ',
|
||||||
Fan_Status[fan1_status]
|
Fan_Status[fan1_status])
|
||||||
print ' Fan2 State: ',\
|
print(' Fan2 State: ',
|
||||||
Fan_Status[fan2_status]
|
Fan_Status[fan2_status])
|
||||||
|
|
||||||
elif (tray == 4):
|
elif (tray == 4):
|
||||||
|
|
||||||
fan1_status = int(get_pmc_register('FAN4_Front_stat'), 16)
|
fan1_status = int(get_pmc_register('FAN4_Front_stat'), 16)
|
||||||
fan2_status = int(get_pmc_register('FAN4_Rear_stat'), 16)
|
fan2_status = int(get_pmc_register('FAN4_Rear_stat'), 16)
|
||||||
|
|
||||||
print ' Fan1 Speed: ',\
|
print(' Fan1 Speed: ',
|
||||||
get_pmc_register('FAN4_Front_rpm')
|
get_pmc_register('FAN4_Front_rpm'))
|
||||||
print ' Fan2 Speed: ',\
|
print(' Fan2 Speed: ',
|
||||||
get_pmc_register('FAN4_Rear_rpm')
|
get_pmc_register('FAN4_Rear_rpm'))
|
||||||
print ' Fan1 State: ',\
|
print(' Fan1 State: ',
|
||||||
Fan_Status[fan1_status]
|
Fan_Status[fan1_status])
|
||||||
print ' Fan2 State: ',\
|
print(' Fan2 State: ',
|
||||||
Fan_Status[fan2_status]
|
Fan_Status[fan2_status])
|
||||||
|
|
||||||
|
|
||||||
print('\nFan Trays:')
|
print('\nFan Trays:')
|
||||||
@ -163,7 +161,7 @@ for tray in range(1, S5248F_MAX_FAN_TRAYS + 1):
|
|||||||
if (get_pmc_register(fan_presence)):
|
if (get_pmc_register(fan_presence)):
|
||||||
print_fan_tray(tray)
|
print_fan_tray(tray)
|
||||||
else:
|
else:
|
||||||
print '\n Fan Tray ' + str(tray + 1) + ': Not present'
|
print('\n Fan Tray ' + str(tray + 1) + ': Not present')
|
||||||
|
|
||||||
def get_psu_presence(index):
|
def get_psu_presence(index):
|
||||||
"""
|
"""
|
||||||
@ -176,9 +174,9 @@ for tray in range(1, S5248F_MAX_FAN_TRAYS + 1):
|
|||||||
ret_status = 1
|
ret_status = 1
|
||||||
|
|
||||||
if index == 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:
|
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:
|
#if ret_status:
|
||||||
# print ipmi_cmd_ret
|
# print ipmi_cmd_ret
|
||||||
@ -214,54 +212,54 @@ def print_psu(psu):
|
|||||||
|
|
||||||
# psu1_fan_status = int(get_pmc_register('PSU1_status'),16)
|
# psu1_fan_status = int(get_pmc_register('PSU1_status'),16)
|
||||||
|
|
||||||
print ' PSU1:'
|
print(' PSU1:')
|
||||||
print ' FAN Normal Temperature: ',\
|
print(' FAN Normal Temperature: ',
|
||||||
get_pmc_register('PSU1_temp')
|
get_pmc_register('PSU1_temp'))
|
||||||
print ' FAN AirFlow Temperature: ',\
|
print(' FAN AirFlow Temperature: ',
|
||||||
get_pmc_register('PSU1_AF_temp')
|
get_pmc_register('PSU1_AF_temp'))
|
||||||
print ' FAN RPM: ',\
|
print(' FAN RPM: ',
|
||||||
get_pmc_register('PSU1_rpm')
|
get_pmc_register('PSU1_rpm'))
|
||||||
# print ' FAN Status: ', Psu_Fan_Status[psu1_fan_status]
|
# print ' FAN Status: ', Psu_Fan_Status[psu1_fan_status]
|
||||||
|
|
||||||
# PSU input & output monitors
|
# PSU input & output monitors
|
||||||
print ' Input Voltage: ',\
|
print(' Input Voltage: ',
|
||||||
get_pmc_register('PSU1_In_volt')
|
get_pmc_register('PSU1_In_volt'))
|
||||||
print ' Output Voltage: ',\
|
print(' Output Voltage: ',
|
||||||
get_pmc_register('PSU1_Out_volt')
|
get_pmc_register('PSU1_Out_volt'))
|
||||||
print ' Input Power: ',\
|
print(' Input Power: ',
|
||||||
get_pmc_register('PSU1_In_watt')
|
get_pmc_register('PSU1_In_watt'))
|
||||||
print ' Output Power: ',\
|
print(' Output Power: ',
|
||||||
get_pmc_register('PSU1_Out_watt')
|
get_pmc_register('PSU1_Out_watt'))
|
||||||
print ' Input Current: ',\
|
print(' Input Current: ',
|
||||||
get_pmc_register('PSU1_In_amp')
|
get_pmc_register('PSU1_In_amp'))
|
||||||
print ' Output Current: ',\
|
print(' Output Current: ',
|
||||||
get_pmc_register('PSU1_Out_amp')
|
get_pmc_register('PSU1_Out_amp'))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
# psu2_fan_status = int(get_pmc_register('PSU1_status'),16)
|
# psu2_fan_status = int(get_pmc_register('PSU1_status'),16)
|
||||||
print ' PSU2:'
|
print(' PSU2:')
|
||||||
print ' FAN Normal Temperature: ',\
|
print(' FAN Normal Temperature: ',
|
||||||
get_pmc_register('PSU2_temp')
|
get_pmc_register('PSU2_temp'))
|
||||||
print ' FAN AirFlow Temperature: ',\
|
print(' FAN AirFlow Temperature: ',
|
||||||
get_pmc_register('PSU2_AF_temp')
|
get_pmc_register('PSU2_AF_temp'))
|
||||||
print ' FAN RPM: ',\
|
print(' FAN RPM: ',
|
||||||
get_pmc_register('PSU2_rpm')
|
get_pmc_register('PSU2_rpm'))
|
||||||
# print ' FAN Status: ', Psu_Fan_Status[psu2_fan_status]
|
# print ' FAN Status: ', Psu_Fan_Status[psu2_fan_status]
|
||||||
|
|
||||||
# PSU input & output monitors
|
# PSU input & output monitors
|
||||||
print ' Input Voltage: ',\
|
print(' Input Voltage: ',
|
||||||
get_pmc_register('PSU2_In_volt')
|
get_pmc_register('PSU2_In_volt'))
|
||||||
print ' Output Voltage: ',\
|
print(' Output Voltage: ',
|
||||||
get_pmc_register('PSU2_Out_volt')
|
get_pmc_register('PSU2_Out_volt'))
|
||||||
print ' Input Power: ',\
|
print(' Input Power: ',
|
||||||
get_pmc_register('PSU2_In_watt')
|
get_pmc_register('PSU2_In_watt'))
|
||||||
print ' Output Power: ',\
|
print(' Output Power: ',
|
||||||
get_pmc_register('PSU2_Out_watt')
|
get_pmc_register('PSU2_Out_watt'))
|
||||||
print ' Input Current: ',\
|
print(' Input Current: ',
|
||||||
get_pmc_register('PSU2_In_amp')
|
get_pmc_register('PSU2_In_amp'))
|
||||||
print ' Output Current: ',\
|
print(' Output Current: ',
|
||||||
get_pmc_register('PSU2_Out_amp')
|
get_pmc_register('PSU2_Out_amp'))
|
||||||
|
|
||||||
|
|
||||||
print('\nPSUs:')
|
print('\nPSUs:')
|
||||||
@ -270,8 +268,7 @@ for psu in range(1, S5248F_MAX_PSUS + 1):
|
|||||||
if (get_psu_presence(psu)):
|
if (get_psu_presence(psu)):
|
||||||
print_psu(psu)
|
print_psu(psu)
|
||||||
else:
|
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'))
|
||||||
|
@ -82,7 +82,7 @@ switch_board_modsel() {
|
|||||||
do
|
do
|
||||||
port_addr=$(( 16384 + ((i - 1) * 16)))
|
port_addr=$(( 16384 + ((i - 1) * 16)))
|
||||||
hex=$( printf "0x%x" $port_addr )
|
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
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ platform_firmware_versions() {
|
|||||||
#This enables the led control for CPU and default states
|
#This enables the led control for CPU and default states
|
||||||
switch_board_led_default() {
|
switch_board_led_default() {
|
||||||
resource="/sys/bus/pci/devices/0000:04:00.0/resource0"
|
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
|
init_devnum
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ if [ "$1" == "init" ]; then
|
|||||||
switch_board_qsfp "new_device"
|
switch_board_qsfp "new_device"
|
||||||
switch_board_modsel
|
switch_board_modsel
|
||||||
switch_board_led_default
|
switch_board_led_default
|
||||||
#python /usr/bin/qsfp_irq_enable.py
|
#/usr/bin/qsfp_irq_enable.py
|
||||||
platform_firmware_versions
|
platform_firmware_versions
|
||||||
|
|
||||||
elif [ "$1" == "deinit" ]; then
|
elif [ "$1" == "deinit" ]; then
|
||||||
|
@ -76,11 +76,10 @@ switch_board_qsfp_lpmode() {
|
|||||||
|
|
||||||
install_python_api_package() {
|
install_python_api_package() {
|
||||||
device="/usr/share/sonic/device"
|
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)
|
rv=$(pip install $device/$platform/sonic_platform-1.0-py2-none-any.whl)
|
||||||
fi
|
rv=$(pip3 install $device/$platform/sonic_platform-1.0-py3-none-any.whl)
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_python_api_package() {
|
remove_python_api_package() {
|
||||||
@ -88,6 +87,11 @@ remove_python_api_package() {
|
|||||||
if [ $? -eq 0 ]; then
|
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
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
# read SONiC immutable variables
|
# read SONiC immutable variables
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
try:
|
try:
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import datetime
|
|
||||||
import struct
|
import struct
|
||||||
import subprocess
|
|
||||||
from sonic_platform_base.chassis_base import ChassisBase
|
from sonic_platform_base.chassis_base import ChassisBase
|
||||||
from sonic_platform.sfp import Sfp
|
from sonic_platform.sfp import Sfp
|
||||||
from sonic_platform.eeprom import Eeprom, EepromS6000
|
from sonic_platform.eeprom import Eeprom, EepromS6000
|
||||||
@ -190,16 +188,6 @@ class Chassis(ChassisBase):
|
|||||||
"""
|
"""
|
||||||
return self._eeprom.get_base_mac()
|
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):
|
def get_system_eeprom_info(self):
|
||||||
"""
|
"""
|
||||||
Retrieves the full content of system EEPROM information for the
|
Retrieves the full content of system EEPROM information for the
|
||||||
|
@ -61,7 +61,7 @@ class Component(ComponentBase):
|
|||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT)
|
||||||
stdout = proc.communicate()[0]
|
stdout = proc.communicate()[0]
|
||||||
proc.wait()
|
proc.wait()
|
||||||
result = stdout.rstrip('\n')
|
result = stdout.decode('utf-8').rstrip('\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
result = None
|
result = None
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ class Eeprom(TlvInfoDecoder):
|
|||||||
for field in self.format:
|
for field in self.format:
|
||||||
field_end = field_start + field[2]
|
field_end = field_start + field[2]
|
||||||
if field[0] == field_name:
|
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
|
field_start = field_end
|
||||||
|
|
||||||
return (False, None)
|
return (False, None)
|
||||||
@ -222,9 +222,9 @@ class Eeprom(TlvInfoDecoder):
|
|||||||
Returns the airflow fan type.
|
Returns the airflow fan type.
|
||||||
"""
|
"""
|
||||||
if self.is_psu_eeprom:
|
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:
|
else:
|
||||||
return int(self.fan_type.encode('hex'), 16)
|
return int(binascii.hexlify(self.fan_type.encode('utf-8')), 16)
|
||||||
|
|
||||||
# System EEPROM specific methods
|
# System EEPROM specific methods
|
||||||
def get_base_mac(self):
|
def get_base_mac(self):
|
||||||
@ -323,13 +323,13 @@ class EepromS6000(EepromDecoder):
|
|||||||
"""
|
"""
|
||||||
Decode and print out the contents of the EEPROM.
|
Decode and print out the contents of the EEPROM.
|
||||||
"""
|
"""
|
||||||
print " Field Name Len Value"
|
print(" Field Name Len Value")
|
||||||
print "-------------------- --- --------------------"
|
print("-------------------- --- --------------------")
|
||||||
for blk_code in self._BLK_INFO.keys():
|
for blk_code in list(self._BLK_INFO.keys()):
|
||||||
blk_start = self._BLK_INFO[blk_code]["offset"]
|
blk_start = self._BLK_INFO[blk_code]["offset"]
|
||||||
blk_end = blk_start + self._BLK_INFO[blk_code]["size"]
|
blk_end = blk_start + self._BLK_INFO[blk_code]["size"]
|
||||||
if not self._is_valid_block(e[blk_start:blk_end], blk_code):
|
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
|
return
|
||||||
|
|
||||||
offset = blk_start + self._BLK_HDR_LEN
|
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()
|
data = ":".join([binascii.b2a_hex(T) for T in e[offset:offset+f[1]]]).upper()
|
||||||
else:
|
else:
|
||||||
data = e[offset:offset+f[1]]
|
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]
|
offset += f[1]
|
||||||
|
|
||||||
if not self._is_valid_block_checksum(e[blk_start:blk_end]):
|
if not self._is_valid_block_checksum(e[blk_start:blk_end]):
|
||||||
print "(*** block checksum invalid)"
|
print("(*** block checksum invalid)")
|
||||||
|
|
||||||
def read_eeprom(self):
|
def read_eeprom(self):
|
||||||
"""
|
"""
|
||||||
@ -363,23 +363,23 @@ class EepromS6000(EepromDecoder):
|
|||||||
if db_state != '1':
|
if db_state != '1':
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
print " Field Name Len Value"
|
print(" Field Name Len Value")
|
||||||
print "-------------------- --- --------------------"
|
print("-------------------- --- --------------------")
|
||||||
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_name = self._BLK_INFO[blk_code]["name"]
|
||||||
blk_start = self._BLK_INFO[blk_code]["offset"]
|
blk_start = self._BLK_INFO[blk_code]["offset"]
|
||||||
is_valid = client.hget('EEPROM_INFO|{}'.format(blk_name), 'Valid')
|
is_valid = client.hget('EEPROM_INFO|{}'.format(blk_name), 'Valid')
|
||||||
if is_valid == '0':
|
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
|
break
|
||||||
|
|
||||||
for f in self._BLK_INFO[blk_code]["format"]:
|
for f in self._BLK_INFO[blk_code]["format"]:
|
||||||
data = client.hget('EEPROM_INFO|{}'.format(f[0]), 'Value')
|
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')
|
is_checksum_valid = client.hget('EEPROM_INFO|{}'.format(blk_name), 'Checksum_Valid')
|
||||||
if is_checksum_valid == '0':
|
if is_checksum_valid == '0':
|
||||||
print "(*** block checksum invalid)"
|
print("(*** block checksum invalid)")
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@ -388,13 +388,13 @@ class EepromS6000(EepromDecoder):
|
|||||||
Decode the contents of the EEPROM and update the contents to database
|
Decode the contents of the EEPROM and update the contents to database
|
||||||
"""
|
"""
|
||||||
client = redis.Redis(db=STATE_DB_INDEX)
|
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_name = self._BLK_INFO[blk_code]["name"]
|
||||||
blk_start = self._BLK_INFO[blk_code]["offset"]
|
blk_start = self._BLK_INFO[blk_code]["offset"]
|
||||||
blk_end = blk_start + self._BLK_INFO[blk_code]["size"]
|
blk_end = blk_start + self._BLK_INFO[blk_code]["size"]
|
||||||
if not self._is_valid_block(e[blk_start:blk_end], blk_code):
|
if not self._is_valid_block(e[blk_start:blk_end], blk_code):
|
||||||
client.hset('EEPROM_INFO|{}'.format(blk_name), 'Valid', '0')
|
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
|
break
|
||||||
else:
|
else:
|
||||||
client.hset('EEPROM_INFO|{}'.format(blk_name), 'Valid', '1')
|
client.hset('EEPROM_INFO|{}'.format(blk_name), 'Valid', '1')
|
||||||
|
@ -87,7 +87,7 @@ class Fan(FanBase):
|
|||||||
cpld_reg_file = self.CPLD_DIR + reg_name
|
cpld_reg_file = self.CPLD_DIR + reg_name
|
||||||
|
|
||||||
if (not os.path.isfile(cpld_reg_file)):
|
if (not os.path.isfile(cpld_reg_file)):
|
||||||
print "open error"
|
print("open error")
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -251,7 +251,7 @@ class Fan(FanBase):
|
|||||||
fan_speed = self._get_i2c_register(self.get_fan_speed_reg)
|
fan_speed = self._get_i2c_register(self.get_fan_speed_reg)
|
||||||
if (fan_speed != 'ERR') and self.get_presence():
|
if (fan_speed != 'ERR') and self.get_presence():
|
||||||
speed_in_rpm = int(fan_speed, 10)
|
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:
|
else:
|
||||||
speed = 0
|
speed = 0
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ class Psu(PsuBase):
|
|||||||
status = False
|
status = False
|
||||||
psu_status = self._get_cpld_register(self.psu_status_reg)
|
psu_status = self._get_cpld_register(self.psu_status_reg)
|
||||||
if (psu_status != 'ERR'):
|
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):
|
if (~psu_status & 0b1000) and (~psu_status & 0b0100):
|
||||||
status = True
|
status = True
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#! /usr/bin/python
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
@ -9,33 +9,35 @@ from mmap import *
|
|||||||
def usage():
|
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 --get --offset <offset> --res <resource>')
|
||||||
print '\t\t pcisysfs.py --set --val <val> --offset <offset> --res <resource>'
|
print('\t\t pcisysfs.py --set --val <val> --offset <offset> --res <resource>')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def pci_mem_read(mm, offset):
|
def pci_mem_read(mm, offset):
|
||||||
mm.seek(offset)
|
mm.seek(offset)
|
||||||
read_data_stream = mm.read(4)
|
read_data_stream = mm.read(4)
|
||||||
print ""
|
print("")
|
||||||
reg_val = struct.unpack('I', read_data_stream)
|
reg_val = struct.unpack('I', read_data_stream)
|
||||||
print "reg_val read:%x"%reg_val
|
print("reg_val read:%x" % reg_val)
|
||||||
return reg_val
|
return reg_val
|
||||||
|
|
||||||
def pci_mem_write(mm, offset, data):
|
def pci_mem_write(mm, offset, data):
|
||||||
mm.seek(offset)
|
mm.seek(offset)
|
||||||
#print "data to write:%x"%data
|
#print("data to write:%x" % data)
|
||||||
mm.write(struct.pack('I', data))
|
mm.write(struct.pack('I', data))
|
||||||
|
|
||||||
def pci_set_value(resource, val, offset):
|
def pci_set_value(resource, val, offset):
|
||||||
fd = open(resource, O_RDWR)
|
fd = open(resource, O_RDWR)
|
||||||
mm = mmap(fd, 0)
|
mm = mmap(fd, 0)
|
||||||
pci_mem_write(mm, offset, val)
|
pci_mem_write(mm, offset, val)
|
||||||
|
mm.close()
|
||||||
close(fd)
|
close(fd)
|
||||||
|
|
||||||
def pci_get_value(resource, offset):
|
def pci_get_value(resource, offset):
|
||||||
fd = open(resource, O_RDWR)
|
fd = open(resource, O_RDWR)
|
||||||
mm = mmap(fd, 0)
|
mm = mmap(fd, 0)
|
||||||
pci_mem_read(mm, offset)
|
pci_mem_read(mm, offset)
|
||||||
|
mm.close()
|
||||||
close(fd)
|
close(fd)
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
@ -50,7 +52,7 @@ def main(argv):
|
|||||||
offset = ''
|
offset = ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(argv, "hgsv:" , \
|
opts, args = getopt.getopt(argv, "hgsv:",
|
||||||
["val=", "res=", "offset=", "help", "get", "set"])
|
["val=", "res=", "offset=", "help", "get", "set"])
|
||||||
|
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
@ -88,4 +90,3 @@ def main(argv):
|
|||||||
# Calling the main method
|
# Calling the main method
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main(sys.argv[1:])
|
main(sys.argv[1:])
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import struct
|
import struct
|
||||||
@ -20,14 +19,14 @@ def ssd_hdparm_upgrade():
|
|||||||
def portio_reg_write(resource, offset, val):
|
def portio_reg_write(resource, offset, val):
|
||||||
fd = os.open(resource, os.O_RDWR)
|
fd = os.open(resource, os.O_RDWR)
|
||||||
if(fd < 0):
|
if(fd < 0):
|
||||||
print 'file open failed %s" % resource'
|
print('file open failed %s" % resource')
|
||||||
return
|
return
|
||||||
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
|
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
|
||||||
print 'lseek failed on %s' % resource
|
print('lseek failed on %s' % resource)
|
||||||
return
|
return
|
||||||
ret = os.write(fd, struct.pack('B', val))
|
ret = os.write(fd, struct.pack('B', val))
|
||||||
if(ret != 1):
|
if(ret != 1):
|
||||||
print 'write failed %d' % ret
|
print('write failed %d' % ret)
|
||||||
return
|
return
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
|
|
||||||
@ -35,4 +34,3 @@ if __name__ == "__main__":
|
|||||||
log_software_reboot()
|
log_software_reboot()
|
||||||
ssd_hdparm_upgrade()
|
ssd_hdparm_upgrade()
|
||||||
portio_reg_write(PORT_RES, 0xcf9, 0xe)
|
portio_reg_write(PORT_RES, 0xcf9, 0xe)
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
|
|
||||||
# On S6100, the Platform Management Controller runs the
|
# On S6100, the Platform Management Controller runs the
|
||||||
# thermal algorithm. It provides a mailbox for the Host
|
# thermal algorithm. It provides a mailbox for the Host
|
||||||
@ -9,7 +9,6 @@
|
|||||||
# * PSU
|
# * PSU
|
||||||
#
|
#
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
S6100_MAX_FAN_TRAYS = 4
|
S6100_MAX_FAN_TRAYS = 4
|
||||||
@ -29,7 +28,7 @@ def get_pmc_register(reg_name):
|
|||||||
mb_reg_file = MAILBOX_DIR+'/'+reg_name
|
mb_reg_file = MAILBOX_DIR+'/'+reg_name
|
||||||
|
|
||||||
if (not os.path.isfile(mb_reg_file)):
|
if (not os.path.isfile(mb_reg_file)):
|
||||||
print mb_reg_file, 'not found !'
|
print(mb_reg_file, 'not found !')
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -45,8 +44,8 @@ def get_pmc_register(reg_name):
|
|||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
if (os.path.isdir(MAILBOX_DIR)):
|
if (os.path.isdir(MAILBOX_DIR)):
|
||||||
print 'dell-s6100-lpc'
|
print('dell-s6100-lpc')
|
||||||
print 'Adapter: S6100 Platform Management Controller'
|
print('Adapter: S6100 Platform Management Controller')
|
||||||
else:
|
else:
|
||||||
logging.error('S6100 Platform Management Controller module not loaded !')
|
logging.error('S6100 Platform Management Controller module not loaded !')
|
||||||
# sys.exit(0)
|
# sys.exit(0)
|
||||||
@ -56,20 +55,20 @@ else:
|
|||||||
|
|
||||||
def print_temperature_sensors():
|
def print_temperature_sensors():
|
||||||
print("\nOnboard Temperature Sensors:")
|
print("\nOnboard Temperature Sensors:")
|
||||||
print ' CPU: ',\
|
print(' CPU: ',
|
||||||
int(get_pmc_register('temp1_input'))/1000, 'C'
|
int(get_pmc_register('temp1_input'))/1000, 'C')
|
||||||
print ' BCM56960 (PSU side): ',\
|
print(' BCM56960 (PSU side): ',
|
||||||
int(get_pmc_register('temp2_input'))/1000, 'C'
|
int(get_pmc_register('temp2_input'))/1000, 'C')
|
||||||
print ' System Outlet 1 (switch board): ',\
|
print(' System Outlet 1 (switch board): ',
|
||||||
int(get_pmc_register('temp3_input'))/1000, 'C'
|
int(get_pmc_register('temp3_input'))/1000, 'C')
|
||||||
print ' BCM56960 (IO side): ',\
|
print(' BCM56960 (IO side): ',
|
||||||
int(get_pmc_register('temp4_input'))/1000, 'C'
|
int(get_pmc_register('temp4_input'))/1000, 'C')
|
||||||
print ' System Outlet 2 (CPU board): ',\
|
print(' System Outlet 2 (CPU board): ',
|
||||||
int(get_pmc_register('temp9_input'))/1000, 'C'
|
int(get_pmc_register('temp9_input'))/1000, 'C')
|
||||||
print ' System Inlet Left (IO side): ',\
|
print(' System Inlet Left (IO side): ',
|
||||||
int(get_pmc_register('temp10_input'))/1000, 'C'
|
int(get_pmc_register('temp10_input'))/1000, 'C')
|
||||||
print ' System Inlet Right (IO side): ',\
|
print(' System Inlet Right (IO side): ',
|
||||||
int(get_pmc_register('temp11_input'))/1000, 'C'
|
int(get_pmc_register('temp11_input'))/1000, 'C')
|
||||||
|
|
||||||
iom_status = get_pmc_register('iom_presence')
|
iom_status = get_pmc_register('iom_presence')
|
||||||
iom_status = int(iom_status, 16)
|
iom_status = int(iom_status, 16)
|
||||||
@ -84,9 +83,9 @@ def print_temperature_sensors():
|
|||||||
for iom in range(0, S6100_MAX_IOMS):
|
for iom in range(0, S6100_MAX_IOMS):
|
||||||
if (~iom_presence & (1 << iom)):
|
if (~iom_presence & (1 << iom)):
|
||||||
iom_sensor_indx = iom + 5
|
iom_sensor_indx = iom + 5
|
||||||
print ' IOM ' + str(iom + 1) + ':\t\t\t ',\
|
print(' IOM ' + str(iom + 1) + ':\t\t\t ',
|
||||||
int(get_pmc_register('temp' + str(iom_sensor_indx) +
|
int(get_pmc_register('temp' + str(iom_sensor_indx) +
|
||||||
'_input'))/1000, 'C'
|
'_input'))/1000, 'C')
|
||||||
|
|
||||||
# Save the IOM Status for later use
|
# Save the IOM Status for later use
|
||||||
if (~iom_status & (1 << iom)):
|
if (~iom_status & (1 << iom)):
|
||||||
@ -95,7 +94,7 @@ def print_temperature_sensors():
|
|||||||
iom_status_list.append('OFF')
|
iom_status_list.append('OFF')
|
||||||
else:
|
else:
|
||||||
iom_status_list.append('Not present')
|
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:
|
else:
|
||||||
logging.error('Unable to check IOM presence')
|
logging.error('Unable to check IOM presence')
|
||||||
|
|
||||||
@ -108,56 +107,56 @@ print_temperature_sensors()
|
|||||||
def print_voltage_sensors():
|
def print_voltage_sensors():
|
||||||
print("\nOnboard Voltage Sensors:")
|
print("\nOnboard Voltage Sensors:")
|
||||||
|
|
||||||
print ' CPU XP3R3V_EARLY ',\
|
print(' CPU XP3R3V_EARLY ',
|
||||||
float(get_pmc_register('in1_input'))/1000, 'V'
|
float(get_pmc_register('in1_input'))/1000, 'V')
|
||||||
print ' CPU XP5R0V_CP ',\
|
print(' CPU XP5R0V_CP ',
|
||||||
float(get_pmc_register('in2_input'))/1000, 'V'
|
float(get_pmc_register('in2_input'))/1000, 'V')
|
||||||
print ' CPU XP3R3V_STD ',\
|
print(' CPU XP3R3V_STD ',
|
||||||
float(get_pmc_register('in3_input'))/1000, 'V'
|
float(get_pmc_register('in3_input'))/1000, 'V')
|
||||||
print ' CPU XP3R3V_CP ',\
|
print(' CPU XP3R3V_CP ',
|
||||||
float(get_pmc_register('in4_input'))/1000, 'V'
|
float(get_pmc_register('in4_input'))/1000, 'V')
|
||||||
print ' CPU XP0R75V_VTT_A ',\
|
print(' CPU XP0R75V_VTT_A ',
|
||||||
float(get_pmc_register('in5_input'))/1000, 'V'
|
float(get_pmc_register('in5_input'))/1000, 'V')
|
||||||
print ' CPU XPPR75V_VTT_B ',\
|
print(' CPU XPPR75V_VTT_B ',
|
||||||
float(get_pmc_register('in6_input'))/1000, 'V'
|
float(get_pmc_register('in6_input'))/1000, 'V')
|
||||||
print ' CPU XP1R07V_CPU ',\
|
print(' CPU XP1R07V_CPU ',
|
||||||
float(get_pmc_register('in7_input'))/1000, 'V'
|
float(get_pmc_register('in7_input'))/1000, 'V')
|
||||||
print ' CPU XP1R0V_CPU ',\
|
print(' CPU XP1R0V_CPU ',
|
||||||
float(get_pmc_register('in8_input'))/1000, 'V'
|
float(get_pmc_register('in8_input'))/1000, 'V')
|
||||||
print ' CPU XP12R0V ',\
|
print(' CPU XP12R0V ',
|
||||||
float(get_pmc_register('in9_input'))/1000, 'V'
|
float(get_pmc_register('in9_input'))/1000, 'V')
|
||||||
print ' CPU VDDR_CPU_2 ',\
|
print(' CPU VDDR_CPU_2 ',
|
||||||
float(get_pmc_register('in10_input'))/1000, 'V'
|
float(get_pmc_register('in10_input'))/1000, 'V')
|
||||||
print ' CPU VDDR_CPU_1 ',\
|
print(' CPU VDDR_CPU_1 ',
|
||||||
float(get_pmc_register('in11_input'))/1000, 'V'
|
float(get_pmc_register('in11_input'))/1000, 'V')
|
||||||
print ' CPU XP1R5V_CLK ',\
|
print(' CPU XP1R5V_CLK ',
|
||||||
float(get_pmc_register('in12_input'))/1000, 'V'
|
float(get_pmc_register('in12_input'))/1000, 'V')
|
||||||
print ' CPU XP1R8V_CPU ',\
|
print(' CPU XP1R8V_CPU ',
|
||||||
float(get_pmc_register('in13_input'))/1000, 'V'
|
float(get_pmc_register('in13_input'))/1000, 'V')
|
||||||
print ' CPU XP1R0V_CPU_VNN ',\
|
print(' CPU XP1R0V_CPU_VNN ',
|
||||||
float(get_pmc_register('in14_input'))/1000, 'V'
|
float(get_pmc_register('in14_input'))/1000, 'V')
|
||||||
print ' CPU XP1R0V_CPU_VCC ',\
|
print(' CPU XP1R0V_CPU_VCC ',
|
||||||
float(get_pmc_register('in15_input'))/1000, 'V'
|
float(get_pmc_register('in15_input'))/1000, 'V')
|
||||||
print ' CPU XP1R5V_EARLY ',\
|
print(' CPU XP1R5V_EARLY ',
|
||||||
float(get_pmc_register('in16_input'))/1000, 'V'
|
float(get_pmc_register('in16_input'))/1000, 'V')
|
||||||
print ' SW XP3R3V_MON ',\
|
print(' SW XP3R3V_MON ',
|
||||||
float(get_pmc_register('in17_input'))/1000, 'V'
|
float(get_pmc_register('in17_input'))/1000, 'V')
|
||||||
print ' SW XP1R25V_MON ',\
|
print(' SW XP1R25V_MON ',
|
||||||
float(get_pmc_register('in19_input'))/1000, 'V'
|
float(get_pmc_register('in19_input'))/1000, 'V')
|
||||||
print ' SW XP1R2V_MON ',\
|
print(' SW XP1R2V_MON ',
|
||||||
float(get_pmc_register('in20_input'))/1000, 'V'
|
float(get_pmc_register('in20_input'))/1000, 'V')
|
||||||
print ' SW XP1R0V_SW_MON ',\
|
print(' SW XP1R0V_SW_MON ',
|
||||||
float(get_pmc_register('in21_input'))/1000, 'V'
|
float(get_pmc_register('in21_input'))/1000, 'V')
|
||||||
print ' SW XP1R0V_ROV_SW_MON ',\
|
print(' SW XP1R0V_ROV_SW_MON ',
|
||||||
float(get_pmc_register('in22_input'))/1000, 'V'
|
float(get_pmc_register('in22_input'))/1000, 'V')
|
||||||
print ' SW XR1R0V_BCM84752_MON ',\
|
print(' SW XR1R0V_BCM84752_MON ',
|
||||||
float(get_pmc_register('in23_input'))/1000, 'V'
|
float(get_pmc_register('in23_input'))/1000, 'V')
|
||||||
print ' SW XP5V_MB_MON ',\
|
print(' SW XP5V_MB_MON ',
|
||||||
float(get_pmc_register('in24_input'))/1000, 'V'
|
float(get_pmc_register('in24_input'))/1000, 'V')
|
||||||
print ' SW XP3R3V_FPGA_MON ',\
|
print(' SW XP3R3V_FPGA_MON ',
|
||||||
float(get_pmc_register('in26_input'))/1000, 'V'
|
float(get_pmc_register('in26_input'))/1000, 'V')
|
||||||
print ' SW XP3R3V_EARLY_MON ',\
|
print(' SW XP3R3V_EARLY_MON ',
|
||||||
float(get_pmc_register('in27_input'))/1000, 'V'
|
float(get_pmc_register('in27_input'))/1000, 'V')
|
||||||
|
|
||||||
print_voltage_sensors()
|
print_voltage_sensors()
|
||||||
|
|
||||||
@ -169,40 +168,40 @@ def print_fan_tray(tray):
|
|||||||
Fan_Status = ['Normal', 'Abnormal']
|
Fan_Status = ['Normal', 'Abnormal']
|
||||||
Airflow_Direction = ['B2F', 'F2B']
|
Airflow_Direction = ['B2F', 'F2B']
|
||||||
|
|
||||||
print ' Fan Tray ' + str(tray) + ':'
|
print(' Fan Tray ' + str(tray) + ':')
|
||||||
|
|
||||||
if (tray == 1):
|
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)
|
air_flow_reg = int(get_pmc_register('fan1_airflow'), 16)
|
||||||
fan1_status = 0 if fan1_speed >= 1000 else 1
|
fan1_status = 0 if fan1_speed >= 1000 else 1
|
||||||
|
|
||||||
print ' Fan Speed: ', fan1_speed, 'RPM'
|
print(' Fan Speed: ', fan1_speed, 'RPM')
|
||||||
print ' Fan State: ', Fan_Status[fan1_status]
|
print(' Fan State: ', Fan_Status[fan1_status])
|
||||||
print ' Air Flow: ', Airflow_Direction[air_flow_reg]
|
print(' Air Flow: ', Airflow_Direction[air_flow_reg])
|
||||||
elif (tray == 2):
|
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)
|
air_flow_reg = int(get_pmc_register('fan3_airflow'), 16)
|
||||||
fan1_status = 0 if fan1_speed >= 1000 else 1
|
fan1_status = 0 if fan1_speed >= 1000 else 1
|
||||||
|
|
||||||
print ' Fan Speed: ', fan1_speed, 'RPM'
|
print(' Fan Speed: ', fan1_speed, 'RPM')
|
||||||
print ' Fan State: ', Fan_Status[fan1_status]
|
print(' Fan State: ', Fan_Status[fan1_status])
|
||||||
print ' Air Flow: ', Airflow_Direction[air_flow_reg]
|
print(' Air Flow: ', Airflow_Direction[air_flow_reg])
|
||||||
elif (tray == 3):
|
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)
|
air_flow_reg = int(get_pmc_register('fan5_airflow'), 16)
|
||||||
fan1_status = 0 if fan1_speed >= 1000 else 1
|
fan1_status = 0 if fan1_speed >= 1000 else 1
|
||||||
|
|
||||||
print ' Fan Speed: ', fan1_speed, 'RPM'
|
print(' Fan Speed: ', fan1_speed, 'RPM')
|
||||||
print ' Fan State: ', Fan_Status[fan1_status]
|
print(' Fan State: ', Fan_Status[fan1_status])
|
||||||
print ' Air Flow: ', Airflow_Direction[air_flow_reg]
|
print(' Air Flow: ', Airflow_Direction[air_flow_reg])
|
||||||
elif (tray == 4):
|
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)
|
air_flow_reg = int(get_pmc_register('fan7_airflow'), 16)
|
||||||
fan1_status = 0 if fan1_speed >= 1000 else 1
|
fan1_status = 0 if fan1_speed >= 1000 else 1
|
||||||
|
|
||||||
print ' Fan Speed: ', fan1_speed, 'RPM'
|
print(' Fan Speed: ', fan1_speed, 'RPM')
|
||||||
print ' Fan State: ', Fan_Status[fan1_status]
|
print(' Fan State: ', Fan_Status[fan1_status])
|
||||||
print ' Air Flow: ', Airflow_Direction[air_flow_reg]
|
print(' Air Flow: ', Airflow_Direction[air_flow_reg])
|
||||||
|
|
||||||
print('\nFan Trays:')
|
print('\nFan Trays:')
|
||||||
fan_tray_presence = get_pmc_register('fan_tray_presence')
|
fan_tray_presence = get_pmc_register('fan_tray_presence')
|
||||||
@ -214,7 +213,7 @@ if (fan_tray_presence != 'ERR'):
|
|||||||
if (fan_tray_presence & (1 << tray)):
|
if (fan_tray_presence & (1 << tray)):
|
||||||
print_fan_tray(tray + 1)
|
print_fan_tray(tray + 1)
|
||||||
else:
|
else:
|
||||||
print '\n Fan Tray ' + str(tray + 1) + ': Not present'
|
print('\n Fan Tray ' + str(tray + 1) + ': Not present')
|
||||||
else:
|
else:
|
||||||
logging.error('Unable to read FAN presence')
|
logging.error('Unable to read FAN presence')
|
||||||
|
|
||||||
@ -233,7 +232,7 @@ def print_psu(psu):
|
|||||||
Psu_Fan_Status = ['Normal', 'Abnormal']
|
Psu_Fan_Status = ['Normal', 'Abnormal']
|
||||||
Psu_Fan_Airflow = ['B2F', 'F2B']
|
Psu_Fan_Airflow = ['B2F', 'F2B']
|
||||||
|
|
||||||
print ' PSU ' + str(psu) + ':'
|
print(' PSU ' + str(psu) + ':')
|
||||||
if (psu == 1):
|
if (psu == 1):
|
||||||
psu_status = int(get_pmc_register('psu1_presence'), 16)
|
psu_status = int(get_pmc_register('psu1_presence'), 16)
|
||||||
else:
|
else:
|
||||||
@ -244,12 +243,12 @@ def print_psu(psu):
|
|||||||
psu_type = (psu_status & (1 << PSU_STATUS_TYPE_BIT)) >>\
|
psu_type = (psu_status & (1 << PSU_STATUS_TYPE_BIT)) >>\
|
||||||
PSU_STATUS_TYPE_BIT
|
PSU_STATUS_TYPE_BIT
|
||||||
|
|
||||||
print ' Input: ', Psu_Input_Type[psu_input_type]
|
print(' Input: ', Psu_Input_Type[psu_input_type])
|
||||||
print ' Type: ', Psu_Type[psu_type]
|
print(' Type: ', Psu_Type[psu_type])
|
||||||
|
|
||||||
# PSU FAN details
|
# PSU FAN details
|
||||||
if (psu == 1):
|
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_airflow = int(get_pmc_register('fan11_airflow'))
|
||||||
psu_fan_status = int(get_pmc_register('fan11_alarm'))
|
psu_fan_status = int(get_pmc_register('fan11_alarm'))
|
||||||
psu_fan_present = int(get_pmc_register('fan11_fault'))
|
psu_fan_present = int(get_pmc_register('fan11_fault'))
|
||||||
@ -262,7 +261,7 @@ def print_psu(psu):
|
|||||||
if (input_power != 0):
|
if (input_power != 0):
|
||||||
psu_fan_temp = int(get_pmc_register('temp14_input'))/1000
|
psu_fan_temp = int(get_pmc_register('temp14_input'))/1000
|
||||||
else:
|
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_airflow = int(get_pmc_register('fan12_airflow'))
|
||||||
psu_fan_status = int(get_pmc_register('fan12_alarm'))
|
psu_fan_status = int(get_pmc_register('fan12_alarm'))
|
||||||
psu_fan_present = int(get_pmc_register('fan12_fault'))
|
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
|
output_power = float(get_pmc_register('power4_input')) / 1000000
|
||||||
if (input_power != 0):
|
if (input_power != 0):
|
||||||
psu_fan_temp = int(get_pmc_register('temp15_input'))/1000
|
psu_fan_temp = int(get_pmc_register('temp15_input'))/1000
|
||||||
print ' FAN: ', Psu_Fan_Presence[psu_fan_present]
|
print(' FAN: ', Psu_Fan_Presence[psu_fan_present])
|
||||||
print ' FAN Status: ', Psu_Fan_Status[psu_fan_status]
|
print(' FAN Status: ', Psu_Fan_Status[psu_fan_status])
|
||||||
print ' FAN AIRFLOW: ', Psu_Fan_Airflow[psu_fan_airflow]
|
print(' FAN AIRFLOW: ', Psu_Fan_Airflow[psu_fan_airflow])
|
||||||
|
|
||||||
# PSU input & output monitors
|
# 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
|
# PSU firmware gives spurious temperature reading without input power
|
||||||
if (input_power != 0):
|
if (input_power != 0):
|
||||||
print ' Temperature: ', psu_fan_temp, 'C'
|
print(' Temperature: ', psu_fan_temp, 'C')
|
||||||
else:
|
else:
|
||||||
print ' Temperature: ', 'NA'
|
print(' Temperature: ', 'NA')
|
||||||
|
|
||||||
print('\nPSUs:')
|
print('\nPSUs:')
|
||||||
for psu in range(1, S6100_MAX_PSUS + 1):
|
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):
|
if (~psu_status & 0b1):
|
||||||
print_psu(psu)
|
print_psu(psu)
|
||||||
else:
|
else:
|
||||||
print '\n PSU ', psu, 'Not present'
|
print('\n PSU ', psu, 'Not present')
|
||||||
else:
|
else:
|
||||||
logging.error('Unable to check PSU presence')
|
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:')
|
print('\nIO Modules:')
|
||||||
|
|
||||||
for iom in range(1, S6100_MAX_IOMS+1):
|
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')
|
||||||
|
@ -7,6 +7,7 @@ install_python_api_package() {
|
|||||||
platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)
|
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=$(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() {
|
remove_python_api_package() {
|
||||||
@ -14,6 +15,11 @@ remove_python_api_package() {
|
|||||||
if [ $? -eq 0 ]; then
|
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
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ setup(
|
|||||||
'Natural Language :: English',
|
'Natural Language :: English',
|
||||||
'Operating System :: POSIX :: Linux',
|
'Operating System :: POSIX :: Linux',
|
||||||
'Programming Language :: Python :: 2.7',
|
'Programming Language :: Python :: 2.7',
|
||||||
|
'Programming Language :: Python :: 3.7',
|
||||||
'Topic :: Utilities',
|
'Topic :: Utilities',
|
||||||
],
|
],
|
||||||
keywords='sonic SONiC platform PLATFORM',
|
keywords='sonic SONiC platform PLATFORM',
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
import os
|
import os
|
||||||
from sonic_platform_base.platform_base import PlatformBase
|
|
||||||
from sonic_platform_base.chassis_base import ChassisBase
|
from sonic_platform_base.chassis_base import ChassisBase
|
||||||
from sonic_platform.sfp import Sfp
|
from sonic_platform.sfp import Sfp
|
||||||
from sonic_platform.psu import Psu
|
from sonic_platform.psu import Psu
|
||||||
@ -19,7 +18,7 @@ try:
|
|||||||
from sonic_platform.thermal import Thermal
|
from sonic_platform.thermal import Thermal
|
||||||
from sonic_platform.component import Component
|
from sonic_platform.component import Component
|
||||||
from sonic_platform.watchdog import Watchdog
|
from sonic_platform.watchdog import Watchdog
|
||||||
from eeprom import Eeprom
|
from sonic_platform.eeprom import Eeprom
|
||||||
import time
|
import time
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise ImportError(str(e) + "- required module not found")
|
raise ImportError(str(e) + "- required module not found")
|
||||||
@ -182,16 +181,6 @@ class Chassis(ChassisBase):
|
|||||||
"""
|
"""
|
||||||
return self._eeprom.base_mac_addr()
|
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):
|
def get_system_eeprom_info(self):
|
||||||
"""
|
"""
|
||||||
Retrieves the full content of system EEPROM information for the chassis
|
Retrieves the full content of system EEPROM information for the chassis
|
||||||
|
@ -79,7 +79,7 @@ class Component(ComponentBase):
|
|||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT)
|
||||||
stdout = proc.communicate()[0]
|
stdout = proc.communicate()[0]
|
||||||
proc.wait()
|
proc.wait()
|
||||||
result = stdout.rstrip('\n')
|
result = stdout.decode('utf-8').rstrip('\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
result = None
|
result = None
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
try:
|
try:
|
||||||
from sonic_eeprom import eeprom_tlvinfo
|
from sonic_eeprom import eeprom_tlvinfo
|
||||||
import binascii
|
import binascii
|
||||||
except ImportError, e:
|
except ImportError as e:
|
||||||
raise ImportError(str(e) + "- required module not found")
|
raise ImportError(str(e) + "- required module not found")
|
||||||
|
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ class Fan(FanBase):
|
|||||||
fan_speed = self._get_pmc_register(self.get_fan_speed_reg)
|
fan_speed = self._get_pmc_register(self.get_fan_speed_reg)
|
||||||
if (fan_speed != 'ERR') and self.get_presence():
|
if (fan_speed != 'ERR') and self.get_presence():
|
||||||
speed_in_rpm = int(fan_speed, 10)
|
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:
|
else:
|
||||||
speed = 0
|
speed = 0
|
||||||
|
|
||||||
|
@ -172,15 +172,6 @@ class Module(ModuleBase):
|
|||||||
# In S6100, individual modules doesn't have MAC address
|
# In S6100, individual modules doesn't have MAC address
|
||||||
return '00:00:00:00:00:00'
|
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):
|
def get_system_eeprom_info(self):
|
||||||
"""
|
"""
|
||||||
Retrieves the full content of system EEPROM information for the module
|
Retrieves the full content of system EEPROM information for the module
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
@ -9,17 +8,16 @@ PORT_RES = '/dev/port'
|
|||||||
def portio_reg_write(resource, offset, val):
|
def portio_reg_write(resource, offset, val):
|
||||||
fd = os.open(resource, os.O_RDWR)
|
fd = os.open(resource, os.O_RDWR)
|
||||||
if(fd < 0):
|
if(fd < 0):
|
||||||
print 'file open failed %s" % resource'
|
print('file open failed %s" % resource')
|
||||||
return
|
return
|
||||||
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
|
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
|
||||||
print 'lseek failed on %s' % resource
|
print('lseek failed on %s' % resource)
|
||||||
return
|
return
|
||||||
ret = os.write(fd, struct.pack('B', val))
|
ret = os.write(fd, struct.pack('B', val))
|
||||||
if(ret != 1):
|
if(ret != 1):
|
||||||
print 'write failed %d' % ret
|
print('write failed %d' % ret)
|
||||||
return
|
return
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
portio_reg_write(PORT_RES, 0xcf9, 0xe)
|
portio_reg_write(PORT_RES, 0xcf9, 0xe)
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
#
|
#
|
||||||
# On Z9100, the Platform Management Controller runs the
|
# On Z9100, the Platform Management Controller runs the
|
||||||
# thermal algorithm. It provides a mailbox for the Host
|
# 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
|
mb_reg_file = MAILBOX_DIR+'/'+reg_name
|
||||||
|
|
||||||
if (not os.path.isfile(mb_reg_file)):
|
if (not os.path.isfile(mb_reg_file)):
|
||||||
print mb_reg_file, 'not found !'
|
print(mb_reg_file, 'not found !')
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -44,8 +44,8 @@ def get_pmc_register(reg_name):
|
|||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
if (os.path.isdir(MAILBOX_DIR)):
|
if (os.path.isdir(MAILBOX_DIR)):
|
||||||
print 'dell-z9100-lpc'
|
print('dell-z9100-lpc')
|
||||||
print 'Adapter: Z9100 Platform Management Controller'
|
print('Adapter: Z9100 Platform Management Controller')
|
||||||
else:
|
else:
|
||||||
logging.error('Z9100 Platform Management Controller module not loaded !')
|
logging.error('Z9100 Platform Management Controller module not loaded !')
|
||||||
# sys.exit(0)
|
# sys.exit(0)
|
||||||
@ -55,18 +55,18 @@ else:
|
|||||||
|
|
||||||
def print_temperature_sensors():
|
def print_temperature_sensors():
|
||||||
print("\nOnboard Temperature Sensors:")
|
print("\nOnboard Temperature Sensors:")
|
||||||
print ' CPU: ',\
|
print(' CPU: ',
|
||||||
int(get_pmc_register('temp1_input'))/1000, 'C'
|
int(get_pmc_register('temp1_input'))/1000, 'C')
|
||||||
print ' BCM56960 (PSU side): ',\
|
print(' BCM56960 (PSU side): ',
|
||||||
int(get_pmc_register('temp2_input'))/1000, 'C'
|
int(get_pmc_register('temp2_input'))/1000, 'C')
|
||||||
print ' System Outlet 1 (switch board): ',\
|
print(' System Outlet 1 (switch board): ',
|
||||||
int(get_pmc_register('temp3_input'))/1000, 'C'
|
int(get_pmc_register('temp3_input'))/1000, 'C')
|
||||||
print ' BCM56960 (IO side): ',\
|
print(' BCM56960 (IO side): ',
|
||||||
int(get_pmc_register('temp4_input'))/1000, 'C'
|
int(get_pmc_register('temp4_input'))/1000, 'C')
|
||||||
print ' System Outlet 2 (CPU board): ',\
|
print(' System Outlet 2 (CPU board): ',
|
||||||
int(get_pmc_register('temp9_input'))/1000, 'C'
|
int(get_pmc_register('temp9_input'))/1000, 'C')
|
||||||
print ' System Inlet Left (IO side): ',\
|
print(' System Inlet Left (IO side): ',
|
||||||
int(get_pmc_register('temp6_input'))/1000, 'C'
|
int(get_pmc_register('temp6_input'))/1000, 'C')
|
||||||
|
|
||||||
print_temperature_sensors()
|
print_temperature_sensors()
|
||||||
|
|
||||||
@ -77,63 +77,62 @@ print_temperature_sensors()
|
|||||||
def print_voltage_sensors():
|
def print_voltage_sensors():
|
||||||
print("\nOnboard Voltage Sensors:")
|
print("\nOnboard Voltage Sensors:")
|
||||||
|
|
||||||
print ' CPU XP3R3V_EARLY ',\
|
print(' CPU XP3R3V_EARLY ',
|
||||||
float(get_pmc_register('in1_input'))/1000, 'V'
|
float(get_pmc_register('in1_input'))/1000, 'V')
|
||||||
print '\n CPU XP5R0V_CP ',\
|
print('\n CPU XP5R0V_CP ',
|
||||||
float(get_pmc_register('in2_input'))/1000, 'V'
|
float(get_pmc_register('in2_input'))/1000, 'V')
|
||||||
print ' CPU XP3R3V_STD ',\
|
print(' CPU XP3R3V_STD ',
|
||||||
float(get_pmc_register('in3_input'))/1000, 'V'
|
float(get_pmc_register('in3_input'))/1000, 'V')
|
||||||
print ' CPU XP3R3V_CP ',\
|
print(' CPU XP3R3V_CP ',
|
||||||
float(get_pmc_register('in4_input'))/1000, 'V'
|
float(get_pmc_register('in4_input'))/1000, 'V')
|
||||||
print ' CPU XP0R75V_VTT_A ',\
|
print(' CPU XP0R75V_VTT_A ',
|
||||||
float(get_pmc_register('in5_input'))/1000, 'V'
|
float(get_pmc_register('in5_input'))/1000, 'V')
|
||||||
print ' CPU XPPR75V_VTT_B ',\
|
print(' CPU XPPR75V_VTT_B ',
|
||||||
float(get_pmc_register('in6_input'))/1000, 'V'
|
float(get_pmc_register('in6_input'))/1000, 'V')
|
||||||
print ' CPU XP1R07V_CPU ',\
|
print(' CPU XP1R07V_CPU ',
|
||||||
float(get_pmc_register('in7_input'))/1000, 'V'
|
float(get_pmc_register('in7_input'))/1000, 'V')
|
||||||
print ' CPU XP1R0V_CPU ',\
|
print(' CPU XP1R0V_CPU ',
|
||||||
float(get_pmc_register('in8_input'))/1000, 'V'
|
float(get_pmc_register('in8_input'))/1000, 'V')
|
||||||
print ' CPU XP12R0V ',\
|
print(' CPU XP12R0V ',
|
||||||
float(get_pmc_register('in9_input'))/1000, 'V'
|
float(get_pmc_register('in9_input'))/1000, 'V')
|
||||||
print ' CPU VDDR_CPU_2 ',\
|
print(' CPU VDDR_CPU_2 ',
|
||||||
float(get_pmc_register('in10_input'))/1000, 'V'
|
float(get_pmc_register('in10_input'))/1000, 'V')
|
||||||
print ' CPU VDDR_CPU_1 ',\
|
print(' CPU VDDR_CPU_1 ',
|
||||||
float(get_pmc_register('in11_input'))/1000, 'V'
|
float(get_pmc_register('in11_input'))/1000, 'V')
|
||||||
print ' CPU XP1R5V_CLK ',\
|
print(' CPU XP1R5V_CLK ',
|
||||||
float(get_pmc_register('in12_input'))/1000, 'V'
|
float(get_pmc_register('in12_input'))/1000, 'V')
|
||||||
print ' CPU XP1R8V_CPU ',\
|
print(' CPU XP1R8V_CPU ',
|
||||||
float(get_pmc_register('in13_input'))/1000, 'V'
|
float(get_pmc_register('in13_input'))/1000, 'V')
|
||||||
print ' CPU XP1R0V_CPU_VNN ',\
|
print(' CPU XP1R0V_CPU_VNN ',
|
||||||
float(get_pmc_register('in14_input'))/1000, 'V'
|
float(get_pmc_register('in14_input'))/1000, 'V')
|
||||||
print ' CPU XP1R0V_CPU_VCC ',\
|
print(' CPU XP1R0V_CPU_VCC ',
|
||||||
float(get_pmc_register('in15_input'))/1000, 'V'
|
float(get_pmc_register('in15_input'))/1000, 'V')
|
||||||
print ' CPU XP1R5V_EARLY ',\
|
print(' CPU XP1R5V_EARLY ',
|
||||||
float(get_pmc_register('in16_input'))/1000, 'V'
|
float(get_pmc_register('in16_input'))/1000, 'V')
|
||||||
print ' SW XP3R3V_MON ',\
|
print(' SW XP3R3V_MON ',
|
||||||
float(get_pmc_register('in17_input'))/1000, 'V'
|
float(get_pmc_register('in17_input'))/1000, 'V')
|
||||||
print ' SW XP1R8V_MON ',\
|
print(' SW XP1R8V_MON ',
|
||||||
float(get_pmc_register('in19_input'))/1000, 'V'
|
float(get_pmc_register('in19_input'))/1000, 'V')
|
||||||
print ' SW XP1R2V_MON ',\
|
print(' SW XP1R2V_MON ',
|
||||||
float(get_pmc_register('in20_input'))/1000, 'V'
|
float(get_pmc_register('in20_input'))/1000, 'V')
|
||||||
print ' SW XP1R0V_SW_MON ',\
|
print(' SW XP1R0V_SW_MON ',
|
||||||
float(get_pmc_register('in21_input'))/1000, 'V'
|
float(get_pmc_register('in21_input'))/1000, 'V')
|
||||||
print ' SW XP1R0V_ROV_SW_MON ',\
|
print(' SW XP1R0V_ROV_SW_MON ',
|
||||||
float(get_pmc_register('in22_input'))/1000, 'V'
|
float(get_pmc_register('in22_input'))/1000, 'V')
|
||||||
print ' SW XR1R0V_BCM84752_MON ',\
|
print(' SW XR1R0V_BCM84752_MON ',
|
||||||
float(get_pmc_register('in23_input'))/1000, 'V'
|
float(get_pmc_register('in23_input'))/1000, 'V')
|
||||||
print ' SW XP5V_MB_MON ',\
|
print(' SW XP5V_MB_MON ',
|
||||||
float(get_pmc_register('in24_input'))/1000, 'V'
|
float(get_pmc_register('in24_input'))/1000, 'V')
|
||||||
print ' SW XP1R8V_FPGA_MON ',\
|
print(' SW XP1R8V_FPGA_MON ',
|
||||||
float(get_pmc_register('in25_input'))/1000, 'V'
|
float(get_pmc_register('in25_input'))/1000, 'V')
|
||||||
print ' SW XP3R3V_FPGA_MON ',\
|
print(' SW XP3R3V_FPGA_MON ',
|
||||||
float(get_pmc_register('in26_input'))/1000, 'V'
|
float(get_pmc_register('in26_input'))/1000, 'V')
|
||||||
print ' SW XP3R3V_EARLY_MON ',\
|
print(' SW XP3R3V_EARLY_MON ',
|
||||||
float(get_pmc_register('in27_input'))/1000, 'V'
|
float(get_pmc_register('in27_input'))/1000, 'V')
|
||||||
print ' SW XP1R0V_ ',\
|
print(' SW XP1R0V_ ',
|
||||||
float(get_pmc_register('curr21_input'))/10000, 'A'
|
float(get_pmc_register('curr21_input'))/10000, 'A')
|
||||||
print ' SW XP1R0V_ROV ',\
|
print(' SW XP1R0V_ROV ',
|
||||||
float(get_pmc_register('curr22_input'))/10000, 'A'
|
float(get_pmc_register('curr22_input'))/10000, 'A')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print_voltage_sensors()
|
print_voltage_sensors()
|
||||||
@ -146,68 +145,68 @@ def print_fan_tray(tray):
|
|||||||
Fan_Status = ['Normal', 'Abnormal']
|
Fan_Status = ['Normal', 'Abnormal']
|
||||||
Airflow_Direction = ['B2F', 'F2B']
|
Airflow_Direction = ['B2F', 'F2B']
|
||||||
|
|
||||||
print ' Fan Tray ' + str(tray) + ':'
|
print(' Fan Tray ' + str(tray) + ':')
|
||||||
|
|
||||||
if (tray == 1):
|
if (tray == 1):
|
||||||
fan1_speed = get_pmc_register('fan1_input')
|
fan1_speed = int(get_pmc_register('fan1_input'))
|
||||||
fan2_speed = get_pmc_register('fan2_input')
|
fan2_speed = int(get_pmc_register('fan2_input'))
|
||||||
air_flow_reg = int(get_pmc_register('fan1_airflow'), 16)
|
air_flow_reg = int(get_pmc_register('fan1_airflow'), 16)
|
||||||
fan1_status = 0 if fan1_speed >= 1000 else 1
|
fan1_status = 0 if fan1_speed >= 1000 else 1
|
||||||
fan2_status = 0 if fan2_speed >= 1000 else 1
|
fan2_status = 0 if fan2_speed >= 1000 else 1
|
||||||
|
|
||||||
print ' Fan1 Speed: ', fan1_speed, 'RPM'
|
print(' Fan1 Speed: ', fan1_speed, 'RPM')
|
||||||
print ' Fan2 Speed: ', fan2_speed, 'RPM'
|
print(' Fan2 Speed: ', fan2_speed, 'RPM')
|
||||||
print ' Fan1 State: ', Fan_Status[fan1_status]
|
print(' Fan1 State: ', Fan_Status[fan1_status])
|
||||||
print ' Fan2 State: ', Fan_Status[fan2_status]
|
print(' Fan2 State: ', Fan_Status[fan2_status])
|
||||||
print ' Air Flow: ', Airflow_Direction[air_flow_reg]
|
print(' Air Flow: ', Airflow_Direction[air_flow_reg])
|
||||||
elif (tray == 2):
|
elif (tray == 2):
|
||||||
fan1_speed = get_pmc_register('fan3_input')
|
fan1_speed = int(get_pmc_register('fan3_input'))
|
||||||
fan2_speed = get_pmc_register('fan4_input')
|
fan2_speed = int(get_pmc_register('fan4_input'))
|
||||||
air_flow_reg = int(get_pmc_register('fan3_airflow'), 16)
|
air_flow_reg = int(get_pmc_register('fan3_airflow'), 16)
|
||||||
fan1_status = 0 if fan1_speed >= 1000 else 1
|
fan1_status = 0 if fan1_speed >= 1000 else 1
|
||||||
fan2_status = 0 if fan2_speed >= 1000 else 1
|
fan2_status = 0 if fan2_speed >= 1000 else 1
|
||||||
|
|
||||||
print ' Fan1 Speed: ', fan1_speed, 'RPM'
|
print(' Fan1 Speed: ', fan1_speed, 'RPM')
|
||||||
print ' Fan2 Speed: ', fan2_speed, 'RPM'
|
print(' Fan2 Speed: ', fan2_speed, 'RPM')
|
||||||
print ' Fan1 State: ', Fan_Status[fan1_status]
|
print(' Fan1 State: ', Fan_Status[fan1_status])
|
||||||
print ' Fan2 State: ', Fan_Status[fan2_status]
|
print(' Fan2 State: ', Fan_Status[fan2_status])
|
||||||
print ' Air Flow: ', Airflow_Direction[air_flow_reg]
|
print(' Air Flow: ', Airflow_Direction[air_flow_reg])
|
||||||
elif (tray == 3):
|
elif (tray == 3):
|
||||||
fan1_speed = get_pmc_register('fan5_input')
|
fan1_speed = int(get_pmc_register('fan5_input'))
|
||||||
fan2_speed = get_pmc_register('fan6_input')
|
fan2_speed = int(get_pmc_register('fan6_input'))
|
||||||
air_flow_reg = int(get_pmc_register('fan5_airflow'), 16)
|
air_flow_reg = int(get_pmc_register('fan5_airflow'), 16)
|
||||||
fan1_status = 0 if fan1_speed >= 1000 else 1
|
fan1_status = 0 if fan1_speed >= 1000 else 1
|
||||||
fan2_status = 0 if fan2_speed >= 1000 else 1
|
fan2_status = 0 if fan2_speed >= 1000 else 1
|
||||||
|
|
||||||
print ' Fan1 Speed: ', fan1_speed, 'RPM'
|
print(' Fan1 Speed: ', fan1_speed, 'RPM')
|
||||||
print ' Fan2 Speed: ', fan2_speed, 'RPM'
|
print(' Fan2 Speed: ', fan2_speed, 'RPM')
|
||||||
print ' Fan1 State: ', Fan_Status[fan1_status]
|
print(' Fan1 State: ', Fan_Status[fan1_status])
|
||||||
print ' Fan2 State: ', Fan_Status[fan2_status]
|
print(' Fan2 State: ', Fan_Status[fan2_status])
|
||||||
print ' Air Flow: ', Airflow_Direction[air_flow_reg]
|
print(' Air Flow: ', Airflow_Direction[air_flow_reg])
|
||||||
elif (tray == 4):
|
elif (tray == 4):
|
||||||
fan1_speed = get_pmc_register('fan7_input')
|
fan1_speed = int(get_pmc_register('fan7_input'))
|
||||||
fan2_speed = get_pmc_register('fan8_input')
|
fan2_speed = int(get_pmc_register('fan8_input'))
|
||||||
air_flow_reg = int(get_pmc_register('fan7_airflow'), 16)
|
air_flow_reg = int(get_pmc_register('fan7_airflow'), 16)
|
||||||
fan1_status = 0 if fan1_speed >= 1000 else 1
|
fan1_status = 0 if fan1_speed >= 1000 else 1
|
||||||
fan2_status = 0 if fan2_speed >= 1000 else 1
|
fan2_status = 0 if fan2_speed >= 1000 else 1
|
||||||
|
|
||||||
print ' Fan1 Speed: ', fan1_speed, 'RPM'
|
print(' Fan1 Speed: ', fan1_speed, 'RPM')
|
||||||
print ' Fan2 Speed: ', fan2_speed, 'RPM'
|
print(' Fan2 Speed: ', fan2_speed, 'RPM')
|
||||||
print ' Fan1 State: ', Fan_Status[fan1_status]
|
print(' Fan1 State: ', Fan_Status[fan1_status])
|
||||||
print ' Fan2 State: ', Fan_Status[fan2_status]
|
print(' Fan2 State: ', Fan_Status[fan2_status])
|
||||||
print ' Air Flow: ', Airflow_Direction[air_flow_reg]
|
print(' Air Flow: ', Airflow_Direction[air_flow_reg])
|
||||||
elif (tray == 5):
|
elif (tray == 5):
|
||||||
fan1_speed = get_pmc_register('fan9_input')
|
fan1_speed = int(get_pmc_register('fan9_input'))
|
||||||
fan2_speed = get_pmc_register('fan10_input')
|
fan2_speed = int(get_pmc_register('fan10_input'))
|
||||||
air_flow_reg = int(get_pmc_register('fan9_airflow'), 16)
|
air_flow_reg = int(get_pmc_register('fan9_airflow'), 16)
|
||||||
fan1_status = 0 if fan1_speed >= 1000 else 1
|
fan1_status = 0 if fan1_speed >= 1000 else 1
|
||||||
fan2_status = 0 if fan2_speed >= 1000 else 1
|
fan2_status = 0 if fan2_speed >= 1000 else 1
|
||||||
|
|
||||||
print ' Fan1 Speed: ', fan1_speed, 'RPM'
|
print(' Fan1 Speed: ', fan1_speed, 'RPM')
|
||||||
print ' Fan2 Speed: ', fan2_speed, 'RPM'
|
print(' Fan2 Speed: ', fan2_speed, 'RPM')
|
||||||
print ' Fan1 State: ', Fan_Status[fan1_status]
|
print(' Fan1 State: ', Fan_Status[fan1_status])
|
||||||
print ' Fan2 State: ', Fan_Status[fan2_status]
|
print(' Fan2 State: ', Fan_Status[fan2_status])
|
||||||
print ' Air Flow: ', Airflow_Direction[air_flow_reg]
|
print(' Air Flow: ', Airflow_Direction[air_flow_reg])
|
||||||
|
|
||||||
|
|
||||||
print('\nFan Trays:')
|
print('\nFan Trays:')
|
||||||
@ -220,7 +219,7 @@ if (fan_tray_presence != 'ERR'):
|
|||||||
if (fan_tray_presence & (1 << tray)):
|
if (fan_tray_presence & (1 << tray)):
|
||||||
print_fan_tray(tray + 1)
|
print_fan_tray(tray + 1)
|
||||||
else:
|
else:
|
||||||
print '\n Fan Tray ' + str(tray + 1) + ': Not present'
|
print('\n Fan Tray ' + str(tray + 1) + ': Not present')
|
||||||
else:
|
else:
|
||||||
logging.error('Unable to read FAN presence')
|
logging.error('Unable to read FAN presence')
|
||||||
|
|
||||||
@ -239,8 +238,7 @@ def print_psu(psu):
|
|||||||
Psu_Fan_Status = ['Normal', 'Abnormal']
|
Psu_Fan_Status = ['Normal', 'Abnormal']
|
||||||
Psu_Fan_Airflow = ['B2F', 'F2B']
|
Psu_Fan_Airflow = ['B2F', 'F2B']
|
||||||
|
|
||||||
|
print(' PSU ' + str(psu) + ':')
|
||||||
print ' PSU ' + str(psu) + ':'
|
|
||||||
if (psu == 1):
|
if (psu == 1):
|
||||||
psu_status = int(get_pmc_register('psu1_presence'), 16)
|
psu_status = int(get_pmc_register('psu1_presence'), 16)
|
||||||
else:
|
else:
|
||||||
@ -251,12 +249,12 @@ def print_psu(psu):
|
|||||||
psu_type = (psu_status & (1 << PSU_STATUS_TYPE_BIT)) >>\
|
psu_type = (psu_status & (1 << PSU_STATUS_TYPE_BIT)) >>\
|
||||||
PSU_STATUS_TYPE_BIT
|
PSU_STATUS_TYPE_BIT
|
||||||
|
|
||||||
print ' Input: ', Psu_Input_Type[psu_input_type]
|
print(' Input: ', Psu_Input_Type[psu_input_type])
|
||||||
print ' Type: ', Psu_Type[psu_type]
|
print(' Type: ', Psu_Type[psu_type])
|
||||||
|
|
||||||
# PSU FAN details
|
# PSU FAN details
|
||||||
if (psu == 1):
|
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_airflow = int(get_pmc_register('fan11_airflow'))
|
||||||
psu_fan_status = int(get_pmc_register('fan11_alarm'))
|
psu_fan_status = int(get_pmc_register('fan11_alarm'))
|
||||||
psu_fan_present = int(get_pmc_register('fan11_fault'))
|
psu_fan_present = int(get_pmc_register('fan11_fault'))
|
||||||
@ -269,7 +267,7 @@ def print_psu(psu):
|
|||||||
if (input_power != 0):
|
if (input_power != 0):
|
||||||
psu_fan_temp = int(get_pmc_register('temp14_input'))/1000
|
psu_fan_temp = int(get_pmc_register('temp14_input'))/1000
|
||||||
else:
|
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_airflow = int(get_pmc_register('fan12_airflow'))
|
||||||
psu_fan_status = int(get_pmc_register('fan12_alarm'))
|
psu_fan_status = int(get_pmc_register('fan12_alarm'))
|
||||||
psu_fan_present = int(get_pmc_register('fan12_fault'))
|
psu_fan_present = int(get_pmc_register('fan12_fault'))
|
||||||
@ -282,28 +280,28 @@ def print_psu(psu):
|
|||||||
if (input_power != 0):
|
if (input_power != 0):
|
||||||
psu_fan_temp = int(get_pmc_register('temp15_input'))/1000
|
psu_fan_temp = int(get_pmc_register('temp15_input'))/1000
|
||||||
|
|
||||||
print ' FAN: ', Psu_Fan_Presence[psu_fan_present]
|
print(' FAN: ', Psu_Fan_Presence[psu_fan_present])
|
||||||
print ' FAN Status: ', Psu_Fan_Status[psu_fan_status]
|
print(' FAN Status: ', Psu_Fan_Status[psu_fan_status])
|
||||||
print ' FAN AIRFLOW: ', Psu_Fan_Airflow[psu_fan_airflow]
|
print(' FAN AIRFLOW: ', Psu_Fan_Airflow[psu_fan_airflow])
|
||||||
|
|
||||||
# PSU input & output monitors
|
# 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
|
# PSU firmware gives spurious temperature reading without input power
|
||||||
if (input_power != 0):
|
if (input_power != 0):
|
||||||
print ' Temperature: ', psu_fan_temp, 'C'
|
print(' Temperature: ', psu_fan_temp, 'C')
|
||||||
else:
|
else:
|
||||||
print ' Temperature: ', 'NA'
|
print(' Temperature: ', 'NA')
|
||||||
|
|
||||||
print('\nPSUs:')
|
print('\nPSUs:')
|
||||||
for psu in range(1, Z9100_MAX_PSUS + 1):
|
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):
|
if (~psu_status & 0b1):
|
||||||
print_psu(psu)
|
print_psu(psu)
|
||||||
else:
|
else:
|
||||||
print '\n PSU ', psu, 'Not present'
|
print('\n PSU ', psu, 'Not present')
|
||||||
else:
|
else:
|
||||||
logging.error('Unable to check PSU presence')
|
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')
|
||||||
|
@ -205,6 +205,7 @@ install_python_api_package() {
|
|||||||
platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)
|
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=$(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() {
|
remove_python_api_package() {
|
||||||
@ -212,6 +213,11 @@ remove_python_api_package() {
|
|||||||
if [ $? -eq 0 ]; then
|
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
|
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
|
init_devnum
|
||||||
|
@ -18,7 +18,7 @@ try:
|
|||||||
from sonic_platform.psu import Psu
|
from sonic_platform.psu import Psu
|
||||||
from sonic_platform.thermal import Thermal
|
from sonic_platform.thermal import Thermal
|
||||||
from sonic_platform.component import Component
|
from sonic_platform.component import Component
|
||||||
from eeprom import Eeprom
|
from sonic_platform.eeprom import Eeprom
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise ImportError(str(e) + "- required module not found")
|
raise ImportError(str(e) + "- required module not found")
|
||||||
|
|
||||||
@ -232,15 +232,6 @@ class Chassis(ChassisBase):
|
|||||||
"""
|
"""
|
||||||
return self._eeprom.base_mac_addr()
|
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):
|
def get_system_eeprom_info(self):
|
||||||
"""
|
"""
|
||||||
Retrieves the full content of system EEPROM information for the chassis
|
Retrieves the full content of system EEPROM information for the chassis
|
||||||
|
@ -67,7 +67,7 @@ class Component(ComponentBase):
|
|||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT)
|
||||||
stdout = proc.communicate()[0]
|
stdout = proc.communicate()[0]
|
||||||
proc.wait()
|
proc.wait()
|
||||||
result = stdout.rstrip('\n')
|
result = stdout.decode('utf-8').rstrip('\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
result = None
|
result = None
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
try:
|
try:
|
||||||
from sonic_eeprom import eeprom_tlvinfo
|
from sonic_eeprom import eeprom_tlvinfo
|
||||||
import binascii
|
import binascii
|
||||||
except ImportError, e:
|
except ImportError as e:
|
||||||
raise ImportError(str(e) + "- required module not found")
|
raise ImportError(str(e) + "- required module not found")
|
||||||
|
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ class Fan(FanBase):
|
|||||||
fan_speed = self._get_pmc_register(self.get_fan_speed_reg)
|
fan_speed = self._get_pmc_register(self.get_fan_speed_reg)
|
||||||
if (fan_speed != 'ERR') and self.get_presence():
|
if (fan_speed != 'ERR') and self.get_presence():
|
||||||
speed_in_rpm = int(fan_speed, 10)
|
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:
|
else:
|
||||||
speed = 0
|
speed = 0
|
||||||
|
|
||||||
|
@ -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:])
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
# On Z9264f, the BaseBoard Management Controller is an
|
# On Z9264f, the BaseBoard Management Controller is an
|
||||||
# autonomous subsystem provides monitoring and management
|
# autonomous subsystem provides monitoring and management
|
||||||
# facility independent of the host CPU. IPMI standard
|
# facility independent of the host CPU. IPMI standard
|
||||||
@ -11,11 +11,9 @@
|
|||||||
# * PSU
|
# * PSU
|
||||||
|
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
import commands
|
|
||||||
|
|
||||||
Z9264F_MAX_FAN_TRAYS = 4
|
Z9264F_MAX_FAN_TRAYS = 4
|
||||||
Z9264F_MAX_PSUS = 2
|
Z9264F_MAX_PSUS = 2
|
||||||
@ -36,7 +34,7 @@ def ipmi_sensor_dump():
|
|||||||
status = 1
|
status = 1
|
||||||
global ipmi_sdr_list
|
global ipmi_sdr_list
|
||||||
ipmi_cmd = IPMI_SENSOR_DATA
|
ipmi_cmd = IPMI_SENSOR_DATA
|
||||||
status, ipmi_sdr_list = commands.getstatusoutput(ipmi_cmd)
|
status, ipmi_sdr_list = subprocess.getstatusoutput(ipmi_cmd)
|
||||||
|
|
||||||
if status:
|
if status:
|
||||||
logging.error('Failed to execute:' + ipmi_sdr_list)
|
logging.error('Failed to execute:' + ipmi_sdr_list)
|
||||||
@ -68,24 +66,24 @@ def print_temperature_sensors():
|
|||||||
|
|
||||||
print("\nOnboard Temperature Sensors:")
|
print("\nOnboard Temperature Sensors:")
|
||||||
|
|
||||||
print ' PT_Left_temp: ',\
|
print(' PT_Left_temp: ',
|
||||||
(get_pmc_register('PT_Left_temp'))
|
get_pmc_register('PT_Left_temp'))
|
||||||
print ' PT_Mid_temp: ',\
|
print(' PT_Mid_temp: ',
|
||||||
(get_pmc_register('PT_Mid_temp'))
|
get_pmc_register('PT_Mid_temp'))
|
||||||
print ' PT_Right_temp: ',\
|
print(' PT_Right_temp: ',
|
||||||
(get_pmc_register('PT_Right_temp'))
|
get_pmc_register('PT_Right_temp'))
|
||||||
print ' Broadcom Temp: ',\
|
print(' Broadcom Temp: ',
|
||||||
(get_pmc_register('TC_Near_temp'))
|
get_pmc_register('TC_Near_temp'))
|
||||||
print ' Inlet Airflow Temp: ',\
|
print(' Inlet Airflow Temp: ',
|
||||||
(get_pmc_register('ILET_AF_temp'))
|
get_pmc_register('ILET_AF_temp'))
|
||||||
print ' CPU Temp: ',\
|
print(' CPU Temp: ',
|
||||||
(get_pmc_register('CPU_Near_temp'))
|
get_pmc_register('CPU_Near_temp'))
|
||||||
print ' CPU Near Temp: ',\
|
print(' CPU Near Temp: ',
|
||||||
(get_pmc_register('CPU_temp'))
|
get_pmc_register('CPU_temp'))
|
||||||
print ' PSU FAN AirFlow Temperature 1: ',\
|
print(' PSU FAN AirFlow Temperature 1: ',
|
||||||
(get_pmc_register('PSU1_AF_temp'))
|
get_pmc_register('PSU1_AF_temp'))
|
||||||
print ' PSU FAN AirFlow Temperature 2: ',\
|
print(' PSU FAN AirFlow Temperature 2: ',
|
||||||
(get_pmc_register('PSU2_AF_temp'))
|
get_pmc_register('PSU2_AF_temp'))
|
||||||
|
|
||||||
ipmi_sensor_dump()
|
ipmi_sensor_dump()
|
||||||
|
|
||||||
@ -99,7 +97,7 @@ def print_fan_tray(tray):
|
|||||||
Fan_Status = [' Normal', ' Abnormal', ' no reading']
|
Fan_Status = [' Normal', ' Abnormal', ' no reading']
|
||||||
Airflow_Direction = ['B2F', 'F2B']
|
Airflow_Direction = ['B2F', 'F2B']
|
||||||
|
|
||||||
print ' Fan Tray ' + str(tray) + ':'
|
print(' Fan Tray ' + str(tray) + ':')
|
||||||
|
|
||||||
if (tray == 1):
|
if (tray == 1):
|
||||||
|
|
||||||
@ -114,14 +112,14 @@ def print_fan_tray(tray):
|
|||||||
fan1_status = 2
|
fan1_status = 2
|
||||||
fan2_status = 2
|
fan2_status = 2
|
||||||
|
|
||||||
print ' Fan1 Speed: ',\
|
print(' Fan1 Speed: ',
|
||||||
get_pmc_register('FAN1_Front_rpm')
|
get_pmc_register('FAN1_Front_rpm'))
|
||||||
print ' Fan2 Speed: ',\
|
print(' Fan2 Speed: ',
|
||||||
get_pmc_register('FAN1_Rear_rpm')
|
get_pmc_register('FAN1_Rear_rpm'))
|
||||||
print ' Fan1 State: ',\
|
print(' Fan1 State: ',
|
||||||
Fan_Status[fan1_status]
|
Fan_Status[fan1_status])
|
||||||
print ' Fan2 State: ',\
|
print(' Fan2 State: ',
|
||||||
Fan_Status[fan2_status]
|
Fan_Status[fan2_status])
|
||||||
|
|
||||||
elif (tray == 2):
|
elif (tray == 2):
|
||||||
|
|
||||||
@ -136,14 +134,14 @@ def print_fan_tray(tray):
|
|||||||
fan1_status = 2
|
fan1_status = 2
|
||||||
fan2_status = 2
|
fan2_status = 2
|
||||||
|
|
||||||
print ' Fan1 Speed: ',\
|
print(' Fan1 Speed: ',
|
||||||
get_pmc_register('FAN2_Front_rpm')
|
get_pmc_register('FAN2_Front_rpm'))
|
||||||
print ' Fan2 Speed: ',\
|
print(' Fan2 Speed: ',
|
||||||
get_pmc_register('FAN2_Rear_rpm')
|
get_pmc_register('FAN2_Rear_rpm'))
|
||||||
print ' Fan1 State: ',\
|
print(' Fan1 State: ',
|
||||||
Fan_Status[fan1_status]
|
Fan_Status[fan1_status])
|
||||||
print ' Fan2 State: ',\
|
print(' Fan2 State: ',
|
||||||
Fan_Status[fan2_status]
|
Fan_Status[fan2_status])
|
||||||
|
|
||||||
elif (tray == 3):
|
elif (tray == 3):
|
||||||
|
|
||||||
@ -158,14 +156,14 @@ def print_fan_tray(tray):
|
|||||||
fan1_status = 2
|
fan1_status = 2
|
||||||
fan2_status = 2
|
fan2_status = 2
|
||||||
|
|
||||||
print ' Fan1 Speed: ',\
|
print(' Fan1 Speed: ',
|
||||||
get_pmc_register('FAN3_Front_rpm')
|
get_pmc_register('FAN3_Front_rpm'))
|
||||||
print ' Fan2 Speed: ',\
|
print(' Fan2 Speed: ',
|
||||||
get_pmc_register('FAN3_Rear_rpm')
|
get_pmc_register('FAN3_Rear_rpm'))
|
||||||
print ' Fan1 State: ',\
|
print(' Fan1 State: ',
|
||||||
Fan_Status[fan1_status]
|
Fan_Status[fan1_status])
|
||||||
print ' Fan2 State: ',\
|
print(' Fan2 State: ',
|
||||||
Fan_Status[fan2_status]
|
Fan_Status[fan2_status])
|
||||||
|
|
||||||
elif (tray == 4):
|
elif (tray == 4):
|
||||||
|
|
||||||
@ -180,14 +178,14 @@ def print_fan_tray(tray):
|
|||||||
fan1_status = 2
|
fan1_status = 2
|
||||||
fan2_status = 2
|
fan2_status = 2
|
||||||
|
|
||||||
print ' Fan1 Speed: ',\
|
print(' Fan1 Speed: ',
|
||||||
get_pmc_register('FAN4_Front_rpm')
|
get_pmc_register('FAN4_Front_rpm'))
|
||||||
print ' Fan2 Speed: ',\
|
print(' Fan2 Speed: ',
|
||||||
get_pmc_register('FAN4_Rear_rpm')
|
get_pmc_register('FAN4_Rear_rpm'))
|
||||||
print ' Fan1 State: ',\
|
print(' Fan1 State: ',
|
||||||
Fan_Status[fan1_status]
|
Fan_Status[fan1_status])
|
||||||
print ' Fan2 State: ',\
|
print(' Fan2 State: ',
|
||||||
Fan_Status[fan2_status]
|
Fan_Status[fan2_status])
|
||||||
|
|
||||||
|
|
||||||
print('\nFan Trays:')
|
print('\nFan Trays:')
|
||||||
@ -197,7 +195,7 @@ for tray in range(1, Z9264F_MAX_FAN_TRAYS + 1):
|
|||||||
if (get_pmc_register(fan_presence)):
|
if (get_pmc_register(fan_presence)):
|
||||||
print_fan_tray(tray)
|
print_fan_tray(tray)
|
||||||
else:
|
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
|
# Print the information for PSU1, PSU2
|
||||||
@ -206,51 +204,51 @@ def print_psu(psu):
|
|||||||
# PSU FAN details
|
# PSU FAN details
|
||||||
if (psu == 1):
|
if (psu == 1):
|
||||||
|
|
||||||
print ' PSU1:'
|
print(' PSU1:')
|
||||||
print ' FAN Normal Temperature: ',\
|
print(' FAN Normal Temperature: ',
|
||||||
get_pmc_register('PSU1_Normal_temp')
|
get_pmc_register('PSU1_Normal_temp'))
|
||||||
print ' Chassis Temperature: ',\
|
print(' Chassis Temperature: ',
|
||||||
get_pmc_register('PSU1_Chass_temp')
|
get_pmc_register('PSU1_Chass_temp'))
|
||||||
print ' System Temperature: ',\
|
print(' System Temperature: ',
|
||||||
get_pmc_register('PSU1_Sys_temp')
|
get_pmc_register('PSU1_Sys_temp'))
|
||||||
print ' FAN RPM: ',\
|
print(' FAN RPM: ',
|
||||||
get_pmc_register('PSU1_rpm')
|
get_pmc_register('PSU1_rpm'))
|
||||||
print ' Input Voltage: ',\
|
print(' Input Voltage: ',
|
||||||
get_pmc_register('PSU1_In_volt')
|
get_pmc_register('PSU1_In_volt'))
|
||||||
print ' Output Voltage: ',\
|
print(' Output Voltage: ',
|
||||||
get_pmc_register('PSU1_Out_volt')
|
get_pmc_register('PSU1_Out_volt'))
|
||||||
print ' Input Power: ',\
|
print(' Input Power: ',
|
||||||
get_pmc_register('PSU1_In_watt')
|
get_pmc_register('PSU1_In_watt'))
|
||||||
print ' Output Power: ',\
|
print(' Output Power: ',
|
||||||
get_pmc_register('PSU1_Out_watt')
|
get_pmc_register('PSU1_Out_watt'))
|
||||||
print ' Input Current: ',\
|
print(' Input Current: ',
|
||||||
get_pmc_register('PSU1_In_amp')
|
get_pmc_register('PSU1_In_amp'))
|
||||||
print ' Output Current: ',\
|
print(' Output Current: ',
|
||||||
get_pmc_register('PSU1_Out_amp')
|
get_pmc_register('PSU1_Out_amp'))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
print ' PSU2:'
|
print(' PSU2:')
|
||||||
print ' FAN Normal Temperature: ',\
|
print(' FAN Normal Temperature: ',
|
||||||
get_pmc_register('PSU2_Normal_temp')
|
get_pmc_register('PSU2_Normal_temp'))
|
||||||
print ' Chassis Temperature: ',\
|
print(' Chassis Temperature: ',
|
||||||
get_pmc_register('PSU2_Chass_temp')
|
get_pmc_register('PSU2_Chass_temp'))
|
||||||
print ' System Temperature: ',\
|
print(' System Temperature: ',
|
||||||
get_pmc_register('PSU2_Sys_temp')
|
get_pmc_register('PSU2_Sys_temp'))
|
||||||
print ' FAN RPM: ',\
|
print(' FAN RPM: ',
|
||||||
get_pmc_register('PSU2_rpm')
|
get_pmc_register('PSU2_rpm'))
|
||||||
print ' Input Voltage: ',\
|
print(' Input Voltage: ',
|
||||||
get_pmc_register('PSU2_In_volt')
|
get_pmc_register('PSU2_In_volt'))
|
||||||
print ' Output Voltage: ',\
|
print(' Output Voltage: ',
|
||||||
get_pmc_register('PSU2_Out_volt')
|
get_pmc_register('PSU2_Out_volt'))
|
||||||
print ' Input Power: ',\
|
print(' Input Power: ',
|
||||||
get_pmc_register('PSU2_In_watt')
|
get_pmc_register('PSU2_In_watt'))
|
||||||
print ' Output Power: ',\
|
print(' Output Power: ',
|
||||||
get_pmc_register('PSU2_Out_watt')
|
get_pmc_register('PSU2_Out_watt'))
|
||||||
print ' Input Current: ',\
|
print(' Input Current: ',
|
||||||
get_pmc_register('PSU2_In_amp')
|
get_pmc_register('PSU2_In_amp'))
|
||||||
print ' Output Current: ',\
|
print(' Output Current: ',
|
||||||
get_pmc_register('PSU2_Out_amp')
|
get_pmc_register('PSU2_Out_amp'))
|
||||||
|
|
||||||
|
|
||||||
print('\nPSUs:')
|
print('\nPSUs:')
|
||||||
@ -259,7 +257,7 @@ for psu in range(1, Z9264F_MAX_PSUS + 1):
|
|||||||
if (get_pmc_register(psu_presence)):
|
if (get_pmc_register(psu_presence)):
|
||||||
print_psu(psu)
|
print_psu(psu)
|
||||||
else:
|
else:
|
||||||
print '\n PSU ', psu, 'Not present'
|
print('\n PSU ', psu, 'Not present')
|
||||||
|
|
||||||
print '\n Total Power: ',\
|
print('\n Total Power: ',
|
||||||
get_pmc_register('PSU_Total_watt')
|
get_pmc_register('PSU_Total_watt'))
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import struct
|
import struct
|
||||||
import sys
|
|
||||||
from os import *
|
from os import *
|
||||||
from mmap import *
|
from mmap import *
|
||||||
|
|
||||||
|
@ -105,20 +105,20 @@ switch_board_modsel() {
|
|||||||
do
|
do
|
||||||
port_addr=$(( 16384 + ((i - 1) * 16)))
|
port_addr=$(( 16384 + ((i - 1) * 16)))
|
||||||
hex=$( printf "0x%x" $port_addr )
|
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
|
done
|
||||||
|
|
||||||
# Disabling low power mode for last two 10G ports
|
# Disabling low power mode for last two 10G ports
|
||||||
# From last 6th bit: Disable - 0; Enable - 1
|
# 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%s' $reg_offset)
|
||||||
reg_offset=$( printf '0x%x' $(( $reg_offset & 0xbf )) )
|
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%s' $reg_offset)
|
||||||
reg_offset=$( printf '0x%x' $(( $reg_offset & 0xbf )) )
|
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
|
# 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)
|
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=$(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() {
|
remove_python_api_package() {
|
||||||
@ -149,6 +150,11 @@ remove_python_api_package() {
|
|||||||
if [ $? -eq 0 ]; then
|
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
|
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
|
# Readout firmware version of the system and
|
||||||
@ -225,7 +231,7 @@ if [ "$1" == "init" ]; then
|
|||||||
switch_board_modsel
|
switch_board_modsel
|
||||||
init_switch_port_led
|
init_switch_port_led
|
||||||
install_python_api_package
|
install_python_api_package
|
||||||
python /usr/bin/port_irq_enable.py
|
/usr/bin/port_irq_enable.py
|
||||||
platform_firmware_versions
|
platform_firmware_versions
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
try:
|
try:
|
||||||
import os
|
import os
|
||||||
import select
|
import select
|
||||||
|
import sys
|
||||||
from sonic_platform_base.chassis_base import ChassisBase
|
from sonic_platform_base.chassis_base import ChassisBase
|
||||||
from sonic_platform.sfp import Sfp
|
from sonic_platform.sfp import Sfp
|
||||||
from sonic_platform.eeprom import Eeprom
|
from sonic_platform.eeprom import Eeprom
|
||||||
@ -49,7 +50,7 @@ class Chassis(ChassisBase):
|
|||||||
self.PORT_START = 1
|
self.PORT_START = 1
|
||||||
self.PORT_END = 66
|
self.PORT_END = 66
|
||||||
PORTS_IN_BLOCK = (self.PORT_END + 1)
|
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"
|
eeprom_base = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"
|
||||||
|
|
||||||
for index in range(self.PORT_START, PORTS_IN_BLOCK):
|
for index in range(self.PORT_START, PORTS_IN_BLOCK):
|
||||||
@ -98,7 +99,7 @@ class Chassis(ChassisBase):
|
|||||||
def _get_register(self, reg_file):
|
def _get_register(self, reg_file):
|
||||||
retval = 'ERR'
|
retval = 'ERR'
|
||||||
if (not os.path.isfile(reg_file)):
|
if (not os.path.isfile(reg_file)):
|
||||||
print reg_file, 'not found !'
|
print(reg_file, 'not found !')
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -258,14 +259,6 @@ class Chassis(ChassisBase):
|
|||||||
"""
|
"""
|
||||||
return self._eeprom.base_mac_addr()
|
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):
|
def get_system_eeprom_info(self):
|
||||||
"""
|
"""
|
||||||
Retrieves the full content of system EEPROM information for the chassis
|
Retrieves the full content of system EEPROM information for the chassis
|
||||||
|
@ -13,7 +13,7 @@ try:
|
|||||||
import os.path
|
import os.path
|
||||||
from sonic_eeprom import eeprom_tlvinfo
|
from sonic_eeprom import eeprom_tlvinfo
|
||||||
import binascii
|
import binascii
|
||||||
except ImportError, e:
|
except ImportError as e:
|
||||||
raise ImportError(str(e) + "- required module not found")
|
raise ImportError(str(e) + "- required module not found")
|
||||||
|
|
||||||
|
|
||||||
|
@ -170,5 +170,5 @@ class Fan(FanBase):
|
|||||||
if not is_valid or self.max_speed == 0:
|
if not is_valid or self.max_speed == 0:
|
||||||
speed = 0
|
speed = 0
|
||||||
else:
|
else:
|
||||||
speed = (100 * fan_speed)/self.max_speed
|
speed = (100 * fan_speed)//self.max_speed
|
||||||
return speed
|
return speed
|
||||||
|
@ -111,7 +111,7 @@ class Psu(PsuBase):
|
|||||||
if not is_valid:
|
if not is_valid:
|
||||||
voltage = 0
|
voltage = 0
|
||||||
|
|
||||||
return "{:.1f}".format(voltage)
|
return float(voltage)
|
||||||
|
|
||||||
def get_current(self):
|
def get_current(self):
|
||||||
"""
|
"""
|
||||||
@ -125,7 +125,7 @@ class Psu(PsuBase):
|
|||||||
if not is_valid:
|
if not is_valid:
|
||||||
current = 0
|
current = 0
|
||||||
|
|
||||||
return "{:.1f}".format(current)
|
return float(current)
|
||||||
|
|
||||||
def get_power(self):
|
def get_power(self):
|
||||||
"""
|
"""
|
||||||
@ -139,7 +139,7 @@ class Psu(PsuBase):
|
|||||||
if not is_valid:
|
if not is_valid:
|
||||||
power = 0
|
power = 0
|
||||||
|
|
||||||
return "{:.1f}".format(power)
|
return float(power)
|
||||||
|
|
||||||
def get_powergood_status(self):
|
def get_powergood_status(self):
|
||||||
"""
|
"""
|
||||||
|
@ -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:])
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
# On Z9332F, the BaseBoard Management Controller is an
|
# On Z9332F, the BaseBoard Management Controller is an
|
||||||
# autonomous subsystem provides monitoring and management
|
# autonomous subsystem provides monitoring and management
|
||||||
# facility independent of the host CPU. IPMI standard
|
# facility independent of the host CPU. IPMI standard
|
||||||
@ -11,11 +11,9 @@
|
|||||||
# * PSU
|
# * PSU
|
||||||
|
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
import commands
|
|
||||||
|
|
||||||
Z9332F_MAX_FAN_TRAYS = 7
|
Z9332F_MAX_FAN_TRAYS = 7
|
||||||
Z9332F_MAX_PSUS = 2
|
Z9332F_MAX_PSUS = 2
|
||||||
@ -40,7 +38,7 @@ def ipmi_sensor_dump():
|
|||||||
status = 1
|
status = 1
|
||||||
global ipmi_sdr_list
|
global ipmi_sdr_list
|
||||||
ipmi_cmd = IPMI_SENSOR_DATA
|
ipmi_cmd = IPMI_SENSOR_DATA
|
||||||
status, ipmi_sdr_list = commands.getstatusoutput(ipmi_cmd)
|
status, ipmi_sdr_list = subprocess.getstatusoutput(ipmi_cmd)
|
||||||
|
|
||||||
if status:
|
if status:
|
||||||
logging.error('Failed to execute:' + ipmi_sdr_list)
|
logging.error('Failed to execute:' + ipmi_sdr_list)
|
||||||
@ -88,7 +86,7 @@ def print_temperature_sensors():
|
|||||||
('SW_U14_Temp', 'SW U14'),
|
('SW_U14_Temp', 'SW U14'),
|
||||||
('SW_U4403_Temp', 'SW U4403')
|
('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()
|
ipmi_sensor_dump()
|
||||||
|
|
||||||
@ -102,14 +100,14 @@ def print_fan_tray(tray):
|
|||||||
Fan_Status = [' Normal', ' Abnormal']
|
Fan_Status = [' Normal', ' Abnormal']
|
||||||
Airflow_Direction = ['B2F', 'F2B']
|
Airflow_Direction = ['B2F', 'F2B']
|
||||||
|
|
||||||
print ' Fan Tray ' + str(tray) + ':'
|
print(' Fan Tray ' + str(tray) + ':')
|
||||||
|
|
||||||
print ' Fan1 Speed: ',\
|
print(' Fan1 Speed: ',
|
||||||
get_pmc_register('Fan{}_Front'.format(tray))
|
get_pmc_register('Fan{}_Front'.format(tray)))
|
||||||
print ' Fan2 Speed: ',\
|
print(' Fan2 Speed: ',
|
||||||
get_pmc_register('Fan{}_Rear'.format(tray))
|
get_pmc_register('Fan{}_Rear'.format(tray)))
|
||||||
print ' Fan State: ',\
|
print(' Fan State: ',
|
||||||
Fan_Status[int(get_pmc_register('Fan{}_Status'.format(tray)), 16)]
|
Fan_Status[int(get_pmc_register('Fan{}_Status'.format(tray)), 16)])
|
||||||
|
|
||||||
|
|
||||||
print('\nFan Trays:')
|
print('\nFan Trays:')
|
||||||
@ -119,7 +117,7 @@ for tray in range(1, Z9332F_MAX_FAN_TRAYS + 1):
|
|||||||
if (get_pmc_register(fan_presence)):
|
if (get_pmc_register(fan_presence)):
|
||||||
print_fan_tray(tray)
|
print_fan_tray(tray)
|
||||||
else:
|
else:
|
||||||
print '\n Fan Tray ' + str(tray + 1) + ': Not present'
|
print('\n Fan Tray ' + str(tray + 1) + ': Not present')
|
||||||
|
|
||||||
def get_psu_presence(index):
|
def get_psu_presence(index):
|
||||||
"""
|
"""
|
||||||
@ -132,9 +130,9 @@ for tray in range(1, Z9332F_MAX_FAN_TRAYS + 1):
|
|||||||
ret_status = 1
|
ret_status = 1
|
||||||
|
|
||||||
if index == 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:
|
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:
|
#if ret_status:
|
||||||
# print ipmi_cmd_ret
|
# print ipmi_cmd_ret
|
||||||
@ -165,28 +163,28 @@ def print_psu(psu):
|
|||||||
# print ' Input: ', Psu_Input_Type[psu_input_type]
|
# print ' Input: ', Psu_Input_Type[psu_input_type]
|
||||||
# print ' Type: ', Psu_Type[psu_type]
|
# print ' Type: ', Psu_Type[psu_type]
|
||||||
|
|
||||||
print ' PSU{}:'.format(psu)
|
print(' PSU{}:'.format(psu))
|
||||||
print ' Inlet Temperature: ',\
|
print(' Inlet Temperature: ',
|
||||||
get_pmc_register('PSU{}_Temp1'.format(psu))
|
get_pmc_register('PSU{}_Temp1'.format(psu)))
|
||||||
print ' Hotspot Temperature: ',\
|
print(' Hotspot Temperature: ',
|
||||||
get_pmc_register('PSU{}_Temp2'.format(psu))
|
get_pmc_register('PSU{}_Temp2'.format(psu)))
|
||||||
print ' FAN RPM: ',\
|
print(' FAN RPM: ',
|
||||||
get_pmc_register('PSU{}_Fan'.format(psu))
|
get_pmc_register('PSU{}_Fan'.format(psu)))
|
||||||
# print ' FAN Status: ', Psu_Fan_Status[psu1_fan_status]
|
# print ' FAN Status: ', Psu_Fan_Status[psu1_fan_status]
|
||||||
|
|
||||||
# PSU input & output monitors
|
# PSU input & output monitors
|
||||||
print ' Input Voltage: ',\
|
print(' Input Voltage: ',
|
||||||
get_pmc_register('PSU{}_VIn'.format(psu))
|
get_pmc_register('PSU{}_VIn'.format(psu)))
|
||||||
print ' Output Voltage: ',\
|
print(' Output Voltage: ',
|
||||||
get_pmc_register('PSU{}_VOut'.format(psu))
|
get_pmc_register('PSU{}_VOut'.format(psu)))
|
||||||
print ' Input Power: ',\
|
print(' Input Power: ',
|
||||||
get_pmc_register('PSU{}_PIn'.format(psu))
|
get_pmc_register('PSU{}_PIn'.format(psu)))
|
||||||
print ' Output Power: ',\
|
print(' Output Power: ',
|
||||||
get_pmc_register('PSU{}_POut'.format(psu))
|
get_pmc_register('PSU{}_POut'.format(psu)))
|
||||||
print ' Input Current: ',\
|
print(' Input Current: ',
|
||||||
get_pmc_register('PSU{}_CIn'.format(psu))
|
get_pmc_register('PSU{}_CIn'.format(psu)))
|
||||||
print ' Output Current: ',\
|
print(' Output Current: ',
|
||||||
get_pmc_register('PSU{}_COut'.format(psu))
|
get_pmc_register('PSU{}_COut'.format(psu)))
|
||||||
|
|
||||||
|
|
||||||
print('\nPSUs:')
|
print('\nPSUs:')
|
||||||
@ -195,4 +193,4 @@ for psu in range(1, Z9332F_MAX_PSUS + 1):
|
|||||||
if (get_psu_presence(psu)):
|
if (get_psu_presence(psu)):
|
||||||
print_psu(psu)
|
print_psu(psu)
|
||||||
else:
|
else:
|
||||||
print '\n PSU ', psu, 'Not present'
|
print('\n PSU ', psu, 'Not present')
|
||||||
|
@ -105,7 +105,7 @@ switch_board_modsel() {
|
|||||||
do
|
do
|
||||||
port_addr=$(( 16384 + ((i - 1) * 16)))
|
port_addr=$(( 16384 + ((i - 1) * 16)))
|
||||||
hex=$( printf "0x%x" $port_addr )
|
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
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ if [ "$1" == "init" ]; then
|
|||||||
switch_board_qsfp "new_device"
|
switch_board_qsfp "new_device"
|
||||||
switch_board_sfp "new_device"
|
switch_board_sfp "new_device"
|
||||||
switch_board_led_default
|
switch_board_led_default
|
||||||
# python /usr/bin/qsfp_irq_enable.py
|
# /usr/bin/qsfp_irq_enable.py
|
||||||
platform_firmware_versions
|
platform_firmware_versions
|
||||||
|
|
||||||
elif [ "$1" == "deinit" ]; then
|
elif [ "$1" == "deinit" ]; then
|
||||||
|
Reference in New Issue
Block a user