def bash_delete_tag(self, node, intf, soft_error=True): """ Function to remove the vlan tag from the host eth interfaces. Note: soft_error=True because in the common use case, we just want to log the error but not trigger failure. """ t = test.Test() n = t.node(node) try: n.sudo("vconfig rem %s" % intf) except: output = helpers.exception_info_value() helpers.log("Output: %s" % output) # Catch error: # ERROR: trying to remove VLAN -:eth1.20:- error: No such device if helpers.any_match(str(output), r'error: No such devices'): helpers.test_error( "vconfig rem error - no such device '%s'" % intf, soft_error) return False else: helpers.test_error( 'Uncaught exception:\n%s' % helpers.exception_info(), soft_error) return False return True
def mininet_bugreport(self): t = test.Test() mn = t.mininet() mn.cli('bugreport') out = mn.cli_content() location = helpers.any_match(out, r'Bugreport left at') helpers.log("Bugreport Location is: %s" % location) return location
def mininet_ping(self, src, dst, count=5): t = test.Test() mn = t.mininet() mn.cli('%s ping %s -c %s' % (src, dst, count)) out = mn.cli_content() unreachable = helpers.any_match(out, r'is unreachable') if unreachable: helpers.log("Network is unreachable. Assuming 100% packet loss.") return 100 loss = helpers.any_match(out, r', (\d+)% packet loss') if loss: helpers.log("packet loss: %s" % loss) return loss[0] helpers.test_error("Uncaught condition")
def mininet_pingall(self): t = test.Test() mn = t.mininet() mn.cli('pingall') out = mn.cli_content() drop = helpers.any_match(out, r'Results: (\d+)% dropped') helpers.log("drop: %s" % drop) if int(drop[0]) > 0: helpers.test_failure(drop[0] + "% packet drop") return out
def mininet_l3_ping(self, src, dst, count=5, options="None"): t = test.Test() mn = t.mininet() if options == "None": mn.cli('%s ping %s -c %s -W 2' % (src, dst, count)) else: mn.cli('%s ping %s -c %s -W 2 %s' % (src, dst, count, options)) out = mn.cli_content() loss = helpers.any_match(out, r', (\d+)% packet loss') helpers.log("packet loss: %s" % loss) return loss[0]