summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/Client/Solaris.py59
-rw-r--r--src/lib/Client/Toolset.py2
-rw-r--r--src/lib/Server/Plugins/Pkgmgr.py1
3 files changed, 36 insertions, 26 deletions
diff --git a/src/lib/Client/Solaris.py b/src/lib/Client/Solaris.py
index 6001d4f62..69d6ee69b 100644
--- a/src/lib/Client/Solaris.py
+++ b/src/lib/Client/Solaris.py
@@ -3,7 +3,7 @@
__revision__ = '$Revision$'
from glob import glob
-from os import popen, stat, system, unlink
+from os import stat, unlink
from re import compile as regcompile
from tempfile import mktemp
@@ -26,7 +26,7 @@ basedir=default
class ToolsetImpl(Toolset):
'''This class implelements support for SYSV/blastware/encap packages
and standard SMF services'''
- pkgtool = {'sysv':("/usr/sbin/pkgadd %s -d %%s -n all", ("%s", ["url"])),
+ pkgtool = {'sysv':("/usr/sbin/pkgadd %s -d %%s -n %%%%s", (("%s", ["name"]))),
'blast':("/opt/csw/bin/pkg-get install %s", ("%s", ["name"])),
'encap':("/local/sbin/epkg -l -q %s", ("%s", ["url"]))}
splitter = regcompile('.*/(?P<name>[\w-]+)\-(?P<version>[\w\.-]+)')
@@ -45,25 +45,31 @@ class ToolsetImpl(Toolset):
self.pkgtool['sysv'] = (self.pkgtool['sysv'][0] % (""), self.pkgtool['sysv'][1])
try:
stat("/opt/csw/bin/pkg-get")
- system("/opt/csw/bin/pkg-get -U > /dev/null")
+ self.saferun("/opt/csw/bin/pkg-get -U > /dev/null")
except OSError:
pass
self.Refresh()
for pkg in [cpkg for cpkg in self.cfg.findall(".//Package") if not cpkg.attrib.has_key('type')]:
pkg.set('type', 'sysv')
+ for pkg in [cpkg for cpkg in self.cfg.findall(".//Package") if cpkg.get('type') == 'sysv']:
+ if pkg.attrib.has_key('url'):
+ pkg.set('url', '/'.join(pkg.get('url').split('/')[:-1]))
+ pkg.set('type', "sysv-%s" % (pkg.get('url')))
+ if not self.pkgtool.has_key(pkg.get('type')):
+ self.pkgtool[pkg.get('type')] = (self.pkgtool['sysv'][0] % (pkg.get('url')),
+ self.pkgtool['sysv'][1])
def Refresh(self):
'''Refresh memory hashes of packages'''
self.installed = {}
self.ptypes = {}
# Build list of packages
- instp = popen("/usr/bin/pkginfo -x")
- lines = instp.readlines()
- while (lines):
+ lines = self.saferun("/usr/bin/pkginfo -x")[1]
+ while lines:
version = lines.pop().split()[1]
- name = lines.pop().split()[0]
- self.installed[name] = version
- self.ptypes[name] = 'sysv'
+ pkg = lines.pop().split()[0]
+ self.installed[pkg] = version
+ self.ptypes[pkg] = 'sysv'
# try to find encap packages
for pkg in glob("/local/encap/*"):
match = self.splitter.match(pkg)
@@ -72,13 +78,14 @@ class ToolsetImpl(Toolset):
self.ptypes[match.group('name')] = 'encap'
else:
print "Failed to split name %s" % pkg
+ print self.installed.keys()
def VerifyService(self, entry):
'''Verify Service status for entry'''
if not entry.attrib.has_key('FMRI'):
- name = popen("/usr/bin/svcs -H -o FMRI %s 2>/dev/null" % entry.get('name')).read().strip()
+ (rc, name) = self.saferun("/usr/bin/svcs -H -o FMRI %s 2>/dev/null" % entry.get('name'))
if name:
- entry.set('FMRI', name)
+ entry.set('FMRI', name[0])
else:
self.CondPrint('verbose', 'Failed to locate FMRI for service %s' % entry.get('name'))
return False
@@ -91,7 +98,7 @@ class ToolsetImpl(Toolset):
else:
return entry.get('status') == 'off'
try:
- srvdata = popen("/usr/bin/svcs -H -o STA %s" % entry.attrib['name']).readlines()[0].split()
+ srvdata = self.saferun("/usr/bin/svcs -H -o STA %s" % entry.attrib['name'])[1][0].split()
except IndexError:
# Ocurrs when no lines are returned (service not installed)
return False
@@ -107,9 +114,9 @@ class ToolsetImpl(Toolset):
self.CondPrint('verbose', 'Insufficient information for Service %s; cannot Install' % entry.get('name'))
return False
if not entry.attrib.has_key('FMRI'):
- name = popen("/usr/bin/svcs -H -o FMRI %s 2>/dev/null" % entry.get('name')).read().strip()
+ name = self.saferun("/usr/bin/svcs -H -o FMRI %s 2>/dev/null" % entry.get('name'))[1]
if name:
- entry.set('FMRI', name)
+ entry.set('FMRI', name[0])
else:
self.CondPrint('verbose', 'Failed to locate FMRI for service %s' % entry.get('name'))
return False
@@ -118,12 +125,12 @@ class ToolsetImpl(Toolset):
if self.setup['dryrun']:
print "Disabling Service %s" % (entry.get('name'))
else:
- cmdrc = system("/usr/sbin/svcadm disable -r %s" % (entry.attrib['FMRI']))
+ cmdrc = self.saferun("/usr/sbin/svcadm disable -r %s" % (entry.attrib['FMRI']))[0]
else:
if self.setup['dryrun']:
print "Enabling Service %s" % (entry.attrib['name'])
else:
- cmdrc = system("/usr/sbin/svcadm enable -r %s" % (entry.attrib['FMRI']))
+ cmdrc = self.saferun("/usr/sbin/svcadm enable -r %s" % (entry.attrib['FMRI']))[0]
return cmdrc == 0
def VerifyPackage(self, entry, modlist):
@@ -132,11 +139,11 @@ class ToolsetImpl(Toolset):
self.CondPrint('verbose',
"Insufficient information of Package %s; cannot Verify" % entry.get('name'))
return False
- if entry.get('type') in ['sysv', 'blast']:
- cmdrc = system("/usr/bin/pkginfo -q -v \"%s\" %s" % (entry.get('version'), entry.get('name')))
+ if entry.get('type') in ['sysv', 'blast'] or entry.get('type')[:4] == 'sysv':
+ cmdrc = self.saferun("/usr/bin/pkginfo -q -v \"%s\" %s" % (entry.get('version'), entry.get('name')))[0]
elif entry.get('type') in ['encap']:
- cmdrc = system("/local/sbin/epkg -q -k %s-%s >/dev/null" %
- (entry.get('name'), entry.get('version')))
+ cmdrc = self.saferun("/local/sbin/epkg -q -k %s-%s >/dev/null" %
+ (entry.get('name'), entry.get('version')))[0]
if cmdrc != 0:
self.CondPrint('debug', "Package %s version incorrect" % entry.get('name'))
else:
@@ -158,14 +165,14 @@ class ToolsetImpl(Toolset):
'''Do standard inventory plus debian extra service check'''
Toolset.Inventory(self)
allsrv = [name for name, version in [ srvc.strip().split() for srvc in
- popen("/usr/bin/svcs -a -H -o FMRI,STATE").readlines() ]
+ self.saferun("/usr/bin/svcs -a -H -o FMRI,STATE")[1] ]
if version != 'disabled']
csrv = self.cfg.findall(".//Service")
# need to build a service name map. services map to a fullname if they are already installed
for srv in csrv:
- name = popen("/usr/bin/svcs -H -o FMRI %s 2>/dev/null" % srv.get('name')).read().strip()
+ name = self.saferun("/usr/bin/svcs -H -o FMRI %s 2>/dev/null" % srv.get('name'))[1]
if name:
- srv.set('FMRI', name)
+ srv.set('FMRI', name[0])
else:
self.CondPrint("verbose", "failed to locate FMRI for service %s" % srv.get('name'))
#nsrv = [ r for r in [ popen("/usr/bin/svcs -H -o FMRI %s " % s).read().strip() for s in csrv ] if r ]
@@ -181,10 +188,10 @@ class ToolsetImpl(Toolset):
sysvrmpkgs = [pkg for pkg in self.pkgwork['remove'] if self.ptypes[pkg] == 'sysv']
enrmpkgs = [pkg for pkg in self.pkgwork['remove'] if self.ptypes[pkg] == 'encap']
if sysvrmpkgs:
- if not system("/usr/sbin/pkgrm -n %s" % " ".join(sysvrmpkgs)):
+ if not self.saferun("/usr/sbin/pkgrm -n %s" % " ".join(sysvrmpkgs))[0]:
[self.pkgwork['remove'].remove(pkg) for pkg in sysvrmpkgs]
if enrmpkgs:
- if not system("/local/sbin/epkg -l -q -r %s" % " ".join(enrmpkgs)):
+ if not self.saferun("/local/sbin/epkg -l -q -r %s" % " ".join(enrmpkgs))[0]:
[self.pkgwork['remove'].remove(pkg) for pkg in enrmpkgs]
else:
self.CondPrint('verbose', "Need to remove packages: %s" % (self.pkgwork['remove']))
@@ -192,7 +199,7 @@ class ToolsetImpl(Toolset):
if self.setup['remove'] in ['all', 'services']:
self.CondPrint('verbose', "Removing services: %s" % (self.extra_services))
for service in self.extra_services:
- if not system("/usr/sbin/svcadm disable %s" % service):
+ if not self.saferun("/usr/sbin/svcadm disable %s" % service)[0]:
self.extra_services.remove(service)
else:
self.CondPrint('verbose', "Need to remove services: %s" % (self.extra_services))
diff --git a/src/lib/Client/Toolset.py b/src/lib/Client/Toolset.py
index 7c2da5f14..5436a595e 100644
--- a/src/lib/Client/Toolset.py
+++ b/src/lib/Client/Toolset.py
@@ -92,6 +92,8 @@ class Toolset(object):
height, width = struct.unpack('hhhh',
fcntl.ioctl(0, termios.TIOCGWINSZ,
"\000"*8))[0:2]
+ if height == 0 or width == 0:
+ return 25, 80
return height, width
except:
return 25, 80
diff --git a/src/lib/Server/Plugins/Pkgmgr.py b/src/lib/Server/Plugins/Pkgmgr.py
index fe03e184b..8521994e0 100644
--- a/src/lib/Server/Plugins/Pkgmgr.py
+++ b/src/lib/Server/Plugins/Pkgmgr.py
@@ -41,6 +41,7 @@ class PackageEntry(XMLFileBacked):
pkgname = mdata.group('name')
self.packages[pkgname] = mdata.groupdict()
self.packages[pkgname]['url'] = location.get('uri') + '/' + pkg.get('file')
+ self.packages[pkgname]['type'] = pkg.get('type')
else:
derived = [(ptype, self.splitters[ptype].match(pkg.get('file')).groupdict())
for ptype in self.splitters if self.splitters[ptype].match(pkg.get('file'))]