ovn-nbctl: Add OVSDB transaction comment.
authorJustin Pettit <jpettit@nicira.com>
Thu, 9 Apr 2015 07:01:44 +0000 (00:01 -0700)
committerJustin Pettit <jpettit@nicira.com>
Thu, 9 Apr 2015 19:31:55 +0000 (12:31 -0700)
Add a comment to the transaction that contains the command that was
executed to aid looking at the transaction log.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
ovn/ovn-nbctl.c

index 3178105..3ffe699 100644 (file)
@@ -23,6 +23,7 @@
 #include "fatal-signal.h"
 #include "ovn/ovn-nb-idl.h"
 #include "poll-loop.h"
+#include "process.h"
 #include "stream.h"
 #include "stream-ssl.h"
 #include "util.h"
@@ -607,6 +608,7 @@ main(int argc, char *argv[])
     enum ovsdb_idl_txn_status txn_status;
     unsigned int seqno;
     int res = 0;
+    char *args;
 
     fatal_ignore_sigpipe();
     set_program_name(argv[0]);
@@ -615,6 +617,8 @@ main(int argc, char *argv[])
     parse_options(argc, argv);
     nbrec_init();
 
+    args = process_escape_args(argv);
+
     nb_ctx.idl = ovsdb_idl_create(db, &nbrec_idl_class, true, false);
     ctx.pvt = &nb_ctx;
     ctx.argc = argc - optind;
@@ -634,6 +638,7 @@ main(int argc, char *argv[])
 
         if (seqno != ovsdb_idl_get_seqno(nb_ctx.idl)) {
             nb_ctx.txn = ovsdb_idl_txn_create(nb_ctx.idl);
+            ovsdb_idl_txn_add_comment(nb_ctx.txn, "ovn-nbctl: %s", args);
             ovs_cmdl_run_command(&ctx, get_all_commands());
             txn_status = ovsdb_idl_txn_commit_block(nb_ctx.txn);
             if (txn_status == TXN_TRY_AGAIN) {
@@ -655,6 +660,7 @@ main(int argc, char *argv[])
         ovsdb_idl_txn_destroy(nb_ctx.txn);
     }
     ovsdb_idl_destroy(nb_ctx.idl);
+    free(args);
 
     exit(res);
 }