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

hadong0720 at gmail.com hadong0720 at gmail.com
Fri Aug 30 04:24:03 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: Ide628895f15ed8f8dc5c047228300868a53f2a0c
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, 28 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/09/18709/1

diff --git a/scripts/ovirt-init-functions.sh.in b/scripts/ovirt-init-functions.sh.in
index e57dea8..52a29ab 100644
--- a/scripts/ovirt-init-functions.sh.in
+++ b/scripts/ovirt-init-functions.sh.in
@@ -237,7 +237,7 @@
     #   disable_aes_ni=[y|n]
     #   use_strong_rng=<bytes>
     #   nfsv4_domain=domain
-    #   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
@@ -413,6 +413,8 @@
     # default keyboard layout
     keyboard_layout=
 
+    #logrotate_max_size=number
+    logrotate_max_size=
 
     cat /etc/system-release >> $OVIRT_LOGFILE
 
@@ -748,6 +750,9 @@
             keyboard*)
             keyboard_layout=${i#keyboard=}
             ;;
+            logrotate_max_size=*)
+            logrotate_max_size=${i#logrotate_max_size=}
+            ;;
             swap_encrypt=* | ovirt_swap_encrypt=* )
             i=${i#ovirt_swap_encrypt=}
             i=${i#swap_encrypt=}
@@ -820,7 +825,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 nfsv4_domain use_strong_rng disable_aes_ni keyboard_layout"
+    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 nfsv4_domain use_strong_rng disable_aes_ni keyboard_layout 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..b5b71d2 100755
--- a/src/ovirtnode/log.py
+++ b/src/ovirtnode/log.py
@@ -190,8 +190,29 @@
         return True
 
 
+def logrotate_auto():
+    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)
+        from ovirt.node.config import defaults
+        try:
+            model = defaults.Logrotate()
+            model.update(max_size=logroate_max_size)
+            tx = model.transaction()
+            tx()
+        except:
+            pass
+        return True
+    else:
+        logger.warn("Invalid logrotate max size: %s" % logroate_max_size)
+        return False
+
+
 def logging_auto():
     try:
+        logrotate_auto()
+        logger.info("Logrotate size Configuration Completed")
+    try:
         syslog_auto()
         logger.info("Syslog Configuration Completed")
     except:


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ide628895f15ed8f8dc5c047228300868a53f2a0c
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