X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=utilities%2Fovs-vsctl.c;h=fd9f8f4aba9600c7c8aff3279b32695076d1737b;hb=6ce39213456b27257acbaf146398dce26d1466b9;hp=1585faee5e1f4b401043060f77ab3168957c5e01;hpb=f74055e705bc9735853e11170b42840977279fb4;p=sliver-openvswitch.git diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 1585faee5..fd9f8f4ab 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -43,21 +43,40 @@ #include "util.h" #include "vlog.h" -VLOG_DEFINE_THIS_MODULE(vsctl) +VLOG_DEFINE_THIS_MODULE(vsctl); /* vsctl_fatal() also logs the error, so it is preferred in this file. */ #define ovs_fatal please_use_vsctl_fatal_instead_of_ovs_fatal struct vsctl_context; -typedef void vsctl_handler_func(struct vsctl_context *); - +/* A command supported by ovs-vsctl. */ struct vsctl_command_syntax { - const char *name; - int min_args; - int max_args; - vsctl_handler_func *run; - vsctl_handler_func *postprocess; + const char *name; /* e.g. "add-br" */ + int min_args; /* Min number of arguments following name. */ + int max_args; /* Max number of arguments following name. */ + + /* If nonnull, calls ovsdb_idl_add_column() or ovsdb_idl_add_table() for + * each column or table in ctx->idl that it uses. */ + void (*prerequisites)(struct vsctl_context *ctx); + + /* Does the actual work of the command and puts the command's output, if + * any, in ctx->output. + * + * Alternatively, if some prerequisite of the command is not met and the + * caller should wait for something to change and then retry, it may set + * ctx->try_again to true. (Only the "wait-until" command currently does + * this.) */ + void (*run)(struct vsctl_context *ctx); + + /* If nonnull, called after the transaction has been successfully + * committed. ctx->output is the output from the "run" function, which + * this function may modify and otherwise postprocess as needed. (Only the + * "create" command currently does any postprocessing.) */ + void (*postprocess)(struct vsctl_context *ctx); + + /* A comma-separated list of supported options, e.g. "--a,--b", or the + * empty string if the command does not support any options. */ const char *options; enum { RO, RW } mode; /* Does this command modify the database? */ }; @@ -108,6 +127,8 @@ static struct vsctl_command *parse_commands(int argc, char *argv[], size_t *n_commandsp); static void parse_command(int argc, char *argv[], struct vsctl_command *); static const struct vsctl_command_syntax *find_command(const char *name); +static void run_prerequisites(struct vsctl_command[], size_t n_commands, + struct ovsdb_idl *); static void do_vsctl(const char *args, struct vsctl_command *, size_t n_commands, struct ovsdb_idl *); @@ -144,8 +165,11 @@ main(int argc, char *argv[]) time_alarm(timeout); } + /* Initialize IDL. */ + idl = the_idl = ovsdb_idl_create(db, &ovsrec_idl_class, false); + run_prerequisites(commands, n_commands, idl); + /* Now execute the commands. */ - idl = the_idl = ovsdb_idl_create(db, &ovsrec_idl_class); for (;;) { if (ovsdb_idl_run(idl)) { do_vsctl(args, commands, n_commands, idl); @@ -507,7 +531,7 @@ default_db(void) { static char *def; if (!def) { - def = xasprintf("unix:%s/db.sock", ovs_rundir); + def = xasprintf("unix:%s/db.sock", ovs_rundir()); } return def; } @@ -568,9 +592,9 @@ struct vsctl_iface { struct vsctl_info { struct vsctl_context *ctx; - struct shash bridges; - struct shash ports; - struct shash ifaces; + struct shash bridges; /* Maps from bridge name to struct vsctl_bridge. */ + struct shash ports; /* Maps from port name to struct vsctl_port. */ + struct shash ifaces; /* Maps from port name to struct vsctl_iface. */ }; static char * @@ -679,6 +703,24 @@ free_info(struct vsctl_info *info) shash_destroy_free_data(&info->ifaces); } +static void +pre_get_info(struct vsctl_context *ctx) +{ + ovsdb_idl_add_column(ctx->idl, &ovsrec_open_vswitch_col_bridges); + + ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_name); + 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_ports); + + ovsdb_idl_add_column(ctx->idl, &ovsrec_port_col_name); + ovsdb_idl_add_column(ctx->idl, &ovsrec_port_col_fake_bridge); + ovsdb_idl_add_column(ctx->idl, &ovsrec_port_col_tag); + ovsdb_idl_add_column(ctx->idl, &ovsrec_port_col_interfaces); + + ovsdb_idl_add_column(ctx->idl, &ovsrec_interface_col_name); +} + static void get_info(struct vsctl_context *ctx, struct vsctl_info *info) { @@ -932,6 +974,29 @@ cmd_init(struct vsctl_context *ctx OVS_UNUSED) { } +static void +pre_cmd_emer_reset(struct vsctl_context *ctx) +{ + ovsdb_idl_add_column(ctx->idl, &ovsrec_open_vswitch_col_managers); + 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_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) { @@ -941,13 +1006,14 @@ cmd_emer_reset(struct vsctl_context *ctx) 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; - /* Reset the Open_vSwitch table. */ ovsrec_open_vswitch_set_managers(ctx->ovs, NULL, 0); + ovsrec_open_vswitch_set_manager_options(ctx->ovs, NULL, 0); ovsrec_open_vswitch_set_ssl(ctx->ovs, NULL); OVSREC_BRIDGE_FOR_EACH (br, idl) { @@ -956,6 +1022,7 @@ cmd_emer_reset(struct vsctl_context *ctx) char *hw_val = NULL; 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); @@ -996,6 +1063,10 @@ cmd_emer_reset(struct vsctl_context *ctx) 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); } @@ -1073,6 +1144,7 @@ cmd_add_br(struct vsctl_context *ctx) iface = ovsrec_interface_insert(ctx->txn); ovsrec_interface_set_name(iface, br_name); + ovsrec_interface_set_type(iface, "internal"); port = ovsrec_port_insert(ctx->txn); ovsrec_port_set_name(port, br_name); @@ -1243,6 +1315,14 @@ set_external_id(char **old_keys, char **old_values, size_t old_n, *new_np = new_n; } +static void +pre_cmd_br_set_external_id(struct vsctl_context *ctx) +{ + pre_get_info(ctx); + ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_external_ids); + ovsdb_idl_add_column(ctx->idl, &ovsrec_port_col_external_ids); +} + static void cmd_br_set_external_id(struct vsctl_context *ctx) { @@ -1302,6 +1382,12 @@ get_external_id(char **keys, char **values, size_t n, svec_destroy(&svec); } +static void +pre_cmd_br_get_external_id(struct vsctl_context *ctx) +{ + pre_cmd_br_set_external_id(ctx); +} + static void cmd_br_get_external_id(struct vsctl_context *ctx) { @@ -1622,6 +1708,14 @@ verify_controllers(struct ovsrec_bridge *bridge) } } +static void +pre_controller(struct vsctl_context *ctx) +{ + pre_get_info(ctx); + + ovsdb_idl_add_column(ctx->idl, &ovsrec_controller_col_target); +} + static void cmd_get_controller(struct vsctl_context *ctx) { @@ -1767,6 +1861,17 @@ cmd_set_fail_mode(struct vsctl_context *ctx) free_info(&info); } +static void +pre_cmd_get_ssl(struct vsctl_context *ctx) +{ + ovsdb_idl_add_column(ctx->idl, &ovsrec_open_vswitch_col_ssl); + + ovsdb_idl_add_column(ctx->idl, &ovsrec_ssl_col_private_key); + ovsdb_idl_add_column(ctx->idl, &ovsrec_ssl_col_certificate); + ovsdb_idl_add_column(ctx->idl, &ovsrec_ssl_col_ca_cert); + ovsdb_idl_add_column(ctx->idl, &ovsrec_ssl_col_bootstrap_ca_cert); +} + static void cmd_get_ssl(struct vsctl_context *ctx) { @@ -1787,6 +1892,12 @@ cmd_get_ssl(struct vsctl_context *ctx) } } +static void +pre_cmd_del_ssl(struct vsctl_context *ctx) +{ + ovsdb_idl_add_column(ctx->idl, &ovsrec_open_vswitch_col_ssl); +} + static void cmd_del_ssl(struct vsctl_context *ctx) { @@ -1799,6 +1910,12 @@ cmd_del_ssl(struct vsctl_context *ctx) } } +static void +pre_cmd_set_ssl(struct vsctl_context *ctx) +{ + ovsdb_idl_add_column(ctx->idl, &ovsrec_open_vswitch_col_ssl); +} + static void cmd_set_ssl(struct vsctl_context *ctx) { @@ -1851,6 +1968,10 @@ static const struct vsctl_table_class tables[] = { {{&ovsrec_table_mirror, &ovsrec_mirror_col_name, NULL}, {NULL, NULL, NULL}}}, + {&ovsrec_table_manager, + {{&ovsrec_table_manager, &ovsrec_manager_col_target, NULL}, + {NULL, NULL, NULL}}}, + {&ovsrec_table_netflow, {{&ovsrec_table_bridge, &ovsrec_bridge_col_name, @@ -1869,6 +1990,16 @@ static const struct vsctl_table_class tables[] = { {{&ovsrec_table_port, &ovsrec_port_col_name, &ovsrec_port_col_qos}, {NULL, NULL, NULL}}}, + {&ovsrec_table_monitor, + {{&ovsrec_table_interface, + &ovsrec_interface_col_name, + &ovsrec_interface_col_monitor}, + {NULL, NULL, NULL}}}, + + {&ovsrec_table_maintenance_point, + {{NULL, NULL, NULL}, + {NULL, NULL, NULL}}}, + {&ovsrec_table_queue, {{NULL, NULL, NULL}, {NULL, NULL, NULL}}}, @@ -1943,6 +2074,31 @@ get_table(const char *table_name) } } +static const struct vsctl_table_class * +pre_get_table(struct vsctl_context *ctx, const char *table_name) +{ + const struct vsctl_table_class *table_class; + int i; + + table_class = get_table(table_name); + ovsdb_idl_add_table(ctx->idl, table_class->class); + + for (i = 0; i < ARRAY_SIZE(table_class->row_ids); i++) { + const struct vsctl_row_id *id = &table_class->row_ids[i]; + if (id->table) { + ovsdb_idl_add_table(ctx->idl, id->table); + } + if (id->name_column) { + ovsdb_idl_add_column(ctx->idl, id->name_column); + } + if (id->uuid_column) { + ovsdb_idl_add_column(ctx->idl, id->uuid_column); + } + } + + return table_class; +} + static const struct ovsdb_idl_row * get_row_by_id(struct vsctl_context *ctx, const struct vsctl_table_class *table, const struct vsctl_row_id *id, const char *record_id) @@ -2091,6 +2247,15 @@ create_symbol(struct ovsdb_symbol_table *symtab, const char *id, bool *newp) return &symbol->uuid; } +static void +pre_get_column(struct vsctl_context *ctx, + const struct vsctl_table_class *table, const char *column_name, + const struct ovsdb_idl_column **columnp) +{ + die_if_error(get_column(table, column_name, columnp)); + ovsdb_idl_add_column(ctx->idl, *columnp); +} + static char * missing_operator_error(const char *arg, const char **allowed_operators, size_t n_allowed) @@ -2255,6 +2420,43 @@ error: return error; } +static void +pre_parse_column_key_value(struct vsctl_context *ctx, + const char *arg, + const struct vsctl_table_class *table) +{ + const struct ovsdb_idl_column *column; + const char *p; + char *column_name; + + p = arg; + die_if_error(ovsdb_token_parse(&p, &column_name)); + if (column_name[0] == '\0') { + vsctl_fatal("%s: missing column name", arg); + } + + pre_get_column(ctx, table, column_name, &column); + free(column_name); +} + +static void +pre_cmd_get(struct vsctl_context *ctx) +{ + const char *table_name = ctx->argv[1]; + const struct vsctl_table_class *table; + int i; + + table = pre_get_table(ctx, table_name); + for (i = 3; i < ctx->argc; i++) { + if (!strcasecmp(ctx->argv[i], "_uuid") + || !strcasecmp(ctx->argv[i], "-uuid")) { + continue; + } + + pre_parse_column_key_value(ctx, ctx->argv[i], table); + } +} + static void cmd_get(struct vsctl_context *ctx) { @@ -2333,6 +2535,19 @@ cmd_get(struct vsctl_context *ctx) } } +static void +pre_cmd_list(struct vsctl_context *ctx) +{ + const char *table_name = ctx->argv[1]; + const struct vsctl_table_class *table; + size_t i; + + table = pre_get_table(ctx, table_name); + for (i = 0; i < table->class->n_columns; i++) { + ovsdb_idl_add_column(ctx->idl, &table->class->columns[i]); + } +} + static void list_record(const struct vsctl_table_class *table, const struct ovsdb_idl_row *row, struct ds *out) @@ -2384,6 +2599,19 @@ cmd_list(struct vsctl_context *ctx) } } +static void +pre_cmd_set(struct vsctl_context *ctx) +{ + const char *table_name = ctx->argv[1]; + const struct vsctl_table_class *table; + int i; + + table = pre_get_table(ctx, table_name); + for (i = 3; i < ctx->argc; i++) { + pre_parse_column_key_value(ctx, ctx->argv[i], table); + } +} + static void set_column(const struct vsctl_table_class *table, const struct ovsdb_idl_row *row, const char *arg, @@ -2451,6 +2679,18 @@ cmd_set(struct vsctl_context *ctx) } } +static void +pre_cmd_add(struct vsctl_context *ctx) +{ + const char *table_name = ctx->argv[1]; + const char *column_name = ctx->argv[3]; + const struct vsctl_table_class *table; + const struct ovsdb_idl_column *column; + + table = pre_get_table(ctx, table_name); + pre_get_column(ctx, table, column_name, &column); +} + static void cmd_add(struct vsctl_context *ctx) { @@ -2493,6 +2733,18 @@ cmd_add(struct vsctl_context *ctx) ovsdb_idl_txn_write(row, column, &old); } +static void +pre_cmd_remove(struct vsctl_context *ctx) +{ + const char *table_name = ctx->argv[1]; + const char *column_name = ctx->argv[3]; + const struct vsctl_table_class *table; + const struct ovsdb_idl_column *column; + + table = pre_get_table(ctx, table_name); + pre_get_column(ctx, table, column_name, &column); +} + static void cmd_remove(struct vsctl_context *ctx) { @@ -2542,6 +2794,21 @@ cmd_remove(struct vsctl_context *ctx) ovsdb_idl_txn_write(row, column, &old); } +static void +pre_cmd_clear(struct vsctl_context *ctx) +{ + const char *table_name = ctx->argv[1]; + const struct vsctl_table_class *table; + int i; + + table = pre_get_table(ctx, table_name); + for (i = 3; i < ctx->argc; i++) { + const struct ovsdb_idl_column *column; + + pre_get_column(ctx, table, ctx->argv[i], &column); + } +} + static void cmd_clear(struct vsctl_context *ctx) { @@ -2616,6 +2883,14 @@ post_create(struct vsctl_context *ctx) ds_put_char(&ctx->output, '\n'); } +static void +pre_cmd_destroy(struct vsctl_context *ctx) +{ + const char *table_name = ctx->argv[1]; + + pre_get_table(ctx, table_name); +} + static void cmd_destroy(struct vsctl_context *ctx) { @@ -2708,6 +2983,20 @@ is_condition_satified(const struct vsctl_table_class *table, : (abort(), 0)); } +static void +pre_cmd_wait_until(struct vsctl_context *ctx) +{ + const char *table_name = ctx->argv[1]; + const struct vsctl_table_class *table; + int i; + + table = pre_get_table(ctx, table_name); + + for (i = 3; i < ctx->argc; i++) { + pre_parse_column_key_value(ctx, ctx->argv[i], table); + } +} + static void cmd_wait_until(struct vsctl_context *ctx) { @@ -2751,7 +3040,7 @@ static void vsctl_context_init(struct vsctl_context *ctx, struct vsctl_command *command, struct ovsdb_idl *idl, struct ovsdb_idl_txn *txn, const struct ovsrec_open_vswitch *ovs, - struct ovsdb_symbol_table *symtab) + struct ovsdb_symbol_table *symtab) { ctx->argc = command->argc; ctx->argv = command->argv; @@ -2773,6 +3062,31 @@ vsctl_context_done(struct vsctl_context *ctx, struct vsctl_command *command) ds_swap(&ctx->output, &command->output); } +static void +run_prerequisites(struct vsctl_command *commands, size_t n_commands, + struct ovsdb_idl *idl) +{ + struct vsctl_command *c; + + ovsdb_idl_add_table(idl, &ovsrec_table_open_vswitch); + if (wait_for_reload) { + ovsdb_idl_add_column(idl, &ovsrec_open_vswitch_col_cur_cfg); + } + for (c = commands; c < &commands[n_commands]; c++) { + if (c->syntax->prerequisites) { + struct vsctl_context ctx; + + ds_init(&c->output); + + vsctl_context_init(&ctx, c, idl, NULL, NULL, NULL); + (c->syntax->prerequisites)(&ctx); + vsctl_context_done(&ctx, c); + + assert(!c->output.string); + } + } +} + static void do_vsctl(const char *args, struct vsctl_command *commands, size_t n_commands, struct ovsdb_idl *idl) @@ -2838,7 +3152,7 @@ do_vsctl(const char *args, struct vsctl_command *commands, size_t n_commands, } error = xstrdup(ovsdb_idl_txn_get_error(txn)); ovsdb_idl_txn_destroy(txn); - the_idl_txn = NULL; + txn = the_idl_txn = NULL; unused = ovsdb_symbol_table_find_unused(symtab); if (unused) { @@ -2873,7 +3187,6 @@ do_vsctl(const char *args, struct vsctl_command *commands, size_t n_commands, for (c = commands; c < &commands[n_commands]; c++) { struct ds *ds = &c->output; - struct shash_node *node; if (oneline) { size_t j; @@ -2900,10 +3213,7 @@ do_vsctl(const char *args, struct vsctl_command *commands, size_t n_commands, } ds_destroy(&c->output); - SHASH_FOR_EACH (node, &c->options) { - free(node->data); - } - shash_destroy(&c->options); + smap_destroy(&c->options); } free(commands); @@ -2927,8 +3237,10 @@ do_vsctl(const char *args, struct vsctl_command *commands, size_t n_commands, try_again: /* Our transaction needs to be rerun, or a prerequisite was not met. Free * resources and return so that the caller can try again. */ - ovsdb_idl_txn_abort(txn); - ovsdb_idl_txn_destroy(txn); + if (txn) { + ovsdb_idl_txn_abort(txn); + ovsdb_idl_txn_destroy(txn); + } ovsdb_symbol_table_destroy(symtab); for (c = commands; c < &commands[n_commands]; c++) { ds_destroy(&c->output); @@ -2938,56 +3250,64 @@ try_again: static const struct vsctl_command_syntax all_commands[] = { /* Open vSwitch commands. */ - {"init", 0, 0, cmd_init, NULL, "", RW}, + {"init", 0, 0, NULL, cmd_init, NULL, "", RW}, /* Bridge commands. */ - {"add-br", 1, 3, cmd_add_br, NULL, "--may-exist", RW}, - {"del-br", 1, 1, cmd_del_br, NULL, "--if-exists", RW}, - {"list-br", 0, 0, cmd_list_br, NULL, "", RO}, - {"br-exists", 1, 1, cmd_br_exists, NULL, "", RO}, - {"br-to-vlan", 1, 1, cmd_br_to_vlan, NULL, "", RO}, - {"br-to-parent", 1, 1, cmd_br_to_parent, NULL, "", RO}, - {"br-set-external-id", 2, 3, cmd_br_set_external_id, NULL, "", RW}, - {"br-get-external-id", 1, 2, cmd_br_get_external_id, NULL, "", RO}, + {"add-br", 1, 3, pre_get_info, cmd_add_br, NULL, "--may-exist", RW}, + {"del-br", 1, 1, pre_get_info, cmd_del_br, NULL, "--if-exists", RW}, + {"list-br", 0, 0, pre_get_info, cmd_list_br, NULL, "", RO}, + {"br-exists", 1, 1, pre_get_info, cmd_br_exists, NULL, "", RO}, + {"br-to-vlan", 1, 1, pre_get_info, cmd_br_to_vlan, NULL, "", RO}, + {"br-to-parent", 1, 1, pre_get_info, cmd_br_to_parent, NULL, "", RO}, + {"br-set-external-id", 2, 3, pre_cmd_br_set_external_id, + cmd_br_set_external_id, NULL, "", RW}, + {"br-get-external-id", 1, 2, pre_cmd_br_get_external_id, + cmd_br_get_external_id, NULL, "", RO}, /* Port commands. */ - {"list-ports", 1, 1, cmd_list_ports, NULL, "", RO}, - {"add-port", 2, INT_MAX, cmd_add_port, NULL, "--may-exist", RW}, - {"add-bond", 4, INT_MAX, cmd_add_bond, NULL, "--may-exist,--fake-iface", RW}, - {"del-port", 1, 2, cmd_del_port, NULL, "--if-exists,--with-iface", RW}, - {"port-to-br", 1, 1, cmd_port_to_br, NULL, "", RO}, + {"list-ports", 1, 1, pre_get_info, cmd_list_ports, NULL, "", RO}, + {"add-port", 2, INT_MAX, pre_get_info, cmd_add_port, NULL, "--may-exist", + RW}, + {"add-bond", 4, INT_MAX, pre_get_info, cmd_add_bond, NULL, + "--may-exist,--fake-iface", RW}, + {"del-port", 1, 2, pre_get_info, cmd_del_port, NULL, + "--if-exists,--with-iface", RW}, + {"port-to-br", 1, 1, pre_get_info, cmd_port_to_br, NULL, "", RO}, /* Interface commands. */ - {"list-ifaces", 1, 1, cmd_list_ifaces, NULL, "", RO}, - {"iface-to-br", 1, 1, cmd_iface_to_br, NULL, "", RO}, + {"list-ifaces", 1, 1, pre_get_info, cmd_list_ifaces, NULL, "", RO}, + {"iface-to-br", 1, 1, pre_get_info, cmd_iface_to_br, NULL, "", RO}, /* Controller commands. */ - {"get-controller", 1, 1, cmd_get_controller, NULL, "", RO}, - {"del-controller", 1, 1, cmd_del_controller, NULL, "", RW}, - {"set-controller", 1, INT_MAX, cmd_set_controller, NULL, "", RW}, - {"get-fail-mode", 1, 1, cmd_get_fail_mode, NULL, "", RO}, - {"del-fail-mode", 1, 1, cmd_del_fail_mode, NULL, "", RW}, - {"set-fail-mode", 2, 2, cmd_set_fail_mode, NULL, "", RW}, + {"get-controller", 1, 1, pre_controller, cmd_get_controller, NULL, "", RO}, + {"del-controller", 1, 1, pre_controller, cmd_del_controller, NULL, "", RW}, + {"set-controller", 1, INT_MAX, pre_controller, cmd_set_controller, NULL, + "", RW}, + {"get-fail-mode", 1, 1, pre_get_info, cmd_get_fail_mode, NULL, "", RO}, + {"del-fail-mode", 1, 1, pre_get_info, cmd_del_fail_mode, NULL, "", RW}, + {"set-fail-mode", 2, 2, pre_get_info, cmd_set_fail_mode, NULL, "", RW}, /* SSL commands. */ - {"get-ssl", 0, 0, cmd_get_ssl, NULL, "", RO}, - {"del-ssl", 0, 0, cmd_del_ssl, NULL, "", RW}, - {"set-ssl", 3, 3, cmd_set_ssl, NULL, "--bootstrap", RW}, + {"get-ssl", 0, 0, pre_cmd_get_ssl, cmd_get_ssl, NULL, "", RO}, + {"del-ssl", 0, 0, pre_cmd_del_ssl, cmd_del_ssl, NULL, "", RW}, + {"set-ssl", 3, 3, pre_cmd_set_ssl, cmd_set_ssl, NULL, "--bootstrap", RW}, /* Switch commands. */ - {"emer-reset", 0, 0, cmd_emer_reset, NULL, "", RW}, + {"emer-reset", 0, 0, pre_cmd_emer_reset, cmd_emer_reset, NULL, "", RW}, /* Parameter commands. */ - {"get", 2, INT_MAX, cmd_get, NULL, "--if-exists,--id=", RO}, - {"list", 1, INT_MAX, cmd_list, NULL, "", RO}, - {"set", 3, INT_MAX, cmd_set, NULL, "", RW}, - {"add", 4, INT_MAX, cmd_add, NULL, "", RW}, - {"remove", 4, INT_MAX, cmd_remove, NULL, "", RW}, - {"clear", 3, INT_MAX, cmd_clear, NULL, "", RW}, - {"create", 2, INT_MAX, cmd_create, post_create, "--id=", RW}, - {"destroy", 1, INT_MAX, cmd_destroy, NULL, "--if-exists", RW}, - {"wait-until", 2, INT_MAX, cmd_wait_until, NULL, "", RO}, - - {NULL, 0, 0, NULL, NULL, NULL, RO}, + {"get", 2, INT_MAX, pre_cmd_get, cmd_get, NULL, "--if-exists,--id=", RO}, + {"list", 1, INT_MAX, pre_cmd_list, cmd_list, NULL, "", RO}, + {"set", 3, INT_MAX, pre_cmd_set, cmd_set, NULL, "", RW}, + {"add", 4, INT_MAX, pre_cmd_add, cmd_add, NULL, "", RW}, + {"remove", 4, INT_MAX, pre_cmd_remove, cmd_remove, NULL, "", RW}, + {"clear", 3, INT_MAX, pre_cmd_clear, cmd_clear, NULL, "", RW}, + {"create", 2, INT_MAX, NULL, cmd_create, post_create, "--id=", RW}, + {"destroy", 1, INT_MAX, pre_cmd_destroy, cmd_destroy, NULL, "--if-exists", + RW}, + {"wait-until", 2, INT_MAX, pre_cmd_wait_until, cmd_wait_until, NULL, "", + RO}, + + {NULL, 0, 0, NULL, NULL, NULL, NULL, RO}, };