summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2017-12-28 08:58:05 -0800
committerBen Pfaff <blp@ovn.org>2018-02-06 11:18:13 -0800
commitc55d0b7b74a772b6696d2efeeb5ecaae637822a0 (patch)
treea58a44ad684cd214e5de50d27483f8cb74d97d2c
parentf15a2320cc0f51876e7d144d8cb2688141e6e44e (diff)
downloadopenvswitch-c55d0b7b74a772b6696d2efeeb5ecaae637822a0.tar.gz
ovsdb-client: Add --timeout option.
Signed-off-by: Ben Pfaff <blp@ovn.org> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com> Acked-by: Justin Pettit <jpettit@ovn.org>
-rw-r--r--NEWS1
-rw-r--r--ovsdb/ovsdb-client.1.in6
-rw-r--r--ovsdb/ovsdb-client.c12
-rw-r--r--tests/ovs-macros.at4
4 files changed, 23 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 8c360ba6c..c269ea4a9 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,7 @@ v2.9.0 - xx xxx xxxx
* Protocol documentation moved from ovsdb-server(1) to ovsdb-server(7).
* ovsdb-client: New "get-schema-cksum" and "query" commands.
* ovsdb-client: New "backup" and "restore" commands.
+ * ovsdb-client: New --timeout option.
* ovsdb-tool: New "db-name" and "schema-name" commands.
- ovs-vsctl and other commands that display data in tables now support a
--max-column-width option to limit column width.
diff --git a/ovsdb/ovsdb-client.1.in b/ovsdb/ovsdb-client.1.in
index 5dbd49f25..d50c941ff 100644
--- a/ovsdb/ovsdb-client.1.in
+++ b/ovsdb/ovsdb-client.1.in
@@ -274,6 +274,12 @@ table update. Most output formats add the timestamp on a line of its own
just above the table. The JSON output format puts the timestamp in a
member of the top-level JSON object named \fBtime\fR.
.
+.IP "\fB\-t\fR"
+.IQ "\fB\-\-timeout=\fIsecs\fR"
+Limits \fBovsdb\-client\fR runtime to approximately \fIsecs\fR
+seconds. If the timeout expires, \fBovsdb\-client\fR will exit with a
+\fBSIGALRM\fR signal.
+.
.SS "Daemon Options"
The daemon options apply only to the \fBmonitor\fR and \fBmonitor\-cond\fR commands.
With any other command, they have no effect.
diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c
index faa6bdb4d..222bd6ca8 100644
--- a/ovsdb/ovsdb-client.c
+++ b/ovsdb/ovsdb-client.c
@@ -199,6 +199,7 @@ parse_options(int argc, char *argv[])
{"version", no_argument, NULL, 'V'},
{"timestamp", no_argument, NULL, OPT_TIMESTAMP},
{"force", no_argument, NULL, OPT_FORCE},
+ {"timeout", required_argument, NULL, 't'},
VLOG_LONG_OPTIONS,
DAEMON_LONG_OPTIONS,
#ifdef HAVE_OPENSSL
@@ -213,6 +214,7 @@ parse_options(int argc, char *argv[])
table_style.format = TF_TABLE;
for (;;) {
+ unsigned long int timeout;
int c;
c = getopt_long(argc, argv, short_options, long_options, NULL);
@@ -245,6 +247,16 @@ parse_options(int argc, char *argv[])
force = true;
break;
+ case 't':
+ timeout = strtoul(optarg, NULL, 10);
+ if (timeout <= 0) {
+ ovs_fatal(0, "value %s on -t or --timeout is not at least 1",
+ optarg);
+ } else {
+ time_alarm(timeout);
+ }
+ break;
+
case '?':
exit(EXIT_FAILURE);
diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at
index 695f405ca..3c6ba03c6 100644
--- a/tests/ovs-macros.at
+++ b/tests/ovs-macros.at
@@ -122,6 +122,7 @@ if [ $? -eq 0 ]; then
alias ovn-sbctl='OVS_SBCTL_TIMEOUT'
alias ovn-nbctl='OVN_NBCTL_TIMEOUT'
alias vtep-ctl='VTEP_CTL_TIMEOUT'
+ alias ovsdb-client='OVSDB_CLIENT_TIMEOUT'
OVS_OFCTL_TIMEOUT () {
command ovs-ofctl --timeout=$OVS_TIMEOUT "$@"
}
@@ -137,6 +138,9 @@ if [ $? -eq 0 ]; then
VTEP_CTL_TIMEOUT () {
command vtep-ctl --timeout=$OVS_TIMEOUT "$@"
}
+ OVSDB_CLIENT_TIMEOUT () {
+ command ovsdb-client --timeout=$OVS_TIMEOUT "$@"
+ }
fi
# parent_pid PID