Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

As7816 64x validate sfputil psuutil #1466

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
909a7e9
Update sonic-platform-modules-accton to lastest
roylee123 Dec 22, 2017
87eed23
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
roylee123 Dec 22, 2017
64529e5
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
roylee123 Dec 28, 2017
2464e45
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
roylee123 Jan 8, 2018
6810dd4
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
roylee123 Jan 9, 2018
5e436b4
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
roylee123 Jan 12, 2018
ce362e4
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
roylee123 Jan 19, 2018
0d14c1c
Merge branch 'master' of https://github.com/roylee123/sonic-buildimage
roylee123 Jan 19, 2018
a40d2d9
Install sonic-platform-common package in platform-monitor docker for …
jleveque Jan 22, 2018
f8e98dd
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
roylee123 Jan 24, 2018
38593b6
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
roylee123 Feb 21, 2018
843ca3f
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
roylee123 Feb 23, 2018
940762d
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
roylee123 Mar 1, 2018
6b03b2d
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
roylee123 Mar 6, 2018
5c11d49
[As7816-64x] Validate psuutil and psuutil.
roylee123 Mar 7, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions device/accton/x86_64-accton_as7816_64x-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python

#############################################################################
# Accton
#
# Module contains an implementation of SONiC PSU Base API and
# provides the PSUs status which are available in the platform
#
#############################################################################

import os.path

try:
from sonic_psu.psu_base import PsuBase
except ImportError as e:
raise ImportError (str(e) + "- required module not found")

class PsuUtil(PsuBase):
"""Platform-specific PSUutil class"""

def __init__(self):
PsuBase.__init__(self)

self.psu_path = "/sys/bus/i2c/devices/"
self.psu_presence = "/psu_present"
self.psu_oper_status = "/psu_power_good"
self.psu_mapping = {
1: "10-0053",
2: "9-0050",
}

def get_num_psus(self):
return len(self.psu_mapping)

def get_psu_status(self, index):
if index is None:
return False

status = 0
node = self.psu_path + self.psu_mapping[index]+self.psu_oper_status
try:
with open(node, 'r') as power_status:
status = int(power_status.read())
except IOError:
return False

return status == 1

def get_psu_presence(self, index):
if index is None:
return False

status = 0
node = self.psu_path + self.psu_mapping[index] + self.psu_presence
try:
with open(node, 'r') as presence_status:
status = int(presence_status.read())
except IOError:
return False

return status == 1
14 changes: 5 additions & 9 deletions device/accton/x86_64-accton_as7816_64x-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,30 +94,26 @@ def reset(self, port_num):
# Check for invalid port_num
if port_num < self._port_start or port_num > self._port_end:
return False

path = "/sys/bus/i2c/devices/{0}-0050/sfp_port_reset"
port_ps = path.format(self.port_to_i2c_mapping[port_num+1])
path = "/sys/bus/i2c/devices/19-0060/module_reset_{0}"
port_ps = path.format(port_num+1)

try:
reg_file = open(port_ps, 'w')
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False

#toggle reset
#HW will clear reset after set.
reg_file.seek(0)
reg_file.write('1')
time.sleep(1)
reg_file.seek(0)
reg_file.write('0')
reg_file.close()
return True

def set_low_power_mode(self, port_nuM, lpmode):
raise NotImplementedErro
raise NotImplementedError

def get_low_power_mode(self, port_num):
raise NotImplementedErro
raise NotImplementedError

def get_presence(self, port_num):
# Check for invalid port_num
Expand Down