How to use is_link_up method in avocado

Best Python code snippet using avocado_python

basics.py

Source:basics.py Github

copy

Full Screen

1from api import *2class BasicHost (HostEntity):3 """ Basic host with a ping method """4 def ping (self, dst, data=None): #dst type = BasicHost5 """ Sends a Ping packet to dst. """6 self.send(Ping(dst, data=data), flood=True)7 def handle_rx (self, packet, port):8 # print("BasicHost received packet")9 """10 Silently drops messages to nobody.11 Warns about received messages to someone besides itself.12 Prints received messages.13 Returns Pings with a Pong.14 """15 if packet.dst is NullAddress:16 # Silently drop messages not to anyone in particular17 return18 trace = ','.join((s.name for s in packet.trace))19 if packet.dst is not self:20 self.log("NOT FOR ME: %s %s" % (packet, trace), level="WARNING")21 else:22 self.log("rx: %s %s" % (packet, trace))23 if type(packet) is Ping:24 # Trace this path25 import core26 core.events.highlight_path([packet.src] + packet.trace)27 # Send a pong response28 self.send(Pong(packet), port)29class Ping (Packet):30 """ A Ping packet """31 def __init__ (self, dst, data=None):32 Packet.__init__(self, dst=dst)33 self.data = data34 self.outer_color[3] = 1 # Full opacity35 self.inner_color = [1,1,1,1] # white36 def __repr__ (self):37 d = self.data38 if d is not None:39 d = ': ' + str(d)40 else:41 d = ''42 return "<Ping %s->%s ttl:%i%s>" % (self.src.name, self.dst.name, self.ttl, d)43class Pong (Packet):44 """45 A Pong packet. It's a returned Ping. The original Ping is in46 the .original property.47 """48 def __init__ (self, original):49 Packet.__init__(self, dst=original.src)50 self.original = original51 # Flip colors from original52 self.outer_color = original.inner_color53 self.inner_color = original.outer_color54 def __repr__ (self):55 return "<Pong " + str(self.original) + ">"56#class DiscoveryPacket (Packet):57# """58# A "link up/down" packet.59# """60# def __init__(self, src, is_link_up):61# Packet.__init__(self, src=src)62# self.is_link_up = is_link_up63#64# def __repr__ (self):65# return "<%s from %s->%s, %s>" % (self.__class__.__name__,66# self.src.name if self.src else None,67# self.dst.name if self.dst else None,68# self.is_link_up)69# Changed to enable link latency - Kaifei Chen(kaifei@berkeley.edu)70class DiscoveryPacket (Packet):71 """72 A "link latency change" packet.73 latency should be float("inf") if the link is down.74 """75 def __init__(self, src, latency):76 Packet.__init__(self, src=src)77 self.latency = latency78 self.is_link_up = (latency != None and latency != float("inf"))79 def __repr__ (self):80 return "<%s from %s->%s, %s, %s>" % (self.__class__.__name__,81 self.src.name if self.src else None,82 self.dst.name if self.dst else None,83 self.latency,84 self.is_link_up)85class RoutingUpdate (Packet):86 """87 A Routing Update message to use with your DVRouter implementation.88 """89 def __init__(self):90 Packet.__init__(self)91 self.paths = {}92 def add_destination(self, dest, distance):93 """94 Add a destination to announce, along with senders distance to that dest.95 """96 self.paths[dest] = distance97 def get_distance(self, dest):98 """99 Get the distance to the specified destination.100 """101 return self.paths[dest]102 def all_dests(self):103 """104 Get a list of all destinations with paths announced in this message.105 """106 return self.paths.keys()107 def str_routing_table(self):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful