[device]Add check exception case when read port present fail (#4107)
Modify get_psu_presence(). Move read() and close() to "try: ... except IOError:" To avoid when read port present sysfs fail. This exception will let sfputil.py to exit. So "sfputil show eeprom" can't show other port status.
This commit is contained in:
parent
c63b5fc719
commit
a6efbaed97
@ -70,16 +70,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
present_path = self.BASE_CPLD_PATH + "module_present_" + str(port_num)
|
present_path = self.BASE_CPLD_PATH + "module_present_" + str(port_num)
|
||||||
self.__port_to_is_present = present_path
|
self.__port_to_is_present = present_path
|
||||||
|
|
||||||
|
content="0"
|
||||||
try:
|
try:
|
||||||
val_file = open(self.__port_to_is_present)
|
val_file = open(self.__port_to_is_present)
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
|
||||||
val_file.close()
|
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -144,16 +144,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
present_path = present_path + "module_present_" + str(port_num)
|
present_path = present_path + "module_present_" + str(port_num)
|
||||||
self.__port_to_is_present = present_path
|
self.__port_to_is_present = present_path
|
||||||
|
|
||||||
|
content="0"
|
||||||
try:
|
try:
|
||||||
val_file = open(self.__port_to_is_present)
|
val_file = open(self.__port_to_is_present)
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
|
||||||
val_file.close()
|
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -175,16 +174,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
q = self.qsfp_sb_remap(port_num)
|
q = self.qsfp_sb_remap(port_num)
|
||||||
lp_mode_path = lp_mode_path + str(q)
|
lp_mode_path = lp_mode_path + str(q)
|
||||||
|
|
||||||
|
content="0"
|
||||||
try:
|
try:
|
||||||
val_file = open(lp_mode_path)
|
val_file = open(lp_mode_path)
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
|
||||||
val_file.close()
|
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -105,16 +105,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
present_path = present_path + "module_present_" + str(port_num)
|
present_path = present_path + "module_present_" + str(port_num)
|
||||||
self.__port_to_is_present = present_path
|
self.__port_to_is_present = present_path
|
||||||
|
|
||||||
|
content="0"
|
||||||
try:
|
try:
|
||||||
val_file = open(self.__port_to_is_present)
|
val_file = open(self.__port_to_is_present)
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
|
||||||
val_file.close()
|
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -129,16 +128,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
lp_mode_path = lp_mode_path + "module_lp_mode_"
|
lp_mode_path = lp_mode_path + "module_lp_mode_"
|
||||||
lp_mode_path = lp_mode_path + str(port_num)
|
lp_mode_path = lp_mode_path + str(port_num)
|
||||||
|
|
||||||
|
content="0"
|
||||||
try:
|
try:
|
||||||
val_file = open(lp_mode_path)
|
val_file = open(lp_mode_path)
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to open file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
|
||||||
val_file.close()
|
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -158,16 +158,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
present_path = present_path + "module_present_" + str(port_num)
|
present_path = present_path + "module_present_" + str(port_num)
|
||||||
self.__port_to_is_present = present_path
|
self.__port_to_is_present = present_path
|
||||||
|
|
||||||
|
content="0"
|
||||||
try:
|
try:
|
||||||
val_file = open(self.__port_to_is_present)
|
val_file = open(self.__port_to_is_present)
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
|
||||||
val_file.close()
|
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -189,16 +188,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
q = self.qsfp_sb_remap(port_num)
|
q = self.qsfp_sb_remap(port_num)
|
||||||
lp_mode_path = lp_mode_path + str(q)
|
lp_mode_path = lp_mode_path + str(q)
|
||||||
|
|
||||||
|
content = "0"
|
||||||
try:
|
try:
|
||||||
val_file = open(lp_mode_path)
|
val_file = open(lp_mode_path)
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to open file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
|
||||||
val_file.close()
|
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -100,16 +100,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
path = "/sys/bus/i2c/devices/3-0062/module_present_{0}"
|
path = "/sys/bus/i2c/devices/3-0062/module_present_{0}"
|
||||||
port_ps = path.format(cage_num)
|
port_ps = path.format(cage_num)
|
||||||
|
|
||||||
|
content="0"
|
||||||
try:
|
try:
|
||||||
val_file = open(port_ps)
|
val_file = open(port_ps)
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
|
||||||
val_file.close()
|
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -131,8 +130,7 @@ class SfpUtil(SfpUtilBase):
|
|||||||
|
|
||||||
content = val_file.readline().rstrip()
|
content = val_file.readline().rstrip()
|
||||||
val_file.close()
|
val_file.close()
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -167,16 +167,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
path = "/sys/bus/i2c/devices/{0}/module_present_{1}"
|
path = "/sys/bus/i2c/devices/{0}/module_present_{1}"
|
||||||
port_ps = path.format(cpld_ps, cage_num)
|
port_ps = path.format(cpld_ps, cage_num)
|
||||||
|
|
||||||
|
content = "0"
|
||||||
try:
|
try:
|
||||||
val_file = open(port_ps)
|
val_file = open(port_ps)
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
|
||||||
val_file.close()
|
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -201,8 +200,7 @@ class SfpUtil(SfpUtilBase):
|
|||||||
|
|
||||||
content = val_file.readline().rstrip()
|
content = val_file.readline().rstrip()
|
||||||
val_file.close()
|
val_file.close()
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -127,16 +127,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
|
|
||||||
self.__port_to_is_present = present_path
|
self.__port_to_is_present = present_path
|
||||||
|
|
||||||
|
content="0"
|
||||||
try:
|
try:
|
||||||
val_file = open(self.__port_to_is_present)
|
val_file = open(self.__port_to_is_present)
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
|
||||||
val_file.close()
|
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -150,16 +149,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
_path = cpld_path + "/module_lp_mode_"
|
_path = cpld_path + "/module_lp_mode_"
|
||||||
_path += str(self._port_to_i2c_mapping[port_num][0])
|
_path += str(self._port_to_i2c_mapping[port_num][0])
|
||||||
|
|
||||||
|
content="0"
|
||||||
try:
|
try:
|
||||||
reg_file = open(_path)
|
reg_file = open(_path)
|
||||||
|
content = reg_file.readline().rstrip()
|
||||||
|
reg_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = reg_file.readline().rstrip()
|
|
||||||
reg_file.close()
|
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -126,14 +126,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
path = "/sys/bus/i2c/devices/{0}-0050/sfp_is_present"
|
path = "/sys/bus/i2c/devices/{0}-0050/sfp_is_present"
|
||||||
port_ps = path.format(self._port_to_i2c_mapping[port_num])
|
port_ps = path.format(self._port_to_i2c_mapping[port_num])
|
||||||
|
|
||||||
|
reg_value = '0'
|
||||||
try:
|
try:
|
||||||
reg_file = open(port_ps)
|
reg_file = open(port_ps)
|
||||||
|
reg_value = reg_file.readline().rstrip()
|
||||||
|
reg_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
reg_value = reg_file.readline().rstrip()
|
|
||||||
if reg_value == '1':
|
if reg_value == '1':
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -97,14 +97,15 @@ class sfputil(SfpUtilBase):
|
|||||||
path = "/sys/bus/i2c/devices/{0}-0050/sfp_is_present"
|
path = "/sys/bus/i2c/devices/{0}-0050/sfp_is_present"
|
||||||
port_ps = path.format(self.port_to_i2c_mapping[port_num+1])
|
port_ps = path.format(self.port_to_i2c_mapping[port_num+1])
|
||||||
|
|
||||||
|
reg_value = '0'
|
||||||
try:
|
try:
|
||||||
reg_file = open(port_ps)
|
reg_file = open(port_ps)
|
||||||
|
reg_value = reg_file.readline().rstrip()
|
||||||
|
reg_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
reg_value = reg_file.readline().rstrip()
|
|
||||||
if reg_value == '1':
|
if reg_value == '1':
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -142,16 +142,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
path = "/sys/bus/i2c/devices/{0}/module_present_{1}"
|
path = "/sys/bus/i2c/devices/{0}/module_present_{1}"
|
||||||
port_ps = path.format(cpld_ps, port_num)
|
port_ps = path.format(cpld_ps, port_num)
|
||||||
|
|
||||||
|
content = "0"
|
||||||
try:
|
try:
|
||||||
val_file = open(port_ps)
|
val_file = open(port_ps)
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
|
||||||
val_file.close()
|
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -142,15 +142,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
path = "/sys/bus/i2c/devices/{0}/module_present_{1}"
|
path = "/sys/bus/i2c/devices/{0}/module_present_{1}"
|
||||||
port_ps = path.format(cpld_ps, port_num)
|
port_ps = path.format(cpld_ps, port_num)
|
||||||
|
|
||||||
|
content = "0"
|
||||||
try:
|
try:
|
||||||
val_file = open(port_ps)
|
val_file = open(port_ps)
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
|
||||||
val_file.close()
|
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
# content is a string, either "0" or "1"
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
@ -114,16 +114,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
index = ((port_num-1)%24) +1
|
index = ((port_num-1)%24) +1
|
||||||
port_ps = path.format(cpld_ps, index)
|
port_ps = path.format(cpld_ps, index)
|
||||||
|
|
||||||
|
content = "0"
|
||||||
try:
|
try:
|
||||||
val_file = open(port_ps)
|
val_file = open(port_ps)
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
|
||||||
val_file.close()
|
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -145,16 +145,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
path = "/sys/bus/i2c/devices/{0}/module_present_{1}"
|
path = "/sys/bus/i2c/devices/{0}/module_present_{1}"
|
||||||
port_ps = path.format(cpld_ps, port_num)
|
port_ps = path.format(cpld_ps, port_num)
|
||||||
|
|
||||||
|
content="0"
|
||||||
try:
|
try:
|
||||||
val_file = open(port_ps)
|
val_file = open(port_ps)
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
|
||||||
val_file.close()
|
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -39,14 +39,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
path = "/sys/bus/i2c/devices/{0}-0050/sfp_is_present"
|
path = "/sys/bus/i2c/devices/{0}-0050/sfp_is_present"
|
||||||
port_ps = path.format(port_num+18)
|
port_ps = path.format(port_num+18)
|
||||||
|
|
||||||
|
reg_value = '0'
|
||||||
try:
|
try:
|
||||||
reg_file = open(port_ps)
|
reg_file = open(port_ps)
|
||||||
|
reg_value = reg_file.readline().rstrip()
|
||||||
|
reg_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
reg_value = reg_file.readline().rstrip()
|
|
||||||
if reg_value == '1':
|
if reg_value == '1':
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -96,13 +96,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
path = "/sys/bus/i2c/devices/4-0060/module_present_{0}"
|
path = "/sys/bus/i2c/devices/4-0060/module_present_{0}"
|
||||||
port_ps = path.format(port_num)
|
port_ps = path.format(port_num)
|
||||||
|
|
||||||
|
reg_value = '0'
|
||||||
try:
|
try:
|
||||||
reg_file = open(port_ps)
|
reg_file = open(port_ps)
|
||||||
|
reg_value = reg_file.readline().rstrip()
|
||||||
|
reg_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
reg_value = reg_file.readline().rstrip()
|
|
||||||
if reg_value == '1':
|
if reg_value == '1':
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -97,16 +97,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
present_path = self.BASE_CPLD_PATH + "module_present_" + str(port_num)
|
present_path = self.BASE_CPLD_PATH + "module_present_" + str(port_num)
|
||||||
self.__port_to_is_present = present_path
|
self.__port_to_is_present = present_path
|
||||||
|
|
||||||
|
content = "0"
|
||||||
try:
|
try:
|
||||||
val_file = open(self.__port_to_is_present)
|
val_file = open(self.__port_to_is_present)
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
|
||||||
val_file.close()
|
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -87,16 +87,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
present_path = self.BASE_CPLD_PATH + "module_present_" + str(port_num+1)
|
present_path = self.BASE_CPLD_PATH + "module_present_" + str(port_num+1)
|
||||||
self.__port_to_is_present = present_path
|
self.__port_to_is_present = present_path
|
||||||
|
|
||||||
|
content = "0"
|
||||||
try:
|
try:
|
||||||
val_file = open(self.__port_to_is_present)
|
val_file = open(self.__port_to_is_present)
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
|
||||||
val_file.close()
|
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -100,16 +100,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
present_path = self.BASE_CPLD_PATH + "module_present_" + str(port_num)
|
present_path = self.BASE_CPLD_PATH + "module_present_" + str(port_num)
|
||||||
self.__port_to_is_present = present_path
|
self.__port_to_is_present = present_path
|
||||||
|
|
||||||
|
content="0"
|
||||||
try:
|
try:
|
||||||
val_file = open(self.__port_to_is_present)
|
val_file = open(self.__port_to_is_present)
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
|
||||||
val_file.close()
|
|
||||||
|
|
||||||
# content is a string, either "0" or "1"
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -122,13 +122,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
path = "/sys/bus/i2c/devices/19-0060/module_present_{0}"
|
path = "/sys/bus/i2c/devices/19-0060/module_present_{0}"
|
||||||
port_ps = path.format(port_num)
|
port_ps = path.format(port_num)
|
||||||
|
|
||||||
|
reg_value = '0'
|
||||||
try:
|
try:
|
||||||
reg_file = open(port_ps)
|
reg_file = open(port_ps)
|
||||||
|
reg_value = reg_file.readline().rstrip()
|
||||||
|
reg_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
reg_value = reg_file.readline().rstrip()
|
|
||||||
if reg_value == '1':
|
if reg_value == '1':
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -98,15 +98,15 @@ class SfpUtil(SfpUtilBase):
|
|||||||
present_path = self.BASE_CPLD2_PATH + "module_present_" + str(port_num+1)
|
present_path = self.BASE_CPLD2_PATH + "module_present_" + str(port_num+1)
|
||||||
self.__port_to_is_present = present_path
|
self.__port_to_is_present = present_path
|
||||||
|
|
||||||
|
content="0"
|
||||||
try:
|
try:
|
||||||
val_file = open(self.__port_to_is_present)
|
val_file = open(self.__port_to_is_present)
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to access file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
|
||||||
val_file.close()
|
|
||||||
|
|
||||||
if content == "1":
|
if content == "1":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user