Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Component Drivers

Connects Component drivers connect and provides provide interfaces to various components in the OpenFlow/SDN topology.

The three main methods of a component driver are connect, disconnect, and execute. Usually, while While writing a custom driver, the user might entirely skip writing these methods and use them from the parent component class or call the equivalent super component method, followed by any logic that is specific to this component.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 driverAs a reference to write a custom driver, please refer to Mininet driver.

In this example, the Mininet driver inherits from the abstract Emulator driver which in turn inherits from the CLI driver. The Mininet driver reuses the execute and disconnect API from the CLI driver. The connect API is the only API that is redifinedredefined.

Code Block
class Mininet(Emulator):

        def __init__(self):
            super(Emulator, self).__init__()
            self.handle = self

        def connect(self,user_name, ip_address, pwd,options):
            self.handle = super(Mininet, self).connect(user_name, ip_address, pwd)

...

Driver specific methods/functions can be specified using the simple execute command of mininet cli driverin mininetclidriver.

Code Block
 def pingall( self, timeout=300 ):
        """
           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 = self.execute(
                    cmd="pingall",
                    prompt="mininet>",
                    timeout=int( timeout ) )

Creating A Driver

  • Create a drivename .py file under "/drivers/common/cli/.." . In this example, the driver is placed under cli > emulator(folderpath) hierarchy. If the user wishes to create a driver that is integrated with an API library, then the same can be created under api-emulator (folder path). The driver should be placed in the same folder as the inherited driver type it inherits from.
  • Create The class name must be the same as the driver name. Naming convention for the module name is lower case letters. Naming convention for the class name is "DriverName"CamelCase. In the test 's .topo file specify the component driver as 'type' = 'DriverName'. 
  • Create a function in DriverName class named as connect with the new driver class "connect" with a suitable return type. It will facilitate the connection for component or remote host used for driver.
  • Create more functions/api in DriverName class with suitable defined parameters.

...