java.lang.Object
org.opendaylight.ovsdb.utils.ovsdb.it.utils.DockerOvs
All Implemented Interfaces:
AutoCloseable

public final class DockerOvs extends Object implements AutoCloseable
Run OVS(s) using docker-compose for use in integration tests. For example,
 try(DockerOvs ovs = new DockerOvs()) {
      ConnectionInfo connectionInfo = SouthboundUtils.getConnectionInfo(
                               ovs.getOvsdbAddress(0), ovs.getOvsdbPort(0));
      ...
       nodeInfo.disconnect();

 } catch (Exception e) {
 ...
 
Nota bene, DockerOvs will check whether or not docker-compose command requires "sudo" to run. However, if it does require sudo, it must be configured to not prompt for a password ("NOPASSWD: ALL" is the sudoers file). DockerOvs loads its docker-compose yaml files from inside the ovsdb-it-utils bundle at the path META-INF/docker-compose-files/. Currently, a single yaml file is used, "docker-ovs-2.5.1.yml." DockerOvs does support docker-compose files that launch more than one docker image, more on this later. DockerOvs will wait for OVS to accept OVSDB connections. Any docker-compose file must have a port mapping.

The following explains how system properties are used to configure DockerOvs

  private static String ENV_USAGE =
  "-Ddocker.run - explicitly configure whether or not DockerOvs should run docker-compose\n" +
  "-Dovsdbserver.ipaddress - specify IP address of ovsdb server - implies -Ddocker.run=false\n" +
  "-Dovsdbserver.port - specify the port of the ovsdb server - required with -Dovsdbserver.ipaddress\n" +
  "-Ddocker.compose.file - docker compose file in META-INF/docker-compose-files/.
      If not specified, default file is used\n" +
  "-Dovsdb.userspace.enabled - true when Ovs is running in user space (usually the case with docker)\n" +
  "-Dovsdb.controller.address - IP address of the controller (usually the docker0 interface with docker)\n" +
  "To auto-run Ovs and connect actively:\n" +
  " -Dovsdb.controller.address=x.x.x.x -Dovsdb.userspace.enabled=yes [-Ddocker.compose.file=ffff]\n" +
  "To auto-run Ovs and connect passively:\n" +
  " -Dovsdbserver.connection=passive -Dovsdb.controller.address=x.x.x.x
    -Dovsdb.userspace.enabled=yes [-Ddocker.compose.file=ffff]\n" +
  "To actively connect to a running Ovs:\n" +
  " -Dovsdbserver.ipaddress=x.x.x.x -Dovsdbserver.port=6641 -Dovsdb.controller.address=y.y.y.y\n" +
  "To passively connect to a running Ovs:\n" +
  " -Dovsdbserver.connection=passive -Ddocker.run=false\n";
 
Note: Ommiting the environment variable ovsdb.controller.address will cause DockerOvs to use a predefined docker network called "odl". This network's subnet must be 172.99.0.0/16 and its gateway must be defined as 172.99.0.254. If the "odl" network is not present, DockerOvs will create it for you. When DockerOvs does not run docker-compose getOvsdbAddress and getOvsdbPort return the address and port specified in the system properties.