static struct table_style table_style = TABLE_STYLE_DEFAULT;
/* All supported commands. */
-static const struct vsctl_command_syntax all_commands[];
+static const struct vsctl_command_syntax *get_all_commands(void);
/* The IDL we're using and the current transaction, if any.
* This is for use by vsctl_exit() only, to allow it to clean up.
options = xmemdup(global_long_options, sizeof global_long_options);
allocated_options = ARRAY_SIZE(global_long_options);
n_options = n_global_long_options;
- for (p = all_commands; p->name; p++) {
+ for (p = get_all_commands(); p->name; p++) {
if (p->options[0]) {
char *save_ptr = NULL;
char *name;
if (shash_is_empty(&commands)) {
const struct vsctl_command_syntax *p;
- for (p = all_commands; p->name; p++) {
+ for (p = get_all_commands(); p->name; p++) {
shash_add_assert(&commands, p->name, p);
}
}
{
bool must_exist = !shash_find(&ctx->options, "--if-exists");
bool with_iface = shash_find(&ctx->options, "--with-iface") != NULL;
+ const char *target = ctx->argv[ctx->argc - 1];
struct vsctl_port *port;
vsctl_context_populate_cache(ctx);
- if (!with_iface) {
- port = find_port(ctx, ctx->argv[ctx->argc - 1], must_exist);
+ if (find_bridge(ctx, target, false)) {
+ if (must_exist) {
+ vsctl_fatal("cannot delete port %s because it is the local port "
+ "for bridge %s (deleting this port requires deleting "
+ "the entire bridge)", target, target);
+ }
+ port = NULL;
+ } else if (!with_iface) {
+ port = find_port(ctx, target, must_exist);
} else {
- const char *target = ctx->argv[ctx->argc - 1];
struct vsctl_iface *iface;
port = find_port(ctx, target, false);
{NULL, 0, 0, NULL, NULL, NULL, NULL, RO},
};
+static const struct vsctl_command_syntax *get_all_commands(void)
+{
+ return all_commands;
+}