struct ovsdb_idl *idl;
struct hmap txn_rows;
enum ovsdb_idl_txn_status status;
+ bool dry_run;
};
static struct vlog_rate_limit syntax_rl = VLOG_RATE_LIMIT_INIT(1, 5);
txn->idl = idl;
txn->status = TXN_INCOMPLETE;
hmap_init(&txn->txn_rows);
+ txn->dry_run = false;
return txn;
}
+void
+ovsdb_idl_txn_set_dry_run(struct ovsdb_idl_txn *txn)
+{
+ txn->dry_run = true;
+}
+
void
ovsdb_idl_txn_destroy(struct ovsdb_idl_txn *txn)
{
}
}
+ if (txn->dry_run) {
+ struct json *op = json_object_create();
+ json_object_put_string(op, "op", "abort");
+ json_array_add(operations, op);
+ }
+
if (!any_updates) {
txn->status = TXN_SUCCESS;
} else if (!jsonrpc_session_send(
if (error->type == JSON_STRING) {
if (!strcmp(error->u.string, "timed out")) {
soft_errors++;
- } else {
+ } else if (strcmp(error->u.string, "aborted")) {
hard_errors++;
}
} else {
const char *ovsdb_idl_txn_status_to_string(enum ovsdb_idl_txn_status);
struct ovsdb_idl_txn *ovsdb_idl_txn_create(struct ovsdb_idl *);
+void ovsdb_idl_txn_set_dry_run(struct ovsdb_idl_txn *);
void ovsdb_idl_txn_destroy(struct ovsdb_idl_txn *);
void ovsdb_idl_txn_wait(const struct ovsdb_idl_txn *);
enum ovsdb_idl_txn_status ovsdb_idl_txn_commit(struct ovsdb_idl_txn *);
/* --oneline: Write each command's output as a single line? */
static bool oneline;
+/* --dry-run: Do not commit any changes. */
+static bool dry_run;
+
static void vsctl_fatal(const char *, ...) PRINTF_FORMAT(1, 2) NO_RETURN;
static char *default_db(void);
static void usage(void) NO_RETURN;
OPT_DB = UCHAR_MAX + 1,
OPT_ONELINE,
OPT_NO_SYSLOG,
- OPT_NO_WAIT
+ OPT_NO_WAIT,
+ OPT_DRY_RUN
};
static struct option long_options[] = {
{"db", required_argument, 0, OPT_DB},
{"no-syslog", no_argument, 0, OPT_NO_SYSLOG},
{"no-wait", no_argument, 0, OPT_NO_WAIT},
+ {"dry-run", no_argument, 0, OPT_DRY_RUN},
{"oneline", no_argument, 0, OPT_ONELINE},
{"verbose", optional_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
/* XXX not yet implemented */
break;
+ case OPT_DRY_RUN:
+ dry_run = true;
+ break;
+
case 'h':
usage();
int i, start;
txn = ovsdb_idl_txn_create(idl);
+ if (dry_run) {
+ ovsdb_idl_txn_set_dry_run(txn);
+ }
ovs = ovsrec_open_vswitch_first(idl);
if (!ovs) {