diff options
-rwxr-xr-x | mpm/python/e320_bist | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mpm/python/e320_bist b/mpm/python/e320_bist index 99da3cd74..c9664ce00 100755 --- a/mpm/python/e320_bist +++ b/mpm/python/e320_bist @@ -797,6 +797,32 @@ class E320BIST(object): } return len(result) == 1, result + def bist_link_up(self): + """ + BIST test for SFP link + Description: Checks if SFP link is up + External Equipment: 1G/10G cable connected to SFP port + Return dictionary: + - sfp0: status of link + Return status: True if link is UP + """ + assert 'link_up' in self.tests_to_run + if self.args.dry_run: + return True, {'sfp0': 'UP'} + from pyroute2 import IPRoute + result = {} + with IPRoute() as ipr: + links = ipr.link_lookup(ifname='sfp0') + if not links: + return False, {'error_msg': "No interface found"} + link_info = next(iter(ipr.get_links(links)), None) + if link_info == None: + return False, {'error_msg': "Error on get_links for sfp0"} + result['sfp0'] = link_info.get_attr('IFLA_OPERSTATE') + if result['sfp0'] != 'UP': + result['error_msg'] = "Link not up for interface" + return 'error_msg' not in result, result + def gpio_set_all(gpio_bank, value, gpio_size, ddr_mask): """Helper function for set gpio. |