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]
25 import time_slider.util as util
27 # Default config file name position
28 configfile = "/etc/time-slider/timesliderd.conf"
31 default_properties = {
32 'application/time-slider': {
33 'zpool/emergency-level': 95,
34 'zpool/critical-level': 90,
35 'zpool/warning-level': 80,
37 'daemon/verbose': 'true',
40 'system/filesystem/zfs/auto-snapshot:monthly': {
41 'zfs/interval': 'months',
46 'system/filesystem/zfs/auto-snapshot:weekly': {
47 'zfs/interval': 'days',
52 'system/filesystem/zfs/auto-snapshot:daily': {
53 'zfs/interval': 'days',
58 'system/filesystem/zfs/auto-snapshot:hourly': {
59 'zfs/interval': 'hours',
64 'system/filesystem/zfs/auto-snapshot:frequent': {
65 'zfs/interval': 'minutes',
72 class MyConfigParser(ConfigParser.ConfigParser):
74 ConfigParser.ConfigParser.__init__(self)
76 for section, content in default_properties.iteritems():
77 if not self.has_section(section):
78 self.add_section(section)
79 for k,v in content.iteritems():
80 self.set(section, k, str(v))
84 self.config = MyConfigParser()
85 self.config.read(configfile)
87 def get(self, section, option):
89 result = self.config.get(section, option)
90 util.debug('CONFIG: GET section %s, option %s with value %s\n' % (section, option, result), 1)
92 except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
93 util.debug('CONFIG: NOTFOUND section %s, option %s\n' % (section, option), 1)
97 return self.config.sections()
100 MyConfigParser().write(sys.stdout)