Use (or set properly) system-id generated by openvswitch
In case when OVN_UUID isn't set by user, and it isn't stored
in /etc/openvswith/system-id.conf file, Devstack will reuse it.
If it's not, it will generate and store it in the
/etc/openvswitch/system-id.conf file so it can be set to same value
after openvswitch will be e.g. restarted.
In case when OVN_UUID is set by user, it will be also saved in
/etc/openvswitch/system-id.conf file to make it persistent when e.g
openvswitch will be restarted.
Closes-Bug: #1918656
Change-Id: I8e3b05f3ab83e204bc1ce895baec0e1ba515895b
diff --git a/lib/neutron_plugins/ovn_agent b/lib/neutron_plugins/ovn_agent
index b661f59..c6ac16d 100644
--- a/lib/neutron_plugins/ovn_agent
+++ b/lib/neutron_plugins/ovn_agent
@@ -66,7 +66,9 @@
# A UUID to uniquely identify this system. If one is not specified, a random
# one will be generated. A randomly generated UUID will be saved in a file
-# 'ovn-uuid' so that the same one will be re-used if you re-run DevStack.
+# $OVS_SYSCONFDIR/system-id.conf (typically /etc/openvswitch/system-id.conf)
+# so that the same one will be re-used if you re-run DevStack or restart
+# Open vSwitch service.
OVN_UUID=${OVN_UUID:-}
# Whether or not to build the openvswitch kernel module from ovs. This is required
@@ -109,6 +111,7 @@
OVS_SHAREDIR=$OVS_PREFIX/share/openvswitch
OVS_SCRIPTDIR=$OVS_SHAREDIR/scripts
OVS_DATADIR=$DATA_DIR/ovs
+OVS_SYSCONFDIR=${OVS_SYSCONFDIR:-/etc/openvswitch}
OVN_DATADIR=$DATA_DIR/ovn
OVN_SHAREDIR=$OVS_PREFIX/share/ovn
@@ -521,11 +524,17 @@
echo "Configuring OVN"
if [ -z "$OVN_UUID" ] ; then
- if [ -f ./ovn-uuid ] ; then
- OVN_UUID=$(cat ovn-uuid)
+ if [ -f $OVS_SYSCONFDIR/system-id.conf ]; then
+ OVN_UUID=$(cat $OVS_SYSCONFDIR/system-id.conf)
else
OVN_UUID=$(uuidgen)
- echo $OVN_UUID > ovn-uuid
+ echo $OVN_UUID | sudo tee $OVS_SYSCONFDIR/system-id.conf
+ fi
+ else
+ local ovs_uuid
+ ovs_uuid=$(cat $OVS_SYSCONFDIR/system-id.conf)
+ if [ "$ovs_uuid" != $OVN_UUID ]; then
+ echo $OVN_UUID | sudo tee $OVS_SYSCONFDIR/system-id.conf
fi
fi