From f27ca04f4ca67d77e1c0b2f91902887e75e9094a Mon Sep 17 00:00:00 2001
From: Vivien Alger <algervivie@tiolive.com>
Date: Fri, 5 Jul 2013 15:19:58 +0200
Subject: [PATCH] Add working monitor for KVM.

---
 software/kvm/common.cfg          |  3 +-
 software/kvm/development.cfg     |  3 ++
 software/kvm/instance-kvm.cfg.in | 47 +++++++++++++++++++++++++++++---
 3 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/software/kvm/common.cfg b/software/kvm/common.cfg
index e10f8a7a3..a3cfa97b4 100644
--- a/software/kvm/common.cfg
+++ b/software/kvm/common.cfg
@@ -9,6 +9,7 @@ extends =
   ../../component/logrotate/buildout.cfg
   ../../component/noVNC/buildout.cfg
   ../../component/openssl/buildout.cfg
+  ../../component/dcron/buildout.cfg
   ../../stack/nodejs.cfg
   ../../stack/slapos.cfg
 
@@ -70,7 +71,7 @@ command =
 [template-kvm]
 recipe = slapos.recipe.template
 url = ${:_profile_base_location_}/instance-kvm.cfg.in
-md5sum = 87197471aa93863c310204e8865b5ac1
+md5sum = cb8adfb70882a07e1df3943983c27963
 output = ${buildout:directory}/template-kvm.cfg
 mode = 0644
 
diff --git a/software/kvm/development.cfg b/software/kvm/development.cfg
index f47846f74..852db9dab 100644
--- a/software/kvm/development.cfg
+++ b/software/kvm/development.cfg
@@ -31,3 +31,6 @@ update-command = ${:command}
 command =
   grep parts ${buildout:develop-eggs-directory}/slapos.cookbook.egg-link &&
   grep parts ${buildout:develop-eggs-directory}/slapos.toolbox.egg-link
+
+[versions]
+websockify = 0.3.0
\ No newline at end of file
diff --git a/software/kvm/instance-kvm.cfg.in b/software/kvm/instance-kvm.cfg.in
index 85305ce65..956018652 100644
--- a/software/kvm/instance-kvm.cfg.in
+++ b/software/kvm/instance-kvm.cfg.in
@@ -10,6 +10,9 @@ parts =
   kvm-promise
   websockify-sighandler
   novnc-promise
+  kvm-monitor
+  cron
+  cron-entry-monitor
   frontend-promise
 
 eggs-directory = ${buildout:eggs-directory}
@@ -22,12 +25,16 @@ etc = $${buildout:directory}/etc
 bin = $${buildout:directory}/bin
 srv = $${buildout:directory}/srv
 var = $${buildout:directory}/var
+log = $${:var}/log
 scripts = $${:etc}/run
 services = $${:etc}/service
 promises = $${:etc}/promise
 novnc-conf = $${:etc}/novnc
 run = $${:var}/run
 ca-dir = $${:srv}/ssl
+cron-entries = $${:etc}/cron.d
+crontabs = $${:etc}/crontabs
+cronstamps = $${:etc}/cronstamps
 
 [create-mac]
 recipe = slapos.cookbook:generate.mac
@@ -123,9 +130,41 @@ port = $${novnc-instance:port}
 
 
 [kvm-monitor]
-recipe = slapos.cookbook:generic.slapmonitor
-db-path = $${directory:srv}/slapmonitor_database
-
+recipe = slapos.cookbook:wrapper
+wrapper-path = $${directory:services}/kvm_monitor
+command-line = ${buildout:bin-directory}/kvm.monitor.test 
+             $${buildout:directory}/buildout-switch-softwaretype.cfg
+             $${buildout:directory}/report.xml
+             -s slap-parameter
+             -opts disk-size ram-size cpu-count
+
+
+
+#----------------
+#--
+#-- Deploy cron.
+
+[cron]
+recipe = slapos.cookbook:cron
+dcrond-binary = ${dcron:location}/sbin/crond
+cron-entries = $${directory:cron-entries}
+crontabs = $${directory:crontabs}
+cronstamps = $${directory:cronstamps}
+catcher = $${cron-simplelogger:wrapper}
+binary = $${directory:services}/crond
+
+[cron-simplelogger]
+recipe = slapos.cookbook:simplelogger
+wrapper = $${directory:bin}/cron_simplelogger
+log = $${directory:log}/crond.log
+
+
+[cron-entry-monitor]
+<= cron
+recipe = slapos.cookbook:cron.d
+name = kvm_monitor
+frequency = 0 0 * * *
+command = $${kvm-monitor:wrapper-path}
 
 [request-slave-frontend]
 recipe = slapos.cookbook:requestoptional
@@ -164,7 +203,7 @@ curl_path = ${curl:location}/bin/curl
 # Default values if not specified
 frontend-software-type = frontend
 frontend-software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.92:/software/kvm/software.cfg
-
+frontend-instance-guid = 
 nbd-port = 1024
 nbd-host = debian.nbd.vifib.net
 nbd2-port = 1024
-- 
2.30.9