+ show->recurse = true;
+ for (i = 0; i < ARRAY_SIZE(show->columns); i++) {
+ const struct ovsdb_idl_column *column = show->columns[i];
+ const struct ovsdb_datum *datum;
+
+ if (!column) {
+ break;
+ }
+
+ datum = ovsdb_idl_read(row, column);
+ if (column->type.key.type == OVSDB_TYPE_UUID &&
+ column->type.key.u.uuid.refTableName) {
+ struct cmd_show_table *ref_show;
+ size_t j;
+
+ ref_show = cmd_show_find_table_by_name(
+ column->type.key.u.uuid.refTableName);
+ if (ref_show) {
+ for (j = 0; j < datum->n; j++) {
+ const struct ovsdb_idl_row *ref_row;
+
+ ref_row = ovsdb_idl_get_row_for_uuid(ctx->idl,
+ ref_show->table,
+ &datum->keys[j].uuid);
+ if (ref_row) {
+ cmd_show_row(ctx, ref_row, level + 1);
+ }
+ }
+ continue;
+ }
+ }
+
+ if (!ovsdb_datum_is_default(datum, &column->type)) {
+ ds_put_char_multiple(&ctx->output, ' ', (level + 1) * 4);
+ ds_put_format(&ctx->output, "%s: ", column->name);
+ ovsdb_datum_to_string(datum, &column->type, &ctx->output);
+ ds_put_char(&ctx->output, '\n');
+ }
+ }
+ show->recurse = false;
+}
+
+static void
+cmd_show(struct vsctl_context *ctx)
+{
+ const struct ovsdb_idl_row *row;
+
+ for (row = ovsdb_idl_first_row(ctx->idl, cmd_show_tables[0].table);
+ row; row = ovsdb_idl_next_row(row)) {
+ cmd_show_row(ctx, row, 0);
+ }
+}
+
+static void
+pre_cmd_emer_reset(struct vsctl_context *ctx)
+{
+ ovsdb_idl_add_column(ctx->idl, &ovsrec_open_vswitch_col_manager_options);
+ ovsdb_idl_add_column(ctx->idl, &ovsrec_open_vswitch_col_ssl);
+
+ ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_controller);
+ ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_fail_mode);
+ ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_mirrors);
+ ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_netflow);
+ ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_sflow);
+ ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_ipfix);
+ ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_flood_vlans);
+ ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_other_config);
+
+ ovsdb_idl_add_column(ctx->idl, &ovsrec_port_col_other_config);
+
+ ovsdb_idl_add_column(ctx->idl,
+ &ovsrec_interface_col_ingress_policing_rate);
+ ovsdb_idl_add_column(ctx->idl,
+ &ovsrec_interface_col_ingress_policing_burst);
+}
+
+static void
+cmd_emer_reset(struct vsctl_context *ctx)
+{
+ const struct ovsdb_idl *idl = ctx->idl;
+ const struct ovsrec_bridge *br;
+ const struct ovsrec_port *port;
+ const struct ovsrec_interface *iface;
+ const struct ovsrec_mirror *mirror, *next_mirror;
+ const struct ovsrec_controller *ctrl, *next_ctrl;
+ const struct ovsrec_manager *mgr, *next_mgr;
+ const struct ovsrec_netflow *nf, *next_nf;
+ const struct ovsrec_ssl *ssl, *next_ssl;
+ const struct ovsrec_sflow *sflow, *next_sflow;
+ const struct ovsrec_ipfix *ipfix, *next_ipfix;
+ const struct ovsrec_flow_sample_collector_set *fscset, *next_fscset;
+
+ /* Reset the Open_vSwitch table. */
+ ovsrec_open_vswitch_set_manager_options(ctx->ovs, NULL, 0);
+ ovsrec_open_vswitch_set_ssl(ctx->ovs, NULL);
+
+ OVSREC_BRIDGE_FOR_EACH (br, idl) {
+ const char *hwaddr;
+
+ ovsrec_bridge_set_controller(br, NULL, 0);
+ ovsrec_bridge_set_fail_mode(br, NULL);
+ ovsrec_bridge_set_mirrors(br, NULL, 0);
+ ovsrec_bridge_set_netflow(br, NULL);
+ ovsrec_bridge_set_sflow(br, NULL);
+ ovsrec_bridge_set_ipfix(br, NULL);
+ ovsrec_bridge_set_flood_vlans(br, NULL, 0);
+
+ /* We only want to save the "hwaddr" key from other_config. */
+ hwaddr = smap_get(&br->other_config, "hwaddr");
+ if (hwaddr) {
+ struct smap smap = SMAP_INITIALIZER(&smap);
+ smap_add(&smap, "hwaddr", hwaddr);
+ ovsrec_bridge_set_other_config(br, &smap);
+ smap_destroy(&smap);
+ } else {
+ ovsrec_bridge_set_other_config(br, NULL);
+ }
+ }
+
+ OVSREC_PORT_FOR_EACH (port, idl) {
+ ovsrec_port_set_other_config(port, NULL);
+ }
+
+ OVSREC_INTERFACE_FOR_EACH (iface, idl) {
+ /* xxx What do we do about gre/patch devices created by mgr? */
+
+ ovsrec_interface_set_ingress_policing_rate(iface, 0);
+ ovsrec_interface_set_ingress_policing_burst(iface, 0);
+ }
+
+ OVSREC_MIRROR_FOR_EACH_SAFE (mirror, next_mirror, idl) {
+ ovsrec_mirror_delete(mirror);
+ }
+
+ OVSREC_CONTROLLER_FOR_EACH_SAFE (ctrl, next_ctrl, idl) {
+ ovsrec_controller_delete(ctrl);
+ }
+
+ OVSREC_MANAGER_FOR_EACH_SAFE (mgr, next_mgr, idl) {
+ ovsrec_manager_delete(mgr);
+ }
+
+ OVSREC_NETFLOW_FOR_EACH_SAFE (nf, next_nf, idl) {
+ ovsrec_netflow_delete(nf);
+ }
+
+ OVSREC_SSL_FOR_EACH_SAFE (ssl, next_ssl, idl) {
+ ovsrec_ssl_delete(ssl);
+ }
+
+ OVSREC_SFLOW_FOR_EACH_SAFE (sflow, next_sflow, idl) {
+ ovsrec_sflow_delete(sflow);
+ }
+
+ OVSREC_IPFIX_FOR_EACH_SAFE (ipfix, next_ipfix, idl) {
+ ovsrec_ipfix_delete(ipfix);
+ }
+
+ OVSREC_FLOW_SAMPLE_COLLECTOR_SET_FOR_EACH_SAFE (fscset, next_fscset, idl) {
+ ovsrec_flow_sample_collector_set_delete(fscset);
+ }
+
+ vsctl_context_invalidate_cache(ctx);
+}
+
+static void
+cmd_add_br(struct vsctl_context *ctx)
+{
+ bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL;
+ const char *br_name, *parent_name;
+ int vlan;
+
+ br_name = ctx->argv[1];
+ if (ctx->argc == 2) {
+ parent_name = NULL;
+ vlan = 0;
+ } else if (ctx->argc == 4) {
+ parent_name = ctx->argv[2];
+ vlan = atoi(ctx->argv[3]);
+ if (vlan < 0 || vlan > 4095) {
+ vsctl_fatal("%s: vlan must be between 0 and 4095", ctx->argv[0]);
+ }
+ } else {
+ vsctl_fatal("'%s' command takes exactly 1 or 3 arguments",
+ ctx->argv[0]);
+ }
+
+ vsctl_context_populate_cache(ctx);
+ if (may_exist) {
+ struct vsctl_bridge *br;
+
+ br = find_bridge(ctx, br_name, false);
+ if (br) {
+ if (!parent_name) {