From dd341e4d2d33964f9c9748bc7bbb4da40264153d Mon Sep 17 00:00:00 2001 From: Chris MacNaughton Date: Thu, 4 Apr 2019 10:17:03 +0200 Subject: [PATCH] Sync charm-helpers for Stein release As a part of the Stein release, we need to ensure that charmhelpers is up to date. Change-Id: Ie7174e1a9788a82c592b25441a3cbc1c2c3f0fd4 --- charmhelpers/contrib/openstack/context.py | 27 +++++++++++++++++++ .../contrib/openstack/templates/logrotate | 9 +++++++ 2 files changed, 36 insertions(+) create mode 100644 charmhelpers/contrib/openstack/templates/logrotate diff --git a/charmhelpers/contrib/openstack/context.py b/charmhelpers/contrib/openstack/context.py index fc950877..d5133713 100644 --- a/charmhelpers/contrib/openstack/context.py +++ b/charmhelpers/contrib/openstack/context.py @@ -1935,3 +1935,30 @@ class VersionsContext(OSContextGenerator): return { 'openstack_release': ostack, 'operating_system_release': osystem} + + +class LogrotateContext(OSContextGenerator): + """Common context generator for logrotate.""" + + def __init__(self, location, interval, count): + """ + :param location: Absolute path for the logrotate config file + :type location: str + :param interval: The interval for the rotations. Valid values are + 'daily', 'weekly', 'monthly', 'yearly' + :type interval: str + :param count: The logrotate count option configures the 'count' times + the log files are being rotated before being + :type count: int + """ + self.location = location + self.interval = interval + self.count = 'rotate {}'.format(count) + + def __call__(self): + ctxt = { + 'logrotate_logs_location': self.location, + 'logrotate_interval': self.interval, + 'logrotate_count': self.count, + } + return ctxt diff --git a/charmhelpers/contrib/openstack/templates/logrotate b/charmhelpers/contrib/openstack/templates/logrotate new file mode 100644 index 00000000..b2900d09 --- /dev/null +++ b/charmhelpers/contrib/openstack/templates/logrotate @@ -0,0 +1,9 @@ +/var/log/{{ logrotate_logs_location }}/*.log { + {{ logrotate_interval }} + {{ logrotate_count }} + compress + delaycompress + missingok + notifempty + copytruncate +}