2009-11-06 15:35:34 -08:00
|
|
|
|
/*
|
2010-01-13 09:55:52 -08:00
|
|
|
|
* Copyright (c) 2009, 2010 Nicira Networks.
|
2009-11-06 15:35:34 -08:00
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at:
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2009-12-21 10:38:26 -08:00
|
|
|
|
#include <assert.h>
|
2009-11-06 15:35:34 -08:00
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <getopt.h>
|
|
|
|
|
#include <limits.h>
|
|
|
|
|
#include <signal.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
#include "command-line.h"
|
|
|
|
|
#include "column.h"
|
|
|
|
|
#include "compiler.h"
|
2009-12-03 14:25:06 -08:00
|
|
|
|
#include "daemon.h"
|
2009-11-06 15:35:34 -08:00
|
|
|
|
#include "dynamic-string.h"
|
|
|
|
|
#include "json.h"
|
|
|
|
|
#include "jsonrpc.h"
|
|
|
|
|
#include "ovsdb.h"
|
|
|
|
|
#include "ovsdb-error.h"
|
|
|
|
|
#include "stream.h"
|
2009-12-21 13:13:48 -08:00
|
|
|
|
#include "stream-ssl.h"
|
2009-11-06 15:35:34 -08:00
|
|
|
|
#include "table.h"
|
|
|
|
|
#include "timeval.h"
|
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
|
|
#include "vlog.h"
|
|
|
|
|
#define THIS_MODULE VLM_ovsdb_client
|
|
|
|
|
|
|
|
|
|
/* --format: Output formatting. */
|
|
|
|
|
static enum {
|
|
|
|
|
FMT_TABLE, /* Textual table. */
|
|
|
|
|
FMT_HTML, /* HTML table. */
|
|
|
|
|
FMT_CSV /* Comma-separated lines. */
|
|
|
|
|
} output_format;
|
|
|
|
|
|
|
|
|
|
/* --no-headings: Whether table output should include headings. */
|
|
|
|
|
static int output_headings = true;
|
|
|
|
|
|
2009-12-11 11:14:00 -08:00
|
|
|
|
/* --pretty: Flags to pass to json_to_string(). */
|
|
|
|
|
static int json_flags = JSSF_SORT;
|
|
|
|
|
|
2009-11-06 15:35:34 -08:00
|
|
|
|
static const struct command all_commands[];
|
|
|
|
|
|
|
|
|
|
static void usage(void) NO_RETURN;
|
|
|
|
|
static void parse_options(int argc, char *argv[]);
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
|
{
|
2010-01-19 15:00:56 -08:00
|
|
|
|
proctitle_init(argc, argv);
|
2009-11-06 15:35:34 -08:00
|
|
|
|
set_program_name(argv[0]);
|
|
|
|
|
time_init();
|
|
|
|
|
vlog_init();
|
|
|
|
|
parse_options(argc, argv);
|
|
|
|
|
signal(SIGPIPE, SIG_IGN);
|
|
|
|
|
run_command(argc - optind, argv + optind, all_commands);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
parse_options(int argc, char *argv[])
|
|
|
|
|
{
|
2009-12-21 13:13:48 -08:00
|
|
|
|
enum {
|
|
|
|
|
OPT_BOOTSTRAP_CA_CERT = UCHAR_MAX + 1
|
|
|
|
|
};
|
2009-11-06 15:35:34 -08:00
|
|
|
|
static struct option long_options[] = {
|
|
|
|
|
{"format", required_argument, 0, 'f'},
|
|
|
|
|
{"no-headings", no_argument, &output_headings, 0},
|
2009-12-11 11:14:00 -08:00
|
|
|
|
{"pretty", no_argument, &json_flags, JSSF_PRETTY | JSSF_SORT},
|
2009-11-06 15:35:34 -08:00
|
|
|
|
{"verbose", optional_argument, 0, 'v'},
|
|
|
|
|
{"help", no_argument, 0, 'h'},
|
|
|
|
|
{"version", no_argument, 0, 'V'},
|
2009-12-03 14:25:06 -08:00
|
|
|
|
DAEMON_LONG_OPTIONS,
|
2009-12-21 13:13:48 -08:00
|
|
|
|
#ifdef HAVE_OPENSSL
|
|
|
|
|
{"bootstrap-ca-cert", required_argument, 0, OPT_BOOTSTRAP_CA_CERT},
|
|
|
|
|
STREAM_SSL_LONG_OPTIONS
|
|
|
|
|
#endif
|
2009-11-06 15:35:34 -08:00
|
|
|
|
{0, 0, 0, 0},
|
|
|
|
|
};
|
|
|
|
|
char *short_options = long_options_to_short_options(long_options);
|
|
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
|
int c;
|
|
|
|
|
|
|
|
|
|
c = getopt_long(argc, argv, short_options, long_options, NULL);
|
|
|
|
|
if (c == -1) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (c) {
|
|
|
|
|
case 'f':
|
|
|
|
|
if (!strcmp(optarg, "table")) {
|
|
|
|
|
output_format = FMT_TABLE;
|
|
|
|
|
} else if (!strcmp(optarg, "html")) {
|
|
|
|
|
output_format = FMT_HTML;
|
|
|
|
|
} else if (!strcmp(optarg, "csv")) {
|
|
|
|
|
output_format = FMT_CSV;
|
|
|
|
|
} else {
|
|
|
|
|
ovs_fatal(0, "unknown output format \"%s\"", optarg);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'h':
|
|
|
|
|
usage();
|
|
|
|
|
|
|
|
|
|
case 'V':
|
|
|
|
|
OVS_PRINT_VERSION(0, 0);
|
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
|
|
|
|
|
|
case 'v':
|
|
|
|
|
vlog_set_verbosity(optarg);
|
|
|
|
|
break;
|
|
|
|
|
|
2009-12-03 14:25:06 -08:00
|
|
|
|
DAEMON_OPTION_HANDLERS
|
|
|
|
|
|
2009-12-21 13:13:48 -08:00
|
|
|
|
#ifdef HAVE_OPENSSL
|
|
|
|
|
STREAM_SSL_OPTION_HANDLERS
|
|
|
|
|
|
|
|
|
|
case OPT_BOOTSTRAP_CA_CERT:
|
|
|
|
|
stream_ssl_set_ca_cert_file(optarg, true);
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-11-06 15:35:34 -08:00
|
|
|
|
case '?':
|
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
|
/* getopt_long() already set the value for us. */
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
abort();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
free(short_options);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
usage(void)
|
|
|
|
|
{
|
|
|
|
|
printf("%s: Open vSwitch database JSON-RPC client\n"
|
|
|
|
|
"usage: %s [OPTIONS] COMMAND [ARG...]\n"
|
|
|
|
|
"\nValid commands are:\n"
|
2010-02-09 10:17:58 -08:00
|
|
|
|
"\n list-dbs SERVER\n"
|
|
|
|
|
" list databases available on SERVER\n"
|
|
|
|
|
"\n get-schema SERVER DATABASE\n"
|
|
|
|
|
" retrieve schema for DATABASE from SERVER\n"
|
|
|
|
|
"\n list-tables SERVER DATABSE\n"
|
|
|
|
|
" list tables for DATABSAE on SERVER\n"
|
|
|
|
|
"\n list-columns SERVER DATABASE [TABLE]\n"
|
|
|
|
|
" list columns in TABLE (or all tables) in DATABASE on SERVER\n"
|
2009-11-16 15:12:04 -08:00
|
|
|
|
"\n transact SERVER TRANSACTION\n"
|
|
|
|
|
" run TRANSACTION (a JSON array of operations) on SERVER\n"
|
2009-11-16 10:38:14 -08:00
|
|
|
|
" and print the results as JSON on stdout\n"
|
2010-02-09 10:17:58 -08:00
|
|
|
|
"\n monitor SERVER DATABASE TABLE [COLUMN,...] [SELECT,...]\n"
|
|
|
|
|
" monitor contents of (COLUMNs in) TABLE in DATABASE on SERVER\n"
|
2009-11-16 10:38:14 -08:00
|
|
|
|
" Valid SELECTs are: initial, insert, delete, modify\n",
|
2009-11-06 15:35:34 -08:00
|
|
|
|
program_name, program_name);
|
2009-12-21 13:13:48 -08:00
|
|
|
|
stream_usage("SERVER", true, true, true);
|
2009-11-06 15:35:34 -08:00
|
|
|
|
printf("\nOutput formatting options:\n"
|
|
|
|
|
" -f, --format=FORMAT set output formatting to FORMAT\n"
|
|
|
|
|
" (\"table\", \"html\", or \"csv\"\n"
|
2009-12-11 11:14:00 -08:00
|
|
|
|
" --no-headings omit table heading row\n"
|
|
|
|
|
" --pretty pretty-print JSON in output");
|
2009-12-03 14:25:06 -08:00
|
|
|
|
daemon_usage();
|
2009-11-06 15:35:34 -08:00
|
|
|
|
vlog_usage();
|
|
|
|
|
printf("\nOther options:\n"
|
|
|
|
|
" -h, --help display this help message\n"
|
|
|
|
|
" -V, --version display version information\n");
|
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-16 15:12:04 -08:00
|
|
|
|
static struct json *
|
|
|
|
|
parse_json(const char *s)
|
|
|
|
|
{
|
|
|
|
|
struct json *json = json_from_string(s);
|
|
|
|
|
if (json->type == JSON_STRING) {
|
|
|
|
|
ovs_fatal(0, "\"%s\": %s", s, json->u.string);
|
|
|
|
|
}
|
|
|
|
|
return json;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-06 15:35:34 -08:00
|
|
|
|
static struct jsonrpc *
|
|
|
|
|
open_jsonrpc(const char *server)
|
|
|
|
|
{
|
|
|
|
|
struct stream *stream;
|
|
|
|
|
int error;
|
|
|
|
|
|
|
|
|
|
error = stream_open_block(server, &stream);
|
2009-11-12 12:53:05 -08:00
|
|
|
|
if (error == EAFNOSUPPORT) {
|
|
|
|
|
struct pstream *pstream;
|
|
|
|
|
|
|
|
|
|
error = pstream_open(server, &pstream);
|
|
|
|
|
if (error) {
|
|
|
|
|
ovs_fatal(error, "failed to connect or listen to \"%s\"", server);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VLOG_INFO("%s: waiting for connection...", server);
|
|
|
|
|
error = pstream_accept_block(pstream, &stream);
|
|
|
|
|
if (error) {
|
|
|
|
|
ovs_fatal(error, "failed to accept connection on \"%s\"", server);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pstream_close(pstream);
|
|
|
|
|
} else if (error) {
|
2009-11-06 15:35:34 -08:00
|
|
|
|
ovs_fatal(error, "failed to connect to \"%s\"", server);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return jsonrpc_open(stream);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_json(struct json *json)
|
|
|
|
|
{
|
2009-12-11 11:14:00 -08:00
|
|
|
|
char *string = json_to_string(json, json_flags);
|
2009-11-06 15:35:34 -08:00
|
|
|
|
fputs(string, stdout);
|
|
|
|
|
free(string);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_and_free_json(struct json *json)
|
|
|
|
|
{
|
|
|
|
|
print_json(json);
|
|
|
|
|
json_destroy(json);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
check_ovsdb_error(struct ovsdb_error *error)
|
|
|
|
|
{
|
|
|
|
|
if (error) {
|
|
|
|
|
ovs_fatal(0, "%s", ovsdb_error_to_string(error));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct ovsdb_schema *
|
2010-02-09 10:17:58 -08:00
|
|
|
|
fetch_schema_from_rpc(struct jsonrpc *rpc, const char *database)
|
2009-11-06 15:35:34 -08:00
|
|
|
|
{
|
|
|
|
|
struct jsonrpc_msg *request, *reply;
|
|
|
|
|
struct ovsdb_schema *schema;
|
|
|
|
|
int error;
|
|
|
|
|
|
2010-02-09 10:17:58 -08:00
|
|
|
|
request = jsonrpc_create_request("get_schema",
|
|
|
|
|
json_array_create_1(
|
|
|
|
|
json_string_create(database)),
|
2009-12-01 16:32:03 -08:00
|
|
|
|
NULL);
|
2009-11-06 15:35:34 -08:00
|
|
|
|
error = jsonrpc_transact_block(rpc, request, &reply);
|
|
|
|
|
if (error) {
|
|
|
|
|
ovs_fatal(error, "transaction failed");
|
|
|
|
|
}
|
|
|
|
|
check_ovsdb_error(ovsdb_schema_from_json(reply->result, &schema));
|
|
|
|
|
jsonrpc_msg_destroy(reply);
|
2009-11-16 10:38:14 -08:00
|
|
|
|
|
|
|
|
|
return schema;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct ovsdb_schema *
|
2010-02-09 10:17:58 -08:00
|
|
|
|
fetch_schema(const char *server, const char *database)
|
2009-11-16 10:38:14 -08:00
|
|
|
|
{
|
|
|
|
|
struct ovsdb_schema *schema;
|
|
|
|
|
struct jsonrpc *rpc;
|
|
|
|
|
|
|
|
|
|
rpc = open_jsonrpc(server);
|
2010-02-09 10:17:58 -08:00
|
|
|
|
schema = fetch_schema_from_rpc(rpc, database);
|
2009-11-06 15:35:34 -08:00
|
|
|
|
jsonrpc_close(rpc);
|
|
|
|
|
|
|
|
|
|
return schema;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct column {
|
|
|
|
|
char *heading;
|
|
|
|
|
int width;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct table {
|
|
|
|
|
char **cells;
|
|
|
|
|
struct column *columns;
|
|
|
|
|
size_t n_columns, allocated_columns;
|
|
|
|
|
size_t n_rows, allocated_rows;
|
|
|
|
|
size_t current_column;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
table_init(struct table *table)
|
|
|
|
|
{
|
|
|
|
|
memset(table, 0, sizeof *table);
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-16 10:38:14 -08:00
|
|
|
|
static void
|
|
|
|
|
table_destroy(struct table *table)
|
|
|
|
|
{
|
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < table->n_columns; i++) {
|
|
|
|
|
free(table->columns[i].heading);
|
|
|
|
|
}
|
|
|
|
|
free(table->columns);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < table->n_columns * table->n_rows; i++) {
|
|
|
|
|
free(table->cells[i]);
|
|
|
|
|
}
|
|
|
|
|
free(table->cells);
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-06 15:35:34 -08:00
|
|
|
|
static void
|
|
|
|
|
table_add_column(struct table *table, const char *heading, ...)
|
|
|
|
|
PRINTF_FORMAT(2, 3);
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
table_add_column(struct table *table, const char *heading, ...)
|
|
|
|
|
{
|
|
|
|
|
struct column *column;
|
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
|
|
assert(!table->n_rows);
|
|
|
|
|
if (table->n_columns >= table->allocated_columns) {
|
|
|
|
|
table->columns = x2nrealloc(table->columns, &table->allocated_columns,
|
|
|
|
|
sizeof *table->columns);
|
|
|
|
|
}
|
|
|
|
|
column = &table->columns[table->n_columns++];
|
|
|
|
|
|
|
|
|
|
va_start(args, heading);
|
|
|
|
|
column->heading = xvasprintf(heading, args);
|
|
|
|
|
column->width = strlen(column->heading);
|
|
|
|
|
va_end(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char **
|
|
|
|
|
table_cell__(const struct table *table, size_t row, size_t column)
|
|
|
|
|
{
|
|
|
|
|
return &table->cells[column + row * table->n_columns];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
table_add_row(struct table *table)
|
|
|
|
|
{
|
|
|
|
|
size_t x, y;
|
|
|
|
|
|
|
|
|
|
if (table->n_rows >= table->allocated_rows) {
|
|
|
|
|
table->cells = x2nrealloc(table->cells, &table->allocated_rows,
|
|
|
|
|
table->n_columns * sizeof *table->cells);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
y = table->n_rows++;
|
|
|
|
|
table->current_column = 0;
|
|
|
|
|
for (x = 0; x < table->n_columns; x++) {
|
|
|
|
|
*table_cell__(table, y, x) = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
table_add_cell_nocopy(struct table *table, char *s)
|
|
|
|
|
{
|
|
|
|
|
size_t x, y;
|
|
|
|
|
int length;
|
|
|
|
|
|
|
|
|
|
assert(table->n_rows > 0);
|
|
|
|
|
assert(table->current_column < table->n_columns);
|
|
|
|
|
|
|
|
|
|
x = table->current_column++;
|
|
|
|
|
y = table->n_rows - 1;
|
|
|
|
|
*table_cell__(table, y, x) = s;
|
|
|
|
|
|
|
|
|
|
length = strlen(s);
|
|
|
|
|
if (length > table->columns[x].width) {
|
|
|
|
|
table->columns[x].width = length;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
table_add_cell(struct table *table, const char *format, ...)
|
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
|
|
va_start(args, format);
|
|
|
|
|
table_add_cell_nocopy(table, xvasprintf(format, args));
|
|
|
|
|
va_end(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-02-10 14:38:05 -08:00
|
|
|
|
table_print_table_line__(struct ds *line)
|
2009-11-06 15:35:34 -08:00
|
|
|
|
{
|
|
|
|
|
puts(ds_cstr(line));
|
|
|
|
|
ds_clear(line);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
table_print_table__(const struct table *table)
|
|
|
|
|
{
|
|
|
|
|
struct ds line = DS_EMPTY_INITIALIZER;
|
|
|
|
|
size_t x, y;
|
|
|
|
|
|
|
|
|
|
if (output_headings) {
|
|
|
|
|
for (x = 0; x < table->n_columns; x++) {
|
|
|
|
|
const struct column *column = &table->columns[x];
|
|
|
|
|
if (x) {
|
|
|
|
|
ds_put_char(&line, ' ');
|
|
|
|
|
}
|
|
|
|
|
ds_put_format(&line, "%-*s", column->width, column->heading);
|
|
|
|
|
}
|
2010-02-10 14:38:05 -08:00
|
|
|
|
table_print_table_line__(&line);
|
2009-11-06 15:35:34 -08:00
|
|
|
|
|
|
|
|
|
for (x = 0; x < table->n_columns; x++) {
|
|
|
|
|
const struct column *column = &table->columns[x];
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (x) {
|
|
|
|
|
ds_put_char(&line, ' ');
|
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < column->width; i++) {
|
|
|
|
|
ds_put_char(&line, '-');
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-10 14:38:05 -08:00
|
|
|
|
table_print_table_line__(&line);
|
2009-11-06 15:35:34 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (y = 0; y < table->n_rows; y++) {
|
|
|
|
|
for (x = 0; x < table->n_columns; x++) {
|
|
|
|
|
const char *cell = *table_cell__(table, y, x);
|
|
|
|
|
if (x) {
|
|
|
|
|
ds_put_char(&line, ' ');
|
|
|
|
|
}
|
|
|
|
|
ds_put_format(&line, "%-*s", table->columns[x].width, cell);
|
|
|
|
|
}
|
2010-02-10 14:38:05 -08:00
|
|
|
|
table_print_table_line__(&line);
|
2009-11-06 15:35:34 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ds_destroy(&line);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
table_print_html_cell__(const char *element, const char *content)
|
|
|
|
|
{
|
|
|
|
|
const char *p;
|
|
|
|
|
|
|
|
|
|
printf(" <%s>", element);
|
|
|
|
|
for (p = content; *p != '\0'; p++) {
|
|
|
|
|
switch (*p) {
|
|
|
|
|
case '&':
|
|
|
|
|
fputs("&", stdout);
|
|
|
|
|
break;
|
|
|
|
|
case '<':
|
|
|
|
|
fputs("<", stdout);
|
|
|
|
|
break;
|
|
|
|
|
case '>':
|
|
|
|
|
fputs(">", stdout);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
putchar(*p);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("</%s>\n", element);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
table_print_html__(const struct table *table)
|
|
|
|
|
{
|
|
|
|
|
size_t x, y;
|
|
|
|
|
|
|
|
|
|
fputs("<table>\n", stdout);
|
|
|
|
|
|
|
|
|
|
if (output_headings) {
|
|
|
|
|
fputs(" <tr>\n", stdout);
|
|
|
|
|
for (x = 0; x < table->n_columns; x++) {
|
|
|
|
|
const struct column *column = &table->columns[x];
|
|
|
|
|
table_print_html_cell__("th", column->heading);
|
|
|
|
|
}
|
|
|
|
|
fputs(" </tr>\n", stdout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (y = 0; y < table->n_rows; y++) {
|
|
|
|
|
fputs(" <tr>\n", stdout);
|
|
|
|
|
for (x = 0; x < table->n_columns; x++) {
|
|
|
|
|
table_print_html_cell__("td", *table_cell__(table, y, x));
|
|
|
|
|
}
|
|
|
|
|
fputs(" </tr>\n", stdout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fputs("</table>\n", stdout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
table_print_csv_cell__(const char *content)
|
|
|
|
|
{
|
|
|
|
|
const char *p;
|
|
|
|
|
|
|
|
|
|
if (!strpbrk(content, "\n\",")) {
|
|
|
|
|
fputs(content, stdout);
|
|
|
|
|
} else {
|
|
|
|
|
putchar('"');
|
|
|
|
|
for (p = content; *p != '\0'; p++) {
|
|
|
|
|
switch (*p) {
|
|
|
|
|
case '"':
|
|
|
|
|
fputs("\"\"", stdout);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
putchar(*p);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
putchar('"');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
table_print_csv__(const struct table *table)
|
|
|
|
|
{
|
|
|
|
|
size_t x, y;
|
|
|
|
|
|
|
|
|
|
if (output_headings) {
|
|
|
|
|
for (x = 0; x < table->n_columns; x++) {
|
|
|
|
|
const struct column *column = &table->columns[x];
|
|
|
|
|
if (x) {
|
|
|
|
|
putchar(',');
|
|
|
|
|
}
|
|
|
|
|
table_print_csv_cell__(column->heading);
|
|
|
|
|
}
|
|
|
|
|
putchar('\n');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (y = 0; y < table->n_rows; y++) {
|
|
|
|
|
for (x = 0; x < table->n_columns; x++) {
|
|
|
|
|
if (x) {
|
|
|
|
|
putchar(',');
|
|
|
|
|
}
|
|
|
|
|
table_print_csv_cell__(*table_cell__(table, y, x));
|
|
|
|
|
}
|
|
|
|
|
putchar('\n');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
table_print(const struct table *table)
|
|
|
|
|
{
|
|
|
|
|
switch (output_format) {
|
|
|
|
|
case FMT_TABLE:
|
|
|
|
|
table_print_table__(table);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FMT_HTML:
|
|
|
|
|
table_print_html__(table);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FMT_CSV:
|
|
|
|
|
table_print_csv__(table);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-09 10:17:58 -08:00
|
|
|
|
static void
|
2010-02-11 11:11:23 -08:00
|
|
|
|
do_list_dbs(int argc OVS_UNUSED, char *argv[])
|
2010-02-09 10:17:58 -08:00
|
|
|
|
{
|
|
|
|
|
struct jsonrpc_msg *request, *reply;
|
|
|
|
|
struct jsonrpc *rpc;
|
|
|
|
|
int error;
|
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
|
|
rpc = open_jsonrpc(argv[1]);
|
|
|
|
|
request = jsonrpc_create_request("list_dbs", json_array_create_empty(),
|
|
|
|
|
NULL);
|
|
|
|
|
error = jsonrpc_transact_block(rpc, request, &reply);
|
|
|
|
|
if (error) {
|
|
|
|
|
ovs_fatal(error, "transaction failed");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (reply->result->type != JSON_ARRAY) {
|
|
|
|
|
ovs_fatal(0, "list_dbs response is not array");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < reply->result->u.array.n; i++) {
|
|
|
|
|
const struct json *name = reply->result->u.array.elems[i];
|
|
|
|
|
|
|
|
|
|
if (name->type != JSON_STRING) {
|
|
|
|
|
ovs_fatal(0, "list_dbs response %zu is not string", i);
|
|
|
|
|
}
|
|
|
|
|
puts(name->u.string);
|
|
|
|
|
}
|
|
|
|
|
jsonrpc_msg_destroy(reply);
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-06 15:35:34 -08:00
|
|
|
|
static void
|
2010-02-11 11:11:23 -08:00
|
|
|
|
do_get_schema(int argc OVS_UNUSED, char *argv[])
|
2009-11-06 15:35:34 -08:00
|
|
|
|
{
|
2010-02-09 10:17:58 -08:00
|
|
|
|
struct ovsdb_schema *schema = fetch_schema(argv[1], argv[2]);
|
2009-11-06 15:35:34 -08:00
|
|
|
|
print_and_free_json(ovsdb_schema_to_json(schema));
|
|
|
|
|
ovsdb_schema_destroy(schema);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-02-11 11:11:23 -08:00
|
|
|
|
do_list_tables(int argc OVS_UNUSED, char *argv[])
|
2009-11-06 15:35:34 -08:00
|
|
|
|
{
|
|
|
|
|
struct ovsdb_schema *schema;
|
|
|
|
|
struct shash_node *node;
|
|
|
|
|
struct table t;
|
|
|
|
|
|
2010-02-09 10:17:58 -08:00
|
|
|
|
schema = fetch_schema(argv[1], argv[2]);
|
2009-11-06 15:35:34 -08:00
|
|
|
|
table_init(&t);
|
|
|
|
|
table_add_column(&t, "Table");
|
|
|
|
|
table_add_column(&t, "Comment");
|
|
|
|
|
SHASH_FOR_EACH (node, &schema->tables) {
|
|
|
|
|
struct ovsdb_table_schema *ts = node->data;
|
|
|
|
|
|
|
|
|
|
table_add_row(&t);
|
|
|
|
|
table_add_cell(&t, ts->name);
|
|
|
|
|
if (ts->comment) {
|
|
|
|
|
table_add_cell(&t, ts->comment);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ovsdb_schema_destroy(schema);
|
|
|
|
|
table_print(&t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-02-11 11:11:23 -08:00
|
|
|
|
do_list_columns(int argc OVS_UNUSED, char *argv[])
|
2009-11-06 15:35:34 -08:00
|
|
|
|
{
|
2010-02-09 10:17:58 -08:00
|
|
|
|
const char *table_name = argv[3];
|
2009-11-06 15:35:34 -08:00
|
|
|
|
struct ovsdb_schema *schema;
|
|
|
|
|
struct shash_node *table_node;
|
|
|
|
|
struct table t;
|
|
|
|
|
|
2010-02-09 10:17:58 -08:00
|
|
|
|
schema = fetch_schema(argv[1], argv[2]);
|
2009-11-06 15:35:34 -08:00
|
|
|
|
table_init(&t);
|
|
|
|
|
if (!table_name) {
|
|
|
|
|
table_add_column(&t, "Table");
|
|
|
|
|
}
|
|
|
|
|
table_add_column(&t, "Column");
|
|
|
|
|
table_add_column(&t, "Type");
|
|
|
|
|
table_add_column(&t, "Comment");
|
|
|
|
|
SHASH_FOR_EACH (table_node, &schema->tables) {
|
|
|
|
|
struct ovsdb_table_schema *ts = table_node->data;
|
|
|
|
|
|
|
|
|
|
if (!table_name || !strcmp(table_name, ts->name)) {
|
|
|
|
|
struct shash_node *column_node;
|
|
|
|
|
|
|
|
|
|
SHASH_FOR_EACH (column_node, &ts->columns) {
|
2010-02-08 14:09:36 -08:00
|
|
|
|
const struct ovsdb_column *column = column_node->data;
|
2009-11-06 15:35:34 -08:00
|
|
|
|
struct json *type = ovsdb_type_to_json(&column->type);
|
|
|
|
|
|
|
|
|
|
table_add_row(&t);
|
|
|
|
|
if (!table_name) {
|
|
|
|
|
table_add_cell(&t, ts->name);
|
|
|
|
|
}
|
|
|
|
|
table_add_cell(&t, column->name);
|
|
|
|
|
table_add_cell_nocopy(&t, json_to_string(type, JSSF_SORT));
|
|
|
|
|
if (column->comment) {
|
|
|
|
|
table_add_cell(&t, column->comment);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
json_destroy(type);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ovsdb_schema_destroy(schema);
|
|
|
|
|
table_print(&t);
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-16 15:12:04 -08:00
|
|
|
|
static void
|
2010-02-11 11:11:23 -08:00
|
|
|
|
do_transact(int argc OVS_UNUSED, char *argv[])
|
2009-11-16 15:12:04 -08:00
|
|
|
|
{
|
|
|
|
|
struct jsonrpc_msg *request, *reply;
|
|
|
|
|
struct json *transaction;
|
|
|
|
|
struct jsonrpc *rpc;
|
|
|
|
|
int error;
|
|
|
|
|
|
|
|
|
|
transaction = parse_json(argv[2]);
|
|
|
|
|
|
|
|
|
|
rpc = open_jsonrpc(argv[1]);
|
2009-12-01 16:32:03 -08:00
|
|
|
|
request = jsonrpc_create_request("transact", transaction, NULL);
|
2009-11-16 15:12:04 -08:00
|
|
|
|
error = jsonrpc_transact_block(rpc, request, &reply);
|
|
|
|
|
if (error) {
|
|
|
|
|
ovs_fatal(error, "transaction failed");
|
|
|
|
|
}
|
|
|
|
|
if (reply->error) {
|
|
|
|
|
ovs_fatal(error, "transaction returned error: %s",
|
2009-12-11 11:14:00 -08:00
|
|
|
|
json_to_string(reply->error, json_flags));
|
2009-11-16 15:12:04 -08:00
|
|
|
|
}
|
|
|
|
|
print_json(reply->result);
|
|
|
|
|
putchar('\n');
|
|
|
|
|
jsonrpc_msg_destroy(reply);
|
|
|
|
|
jsonrpc_close(rpc);
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-16 10:38:14 -08:00
|
|
|
|
static void
|
|
|
|
|
monitor_print_row(struct json *row, const char *type, const char *uuid,
|
|
|
|
|
const struct ovsdb_column_set *columns, struct table *t)
|
|
|
|
|
{
|
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
|
|
if (!row) {
|
|
|
|
|
ovs_error(0, "missing %s row", type);
|
|
|
|
|
return;
|
|
|
|
|
} else if (row->type != JSON_OBJECT) {
|
|
|
|
|
ovs_error(0, "<row> is not object");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
table_add_row(t);
|
|
|
|
|
table_add_cell(t, uuid);
|
|
|
|
|
table_add_cell(t, type);
|
|
|
|
|
for (i = 0; i < columns->n_columns; i++) {
|
|
|
|
|
const struct ovsdb_column *column = columns->columns[i];
|
|
|
|
|
struct json *value = shash_find_data(json_object(row), column->name);
|
|
|
|
|
if (value) {
|
|
|
|
|
table_add_cell_nocopy(t, json_to_string(value, JSSF_SORT));
|
|
|
|
|
} else {
|
|
|
|
|
table_add_cell(t, "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
monitor_print(struct json *table_updates,
|
|
|
|
|
const struct ovsdb_table_schema *table,
|
|
|
|
|
const struct ovsdb_column_set *columns, bool initial)
|
|
|
|
|
{
|
|
|
|
|
struct json *table_update;
|
|
|
|
|
struct shash_node *node;
|
|
|
|
|
struct table t;
|
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
|
|
table_init(&t);
|
|
|
|
|
|
|
|
|
|
if (table_updates->type != JSON_OBJECT) {
|
|
|
|
|
ovs_error(0, "<table-updates> is not object");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
table_update = shash_find_data(json_object(table_updates), table->name);
|
|
|
|
|
if (!table_update) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (table_update->type != JSON_OBJECT) {
|
|
|
|
|
ovs_error(0, "<table-update> is not object");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
table_add_column(&t, "row");
|
|
|
|
|
table_add_column(&t, "action");
|
|
|
|
|
for (i = 0; i < columns->n_columns; i++) {
|
|
|
|
|
table_add_column(&t, "%s", columns->columns[i]->name);
|
|
|
|
|
}
|
|
|
|
|
SHASH_FOR_EACH (node, json_object(table_update)) {
|
|
|
|
|
struct json *row_update = node->data;
|
|
|
|
|
struct json *old, *new;
|
|
|
|
|
|
|
|
|
|
if (row_update->type != JSON_OBJECT) {
|
|
|
|
|
ovs_error(0, "<row-update> is not object");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
old = shash_find_data(json_object(row_update), "old");
|
|
|
|
|
new = shash_find_data(json_object(row_update), "new");
|
|
|
|
|
if (initial) {
|
|
|
|
|
monitor_print_row(new, "initial", node->name, columns, &t);
|
|
|
|
|
} else if (!old) {
|
|
|
|
|
monitor_print_row(new, "insert", node->name, columns, &t);
|
|
|
|
|
} else if (!new) {
|
|
|
|
|
monitor_print_row(old, "delete", node->name, columns, &t);
|
|
|
|
|
} else {
|
|
|
|
|
monitor_print_row(old, "old", node->name, columns, &t);
|
|
|
|
|
monitor_print_row(new, "new", "", columns, &t);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
table_print(&t);
|
|
|
|
|
table_destroy(&t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
do_monitor(int argc, char *argv[])
|
|
|
|
|
{
|
2010-02-09 10:17:58 -08:00
|
|
|
|
const char *server = argv[1];
|
|
|
|
|
const char *database = argv[2];
|
|
|
|
|
const char *table_name = argv[3];
|
2009-11-16 10:38:14 -08:00
|
|
|
|
struct ovsdb_column_set columns = OVSDB_COLUMN_SET_INITIALIZER;
|
|
|
|
|
struct ovsdb_table_schema *table;
|
|
|
|
|
struct ovsdb_schema *schema;
|
|
|
|
|
struct jsonrpc_msg *request;
|
|
|
|
|
struct jsonrpc *rpc;
|
|
|
|
|
struct json *select, *monitor, *monitor_request, *monitor_requests,
|
|
|
|
|
*request_id;
|
|
|
|
|
|
2010-02-09 10:17:58 -08:00
|
|
|
|
rpc = open_jsonrpc(server);
|
2009-11-16 10:38:14 -08:00
|
|
|
|
|
2010-02-09 10:17:58 -08:00
|
|
|
|
schema = fetch_schema_from_rpc(rpc, database);
|
|
|
|
|
table = shash_find_data(&schema->tables, table_name);
|
2009-11-16 10:38:14 -08:00
|
|
|
|
if (!table) {
|
2010-02-09 10:17:58 -08:00
|
|
|
|
ovs_fatal(0, "%s: %s does not have a table named \"%s\"",
|
|
|
|
|
server, database, table_name);
|
2009-11-16 10:38:14 -08:00
|
|
|
|
}
|
|
|
|
|
|
2010-02-09 10:17:58 -08:00
|
|
|
|
if (argc >= 5 && *argv[4] != '\0') {
|
2009-11-16 10:38:14 -08:00
|
|
|
|
char *save_ptr = NULL;
|
|
|
|
|
char *token;
|
|
|
|
|
|
2010-02-09 10:17:58 -08:00
|
|
|
|
for (token = strtok_r(argv[4], ",", &save_ptr); token != NULL;
|
2009-11-16 10:38:14 -08:00
|
|
|
|
token = strtok_r(NULL, ",", &save_ptr)) {
|
|
|
|
|
const struct ovsdb_column *column;
|
|
|
|
|
column = ovsdb_table_schema_get_column(table, token);
|
|
|
|
|
if (!column) {
|
2010-02-09 10:17:58 -08:00
|
|
|
|
ovs_fatal(0, "%s: table \"%s\" in %s does not have a "
|
|
|
|
|
"column named \"%s\"",
|
|
|
|
|
server, table_name, database, token);
|
2009-11-16 10:38:14 -08:00
|
|
|
|
}
|
|
|
|
|
ovsdb_column_set_add(&columns, column);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
struct shash_node *node;
|
|
|
|
|
|
|
|
|
|
SHASH_FOR_EACH (node, &table->columns) {
|
|
|
|
|
const struct ovsdb_column *column = node->data;
|
|
|
|
|
if (column->index != OVSDB_COL_UUID) {
|
|
|
|
|
ovsdb_column_set_add(&columns, column);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-09 10:17:58 -08:00
|
|
|
|
if (argc >= 6 && *argv[5] != '\0') {
|
2009-11-16 10:38:14 -08:00
|
|
|
|
char *save_ptr = NULL;
|
|
|
|
|
char *token;
|
|
|
|
|
|
|
|
|
|
select = json_object_create();
|
2010-02-09 10:17:58 -08:00
|
|
|
|
for (token = strtok_r(argv[5], ",", &save_ptr); token != NULL;
|
2009-11-16 10:38:14 -08:00
|
|
|
|
token = strtok_r(NULL, ",", &save_ptr)) {
|
|
|
|
|
json_object_put(select, token, json_boolean_create(true));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
select = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
monitor_request = json_object_create();
|
|
|
|
|
json_object_put(monitor_request,
|
|
|
|
|
"columns", ovsdb_column_set_to_json(&columns));
|
|
|
|
|
if (select) {
|
|
|
|
|
json_object_put(monitor_request, "select", select);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
monitor_requests = json_object_create();
|
2010-02-09 10:17:58 -08:00
|
|
|
|
json_object_put(monitor_requests, table_name, monitor_request);
|
2009-11-16 10:38:14 -08:00
|
|
|
|
|
2010-02-09 10:17:58 -08:00
|
|
|
|
monitor = json_array_create_3(json_string_create(database),
|
|
|
|
|
json_null_create(), monitor_requests);
|
2009-12-01 16:32:03 -08:00
|
|
|
|
request = jsonrpc_create_request("monitor", monitor, NULL);
|
2009-11-16 10:38:14 -08:00
|
|
|
|
request_id = json_clone(request->id);
|
|
|
|
|
jsonrpc_send(rpc, request);
|
|
|
|
|
for (;;) {
|
|
|
|
|
struct jsonrpc_msg *msg;
|
|
|
|
|
int error;
|
|
|
|
|
|
|
|
|
|
error = jsonrpc_recv_block(rpc, &msg);
|
|
|
|
|
if (error) {
|
2010-02-02 14:09:41 -08:00
|
|
|
|
ovsdb_schema_destroy(schema);
|
2010-02-09 10:17:58 -08:00
|
|
|
|
ovs_fatal(error, "%s: receive failed", server);
|
2009-11-16 10:38:14 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (msg->type == JSONRPC_REQUEST && !strcmp(msg->method, "echo")) {
|
|
|
|
|
jsonrpc_send(rpc, jsonrpc_create_reply(json_clone(msg->params),
|
|
|
|
|
msg->id));
|
|
|
|
|
} else if (msg->type == JSONRPC_REPLY
|
|
|
|
|
&& json_equal(msg->id, request_id)) {
|
|
|
|
|
monitor_print(msg->result, table, &columns, true);
|
2009-12-03 14:25:06 -08:00
|
|
|
|
fflush(stdout);
|
2010-01-13 09:55:52 -08:00
|
|
|
|
if (get_detach()) {
|
|
|
|
|
/* daemonize() closes the standard file descriptors. We output
|
|
|
|
|
* to stdout, so we need to save and restore STDOUT_FILENO. */
|
|
|
|
|
int fd = dup(STDOUT_FILENO);
|
|
|
|
|
daemonize();
|
|
|
|
|
dup2(fd, STDOUT_FILENO);
|
|
|
|
|
close(fd);
|
|
|
|
|
}
|
2009-11-16 10:38:14 -08:00
|
|
|
|
} else if (msg->type == JSONRPC_NOTIFY
|
|
|
|
|
&& !strcmp(msg->method, "update")) {
|
|
|
|
|
struct json *params = msg->params;
|
|
|
|
|
if (params->type == JSON_ARRAY
|
|
|
|
|
&& params->u.array.n == 2
|
|
|
|
|
&& params->u.array.elems[0]->type == JSON_NULL) {
|
|
|
|
|
monitor_print(params->u.array.elems[1],
|
|
|
|
|
table, &columns, false);
|
2009-12-03 14:25:06 -08:00
|
|
|
|
fflush(stdout);
|
2009-11-16 10:38:14 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-02 14:09:41 -08:00
|
|
|
|
jsonrpc_msg_destroy(msg);
|
2009-11-16 10:38:14 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-06 15:35:34 -08:00
|
|
|
|
static void
|
2010-02-11 11:11:23 -08:00
|
|
|
|
do_help(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
|
2009-11-06 15:35:34 -08:00
|
|
|
|
{
|
|
|
|
|
usage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct command all_commands[] = {
|
2010-02-09 10:17:58 -08:00
|
|
|
|
{ "list-dbs", 1, 1, do_list_dbs },
|
|
|
|
|
{ "get-schema", 2, 2, do_get_schema },
|
|
|
|
|
{ "list-tables", 2, 2, do_list_tables },
|
|
|
|
|
{ "list-columns", 2, 3, do_list_columns },
|
2009-11-16 15:12:04 -08:00
|
|
|
|
{ "transact", 2, 2, do_transact },
|
2010-02-09 10:17:58 -08:00
|
|
|
|
{ "monitor", 3, 5, do_monitor },
|
2009-11-06 15:35:34 -08:00
|
|
|
|
{ "help", 0, INT_MAX, do_help },
|
|
|
|
|
{ NULL, 0, 0, NULL },
|
|
|
|
|
};
|