]> git.proxmox.com Git - ovs.git/commitdiff
ovsdb-client: Add --timeout option.
authorBen Pfaff <blp@ovn.org>
Thu, 28 Dec 2017 16:58:05 +0000 (08:58 -0800)
committerBen Pfaff <blp@ovn.org>
Mon, 30 Apr 2018 23:56:05 +0000 (16:56 -0700)
Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Acked-by: Justin Pettit <jpettit@ovn.org>
NEWS
ovsdb/ovsdb-client.1.in
ovsdb/ovsdb-client.c
tests/ovs-macros.at

diff --git a/NEWS b/NEWS
index 5ea4f2f879447ca4a2452413203d29408578bb66..0b753ad6ed1027993a7c7b1afd30abe7f1d11a59 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ v2.9.0 - 19 Feb 2018
      * 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.
index 5dbd49f25263382addd29e9e20e57389e3dcf00b..d50c941ff498e7e19bfc2379faddd051ea2eacd2 100644 (file)
@@ -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.
index faa6bdb4da0b75221f072cc0e15eb6bacaeeace6..222bd6ca88ab0f28f283bd2eeae58cbed9dc8bc2 100644 (file)
@@ -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);
 
index 695f405ca1b77e85a668229704c5fbefdb64f4e4..3c6ba03c60c884ea7a66c23f24bd9b0c22ebd4c3 100644 (file)
@@ -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