Douglas Schilling Landgraf has uploaded a new change for review. Change subject: hooks: Adding hooks for ovirt-node-upgrade ......................................................................
hooks: Adding hooks for ovirt-node-upgrade Currently ovirt-node offers ovirt-node-upgrade tool to upgrade node images. This patch adds the pre-upgrade script for vdsm tasks before the upgrade. Change-Id: I986fe6edb8f5619dcbca33cccab080245654fd02 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1079087 Signed-off-by: Douglas Schilling Landgraf <[email protected]> --- M Makefile.am M configure.ac A hooks/Makefile.am A hooks/README A hooks/pre-upgrade/01-vdsm M ovirt-node-plugin-vdsm.spec.in 6 files changed, 99 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-node-plugin-vdsm refs/changes/51/28251/1 diff --git a/Makefile.am b/Makefile.am index 55d6ff9..694d7b8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,6 +25,7 @@ SUBDIRS = \ conf \ + hooks \ src \ recipe diff --git a/configure.ac b/configure.ac index 353ddf7..44b85cb 100644 --- a/configure.ac +++ b/configure.ac @@ -8,6 +8,7 @@ src/Makefile src/config.py conf/Makefile + hooks/Makefile recipe/Makefile ovirt-node-plugin-vdsm.spec]) AC_OUTPUT diff --git a/hooks/Makefile.am b/hooks/Makefile.am new file mode 100644 index 0000000..8ac56cf --- /dev/null +++ b/hooks/Makefile.am @@ -0,0 +1,22 @@ +# Copyright (C) 2014 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. A copy of the GNU General Public License is +# also available at http://www.gnu.org/copyleft/gpl.html. + +vdsmplugindir = $(libexecdir)/ovirt-node/hooks/pre-upgrade/ + +dist_vdsmplugin_DATA = \ + pre-upgrade/01-vdsm \ + $(NULL) diff --git a/hooks/README b/hooks/README new file mode 100644 index 0000000..c138ef9 --- /dev/null +++ b/hooks/README @@ -0,0 +1,18 @@ +This hooks dir contains the hooks to ovirt-node-upgrade tool. + +Notes +======== +pre-upgrade: +This directory should contain any PRE-upgrade script needed for upgrade + +post-upgrade: +This directory should contain any POST-upgrade script needed for upgrade + +Naming and Permissions +======================= +The naming of script should follow: '01-name-of-script', '02-name-of-script', the numbering +is the order of running. Permission should be 755. + +Format +=========== +These pre and post script can be in python, bash, etc. diff --git a/hooks/pre-upgrade/01-vdsm b/hooks/pre-upgrade/01-vdsm new file mode 100755 index 0000000..b4d4758 --- /dev/null +++ b/hooks/pre-upgrade/01-vdsm @@ -0,0 +1,47 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# 01-vdsm - Copyright (C) 2014 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. +import shlex +import sys + +from vdsm import utils + + +def main(): + rc, out, err = utils.execCmd( + shlex.split("vdsm-tool service-status vdsmd"), + sudo=False, + raw=True + ) + if rc == 0: + rc, out, err = utils.execCmd( + shlex.split("vdsm-tool service-stop vdsmd"), + sudo=True, + raw=True + ) + if rc != 0: + msg = "<BSTRAP component='RHEL_INSTALL' status='FAIL'" \ + " message='Cannot stop vdsm daemon before we" \ + " start the upgrade, please verify!'/>" + else: + msg = "<BSTRAP component='RHEL_INSTALL' status='OK'" \ + " message='vdsm daemon stopped for upgrade process!'/>" + else: + msg = "<BSTRAP component='RHEL_INSTALL' status='WARN'" \ + " message='vdsm daemon is already down before we" \ + " stop it for upgrade.'/>" + print(msg) + return rc + +if __name__ == "__main__": + sys.exit(main()) diff --git a/ovirt-node-plugin-vdsm.spec.in b/ovirt-node-plugin-vdsm.spec.in index 09a6dfd..fd7e34f 100644 --- a/ovirt-node-plugin-vdsm.spec.in +++ b/ovirt-node-plugin-vdsm.spec.in @@ -10,7 +10,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot URL: http://www.ovirt.org/ -Requires: ovirt-node >= 3.0.0 +Requires: ovirt-node >= 3.0.4 Requires: python Requires: vdsm-reg >= 4.10.3 Requires: ovirt-host-deploy-offline >= 1.1.0 @@ -49,7 +49,15 @@ %{__rm} -rf %{buildroot} make install DESTDIR=%{buildroot} +# hooks to ovirt-node-upgrade +install -Dm 0755 hooks/pre-upgrade/01-vdsm \ + %{buildroot}%{_libexecdir}/ovirt-node/hooks/pre-upgrade/01-vdsm + + %post +# persist hook to ovirt-node-upgrade +persist {_libexecdir}/ovirt-node/hooks/pre-upgrade/01-vdsm >/dev/null 2>&1 || : + # reserve vdsm port 54321 augtool << \EOF_sysctl set /files/etc/sysctl.conf/net.ipv4.ip_local_reserved_ports 54321 @@ -73,6 +81,7 @@ %files %{python_sitelib}/ovirt/node/setup/vdsm +%{_libexecdir}/ovirt-node/hooks/pre-upgrade/01-vdsm %{_sysconfdir}/ovirt-plugins.d %changelog -- To view, visit http://gerrit.ovirt.org/28251 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I986fe6edb8f5619dcbca33cccab080245654fd02 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-node-plugin-vdsm Gerrit-Branch: master Gerrit-Owner: Douglas Schilling Landgraf <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
