struct ovsdb_idl_txn *txn;
struct ovsdb_symbol_table *symtab;
const struct ovsrec_open_vswitch *ovs;
+ bool verified_ports;
/* A command may set this member to true if some prerequisite is not met
* and the caller should wait for something to change and then retry. */
return s;
}
+static void
+verify_ports(struct vsctl_context *ctx)
+{
+ if (!ctx->verified_ports) {
+ const struct ovsrec_bridge *bridge;
+ const struct ovsrec_port *port;
+
+ ovsrec_open_vswitch_verify_bridges(ctx->ovs);
+ OVSREC_BRIDGE_FOR_EACH (bridge, ctx->idl) {
+ ovsrec_bridge_verify_ports(bridge);
+ }
+ OVSREC_PORT_FOR_EACH (port, ctx->idl) {
+ ovsrec_port_verify_interfaces(port);
+ }
+
+ ctx->verified_ports = true;
+ }
+}
+
static struct vsctl_bridge *
add_bridge(struct vsctl_info *b,
struct ovsrec_bridge *br_cfg, const char *name,
struct vsctl_iface *iface;
struct vsctl_port *port;
+ verify_ports(info->ctx);
+
if (shash_find(&info->bridges, name)) {
vsctl_fatal("%s because a bridge named %s already exists",
msg, name);
if (must_exist && !br) {
vsctl_fatal("no bridge named %s", name);
}
+ ovsrec_open_vswitch_verify_bridges(info->ctx->ovs);
return br;
}
if (must_exist && !port) {
vsctl_fatal("no port named %s", name);
}
+ verify_ports(info->ctx);
return port;
}
if (must_exist && !iface) {
vsctl_fatal("no interface named %s", name);
}
+ verify_ports(info->ctx);
return iface;
}
bridge->br_cfg->n_external_ids,
ctx->argv[2], ctx->argc >= 4 ? ctx->argv[3] : NULL,
&keys, &values, &n);
+ ovsrec_bridge_verify_external_ids(bridge->br_cfg);
ovsrec_bridge_set_external_ids(bridge->br_cfg, keys, values, n);
} else {
char *key = xasprintf("fake-bridge-%s", ctx->argv[2]);
port->port_cfg->n_external_ids,
key, ctx->argc >= 4 ? ctx->argv[3] : NULL,
&keys, &values, &n);
+ ovsrec_port_verify_external_ids(port->port_cfg);
ovsrec_port_set_external_ids(port->port_cfg, keys, values, n);
free(key);
}
get_info(ctx, &info);
bridge = find_bridge(&info, ctx->argv[1], true);
if (bridge->br_cfg) {
+ ovsrec_bridge_verify_external_ids(bridge->br_cfg);
get_external_id(bridge->br_cfg->key_external_ids,
bridge->br_cfg->value_external_ids,
bridge->br_cfg->n_external_ids,
&ctx->output);
} else {
struct vsctl_port *port = shash_find_data(&info.ports, ctx->argv[1]);
+ ovsrec_port_verify_external_ids(port->port_cfg);
get_external_id(port->port_cfg->key_external_ids,
port->port_cfg->value_external_ids,
port->port_cfg->n_external_ids,
get_info(ctx, &info);
br = find_bridge(&info, ctx->argv[1], true);
+ ovsrec_bridge_verify_ports(br->br_cfg ? br->br_cfg : br->parent->br_cfg);
svec_init(&ports);
SHASH_FOR_EACH (node, &info.ports) {
get_info(ctx, &info);
br = find_bridge(&info, ctx->argv[1], true);
+ verify_ports(ctx);
svec_init(&ifaces);
SHASH_FOR_EACH (node, &info.ifaces) {
free_info(&info);
}
+static void
+verify_controllers(struct ovsrec_bridge *bridge)
+{
+ if (bridge) {
+ size_t i;
+
+ ovsrec_bridge_verify_controller(bridge);
+ for (i = 0; i < bridge->n_controller; i++) {
+ ovsrec_controller_verify_target(bridge->controller[i]);
+ }
+ }
+}
+
static void
cmd_get_controller(struct vsctl_context *ctx)
{
get_info(ctx, &info);
br = find_bridge(&info, ctx->argv[1], true);
+ verify_controllers(br->br_cfg);
/* Print the targets in sorted order for reproducibility. */
svec_init(&targets);
get_info(ctx, &info);
br = find_real_bridge(&info, ctx->argv[1], true);
+ verify_controllers(br->br_cfg);
if (br->ctrl) {
delete_controllers(br->ctrl, br->n_ctrl);
get_info(ctx, &info);
br = find_real_bridge(&info, ctx->argv[1], true);
+ verify_controllers(br->br_cfg);
delete_controllers(br->ctrl, br->n_ctrl);
get_info(ctx, &info);
br = find_bridge(&info, ctx->argv[1], true);
+ if (br->br_cfg) {
+ ovsrec_bridge_verify_fail_mode(br->br_cfg);
+ }
if (br->fail_mode && strlen(br->fail_mode)) {
ds_put_format(&ctx->output, "%s\n", br->fail_mode);
}
{
struct ovsrec_ssl *ssl = ctx->ovs->ssl;
+ ovsrec_open_vswitch_verify_ssl(ctx->ovs);
if (ssl) {
+ ovsrec_ssl_verify_private_key(ssl);
+ ovsrec_ssl_verify_certificate(ssl);
+ ovsrec_ssl_verify_ca_cert(ssl);
+ ovsrec_ssl_verify_bootstrap_ca_cert(ssl);
+
ds_put_format(&ctx->output, "Private key: %s\n", ssl->private_key);
ds_put_format(&ctx->output, "Certificate: %s\n", ssl->certificate);
ds_put_format(&ctx->output, "CA Certificate: %s\n", ssl->ca_cert);
struct ovsrec_ssl *ssl = ctx->ovs->ssl;
if (ssl) {
+ ovsrec_open_vswitch_verify_ssl(ctx->ovs);
ovsrec_ssl_delete(ssl);
ovsrec_open_vswitch_set_ssl(ctx->ovs, NULL);
}
bool bootstrap = shash_find(&ctx->options, "--bootstrap");
struct ovsrec_ssl *ssl = ctx->ovs->ssl;
+ ovsrec_open_vswitch_verify_ssl(ctx->ovs);
if (ssl) {
ovsrec_ssl_delete(ssl);
}
if (id->uuid_column) {
const struct ovsdb_datum *uuid;
+ ovsdb_idl_txn_verify(referrer, id->uuid_column);
uuid = ovsdb_idl_get(referrer, id->uuid_column,
OVSDB_TYPE_UUID, OVSDB_TYPE_VOID);
if (uuid->n == 1) {
&column, &key_string,
NULL, NULL, 0, NULL));
+ ovsdb_idl_txn_verify(row, column);
datum = ovsdb_idl_read(row, column);
if (key_string) {
union ovsdb_atom key;
type->value.type == OVSDB_TYPE_VOID ? "values" : "pairs",
column->name, table->class->name, type->n_max);
}
+ ovsdb_idl_txn_verify(row, column);
ovsdb_idl_txn_write(row, column, &old);
}
type->value.type == OVSDB_TYPE_VOID ? "values" : "pairs",
column->name, table->class->name, type->n_min);
}
+ ovsdb_idl_txn_verify(row, column);
ovsdb_idl_txn_write(row, column, &old);
}
ctx->txn = txn;
ctx->ovs = ovs;
ctx->symtab = symtab;
+ ctx->verified_ports = false;
ctx->try_again = false;
}