[Mellanox]: Add get_presence implementation for SFP on Mellanox platforms (#1056)

Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
This commit is contained in:
Andriy Moroz 2017-10-20 04:36:25 +03:00 committed by Shuotian Cheng
parent a9566bdb1e
commit 587b14a3bf
3 changed files with 48 additions and 3 deletions

View File

@ -46,8 +46,23 @@ class SfpUtil(SfpUtilBase):
SfpUtilBase.__init__(self) SfpUtilBase.__init__(self)
def get_presence(self, port_num): def get_presence(self, port_num):
# Check for invalid port_num
if port_num < self.port_start or port_num > self.port_end:
return False
raise NotImplementedError try:
reg_file = open("/bsp/qsfp/qsfp%d_status" % (port_num+1))
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False
content = reg_file.readline().rstrip()
# content is a string with the qsfp status
if content == "good":
return True
return False
def get_low_power_mode(self, port_num): def get_low_power_mode(self, port_num):

View File

@ -46,8 +46,23 @@ class SfpUtil(SfpUtilBase):
SfpUtilBase.__init__(self) SfpUtilBase.__init__(self)
def get_presence(self, port_num): def get_presence(self, port_num):
# Check for invalid port_num
if port_num < self.port_start or port_num > self.port_end:
return False
raise NotImplementedError try:
reg_file = open("/bsp/qsfp/qsfp%d_status" % (port_num+1))
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False
content = reg_file.readline().rstrip()
# content is a string with the qsfp status
if content == "good":
return True
return False
def get_low_power_mode(self, port_num): def get_low_power_mode(self, port_num):

View File

@ -46,8 +46,23 @@ class SfpUtil(SfpUtilBase):
SfpUtilBase.__init__(self) SfpUtilBase.__init__(self)
def get_presence(self, port_num): def get_presence(self, port_num):
# Check for invalid port_num
if port_num < self.port_start or port_num > self.port_end:
return False
raise NotImplementedError try:
reg_file = open("/bsp/qsfp/qsfp%d_status" % (port_num+1))
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False
content = reg_file.readline().rstrip()
# content is a string with the qsfp status
if content == "good":
return True
return False
def get_low_power_mode(self, port_num): def get_low_power_mode(self, port_num):