summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/Client/Tools/SMF.py23
-rw-r--r--src/lib/Client/Tools/__init__.py21
2 files changed, 17 insertions, 27 deletions
diff --git a/src/lib/Client/Tools/SMF.py b/src/lib/Client/Tools/SMF.py
index 321c3cc17..1a1fc6c63 100644
--- a/src/lib/Client/Tools/SMF.py
+++ b/src/lib/Client/Tools/SMF.py
@@ -41,7 +41,7 @@ class SMF(Bcfg2.Client.Tools.Tool):
self.logger.debug("No service matching %s" % (entry.get("FMRI")))
return entry.get('status') == 'off'
try:
- srvdata = self.cmd.run("/usr/bin/svcs -H -o STA %s" % entry.attrib['name'])[1][0].split()
+ srvdata = self.cmd.run("/usr/bin/svcs -H -o STA %s" % entry.get('name'))[1][0].split()
except IndexError:
# Ocurrs when no lines are returned (service not installed)
return False
@@ -93,21 +93,16 @@ class SMF(Bcfg2.Client.Tools.Tool):
def FindExtra(self):
'''Find Extra SMF Services'''
allsrv = [name for name, version in \
- [ srvc.strip().split() for srvc in
- self.cmd.run("/usr/bin/svcs -a -H -o FMRI,STATE")[1] ]
+ [srvc.split() for srvc in
+ self.cmd.run("/usr/bin/svcs -a -H -o FMRI,STATE")[1]]
if version != 'disabled']
- for svc in self.getSupportedEntries():
- name = self.cmd.run("/usr/bin/svcs -H -o FMRI %s 2>/dev/null" % \
- svc.get('name'))[1]
- if name:
- svc.set('FMRI', name[0])
- if name in allsrv:
- allsrv.remove(name)
- else:
- self.logger.info("Failed to locate FMRI for service %s" % svc.get('name'))
-
- return [Bcfg2.Client.XML.Element("Service", type='smf', name=name) for name in allsrv]
+ self.logger.info("Found %d total services" % (len(allsrv)))
+ [allsrv.remove(svc.get('FMRI')) for svc in self.getSupportedEntries() \
+ if svc.get("FMRI") in allsrv]
+ self.logger.info("Found %d extra services" % (len(allsrv)))
+ return [Bcfg2.Client.XML.Element("Service", type='smf', name=name) \
+ for name in allsrv]
def BundleUpdated(self, bundle):
'''Restart smf services'''
diff --git a/src/lib/Client/Tools/__init__.py b/src/lib/Client/Tools/__init__.py
index 9b7acee02..56d9aba8b 100644
--- a/src/lib/Client/Tools/__init__.py
+++ b/src/lib/Client/Tools/__init__.py
@@ -38,21 +38,16 @@ class executor:
self.logger.debug('> %s' % command)
runpipe = readonlypipe(command, bufsize=16384)
- output = ''
- cmdstat = -1
- while cmdstat == -1:
- runpipe.fromchild.flush()
- moreOutput = runpipe.fromchild.readline()
- if len(moreOutput) > 0:
- self.logger.debug('< %s' % moreOutput[:-1])
- output += moreOutput
- cmdstat = runpipe.poll()
- for line in runpipe.fromchild.readlines():
+ output = []
+ runpipe.fromchild.flush()
+ line = runpipe.fromchild.readline()
+ while line:
if len(line) > 0:
self.logger.debug('< %s' % line[:-1])
- output += line
-
- return (cmdstat, [line for line in output.split('\n') if line])
+ output.append(line[:-1])
+ line = runpipe.fromchild.readline()
+ cmdstat = runpipe.poll()
+ return (cmdstat, output)
class Tool:
'''All tools subclass this. It defines all interfaces that need to be defined'''