Skip to content

Commit 763461e

Browse files
roylee123lguohan
authored andcommitted
[devices]: As7816 64x validate sfputil psuutil (#1466)
1 parent f250fe7 commit 763461e

File tree

3 files changed

+67
-10
lines changed

3 files changed

+67
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python
2+
3+
#############################################################################
4+
# Accton
5+
#
6+
# Module contains an implementation of SONiC PSU Base API and
7+
# provides the PSUs status which are available in the platform
8+
#
9+
#############################################################################
10+
11+
import os.path
12+
13+
try:
14+
from sonic_psu.psu_base import PsuBase
15+
except ImportError as e:
16+
raise ImportError (str(e) + "- required module not found")
17+
18+
class PsuUtil(PsuBase):
19+
"""Platform-specific PSUutil class"""
20+
21+
def __init__(self):
22+
PsuBase.__init__(self)
23+
24+
self.psu_path = "/sys/bus/i2c/devices/"
25+
self.psu_presence = "/psu_present"
26+
self.psu_oper_status = "/psu_power_good"
27+
self.psu_mapping = {
28+
1: "10-0053",
29+
2: "9-0050",
30+
}
31+
32+
def get_num_psus(self):
33+
return len(self.psu_mapping)
34+
35+
def get_psu_status(self, index):
36+
if index is None:
37+
return False
38+
39+
status = 0
40+
node = self.psu_path + self.psu_mapping[index]+self.psu_oper_status
41+
try:
42+
with open(node, 'r') as power_status:
43+
status = int(power_status.read())
44+
except IOError:
45+
return False
46+
47+
return status == 1
48+
49+
def get_psu_presence(self, index):
50+
if index is None:
51+
return False
52+
53+
status = 0
54+
node = self.psu_path + self.psu_mapping[index] + self.psu_presence
55+
try:
56+
with open(node, 'r') as presence_status:
57+
status = int(presence_status.read())
58+
except IOError:
59+
return False
60+
61+
return status == 1

device/accton/x86_64-accton_as7816_64x-r0/plugins/sfputil.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -94,30 +94,26 @@ def reset(self, port_num):
9494
# Check for invalid port_num
9595
if port_num < self._port_start or port_num > self._port_end:
9696
return False
97-
98-
path = "/sys/bus/i2c/devices/{0}-0050/sfp_port_reset"
99-
port_ps = path.format(self.port_to_i2c_mapping[port_num+1])
97+
path = "/sys/bus/i2c/devices/19-0060/module_reset_{0}"
98+
port_ps = path.format(port_num+1)
10099

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

107-
#toggle reset
106+
#HW will clear reset after set.
108107
reg_file.seek(0)
109108
reg_file.write('1')
110-
time.sleep(1)
111-
reg_file.seek(0)
112-
reg_file.write('0')
113109
reg_file.close()
114110
return True
115111

116112
def set_low_power_mode(self, port_nuM, lpmode):
117-
raise NotImplementedErro
113+
raise NotImplementedError
118114

119115
def get_low_power_mode(self, port_num):
120-
raise NotImplementedErro
116+
raise NotImplementedError
121117

122118
def get_presence(self, port_num):
123119
# Check for invalid port_num

0 commit comments

Comments
 (0)