#include "chassis.h"
+#include "lib/smap.h"
#include "lib/vswitch-idl.h"
#include "openvswitch/dynamic-string.h"
#include "openvswitch/vlog.h"
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)
{
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);
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;
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);
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.
diff -u stdout expout >/dev/null])
}
+# Make sure that the configured bridge mappings in the Open_vSwitch db
+# is mirrored into the Chassis record in the OVN_Southbound db.
+check_bridge_mappings () {
+ local_mappings=$1
+ sysid=$(ovs-vsctl get Open_vSwitch . external_ids:system-id)
+ chassis_mappings=$(ovn-sbctl get Chassis ${sysid} external_ids:ovn-bridge-mappings | sed -e 's/\"//g')
+ echo $local_mappings
+ echo $chassis_mappings
+ AT_CHECK([test "${local_mappings}" = "${chassis_mappings}"])
+}
+
# Initially there should be no patch ports.
check_patches
# Configure two ovn-bridge mappings, but no patch ports should be created yet
AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0,physnet2:br-eth1])
+check_bridge_mappings "physnet1:br-eth0,physnet2:br-eth1"
check_patches
# Create a localnet port, but we should still have no patch ports, as they
# Delete the mapping and the ovn-bridge-mapping patch ports should go away;
# the ones from the logical patch port remain.
AT_CHECK([ovs-vsctl remove Open_vSwitch . external-ids ovn-bridge-mappings])
+check_bridge_mappings
check_patches \
'br-int patch-foo-to-bar patch-bar-to-foo' \
'br-int patch-bar-to-foo patch-foo-to-bar'