Get and Set Controllers with CLI on a device through OVSDB

An example of OVSDB infrastructure usage is getting and setting controllers on a device through CLI commands. The set and get conntrollers operations are defined in an ONOS Behaviour, in our case the OvsdbControllerConfig.java, that implements ControllerConfig general behaviour. In the behavior to do operations on the devices, you need the OvsdbController, which you can obtain through the DriverHandler. The OvsdbController instance now gives you access to the database and you can do operations on a specific device through a OvsdbClient specific for that device.

To call the getControllers and setControllers methods you need to obtain the ControllerConfig Behaviour and then call on this instance the methods.

Example

The set and get commands are implemented, as an example, in DeviceControllersCommand.java and DeviceSetControllersCommand.java that provide, in two CLI commands

onos> device-controllers <openflow_device>

This command returns the list of controllers for that particular openflow device.

onos> device-setcontrollers <openflow_device> <list of controllers>

This command puts the given list of controllers as the controllers of the device, removing all the old ones.

Try it on your machine

Infrastructure Setup: