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 #from string import letters, digits
26 from plugin import pluginsmf
28 RSYNCPROPGROUP = "rsync"
29 RSYNCDIRPREFIX = "TIMESLIDER"
30 RSYNCDIRSUFFIX = ".time-slider/rsync"
31 RSYNCPARTIALSUFFIX = ".time-slider/.rsync-partial"
32 RSYNCTRASHSUFFIX = ".time-slider/.trash"
33 RSYNCLOCKSUFFIX = ".time-slider/.rsync-lock"
34 RSYNCLOGSUFFIX = ".time-slider/.rsync-log"
35 RSYNCCONFIGFILE = ".rsync-config"
36 RSYNCFSTAG = "org.opensolaris:time-slider-rsync"
38 class RsyncSMF(pluginsmf.PluginSMF):
40 def __init__(self, instanceName):
41 pluginsmf.PluginSMF.__init__(self, instanceName)
42 self._archivedSchedules = None
44 def get_cleanup_threshold(self):
45 result = self.get_prop(RSYNCPROPGROUP, "cleanup_threshold").strip()
48 def get_target_dir(self):
49 result = self.get_prop(RSYNCPROPGROUP, "target_dir").strip()
50 # Strip out '\' characters inserted by svcprop
51 return result.strip().replace('\\', '')
53 def get_target_key(self):
54 return self.get_prop(RSYNCPROPGROUP, "target_key").strip()
56 def set_target_dir(self, path):
57 self.set_string_prop(RSYNCPROPGROUP, "target_dir", path)
59 def set_target_key(self, key):
60 self.set_string_prop(RSYNCPROPGROUP, "target_key", key)
62 def get_archived_schedules(self):
63 #FIXME Use mutex locking to make MT-safe
64 if self._archivedSchedules == None:
65 self._archivedSchedules = []
66 value = self.get_prop(RSYNCPROPGROUP, "archived_schedules")
68 # Strip out '\' characters inserted by svcprop
69 archiveList = value.strip().replace('\\', '').split(',')
70 for schedule in archiveList:
71 self._archivedSchedules.append(schedule.strip())
72 return self._archivedSchedules
74 def get_rsync_verbose(self):
75 value = self.get_prop(RSYNCPROPGROUP, "verbose")
82 ret = "SMF Instance:\n" +\
83 "\tName:\t\t\t%s\n" % (self.instance_name) +\
84 "\tState:\t\t\t%s\n" % (self.svcstate) + \
85 "\tTriggers:\t\t%s\n" % str(self.get_triggers()) + \
86 "\tTarget Dir:\t%s\n" % self.get_target_dir() + \
87 "\tVerbose:\t\t\'%s\'" % str((self.get_verbose()))