[node-patches] Change in ovirt-node[master]: init: Add support for logrotate_max_size cmdline args

hadong0720 at gmail.com hadong0720 at gmail.com
Tue Aug 6 09:26:04 UTC 2013


hadong has uploaded a new change for review.

Change subject: init: Add support for logrotate_max_size cmdline args
......................................................................

init: Add support for logrotate_max_size cmdline args

This patch adds support for setting logrotate_max_size in cmdline args:
logrotate_max_size=number
This informations are sued to set logrotate_max_size during
an auto-installation.

Change-Id: Iea5aaea8e16390415db69458937d4bb495c9734d
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=986830
Signed-off-by: hadong <hadong0720 at gmail.com>
---
M scripts/ovirt-init-functions.sh.in
M src/ovirtnode/log.py
2 files changed, 39 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/07/17707/1

diff --git a/scripts/ovirt-init-functions.sh.in b/scripts/ovirt-init-functions.sh.in
index b8f7cb8..76336b7 100644
--- a/scripts/ovirt-init-functions.sh.in
+++ b/scripts/ovirt-init-functions.sh.in
@@ -233,7 +233,7 @@
     #   collectd=server[:port]
     #   hostname=fqdn
     #   tuned=profile
-    #   TBD logrotate maxsize
+    #   logrotate_max_size=number
 
     #   BOOTIF=link|eth*|<MAC> (appended by pxelinux)
     # network boot interface is assumed to be on management network where
@@ -392,6 +392,9 @@
     #tuned=profile
     # the tuned profile to run by default
     tuned_profile=
+
+    #logrotate_max_size=number
+    logrotate_max_size=
 
     cat /etc/system-release >> $OVIRT_LOGFILE
 
@@ -712,6 +715,9 @@
             tuned*)
             tuned_profile=${i#tuned=}
             ;;
+            logrotate_max_size=*)
+            logrotate_max_size=${i#logrotate_max_size=}
+            ;;
             swap_encrypt=* | ovirt_swap_encrypt=* )
             i=${i#ovirt_swap_encrypt=}
             i=${i#swap_encrypt=}
@@ -784,7 +790,7 @@
 
 
     # save boot parameters as defaults for ovirt-config-*
-    params="bootif init init_app vol_boot_size vol_efi_size vol_swap_size vol_root_size vol_config_size vol_logging_size vol_data_size vol_swap2_size vol_data2_size crypt_swap crypt_swap2 upgrade standalone overcommit ip_address ip_netmask ip_gateway ipv6 dns ntp vlan ssh_pwauth syslog_server syslog_port collectd_server collectd_port bootparams hostname firstboot runtime_mode kdump_nfs iscsi_name snmp_password install netconsole_server netconsole_port stateless cim_enabled wipe_fakeraid iscsi_init iscsi_target_name iscsi_target_host iscsi_target_port iscsi_install network_layout bond_name bond_slaves bond_options tuned_profile"
+    params="bootif init init_app vol_boot_size vol_efi_size vol_swap_size vol_root_size vol_config_size vol_logging_size vol_data_size vol_swap2_size vol_data2_size crypt_swap crypt_swap2 upgrade standalone overcommit ip_address ip_netmask ip_gateway ipv6 dns ntp vlan ssh_pwauth syslog_server syslog_port collectd_server collectd_port bootparams hostname firstboot runtime_mode kdump_nfs iscsi_name snmp_password install netconsole_server netconsole_port stateless cim_enabled wipe_fakeraid iscsi_init iscsi_target_name iscsi_target_host iscsi_target_port iscsi_install network_layout bond_name bond_slaves bond_options tuned_profile logrotate_max_size"
     # mount /config unless firstboot is forced
     if [ "$firstboot" != "1" ]; then
         mount_config
diff --git a/src/ovirtnode/log.py b/src/ovirtnode/log.py
index 96c1888..7994581 100755
--- a/src/ovirtnode/log.py
+++ b/src/ovirtnode/log.py
@@ -114,6 +114,16 @@
     return True
 
 
+def set_logrotate_size(size):
+    try:
+        _functions.augtool("set", \
+                           "/files/etc/logrotate.d/ovirt-node/rule/size", size)
+        _functions.ovirt_store_config("/etc/logrotate.d/ovirt-node")
+        return True
+    except:
+        return False
+
+
 def get_rsyslog_config():
     rsyslog_config = open(RSYSLOG_FILE)
     for line in rsyslog_config:
@@ -190,8 +200,29 @@
         return True
 
 
+def logrotate_auto():
+    logroate_max_size = ""
+    if not "OVIRT_LOGROTATE_MAX_SIZE" in _functions.OVIRT_VARS:
+        logger.warn("OVIRT_LOGROTATE_MAX_SIZE not found!")
+        return False
+    else:
+        logroate_max_size = _functions.OVIRT_VARS["OVIRT_LOGROTATE_MAX_SIZE"]
+        if not logroate_max_size is "":
+            logger.info("Found! Using logroate_max_size " + logroate_max_size)
+            set_logrotate_size(logroate_max_size)
+            return True
+        else:
+            logger.warn("logroate_max_size not found!")
+            return False
+
+
 def logging_auto():
     try:
+        logrotate_auto()
+        logger.info("Logrotate size Configuration Completed")
+    except:
+        logger.warn("Logrotate size Configuration Failed")
+    try:
         syslog_auto()
         logger.info("Syslog Configuration Completed")
     except:


-- 
To view, visit http://gerrit.ovirt.org/17707
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iea5aaea8e16390415db69458937d4bb495c9734d
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: hadong <hadong0720 at gmail.com>



More information about the node-patches mailing list