};
static const struct vsctl_column bridge_columns[] = {
+ {&ovsrec_bridge_col_controller, VSCF_READONLY, NULL},
{&ovsrec_bridge_col_datapath_id, VSCF_READONLY, NULL},
{&ovsrec_bridge_col_datapath_type, VSCF_READONLY, NULL},
- {&ovsrec_bridge_col_name, VSCF_READONLY, NULL},
- {&ovsrec_bridge_col_mirrors, VSCF_READONLY, NULL},
- {&ovsrec_bridge_col_other_config, 0, NULL},
+ {&ovsrec_bridge_col_external_ids, 0, NULL},
{&ovsrec_bridge_col_flood_vlans, 0, "[1,4095]"},
- {&ovsrec_bridge_col_controller, VSCF_READONLY, NULL},
+ {&ovsrec_bridge_col_mirrors, VSCF_READONLY, NULL},
+ {&ovsrec_bridge_col_name, VSCF_READONLY, NULL},
{&ovsrec_bridge_col_netflow, VSCF_READONLY, NULL},
- {&ovsrec_bridge_col_external_ids, 0, NULL},
+ {&ovsrec_bridge_col_other_config, 0, NULL},
{&ovsrec_bridge_col_ports, VSCF_READONLY, NULL},
{NULL, 0, NULL},
};
static const struct vsctl_column netflow_columns[] = {
{&ovsrec_netflow_col_active_timeout, 0, "[-1,]"},
{&ovsrec_netflow_col_add_id_to_interface, 0, NULL},
- {&ovsrec_netflow_col_targets, 0, IP_RE":"PORT_RE},
- {&ovsrec_netflow_col_engine_type, 0, "[0,255]"},
{&ovsrec_netflow_col_engine_id, 0, "[0,255]"},
+ {&ovsrec_netflow_col_engine_type, 0, "[0,255]"},
+ {&ovsrec_netflow_col_targets, 0, IP_RE":"PORT_RE},
{NULL, 0, NULL},
};
{&ovsrec_open_vswitch_col_bridges, VSCF_READONLY, NULL},
{&ovsrec_open_vswitch_col_controller, VSCF_READONLY, NULL},
{&ovsrec_open_vswitch_col_cur_cfg, VSCF_HIDDEN, NULL},
- {&ovsrec_open_vswitch_col_management_id, 0, "[0-9a-fA-F]{12}"},
{&ovsrec_open_vswitch_col_managers, 0, "p?(ssl|tcp|unix):.*"},
{&ovsrec_open_vswitch_col_next_cfg, VSCF_HIDDEN, NULL},
{&ovsrec_open_vswitch_col_ssl, VSCF_READONLY, NULL},
};
static const struct vsctl_column port_columns[] = {
- {&ovsrec_port_col_bond_updelay, 0, "[0,]"},
{&ovsrec_port_col_bond_downdelay, 0, "[0,]"},
{&ovsrec_port_col_bond_fake_iface, VSCF_READONLY, NULL},
+ {&ovsrec_port_col_bond_updelay, 0, "[0,]"},
{&ovsrec_port_col_external_ids, 0, NULL},
{&ovsrec_port_col_fake_bridge, VSCF_READONLY, NULL},
{&ovsrec_port_col_interfaces, VSCF_READONLY, NULL},
}
ovsdb_datum_destroy(&name, &id->name_column->type);
}
+ if (best_score && !referrer) {
+ ovs_fatal(0, "multiple rows in %s match \"%s\"",
+ table->class->name, record_id);
+ }
}
if (!referrer) {
return NULL;
*valuep = NULL;
}
if (*p != '\0') {
- error = xasprintf("%s: trailing garbage in argument at offset %td",
- arg, p - arg);
+ error = xasprintf("%s: trailing garbage \"%s\" in argument",
+ arg, p);
goto error;
}
}
static void
cmd_get(struct vsctl_context *ctx)
{
+ bool if_exists = shash_find(&ctx->options, "--if-exists");
const char *table_name = ctx->argv[1];
const char *record_id = ctx->argv[2];
const struct vsctl_table_class *table;
idx = ovsdb_datum_find_key(&datum, &key,
column->idl->type.key_type);
if (idx == UINT_MAX) {
- ovs_fatal(0, "no key %s in %s record \"%s\" column %s",
- key_string, table_name, record_id,
- column->idl->name);
-
+ if (!if_exists) {
+ ovs_fatal(0, "no key \"%s\" in %s record \"%s\" column %s",
+ key_string, table->class->name, record_id,
+ column->idl->name);
+ }
+ } else {
+ ovsdb_atom_to_string(&datum.values[idx],
+ column->idl->type.value_type, out);
}
- ovsdb_atom_to_string(&datum.values[idx],
- column->idl->type.value_type, out);
-
ovsdb_atom_destroy(&key, column->idl->type.key_type);
} else {
ovsdb_datum_to_string(&datum, &column->idl->type, out);
table = get_table(table_name);
row = must_get_row(ctx, table, record_id);
die_if_error(get_column(table, column_name, &column));
+ if (column->flags & VSCF_READONLY && !force) {
+ ovs_fatal(0, "cannot modify read-only column %s in table %s",
+ column->idl->name, table->class->name);
+ }
+
type = &column->idl->type;
ovsdb_idl_txn_read(row, column->idl, &old);
for (i = 4; i < ctx->argc; i++) {
struct ovsdb_type add_type;
struct ovsdb_datum add;
- if (column->flags & VSCF_READONLY && !force) {
- ovs_fatal(0, "%s: cannot modify read-only column %s in table %s",
- ctx->argv[i], column->idl->name, table_name);
- }
-
add_type = *type;
add_type.n_min = 1;
add_type.n_max = UINT_MAX;
}
if (old.n > type->n_max) {
ovs_fatal(0, "\"add\" operation would put %u %s in column %s of "
- "table %s but at most %u are allowed",
+ "table %s but the maximum number is %u",
old.n,
type->value_type == OVSDB_TYPE_VOID ? "values" : "pairs",
- column->idl->name, table_name, type->n_max);
+ column->idl->name, table->class->name, type->n_max);
}
ovsdb_idl_txn_write(row, column->idl, &old);
}
table = get_table(table_name);
row = must_get_row(ctx, table, record_id);
die_if_error(get_column(table, column_name, &column));
+ if (column->flags & VSCF_READONLY && !force) {
+ ovs_fatal(0, "cannot modify read-only column %s in table %s",
+ column->idl->name, table->class->name);
+ }
+
type = &column->idl->type;
ovsdb_idl_txn_read(row, column->idl, &old);
for (i = 4; i < ctx->argc; i++) {
struct ovsdb_datum rm;
char *error;
- if (column->flags & VSCF_READONLY && !force) {
- ovs_fatal(0, "%s: cannot modify read-only column %s in table %s",
- ctx->argv[i], column->idl->name, table_name);
- }
-
rm_type = *type;
rm_type.n_min = 1;
rm_type.n_max = UINT_MAX;
}
if (old.n < type->n_min) {
ovs_fatal(0, "\"remove\" operation would put %u %s in column %s of "
- "table %s but at least %u are required",
+ "table %s but the minimun number is %u",
old.n,
type->value_type == OVSDB_TYPE_VOID ? "values" : "pairs",
- column->idl->name, table_name, type->n_min);
+ column->idl->name, table->class->name, type->n_min);
}
ovsdb_idl_txn_write(row, column->idl, &old);
}
type = &column->idl->type;
if (column->flags & VSCF_READONLY && !force) {
- ovs_fatal(0, "%s: cannot modify read-only column %s in table %s",
- ctx->argv[i], column->idl->name, table_name);
+ ovs_fatal(0, "cannot modify read-only column %s in table %s",
+ column->idl->name, table->class->name);
} else if (type->n_min > 0) {
ovs_fatal(0, "\"clear\" operation cannot be applied to column %s "
"of table %s, which is not allowed to be empty",
- column->idl->name, table_name);
+ column->idl->name, table->class->name);
}
ovsdb_datum_init_empty(&datum);
{"set-ssl", 3, 3, cmd_set_ssl, NULL, "--bootstrap"},
/* Parameter commands. */
- {"get", 3, INT_MAX, cmd_get, NULL, ""},
+ {"get", 3, INT_MAX, cmd_get, NULL, "--if-exists"},
{"list", 1, INT_MAX, cmd_list, NULL, ""},
{"set", 3, INT_MAX, cmd_set, NULL, "--force"},
{"add", 4, INT_MAX, cmd_add, NULL, "--force"},