Assaf Muller has uploaded a new change for review. Change subject: Unified network persistence [2/3] - Respond to setSafeNetworkConfig ......................................................................
Unified network persistence [2/3] - Respond to setSafeNetworkConfig Change-Id: I320677e40ff5b11da684d3ab7195d018135356b2 Signed-off-by: Assaf Muller <[email protected]> --- M lib/vdsm/netinfo.py M vdsm/Makefile.am M vdsm/configNetwork.py M vdsm/vdsm-store-net-config.in 4 files changed, 61 insertions(+), 10 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/09/17009/1 diff --git a/lib/vdsm/netinfo.py b/lib/vdsm/netinfo.py index 6a75067..00ab7ad 100644 --- a/lib/vdsm/netinfo.py +++ b/lib/vdsm/netinfo.py @@ -44,6 +44,8 @@ # Unified persistence directories NET_CONF_RUN_DIR = constants.P_VDSM_RUN + 'netconf/nets/' BOND_CONF_RUN_DIR = constants.P_VDSM_RUN + 'netconf/bonds/' +NET_CONF_PERS_DIR = constants.P_VDSM_LIB + 'persistence/netconf/nets/' +BOND_CONF_PERS_DIR = constants.P_VDSM_LIB + 'persistence/netconf/bonds/' NET_CONF_PREF = NET_CONF_DIR + 'ifcfg-' PROC_NET_VLAN = '/proc/net/vlan/' diff --git a/vdsm/Makefile.am b/vdsm/Makefile.am index c30dcd9..7b56e6a 100644 --- a/vdsm/Makefile.am +++ b/vdsm/Makefile.am @@ -172,6 +172,7 @@ $(MKDIR_P) $(DESTDIR)$(vdsmrundir)/trackedInterfaces $(MKDIR_P) $(DESTDIR)$(vdsmrundir)/payload $(MKDIR_P) $(DESTDIR)$(vdsmlibdir)/netconfback + $(MKDIR_P) $(DESTDIR)$(vdsmlibdir)/persistence $(MKDIR_P) $(DESTDIR)$(vdsmpoolsdir) $(MKDIR_P) $(DESTDIR)$(vdsmbackupdir) $(MKDIR_P) $(DESTDIR)$(localstatedir)/lib/libvirt/qemu/channels diff --git a/vdsm/configNetwork.py b/vdsm/configNetwork.py index 7827727..3399e51 100755 --- a/vdsm/configNetwork.py +++ b/vdsm/configNetwork.py @@ -649,7 +649,8 @@ def setSafeNetworkConfig(): """Declare current network configuration as 'safe'""" - execCmd([constants.EXT_VDSM_STORE_NET_CONFIG]) + execCmd([constants.EXT_VDSM_STORE_NET_CONFIG, + config.get('vars', 'persistence')]) def usage(): diff --git a/vdsm/vdsm-store-net-config.in b/vdsm/vdsm-store-net-config.in index ea87bca..f4ba1f4 100755 --- a/vdsm/vdsm-store-net-config.in +++ b/vdsm/vdsm-store-net-config.in @@ -5,16 +5,18 @@ . @LIBEXECDIR@/ovirt_functions.sh +# ifcfg persistence directories NET_CONF_DIR='/etc/sysconfig/network-scripts/' -NET_CONF_BACK_DIR=@VDSMLIBDIR@/netconfback -DELETE_HEADER='# original file did not exist' +NET_CONF_BACK_DIR="@VDSMLIBDIR@/netconfback" -if isOvirtNode -then - # for ovirt, persist the changed configuration files +# Unified persistence directories +RUN_CONF_DIR='@VDSMRUNDIR@/netconf' +PERS_CONF_PATH="@VDSMLIBDIR@/persistence" +PERS_NET_CONF_PATH="$PERS_CONF_PATH/netconf" - . /usr/libexec/ovirt-functions +PERSISTENCE=$1 +ifcfg_node_persist() { for f in "$NET_CONF_BACK_DIR"/*; do [ ! -f "$f" ] && continue @@ -27,9 +29,54 @@ fi rm "$NET_CONF_BACK_DIR/$bf" done -else - # for rhel, remove the backed up configuration files, and thus mark the - # ones under /etc/sysconfig as "safe". +} +ifcfg_nonnode_persist() { + # Remove the backed up configuration files thus marking the ones under + # /etc/sysconfig as "safe". rm -rf "$NET_CONF_BACK_DIR"/* +} + +unified_node_persist() { + unified_nonnode_persist + + # oVirt node ovirt_store_config puts the dir in persistent storage and + # bind mounts it in the original place. So that's all we really need to do. + ovirt_store_config "$PERS_CONF_PATH" +} + +unified_nonnode_persist() { + # Atomic directory copy by using the atomicity of overwriting a link + # (rename syscall). + TIMESTAMP=$(date +%s) + PERS_CONF_SYMLINK=$PERS_NET_CONF_PATH + PERS_CONF_DIR_ROOTNAME="$PERS_CONF_SYMLINK." + PERS_CONF_NEW_DIR="$PERS_CONF_DIR_ROOTNAME$TIMESTAMP" + PERS_CONF_NEW_SYMLINK="$PERS_CONF_SYMLINK.link.$TIMESTAMP" + + cp -r "$RUN_CONF_DIR" "$PERS_CONF_NEW_DIR" + ln -s "$PERS_CONF_NEW_DIR" "$PERS_CONF_NEW_SYMLINK" + mv -fT "$PERS_CONF_NEW_SYMLINK" "$PERS_CONF_SYMLINK" + find "$PERS_CONF_PATH" -type d -path "$PERS_CONF_DIR_ROOTNAME*" | \ + grep -v "$PERS_CONF_NEW_DIR" | xargs rm -fr +} + + +if isOvirtNode +then + # for node, persist the changed configuration files + + . /usr/libexec/ovirt-functions + + if [ "$PERSISTENCE" == "unified" ]; then + unified_node_persist + else + ifcfg_node_persist + fi +else + if [ "$PERSISTENCE" == "unified" ]; then + unified_nonnode_persist + else + ifcfg_nonnode_persist + fi fi -- To view, visit http://gerrit.ovirt.org/17009 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I320677e40ff5b11da684d3ab7195d018135356b2 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Assaf Muller <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
