Skip to content

Latest commit

 

History

History
494 lines (271 loc) · 14 KB

ovsdb_client.md

File metadata and controls

494 lines (271 loc) · 14 KB

Module ovsdb_client

OVSDB Client Module.

Behaviours: gen_server.

Authors: Vasu Dasari.

Description

This Module is the primary interface to OVSDB library

Data Types


db_name() = unicode:chardata()

db_table() = unicode:chardata()

dst() = pid() | port() | (RegName::atom()) | {RegName::atom(), Node::node()}

json_value() = jsone:json_value()

opts() = #{pid => dst(), database => db_name(), br_name => all | unicode:chardata(), port_name => all | unicode:chardata(), term() => term()}

ovsdb_ops() = map() | list()

proto_type() = tcp | ssl

rpc_return() = {ok, term()} | {error, term()} | not_connected

Function Index

start/4Starts TCP connection.
start/2Starts TCP connection.
stop/1Stop ovsdb connection if established.
info/1Get information about the ovsdb process.
list_dbs/1Lists available databases.
list_dbs/0Equivalent to list_dbs(#{}).
get_schema/1Get database schema.
get_schema/0Equivalent to get_schema(#{}).
transaction/2Perform OVSDB Transaction.
transaction/1Equivalent to transaction(Operation, #{}).
cancel/2Cancel Transaction.
cancel/1Equivalent to cancel(Operation, #{}).
monitor/3Monitor.
monitor/2Equivalent to monitor(Id, Select, #{}).
monitor_cancel/2Cancel Monitor Operation.
monitor_cancel/1Equivalent to monitor_cancel(Id, #{}).
lock/2Lock Database.
lock/1Equivalent to lock(Id, #{}).
steal/2Steal lock.
steal/1Equivalent to steal(Id, #{}).
unlock/2Unlock database.
unlock/1Equivalent to unlock(Id, #{}).
echo/1Echo.
echo/0Equivalent to echo().
get_schema_version/1Get OVSDB Schema's version.
get_schema_version/0Equivalent to get_schema_version(#{}).
list_columns/2Get columns of table.
list_columns/1Equivalent to list_columns(Table, #{}).
list_tables/1Get a list of tables.
list_tables/0Equivalent to list_tables(#{}).
dump/2
dump/3
start_link/3start_link when instantiated from applications own supervisor.

Function Details

start/4


start(Type::proto_type(), IpAddr::ip_addr(), Port::inet:port_number(), Opts::opts()) -> ok

Starts TCP connection

Establishes TCP connection with OVSDB server identified by IpAddr and Port. Optionally user can set defaul database to be used in future transactions, by specifying opts with Opts = #{database => "DbName" If a connection is already in polace, it would drop it and restarts new session if endpoint is different.

start/2

start(Ovsdb_Server_Str, Opts) -> any()

Starts TCP connection

Establishes TCP connection with OVSDB server identified by "IpAddr:Port" string format.

stop/1

stop(Opts) -> any()

Stop ovsdb connection if established

info/1

info(Opts) -> any()

Get information about the ovsdb process

This API can be used to retrieve the callback module information among other things

list_dbs/1


list_dbs(Opts::opts()) -> rpc_return()

Lists available databases

Reference 4.1.1. List Databases

list_dbs/0

list_dbs() -> any()

Equivalent to list_dbs(#{}).

get_schema/1


get_schema(Opts::opts()) -> rpc_return()

Get database schema

Reference 4.1.2. Get Schema

get_schema/0

get_schema() -> any()

Equivalent to get_schema(#{}).

transaction/2


transaction(Operation::ovsdb_ops(), Opts::opts()) -> rpc_return()

Perform OVSDB Transaction

Reference 4.1.3. Transaction

transaction/1

transaction(Operation) -> any()

Equivalent to transaction(Operation, #{}).

cancel/2


cancel(Operation::ovsdb_ops(), Opts::opts()) -> rpc_return()

Cancel Transaction

Reference 4.1.4. Cancel

cancel/1

cancel(Operation) -> any()

Equivalent to cancel(Operation, #{}).

monitor/3


monitor(Id::json_value(), Select::term(), Opts::opts()) -> rpc_return()

Monitor

Caller initiates monitor session identified by an Id. This Id need to be used to cancel/stop monitor operation. All monitored events will be sent to caller process with following syntax.

     {ovsdb_monitor, Id, Update}

Reference 4.1.5. Monitor

monitor/2

monitor(Id, Select) -> any()

Equivalent to monitor(Id, Select, #{}).

monitor_cancel/2


monitor_cancel(Id::json_value(), Opts::opts()) -> rpc_return()

Cancel Monitor Operation

Reference 4.1.7. Monitor Cancellation

monitor_cancel/1

monitor_cancel(Id) -> any()

Equivalent to monitor_cancel(Id, #{}).

lock/2


lock(Id::json_value(), Opts::opts()) -> rpc_return()

Lock Database

This function returns with status of database getting locked or not. If it is not locked, a notification will be sent when the database is locked. And it would like this:

     {ovsdb_notification, Method, LockId}
           Method: locked | stolen

Reference 4.1.8. Lock Operations

lock/1

lock(Id) -> any()

Equivalent to lock(Id, #{}).

steal/2


steal(Id::json_value(), Opts::opts()) -> rpc_return()

Steal lock

This method would forcefully grab the database access which was previously locked by Id by another process. This operation would notify the process which originally had lock that the lock is stolen.

Reference 4.1.8. Lock Operations

steal/1

steal(Id) -> any()

Equivalent to steal(Id, #{}).

unlock/2


unlock(Id::json_value(), Opts::opts()) -> rpc_return()

Unlock database

Unlock the database by releasing the lock.

Reference 4.1.8. Lock Operations

unlock/1

unlock(Id) -> any()

Equivalent to unlock(Id, #{}).

echo/1


echo(Opts::opts()) -> rpc_return()

Echo

This can be used to check by caller if the session is active. By default, ovsdb_client performs echo - echo-reply handshakes to makesure session is active. This function can be used for debugging.

Reference 4.1.11. Echo

echo/0

echo() -> any()

Equivalent to echo().

get_schema_version/1


get_schema_version(Opts::opts()) -> rpc_return()

Get OVSDB Schema's version

get_schema_version/0

get_schema_version() -> any()

Equivalent to get_schema_version(#{}).

list_columns/2


list_columns(Table::db_table(), Opts::opts()) -> rpc_return()

Get columns of table

Reference 4.1.3. Transaction

list_columns/1

list_columns(Table) -> any()

Equivalent to list_columns(Table, #{}).

list_tables/1


list_tables(Opts::opts()) -> rpc_return()

Get a list of tables

list_tables/0

list_tables() -> any()

Equivalent to list_tables(#{}).

dump/2


dump(Table::db_table(), Columns::list()) -> rpc_return()

dump/3

dump(Table, Columns, Opts) -> any()

start_link/3


start_link(ProcName::dst(), CallbackModuleName::module(), CallbackState::term()) -> {ok, Pid::pid()} | ignore | {error, Reason::term()}

start_link when instantiated from applications own supervisor

ovsdb_client keeps a state for the application module which can provide contet to the application when callbacks are called