git://git.onelab.eu
/
sliver-openvswitch.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'mainstream'
[sliver-openvswitch.git]
/
ovsdb
/
ovsdb-client.c
diff --git
a/ovsdb/ovsdb-client.c
b/ovsdb/ovsdb-client.c
index
a94d7cb
..
67d09cb
100644
(file)
--- a/
ovsdb/ovsdb-client.c
+++ b/
ovsdb/ovsdb-client.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012
, 2013
Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-16,7
+16,6
@@
#include <config.h>
#include <config.h>
-#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <getopt.h>
#include <ctype.h>
#include <errno.h>
#include <getopt.h>
@@
-39,7
+38,7
@@
#include "ovsdb-data.h"
#include "ovsdb-error.h"
#include "sort.h"
#include "ovsdb-data.h"
#include "ovsdb-error.h"
#include "sort.h"
-#include "s
set
.h"
+#include "s
vec
.h"
#include "stream.h"
#include "stream-ssl.h"
#include "table.h"
#include "stream.h"
#include "stream-ssl.h"
#include "table.h"
@@
-70,12
+69,12
@@
static bool timestamp;
/* Format for table output. */
static struct table_style table_style = TABLE_STYLE_DEFAULT;
/* Format for table output. */
static struct table_style table_style = TABLE_STYLE_DEFAULT;
-static const struct ovsdb_client_command
all_commands[]
;
+static const struct ovsdb_client_command
*get_all_commands(void)
;
static void usage(void) NO_RETURN;
static void parse_options(int argc, char *argv[]);
static struct jsonrpc *open_jsonrpc(const char *server);
static void usage(void) NO_RETURN;
static void parse_options(int argc, char *argv[]);
static struct jsonrpc *open_jsonrpc(const char *server);
-static void fetch_dbs(struct jsonrpc *, struct s
set
*dbs);
+static void fetch_dbs(struct jsonrpc *, struct s
vec
*dbs);
int
main(int argc, char *argv[])
int
main(int argc, char *argv[])
@@
-93,7
+92,7
@@
main(int argc, char *argv[])
ovs_fatal(0, "missing command name; use --help for help");
}
ovs_fatal(0, "missing command name; use --help for help");
}
- for (command =
all_commands
; ; command++) {
+ for (command =
get_all_commands()
; ; command++) {
if (!command->name) {
VLOG_FATAL("unknown command '%s'; use --help for help",
argv[optind]);
if (!command->name) {
VLOG_FATAL("unknown command '%s'; use --help for help",
argv[optind]);
@@
-118,22
+117,22
@@
main(int argc, char *argv[])
}
if (command->need == NEED_DATABASE) {
}
if (command->need == NEED_DATABASE) {
- struct s
set
dbs;
+ struct s
vec
dbs;
- s
set
_init(&dbs);
+ s
vec
_init(&dbs);
fetch_dbs(rpc, &dbs);
if (argc - optind > command->min_args
fetch_dbs(rpc, &dbs);
if (argc - optind > command->min_args
- && s
set
_contains(&dbs, argv[optind])) {
+ && s
vec
_contains(&dbs, argv[optind])) {
database = argv[optind++];
database = argv[optind++];
- } else if (
sset_count(&dbs)
== 1) {
- database = xstrdup(
SSET_FIRST(&dbs)
);
- } else if (s
set
_contains(&dbs, "Open_vSwitch")) {
+ } else if (
dbs.n
== 1) {
+ database = xstrdup(
dbs.names[0]
);
+ } else if (s
vec
_contains(&dbs, "Open_vSwitch")) {
database = "Open_vSwitch";
} else {
ovs_fatal(0, "no default database for `%s' command, please "
"specify a database name", command->name);
}
database = "Open_vSwitch";
} else {
ovs_fatal(0, "no default database for `%s' command, please "
"specify a database name", command->name);
}
- s
set
_destroy(&dbs);
+ s
vec
_destroy(&dbs);
} else {
database = NULL;
}
} else {
database = NULL;
}
@@
-167,7
+166,7
@@
parse_options(int argc, char *argv[])
DAEMON_OPTION_ENUMS,
TABLE_OPTION_ENUMS
};
DAEMON_OPTION_ENUMS,
TABLE_OPTION_ENUMS
};
- static struct option long_options[] = {
+ static
const
struct option long_options[] = {
{"verbose", optional_argument, NULL, 'v'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},
{"verbose", optional_argument, NULL, 'v'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},
@@
-371,7
+370,7
@@
fetch_schema(struct jsonrpc *rpc, const char *database)
}
static void
}
static void
-fetch_dbs(struct jsonrpc *rpc, struct s
set
*dbs)
+fetch_dbs(struct jsonrpc *rpc, struct s
vec
*dbs)
{
struct jsonrpc_msg *request, *reply;
size_t i;
{
struct jsonrpc_msg *request, *reply;
size_t i;
@@
-390,9
+389,10
@@
fetch_dbs(struct jsonrpc *rpc, struct sset *dbs)
if (name->type != JSON_STRING) {
ovs_fatal(0, "list_dbs response %zu is not string", i);
}
if (name->type != JSON_STRING) {
ovs_fatal(0, "list_dbs response %zu is not string", i);
}
- s
set
_add(dbs, name->u.string);
+ s
vec
_add(dbs, name->u.string);
}
jsonrpc_msg_destroy(reply);
}
jsonrpc_msg_destroy(reply);
+ svec_sort(dbs);
}
\f
static void
}
\f
static void
@@
-400,14
+400,15
@@
do_list_dbs(struct jsonrpc *rpc, const char *database OVS_UNUSED,
int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
const char *db_name;
int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
const char *db_name;
- struct sset dbs;
+ struct svec dbs;
+ size_t i;
- s
set
_init(&dbs);
+ s
vec
_init(&dbs);
fetch_dbs(rpc, &dbs);
fetch_dbs(rpc, &dbs);
- S
SET_FOR_EACH (
db_name, &dbs) {
+ S
VEC_FOR_EACH (i,
db_name, &dbs) {
puts(db_name);
}
puts(db_name);
}
- s
set
_destroy(&dbs);
+ s
vec
_destroy(&dbs);
}
static void
}
static void
@@
-996,3
+997,8
@@
static const struct ovsdb_client_command all_commands[] = {
{ NULL, 0, 0, 0, NULL },
};
{ NULL, 0, 0, 0, NULL },
};
+
+static const struct ovsdb_client_command *get_all_commands(void)
+{
+ return all_commands;
+}