summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorKamil Kisiel <kamil@kamilkisiel.net>2009-11-03 17:31:32 +0000
committerKamil Kisiel <kamil@kamilkisiel.net>2009-11-03 17:31:32 +0000
commit232aed6a4c276172d5253273d66264333cc79cec (patch)
tree15bde0d769e3d1dafd18e27fe288d8637ba7bb59 /src/lib
parentba729b554d23e855da068887fa32553e27d6856f (diff)
downloadbcfg2-232aed6a4c276172d5253273d66264333cc79cec.tar.gz
bcfg2-232aed6a4c276172d5253273d66264333cc79cec.tar.bz2
bcfg2-232aed6a4c276172d5253273d66264333cc79cec.zip
Moved launchd plist cache to __init__ function.
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5524 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Client/Tools/launchd.py45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/lib/Client/Tools/launchd.py b/src/lib/Client/Tools/launchd.py
index bcdb50df8..cd786a7e8 100644
--- a/src/lib/Client/Tools/launchd.py
+++ b/src/lib/Client/Tools/launchd.py
@@ -5,26 +5,6 @@ import os
import Bcfg2.Client.Tools
import popen2
-'''Locate plist file that provides given reverse-fqdn name
-/Library/LaunchAgents Per-user agents provided by the administrator.
-/Library/LaunchDaemons System wide daemons provided by the administrator.
-/System/Library/LaunchAgents Mac OS X Per-user agents.
-/System/Library/LaunchDaemons Mac OS X System wide daemons.'''
-plistLocations = ["/Library/LaunchDaemons", "/System/Library/LaunchDaemons"]
-plistMapping = {}
-for directory in plistLocations:
- for daemon in os.listdir(directory):
- try:
- if daemon.endswith(".plist"):
- d = daemon[:-6]
- else:
- d = daemon
- (stdout, _) = popen2.popen2('defaults read %s/%s Label' % (directory, d))
- label = stdout.read().strip()
- plistMapping[label] = "%s/%s" % (directory, daemon)
- except KeyError: #perhaps this could be more robust
- pass
-
class launchd(Bcfg2.Client.Tools.Tool):
'''Support for Mac OS X Launchd Services'''
__handles__ = [('Service', 'launchd')]
@@ -36,8 +16,31 @@ class launchd(Bcfg2.Client.Tools.Tool):
currently requires the path to the plist to load/unload,
and Name is acually a reverse-fqdn (or the label)
'''
+ def __init__(self, logger, setup, config):
+ Bcfg2.Client.Tools.Tool.__init__(self, logger, setup, config)
+
+ '''Locate plist file that provides given reverse-fqdn name
+ /Library/LaunchAgents Per-user agents provided by the administrator.
+ /Library/LaunchDaemons System wide daemons provided by the administrator.
+ /System/Library/LaunchAgents Mac OS X Per-user agents.
+ /System/Library/LaunchDaemons Mac OS X System wide daemons.'''
+ plistLocations = ["/Library/LaunchDaemons", "/System/Library/LaunchDaemons"]
+ self.plistMapping = {}
+ for directory in plistLocations:
+ for daemon in os.listdir(directory):
+ try:
+ if daemon.endswith(".plist"):
+ d = daemon[:-6]
+ else:
+ d = daemon
+ (stdout, _) = popen2.popen2('defaults read %s/%s Label' % (directory, d))
+ label = stdout.read().strip()
+ self.plistMapping[label] = "%s/%s" % (directory, daemon)
+ except KeyError: #perhaps this could be more robust
+ pass
+
def FindPlist(self, entry):
- return plistMapping.get(entry.get('name'), None)
+ return self.plistMapping.get(entry.get('name'), None)
def os_version(self):
version = ""