summaryrefslogtreecommitdiff
path: root/utilities
diff options
context:
space:
mode:
authorJustin Pettit <jpettit@nicira.com>2012-11-30 18:50:18 -0800
committerJustin Pettit <jpettit@nicira.com>2012-12-01 16:47:56 -0800
commit515d830a06869536ccc9c70bfdf8c631ba774999 (patch)
tree7de05e4c681faabbb3c0a85aaf6520a13bf572da /utilities
parentf0992bedf1f0d01667067cab4c25cefbdb6ad9d6 (diff)
downloadopenvswitch-515d830a06869536ccc9c70bfdf8c631ba774999.tar.gz
ovs-vsctl: Add "--real" and "--fake" options to "list-br".
By default, "ovs-vsctl list-br" returns all bridges, real or fake. This commit adds "--real" and "--fake" options that limit the output to only bridges of that type. This will be useful in a future commit that needs to perform actions only on bridges of a particular type. Signed-off-by: Justin Pettit <jpettit@nicira.com>
Diffstat (limited to 'utilities')
-rw-r--r--utilities/ovs-vsctl.8.in5
-rw-r--r--utilities/ovs-vsctl.c14
2 files changed, 15 insertions, 4 deletions
diff --git a/utilities/ovs-vsctl.8.in b/utilities/ovs-vsctl.8.in
index 1b80d050d..79269db76 100644
--- a/utilities/ovs-vsctl.8.in
+++ b/utilities/ovs-vsctl.8.in
@@ -195,9 +195,10 @@ Without \fB\-\-if\-exists\fR, attempting to delete a bridge that does
not exist is an error. With \fB\-\-if\-exists\fR, attempting to
delete a bridge that does not exist has no effect.
.
-.IP "\fBlist\-br\fR"
+.IP "[\fB\-\-real\fR|\fB\-\-fake\fR] \fBlist\-br\fR"
Lists all existing real and fake bridges on standard output, one per
-line.
+line. With \fB\-\-real\fR or \fB\-\-fake\fR, only bridges of that type
+are returned.
.
.IP "\fBbr\-exists \fIbridge\fR"
Tests whether \fIbridge\fR exists as a real or fake bridge. If so,
diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c
index fda3a89db..69e37e002 100644
--- a/utilities/ovs-vsctl.c
+++ b/utilities/ovs-vsctl.c
@@ -1582,13 +1582,23 @@ cmd_list_br(struct vsctl_context *ctx)
{
struct shash_node *node;
struct svec bridges;
+ bool real = shash_find(&ctx->options, "--real");
+ bool fake = shash_find(&ctx->options, "--fake");
+
+ /* If neither fake nor real were requested, return both. */
+ if (!real && !fake) {
+ real = fake = true;
+ }
vsctl_context_populate_cache(ctx);
svec_init(&bridges);
SHASH_FOR_EACH (node, &ctx->bridges) {
struct vsctl_bridge *br = node->data;
- svec_add(&bridges, br->name);
+
+ if (br->parent ? fake : real) {
+ svec_add(&bridges, br->name);
+ }
}
output_sorted(&bridges, &ctx->output);
svec_destroy(&bridges);
@@ -3961,7 +3971,7 @@ static const struct vsctl_command_syntax all_commands[] = {
/* Bridge commands. */
{"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},
+ {"list-br", 0, 0, pre_get_info, cmd_list_br, NULL, "--real,--fake", 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},