diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2009-01-23 02:57:34 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2009-01-23 02:57:34 +0000 |
commit | 154c97c06501ef66e0a103644731ed53d1096fc3 (patch) | |
tree | ac1f97249e4209e0dc49a312d87b9b674faa6ee0 /src/lib/Client/Tools/SMF.py | |
parent | f7f0b49a8d6e7ffef6690184bf083a678dc2e5fb (diff) | |
download | bcfg2-154c97c06501ef66e0a103644731ed53d1096fc3.tar.gz bcfg2-154c97c06501ef66e0a103644731ed53d1096fc3.tar.bz2 bcfg2-154c97c06501ef66e0a103644731ed53d1096fc3.zip |
Simplify service configuration; make all services use common restart framework
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5040 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Client/Tools/SMF.py')
-rw-r--r-- | src/lib/Client/Tools/SMF.py | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/src/lib/Client/Tools/SMF.py b/src/lib/Client/Tools/SMF.py index 399418986..bbe9a3055 100644 --- a/src/lib/Client/Tools/SMF.py +++ b/src/lib/Client/Tools/SMF.py @@ -4,7 +4,7 @@ __revision__ = '$Revision$' import glob, os import Bcfg2.Client.Tools -class SMF(Bcfg2.Client.Tools.Tool): +class SMF(Bcfg2.Client.Tools.SvcTool): '''Support for Solaris SMF Services''' __handles__ = [('Service', 'smf')] __execs__ = ['/usr/sbin/svcadm', '/usr/bin/svcs'] @@ -12,6 +12,17 @@ class SMF(Bcfg2.Client.Tools.Tool): __req__ = {'Service':['name', 'status']} __ireq__ = {'Service': ['name', 'status', 'FMRI']} + def get_svc_command(self, service, action): + if service.get('type') == 'lrc': + return Bcfg2.Client.Tools.SvcTool.get_svc_command(self, + service, action) + if action == 'stop': + return "/usr/sbin/svcadm disable %s" % (service.get('FMRI')) + elif action == 'restart': + return "/usr/sbin/svcadm restart %s" % (service.get('FMRI')) + elif action == 'start': + return "/usr/sbin/svcadm enable %s" % (service.get('FMRI')) + def GetFMRI(self, entry): '''Perform FMRI resolution for service''' if not 'FMRI' in entry.attrib: @@ -114,23 +125,3 @@ class SMF(Bcfg2.Client.Tools.Tool): if svc.get("FMRI") in allsrv] return [Bcfg2.Client.XML.Element("Service", type='smf', name=name) \ for name in allsrv] - - def BundleUpdated(self, bundle, states): - '''Restart smf services''' - for entry in [entry for entry in bundle if self.handlesEntry(entry)]: - if not self.canInstall(entry): - self.logger.error("Insufficient information to restart service %s" % \ - (entry.get('name'))) - else: - if entry.get("FMRI").startswith('lrc'): - if entry.get('status') == 'on': - self.logger.info("Restarting smf/lrc service %s"%(entry.get("name"))) - self.cmd.run("/etc/init.d/%s %s" % (entry.get('name'), - entry.get('reload', 'reload'))) - else: - if entry.get('status') == 'on': - self.logger.info("Restarting smf service %s" % (entry.get("FMRI"))) - self.cmd.run("/usr/sbin/svcadm restart %s" % (entry.get("FMRI"))) - else: - self.cmd.run("/usr/sbin/svcadm disable %s" % (entry.get("FMRI"))) - |