Fabian Deutsch has uploaded a new change for review. Change subject: Add on-shutdown hooks ......................................................................
Add on-shutdown hooks With requests to save some files which aren't managed by the TUI or our config classes on reboot, add on-shutdown hooks which run when the system comes down so we can execute things there. For now, this is only used for saving virt-who config files. Change-Id: I2cc830b1b4b28db29a3fe995ac31c36b15cf6676 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1209356 Signed-off-by: Ryan Barry <[email protected]> --- M hooks/Makefile.am M hooks/README A hooks/on-shutdown/01-save-virtwho.py M ovirt-node.spec.in M services/ovirt-node-hooks.service 5 files changed, 34 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/29/49029/1 diff --git a/hooks/Makefile.am b/hooks/Makefile.am index f008d35..ff68c45 100644 --- a/hooks/Makefile.am +++ b/hooks/Makefile.am @@ -16,7 +16,15 @@ # also available at http://www.gnu.org/copyleft/gpl.html. onbootdir = $(libexecdir)/ovirt-node/hooks/on-boot +onshutdowndir = $(libexecdir)/ovirt-node/hooks/on-shutdown dist_onboot_SCRIPTS = \ on-boot/03-validate-owner-ssh-keys \ $(NULL) + +dist_onshutdown_SCRIPTS = \ + on-shutdown/01-save-virtwho.py + +install-data-hook: + mv $(DESTDIR)$(libexecdir)/ovirt-node/hooks/on-shutdown/01-save-virtwho.py \ + $(DESTDIR)$(libexecdir)/ovirt-node/hooks/on-shutdown/01-save-virtwho diff --git a/hooks/README b/hooks/README index b544b01..ae75767 100644 --- a/hooks/README +++ b/hooks/README @@ -1,2 +1,2 @@ on-boot dir contains scripts that will run during the boot. - +on-shutdown dir contains scripts that will be run during shutdown. diff --git a/hooks/on-shutdown/01-save-virtwho.py b/hooks/on-shutdown/01-save-virtwho.py new file mode 100755 index 0000000..9c5d6b1 --- /dev/null +++ b/hooks/on-shutdown/01-save-virtwho.py @@ -0,0 +1,23 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# 01-save-virtwho - Copyright (C) 2015 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +from glob import glob +from ovirt.node.utils.fs import Config + + +if __name__ == "__main__": + try: + Config().persist("/etc/virt-who.d/") + except: + "Couldn't persist %s!" % "/etc/virt-who.d" + raise diff --git a/ovirt-node.spec.in b/ovirt-node.spec.in index 5ee4523..c489d4c 100644 --- a/ovirt-node.spec.in +++ b/ovirt-node.spec.in @@ -579,6 +579,7 @@ %{__install} -d -m0755 %{buildroot}%{_libexecdir}/ovirt-node/hooks/post-upgrade %{__install} -d -m0755 %{buildroot}%{_libexecdir}/ovirt-node/hooks/rollback %{__install} -d -m0755 %{buildroot}%{_libexecdir}/ovirt-node/hooks/on-boot +%{__install} -d -m0755 %{buildroot}%{_libexecdir}/ovirt-node/hooks/on-shutdown %{__install} -d -m0755 %{buildroot}%{_libexecdir}/ovirt-node/hooks/on-changed-boot-image %if 0%{?is_systemd} diff --git a/services/ovirt-node-hooks.service b/services/ovirt-node-hooks.service index e71e6d3..45894e7 100644 --- a/services/ovirt-node-hooks.service +++ b/services/ovirt-node-hooks.service @@ -8,6 +8,7 @@ Type=oneshot RemainAfterExit=yes ExecStart=/usr/libexec/ovirt-node-hooks trigger on-boot +ExecStop=/usr/libexec/ovirt-node-hooks trigger on-shutdown [Install] WantedBy=multi-user.target -- To view, visit https://gerrit.ovirt.org/49029 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2cc830b1b4b28db29a3fe995ac31c36b15cf6676 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-node Gerrit-Branch: ovirt-3.6 Gerrit-Owner: Fabian Deutsch <[email protected]> Gerrit-Reviewer: Fabian Deutsch <[email protected]> _______________________________________________ node-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/node-patches
