OVSDB Client Library

An OVSDB client for interacting with an OVSDB server.

License

License

Categories

Categories

VMware Container Virtualization Tools CLI User Interface
GroupId

GroupId

com.vmware.ovsdb
ArtifactId

ArtifactId

ovsdb-client-library
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

pom
Description

Description

OVSDB Client Library
An OVSDB client for interacting with an OVSDB server.
Project URL

Project URL

https://github.com/vmware/ovsdb-client-library/
Source Code Management

Source Code Management

https://github.com/vmware/ovsdb-client-library/tree/master

Download ovsdb-client-library

How to add to project

<!-- https://jarcasting.com/artifacts/com.vmware.ovsdb/ovsdb-client-library/ -->
<dependency>
    <groupId>com.vmware.ovsdb</groupId>
    <artifactId>ovsdb-client-library</artifactId>
    <version>1.0.1</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/com.vmware.ovsdb/ovsdb-client-library/
implementation 'com.vmware.ovsdb:ovsdb-client-library:1.0.1'
// https://jarcasting.com/artifacts/com.vmware.ovsdb/ovsdb-client-library/
implementation ("com.vmware.ovsdb:ovsdb-client-library:1.0.1")
'com.vmware.ovsdb:ovsdb-client-library:pom:1.0.1'
<dependency org="com.vmware.ovsdb" name="ovsdb-client-library" rev="1.0.1">
  <artifact name="ovsdb-client-library" type="pom" />
</dependency>
@Grapes(
@Grab(group='com.vmware.ovsdb', module='ovsdb-client-library', version='1.0.1')
)
libraryDependencies += "com.vmware.ovsdb" % "ovsdb-client-library" % "1.0.1"
[com.vmware.ovsdb/ovsdb-client-library "1.0.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.slf4j : slf4j-log4j12 jar 1.7.25

test (4)

Group / Artifact Type Version
junit : junit jar 4.12
org.mockito : mockito-core jar 2.15.0
com.google.guava : guava jar 23.0
com.google.guava : guava-testlib jar 23.0

Project Modules

  • json-rpc
  • ovsdb-client

OVSDB Client Library

Build Status Coverage Status Sonatype Nexus (Releases) Maven Central

Overview

This is a schema-independent OVSDB client implementation of OVSDB Management Protocol (RFC 7047). All RPC methods defined in the protocol are implemented.

Getting Started

Dependency

In order to use this library you have to add a dependency to the pom file:

<dependencies>
    <dependency>
        <groupId>com.vmware.ovsdb</groupId>
        <artifactId>ovsdb-client</artifactId>
        <version>LATEST</version>
    </dependency>
</dependencies>

Passive Connection

When the OVSDB client uses passive connection mode, it implies that the OVSDB server is running on active connection mode. In other words, the client listens on certain port (6640 by default) and waits for the server to connects. For more information, see ovsdb-server(1)

In the following example, the ovsdb-server is started by command:

$ ovsdb-server --remote=tcp:192.168.201.4:6640

Note: You can also configure it to read connection methods from a db table. For example, the manager table in hardware_vtep database.

ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();    
OvsdbPassiveConnectionListener listener = new OvsdbPassiveConnectionListenerImpl(executorService);  // (1)

CompletableFuture<OvsdbClient> ovsdbClientFuture = new CompletableFuture<>();
ConnectionCallback connectionCallback = new ConnectionCallback() {      // (2)
    public void connected(OvsdbClient ovsdbClient) {
        System.out.println(ovsdbClient + " connected");
        ovsdbClientFuture.complete(ovsdbClient);
    }
    public void disconnected(OvsdbClient ovsdbClient) {
        System.out.println(ovsdbClient + " disconnected");
    }
};
listener.startListening(6640, connectionCallback).join();       // (3)

OvsdbClient ovsdbClient = ovsdbClientFuture.get(3, TimeUnit.SECONDS);   // (4)
CompletableFuture<String[]> f = ovsdbClient.listDatabases();
String[] dbs = f.get(3, TimeUnit.SECONDS);
System.out.println(Arrays.toString(dbs));

From above example we can see the steps of getting an OvsdbClient object from a passive connection.

(1) Construct a OvsdbPassiveConnectionListener. The OvsdbPassiveConnectionListenerImpl takes a ScheduledExecutorService for asynchronous operations.
(2) Implement the ConnectionCallback interface and construct a callback object.
(3) Start listening on the port.
(4) Get the OvsdbClient object from the callback and use it for operations on the OVSDB server.

Note:

  • All the interfaces provided by OvsdbClient are asynchronous and return a CompletableFuture. See OvsdbClient.java.
  • Exception handling is omitted in this example.

Active Connection

When the OVSDB client uses active connection mode, it implies that the OVSDB server is running on passive connection mode. In other words, the server listens on certain port (6640 by default) and waits for the client to connects. For more information, see ovsdb-server(1)

In the following example, the ovsdb-server is started by command:

$ ovsdb-server --remote=ptcp:6640
ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();    
OvsdbActiveConnectionConnector connector = new OvsdbActiveConnectionConnectorImpl(executorService);  // (1)

CompletableFuture<OvsdbClient> ovsdbClientFuture = connector.connect("192.168.33.74", 6640);       // (2)

OvsdbClient ovsdbClient = ovsdbClientFuture.get(3, TimeUnit.SECONDS);   // (3)
CompletableFuture<String[]> f = ovsdbClient.listDatabases();
String[] dbs = f.get(3, TimeUnit.SECONDS);
System.out.println(Arrays.toString(dbs));

From above example we can see the steps of getting an OvsdbClient object from an active connection.

(1) Construct a OvsdbActiveConnectionConnector. The OvsdbActiveConnectionConnectorImpl takes a ScheduledExecutorService for asynchronous operations.
(2) Connect to the host:port and get a CompletableFuture<OvsdbClient>.
(3) Get the OvsdbClient object from the CompletableFuture<OvsdbClient>.

Documentation

For detailed documentation, see Wiki.

Contributing

The ovsdb-client-library project team welcomes contributions from the community. Before you start working with ovsdb-client-library, please read our Developer Certificate of Origin. All contributions to this repository must be signed as described on that page. Your signature certifies that you wrote the patch or have the right to pass it on as an open-source patch. For more detailed information, refer to CONTRIBUTING.md.

License

com.vmware.ovsdb

VMware

Versions

Version
1.0.1
1.0.0