diff options
| author | Justin Pettit <jpettit@nicira.com> | 2010-07-15 20:56:43 -0700 |
|---|---|---|
| committer | Justin Pettit <jpettit@nicira.com> | 2010-07-30 21:26:54 -0700 |
| commit | 31681a5d627cec70864764586829bdb92abf2f30 (patch) | |
| tree | 26c2117bbfc16091c65be3cb9cbd630b9253df70 /utilities/ovs-vsctl.c | |
| parent | 1a048029a0902439c3f17c49a7f71e4d09fecf70 (diff) | |
| download | openvswitch-31681a5d627cec70864764586829bdb92abf2f30.tar.gz | |
vswitchd: Move fail-mode config to Bridge table
Configuration of the fail-mode was an attribute of the Controller table.
However, it makes more sense as an attribute of the Bridge table, since
the behavior defines what a bridge should do if it can't connect to
*any* controller. This commit makes the move.
Diffstat (limited to 'utilities/ovs-vsctl.c')
| -rw-r--r-- | utilities/ovs-vsctl.c | 49 |
1 files changed, 7 insertions, 42 deletions
diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 88ddd9968..d68e4740a 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -512,6 +512,7 @@ struct vsctl_bridge { struct ovsrec_bridge *br_cfg; char *name; struct ovsrec_controller **ctrl; + char *fail_mode; size_t n_ctrl; struct vsctl_bridge *parent; int vlan; @@ -570,9 +571,11 @@ add_bridge(struct vsctl_info *b, if (parent) { br->ctrl = parent->br_cfg->controller; br->n_ctrl = parent->br_cfg->n_controller; + br->fail_mode = parent->br_cfg->fail_mode; } else { br->ctrl = br_cfg->controller; br->n_ctrl = br_cfg->n_controller; + br->fail_mode = br_cfg->fail_mode; } shash_add(&b->bridges, br->name, br); return br; @@ -1625,58 +1628,23 @@ cmd_set_controller(struct vsctl_context *ctx) free_info(&info); } -static const char * -get_fail_mode(struct ovsrec_controller **controllers, size_t n_controllers) -{ - const char *fail_mode; - size_t i; - - fail_mode = NULL; - for (i = 0; i < n_controllers; i++) { - const char *s = controllers[i]->fail_mode; - if (s) { - if (!strcmp(s, "secure")) { - return s; - } else { - fail_mode = s; - } - } - } - - return fail_mode; -} - static void cmd_get_fail_mode(struct vsctl_context *ctx) { struct vsctl_info info; struct vsctl_bridge *br; - const char *fail_mode = NULL; get_info(ctx->ovs, &info); br = find_bridge(&info, ctx->argv[1], true); - fail_mode = get_fail_mode(br->ctrl, br->n_ctrl); - - if (fail_mode && strlen(fail_mode)) { - ds_put_format(&ctx->output, "%s\n", fail_mode); + if (br->fail_mode && strlen(br->fail_mode)) { + ds_put_format(&ctx->output, "%s\n", br->fail_mode); } free_info(&info); } static void -set_fail_mode(struct ovsrec_controller **controllers, size_t n_controllers, - const char *fail_mode) -{ - size_t i; - - for (i = 0; i < n_controllers; i++) { - ovsrec_controller_set_fail_mode(controllers[i], fail_mode); - } -} - -static void cmd_del_fail_mode(struct vsctl_context *ctx) { struct vsctl_info info; @@ -1685,7 +1653,7 @@ cmd_del_fail_mode(struct vsctl_context *ctx) get_info(ctx->ovs, &info); br = find_real_bridge(&info, ctx->argv[1], true); - set_fail_mode(br->ctrl, br->n_ctrl, NULL); + ovsrec_bridge_set_fail_mode(br->br_cfg, NULL); free_info(&info); } @@ -1704,10 +1672,7 @@ cmd_set_fail_mode(struct vsctl_context *ctx) vsctl_fatal("fail-mode must be \"standalone\" or \"secure\""); } - if (!br->ctrl) { - vsctl_fatal("no controller declared for %s", br->name); - } - set_fail_mode(br->ctrl, br->n_ctrl, fail_mode); + ovsrec_bridge_set_fail_mode(br->br_cfg, fail_mode); free_info(&info); } |
