Date: Fri, 29 Mar 2024 11:40:00 +0000 (UTC) Message-ID: <705969896.1093.1711712400945@ip-10-30-146-46.us-west-2.compute.internal> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_1092_1454500711.1711712400942" ------=_Part_1092_1454500711.1711712400942 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Component drivers connect and provide interfaces to various components i= n the OpenFlow/SDN topology.
The three main = methods of a component driver are connect, disconnect, and execute. While w= riting a custom driver, overriding an existing component method may be used= in favor of writing a new method that contains similar logic.
The Mininet driver may be used as a reference to writing a = custom driver.
In this example= , the Mininet driver inherits from the abstract Emulator driver which inher= its from the CLI driver. The Mininet driver reuses the execute and disconne= ct API from the CLI driver. The connect API is the only API that is redefin= ed.
class M= ininetCliDriver( Emulator ): def __init__( self ): super( MininetCliDriver, self ).__init__() self.handle =3D self def connect( self, user_name, ip_address, pwd, options ): self.handle =3D super( MininetCliDriver, self ).connect( user_n= ame, ip_address, pwd )
Here the connec= t will call the inherited connect() method from CLI driver (via Emulator cl= ass).
Driver specific= methods/functions can be specified using the simple execute command in&nbs= p;mininetclidriver.
def pi= ngall( self, timeout=3D300 ): """ Verifies the reachability of the hosts using pingall command. Optional parameter timeout allows you to specify how long to wait for pingall to complete Returns: main.TRUE if pingall completes with no pings dropped otherwise main.FALSE""" if self.handle: main.log.info( self.name + ": Checking reachabilty to the hosts using pingall" ) try: response =3D self.execute( cmd=3D"pingall", prompt=3D"mininet>", timeout=3Dint( timeout ) )
The cluster driver combines the CLI, REST, and Bench components as a clu= ster. This allows the use of a function or variable from another driv= er without the need to specify that specific driver. For example,
main.Clus= ter.active( 0 ).devices()
can be used instead of
main.ONOS= cli1.devices()
and keeps the same context as the former. This can be helpful in tests w= here the number of ONOS nodes is not static throughout the test.
However, if the function name is similar across more than one driver, th= e driver name will need to be specified. For example, in
main.Cl= uster.active( 0 ).CLI.sendline( "roles" )
"CLI" must be specified to avoid ambiguity.
NOTE: More documentation for writing drivers will be ad= ded in the future.
Email us if you=E2=80= =99re stuck, think you=E2=80=99ve found a bug, or just want to send some fe= edback. Please have a look at the guidelines to learn ho= w to efficiently submit a bug report.