This makes sense to me, though before I ack it, I'm wondering if a test case would be a useful addition?
Ryan "dev" <[email protected]> wrote on 03/28/2016 05:44:49 PM: > From: Russell Bryant <[email protected]> > To: [email protected] > Date: 03/28/2016 05:45 PM > Subject: [ovs-dev] [PATCH v2] ovn: Add ovn-bridge-mappings to > Chassis external_ids. > Sent by: "dev" <[email protected]> > > Publish ovn-controller's local bridge mappings configuration > in the external_ids column of the Chassis table. Having this > information available for reading is useful to applications > integrating with OVN. > > Signed-off-by: Russell Bryant <[email protected]> > --- > ovn/controller/chassis.c | 24 ++++++++++++++++++++++++ > ovn/ovn-sb.xml | 7 +++++++ > 2 files changed, 31 insertions(+) > > v1->v2: > - add verify() before updating a key in Chassis external_ids > - add get_bridge_mappings() helper > > > diff --git a/ovn/controller/chassis.c b/ovn/controller/chassis.c > index 52c9993..d40181b 100644 > --- a/ovn/controller/chassis.c > +++ b/ovn/controller/chassis.c > @@ -18,6 +18,7 @@ > > #include "chassis.h" > > +#include "lib/smap.h" > #include "lib/vswitch-idl.h" > #include "openvswitch/dynamic-string.h" > #include "openvswitch/vlog.h" > @@ -55,6 +56,13 @@ pop_tunnel_name(uint32_t *type) > OVS_NOT_REACHED(); > } > > +static const char * > +get_bridge_mappings(const struct smap *ext_ids) > +{ > + const char *bridge_mappings = smap_get(ext_ids, "ovn-bridge-mappings"); > + return bridge_mappings ? bridge_mappings : ""; > +} > + > void > chassis_run(struct controller_ctx *ctx, const char *chassis_id) > { > @@ -102,6 +110,8 @@ chassis_run(struct controller_ctx *ctx, const > char *chassis_id) > hostname = hostname_; > } > > + const char *bridge_mappings = get_bridge_mappings(&cfg-> external_ids); > + > const struct sbrec_chassis *chassis_rec > = get_chassis(ctx->ovnsb_idl, chassis_id); > > @@ -110,6 +120,17 @@ chassis_run(struct controller_ctx *ctx, const > char *chassis_id) > sbrec_chassis_set_hostname(chassis_rec, hostname); > } > > + const char *chassis_bridge_mappings > + = get_bridge_mappings(&chassis_rec->external_ids); > + if (strcmp(bridge_mappings, chassis_bridge_mappings)) { > + struct smap new_ids; > + smap_clone(&new_ids, &chassis_rec->external_ids); > + smap_replace(&new_ids, "ovn-bridge-mappings", bridge_mappings); > + sbrec_chassis_verify_external_ids(chassis_rec); > + sbrec_chassis_set_external_ids(chassis_rec, &new_ids); > + smap_destroy(&new_ids); > + } > + > /* Compare desired tunnels against those currently in the > database. */ > uint32_t cur_tunnels = 0; > bool same = true; > @@ -145,9 +166,12 @@ chassis_run(struct controller_ctx *ctx, const > char *chassis_id) > chassis_id); > > if (!chassis_rec) { > + struct smap ext_ids = SMAP_CONST1(&ext_ids, "ovn-bridge-mappings", > + bridge_mappings); > chassis_rec = sbrec_chassis_insert(ctx->ovnsb_idl_txn); > sbrec_chassis_set_name(chassis_rec, chassis_id); > sbrec_chassis_set_hostname(chassis_rec, hostname); > + sbrec_chassis_set_external_ids(chassis_rec, &ext_ids); > } > > int n_encaps = count_1bits(req_tunnels); > diff --git a/ovn/ovn-sb.xml b/ovn/ovn-sb.xml > index d68f3f6..321bf5b 100644 > --- a/ovn/ovn-sb.xml > +++ b/ovn/ovn-sb.xml > @@ -172,6 +172,13 @@ > ovn-controller-vtep will leave this column empty. > </column> > > + <column name="external_ids" key="ovn-bridge-mappings"> > + <code>ovn-controller</code> populates this key with the set of bridge > + mappings it has been configured to use. Other applications > should treat > + this key as read-only. See <code>ovn-controller</code>(8) for more > + information. > + </column> > + > <group title="Common Columns"> > The overall purpose of these columns is described under <code>Common > Columns</code> at the beginning of this document. > -- > 2.5.5 > > _______________________________________________ > dev mailing list > [email protected] > http://openvswitch.org/mailman/listinfo/dev _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
