Browse code

xenapi: Setup and Rotate text console logs

This patch installs the cronjob that rotates/sets up the text console
logs of the guests.

Related to blueprint xenapi-server-log

Change-Id: Ie4c778b54f69519fbb80aa0d9822383f55a1e2f9

Mate Lakat authored on 2013/07/24 19:06:27
Showing 2 changed files
... ...
@@ -53,18 +53,18 @@ function find_xapi_plugins_dir {
53 53
     find $1 -path '*/xapi.d/plugins' -type d -print
54 54
 }
55 55
 
56
-function install_xapi_plugins_from_zipball {
56
+function install_xapi_plugins_from {
57 57
     local XAPI_PLUGIN_DIR
58 58
     local EXTRACTED_FILES
59 59
     local EXTRACTED_PLUGINS_DIR
60 60
 
61
+    EXTRACTED_FILES="$1"
62
+
61 63
     XAPI_PLUGIN_DIR=$(xapi_plugin_location)
62 64
 
63
-    EXTRACTED_FILES=$(extract_remote_zipball $1)
64 65
     EXTRACTED_PLUGINS_DIR=$(find_xapi_plugins_dir $EXTRACTED_FILES)
65 66
 
66 67
     cp -pr $EXTRACTED_PLUGINS_DIR/* $XAPI_PLUGIN_DIR
67
-    rm -rf $EXTRACTED_FILES
68 68
     chmod a+x ${XAPI_PLUGIN_DIR}*
69 69
 }
70 70
 
... ...
@@ -63,12 +63,25 @@ fi
63 63
 
64 64
 ## Nova plugins
65 65
 NOVA_ZIPBALL_URL=${NOVA_ZIPBALL_URL:-$(zip_snapshot_location $NOVA_REPO $NOVA_BRANCH)}
66
-install_xapi_plugins_from_zipball $NOVA_ZIPBALL_URL
66
+EXTRACTED_NOVA=$(extract_remote_zipball "$NOVA_ZIPBALL_URL")
67
+install_xapi_plugins_from "$EXTRACTED_NOVA"
68
+
69
+LOGROT_SCRIPT=$(find "$EXTRACTED_NOVA" -name "rotate_xen_guest_logs.sh" -print)
70
+if [ -n "$LOGROT_SCRIPT" ]; then
71
+    mkdir -p "/var/log/xen/guest"
72
+    cp "$LOGROT_SCRIPT" /root/consolelogrotate
73
+    chmod +x /root/consolelogrotate
74
+    echo "* * * * * /root/consolelogrotate" | crontab
75
+fi
76
+
77
+rm -rf "$EXTRACTED_NOVA"
67 78
 
68 79
 ## Install the netwrap xapi plugin to support agent control of dom0 networking
69 80
 if [[ "$ENABLED_SERVICES" =~ "q-agt" && "$Q_PLUGIN" = "openvswitch" ]]; then
70 81
     NEUTRON_ZIPBALL_URL=${NEUTRON_ZIPBALL_URL:-$(zip_snapshot_location $NEUTRON_REPO $NEUTRON_BRANCH)}
71
-    install_xapi_plugins_from_zipball $NEUTRON_ZIPBALL_URL
82
+    EXTRACTED_NEUTRON=$(extract_remote_zipball "$NEUTRON_ZIPBALL_URL")
83
+    install_xapi_plugins_from "$EXTRACTED_NEUTRON"
84
+    rm -rf "$EXTRACTED_NEUTRON"
72 85
 fi
73 86
 
74 87
 create_directory_for_kernels