Jeongkeun Lee jklee@hp.com
Joan Cirer joan@ev0.net
John Galgay john@galgay.net
+Kevin Mancuso kevin.mancuso@rackspace.com
Koichi Yagishita yagishita.koichi@jrc.co.jp
Krishna Miriyala krishna@nicira.com
Luca Falavigna dktrkranz@debian.org
]], [ignore], [test ! -e pid || kill `cat pid`])
OVS_VSCTL_CLEANUP
AT_CLEANUP
+
+dnl This test will create a linux-htb QoS record that
+dnl points to a few queues and use it on a1 and a2 port.
+dnl It also destroys all records from Qos and Queue table.
+AT_SETUP([--all option on destroy command])
+AT_KEYWORDS([ovs-vsctl])
+OVS_VSCTL_SETUP
+AT_CHECK([RUN_OVS_VSCTL(
+ [add-br a],
+ [add-port a a1],
+ [add-port a a2])], [0], [], [], [OVS_VSCTL_CLEANUP])
+CHECK_BRIDGES([a, a, 0])
+CHECK_PORTS([a], [a1], [a2])
+CHECK_IFACES([a], [a1], [a2])
+AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
+ [set Port a1 qos=@newqos],
+ [set Port a2 qos=@newqos],
+ [--id=@newqos create QoS type=linux-htb other-config:max-rate=1000000000 queues=0=@q0,1=@q1],
+ [--id=@q0 create Queue other-config:min-rate=100000000 other-config:max-rate=100000000],
+ [--id=@q1 create Queue other-config:min-rate=500000000])], [0], [ignore], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL(
+ [--columns=other_config,type list Qos])], [0],
+[other_config : {max-rate="1000000000"}
+type : linux-htb
+], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL(
+ [--columns=other_config list Queue | sort | xargs echo])], [0],
+[other_config : {max-rate=100000000, min-rate=100000000} other_config : {min-rate=500000000}
+], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL(
+ [clear Port a1 qos],
+ [clear Port a2 qos])], [0], [], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL(
+ [--columns=qos list Port a1 a2])], [0],
+[[qos : []
+
+qos : []
+]], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL(
+ [--all destroy Qos])], [0], [], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL(
+ [-- list Qos])], [0], [], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL(
+ [--all destroy Queue])], [0], [], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL(
+ [-- list Queue])], [0], [], [], [OVS_VSCTL_CLEANUP])
+OVS_VSCTL_CLEANUP
+AT_CLEANUP
.IP "\fR[\fB\-\-if\-exists\fR] \fBdestroy \fItable record\fR..."
Deletes each specified \fIrecord\fR from \fItable\fR. Unless
\fB\-\-if\-exists\fR is specified, each \fIrecord\fRs must exist.
+.IP "\fB\-\-all destroy \fItable\fR"
+Deletes all records from the \fItable\fR.
.IP
The \fBdestroy\fR command is only useful for records in the \fBQoS\fR
or \fBQueue\fR tables. Records in other tables are automatically
(This command will leave two unreferenced Queue records in the
database. To delete them, use "\fBovs\-vsctl list Queue\fR" to find
their UUIDs, then "\fBovs\-vsctl destroy Queue \fIuuid1\fR
-\fIuuid2\fR" to destroy each of them.)
+\fIuuid2\fR" to destroy each of them or use
+"\fBovs\-vsctl -- --all destroy Queue\fR" to delete all records.)
.SS "Connectivity Monitoring"
.PP
Monitor connectivity to a remote maintenance point on eth0.
cmd_destroy(struct vsctl_context *ctx)
{
bool must_exist = !shash_find(&ctx->options, "--if-exists");
+ bool delete_all = shash_find(&ctx->options, "--all");
const char *table_name = ctx->argv[1];
const struct vsctl_table_class *table;
int i;
table = get_table(table_name);
- for (i = 2; i < ctx->argc; i++) {
+
+ if (delete_all && ctx->argc > 2) {
+ vsctl_fatal("--all and records argument should not be specified together");
+ }
+
+ if (delete_all && !must_exist) {
+ vsctl_fatal("--all and --if-exists should not be specified together");
+ }
+
+ if (delete_all) {
const struct ovsdb_idl_row *row;
+ const struct ovsdb_idl_row *next_row;
- row = (must_exist ? must_get_row : get_row)(ctx, table, ctx->argv[i]);
- if (row) {
- ovsdb_idl_txn_delete(row);
+ for (row = ovsdb_idl_first_row(ctx->idl, table->class);
+ row;) {
+ next_row = ovsdb_idl_next_row(row);
+ ovsdb_idl_txn_delete(row);
+ row = next_row;
}
- }
+ } else {
+ for (i = 2; i < ctx->argc; i++) {
+ const struct ovsdb_idl_row *row;
+ row = (must_exist ? must_get_row : get_row)(ctx, table, ctx->argv[i]);
+ if (row) {
+ ovsdb_idl_txn_delete(row);
+ }
+ }
+ }
vsctl_context_invalidate_cache(ctx);
}
{"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, pre_create, cmd_create, post_create, "--id=", RW},
- {"destroy", 1, INT_MAX, pre_cmd_destroy, cmd_destroy, NULL, "--if-exists",
- RW},
+ {"destroy", 1, INT_MAX, pre_cmd_destroy, cmd_destroy, NULL,
+ "--if-exists,--all", RW},
{"wait-until", 2, INT_MAX, pre_cmd_wait_until, cmd_wait_until, NULL, "",
RO},