From 663ed0cea3e21537792c7cd3354478bc8b333d80 Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Thu, 8 Nov 2007 11:51:03 +0000
Subject: [PATCH] Implement sample hook.

Reviewed-by: schreiberal
---
 configure.ac         |  1 +
 qa/Makefile.am       |  1 +
 qa/hooks/Makefile.am |  2 ++
 qa/hooks/datehook.py | 42 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 46 insertions(+)
 create mode 100644 qa/hooks/Makefile.am
 create mode 100644 qa/hooks/datehook.py

diff --git a/configure.ac b/configure.ac
index c1bcd56bd..d39cfaa35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,6 +76,7 @@ AC_CONFIG_FILES([
   lib/Makefile
   man/Makefile
   qa/Makefile
+  qa/hooks/Makefile
   scripts/Makefile
   test/Makefile
   tools/Makefile
diff --git a/qa/Makefile.am b/qa/Makefile.am
index 0c4d8453f..3f080ee48 100644
--- a/qa/Makefile.am
+++ b/qa/Makefile.am
@@ -1,3 +1,4 @@
+SUBDIRS = hooks
 EXTRA_DIST = ganeti-qa.py qa-sample.yaml \
 	qa_cluster.py \
 	qa_config.py \
diff --git a/qa/hooks/Makefile.am b/qa/hooks/Makefile.am
new file mode 100644
index 000000000..7f0c8a355
--- /dev/null
+++ b/qa/hooks/Makefile.am
@@ -0,0 +1,2 @@
+EXTRA_DIST = datehook.py
+CLEANFILES = *.py[co]
diff --git a/qa/hooks/datehook.py b/qa/hooks/datehook.py
new file mode 100644
index 000000000..590bc8556
--- /dev/null
+++ b/qa/hooks/datehook.py
@@ -0,0 +1,42 @@
+# Copyright (C) 2007 Google 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# 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.
+
+
+"""Example QA hook.
+
+"""
+
+from ganeti import utils
+
+import qa_utils
+import qa_config
+
+from qa_utils import AssertEqual, StartSSH
+
+
+class DateHook:
+  def run(self, ctx):
+    if ctx.name == 'cluster-init' and ctx.phase == 'pre':
+      self._CallDate(ctx)
+
+  def _CallDate(self, ctx):
+    for node in qa_config.get('nodes'):
+      cmd = ['date']
+      AssertEqual(StartSSH(node['primary'],
+                           utils.ShellQuoteArgs(cmd)).wait(), 0)
+
+hook = DateHook
-- 
GitLab