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 <russ...@ovn.org> --- ovn/controller/chassis.c | 23 +++++++++++++++++++++++ ovn/ovn-sb.xml | 7 +++++++ 2 files changed, 30 insertions(+) diff --git a/ovn/controller/chassis.c b/ovn/controller/chassis.c index 52c9993..cd4f787 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" @@ -102,6 +103,12 @@ chassis_run(struct controller_ctx *ctx, const char *chassis_id) hostname = hostname_; } + const char *bridge_mappings = smap_get(&cfg->external_ids, + "ovn-bridge-mappings"); + if (!bridge_mappings) { + bridge_mappings = ""; + } + const struct sbrec_chassis *chassis_rec = get_chassis(ctx->ovnsb_idl, chassis_id); @@ -110,6 +117,19 @@ chassis_run(struct controller_ctx *ctx, const char *chassis_id) sbrec_chassis_set_hostname(chassis_rec, hostname); } + const char *chassis_bridge_mappings + = smap_get(&chassis_rec->external_ids, "ovn-bridge-mappings"); + if (!chassis_bridge_mappings) { + chassis_bridge_mappings = ""; + } + 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_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 +165,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..08c3105 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 applicatoins 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 dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev