5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
26 # Default config file name position
27 configfile = "/etc/time-slider/timesliderd.conf"
30 default_properties = {
31 'application/time-slider': {
32 'zpool/emergency-level': 95,
33 'zpool/critical-level': 90,
34 'zpool/warning-level': 80,
36 'daemon/verbose': 'true',
39 'system/filesystem/zfs/auto-snapshot:monthly': {
40 'zfs/interval': 'months',
45 'system/filesystem/zfs/auto-snapshot:weekly': {
46 'zfs/interval': 'days',
51 'system/filesystem/zfs/auto-snapshot:daily': {
52 'zfs/interval': 'days',
57 'system/filesystem/zfs/auto-snapshot:hourly': {
58 'zfs/interval': 'hours',
63 'system/filesystem/zfs/auto-snapshot:frequent': {
64 'zfs/interval': 'minutes',
71 class MyConfigParser(ConfigParser.ConfigParser):
73 ConfigParser.ConfigParser.__init__(self)
75 for section, content in default_properties.iteritems():
76 if not self.has_section(section):
77 self.add_section(section)
78 for k,v in content.iteritems():
79 self.set(section, k, v)
83 self.config = MyConfigParser()
84 self.config.read(configfile)
86 def get(self, section, option):
88 result = self.config.get(section, option)
89 sys.stderr.write('CONFIG: GET section %s, option %s with value %s\n' % (section, option, result))
91 except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
92 sys.stderr.write('CONFIG: NOTFOUND section %s, option %s\n' % (section, option))
96 return self.config.sections()