summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2009-04-01 03:15:36 +0000
committerNarayan Desai <desai@mcs.anl.gov>2009-04-01 03:15:36 +0000
commit0783c0f22ade3ce9de17f18818f6edf8fd6077a5 (patch)
tree95ded81150558c92947f1679d55bfb0731148ddf /src
parentabc006ec95cbc409f395dbc62dd6a07ac88f91c4 (diff)
downloadbcfg2-0783c0f22ade3ce9de17f18818f6edf8fd6077a5.tar.gz
bcfg2-0783c0f22ade3ce9de17f18818f6edf8fd6077a5.tar.bz2
bcfg2-0783c0f22ade3ce9de17f18818f6edf8fd6077a5.zip
Initial IPS (Opensolaris) driver
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5146 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/lib/Client/Tools/IPS.py60
-rw-r--r--src/lib/Client/Tools/__init__.py2
2 files changed, 61 insertions, 1 deletions
diff --git a/src/lib/Client/Tools/IPS.py b/src/lib/Client/Tools/IPS.py
new file mode 100644
index 000000000..78fe9776f
--- /dev/null
+++ b/src/lib/Client/Tools/IPS.py
@@ -0,0 +1,60 @@
+'''This is the bcfg2 support for OpenSolaris pkg'''
+__revision__ = '$Revision$'
+
+import Bcfg2.Client.Tools
+
+import pkg.client.image as image
+import pkg.client.progress as progress
+
+class IPS(Bcfg2.Client.Tools.PkgTool):
+ '''The IPS driver implements OpenSolaris package operations'''
+ name = 'IPS'
+ pkgtype = 'ips'
+ conflicts = ['SYSV']
+ __handles__ = [('Package', 'ips')]
+ __req__ = {'Package': ['name', 'version']}
+ pkgtool = ('pkg install --no-refresh %s', ('%s', ['name']))
+
+ def __init__(self, logger, cfg, setup):
+ self.installed = {}
+ self.pending_upgrades = set()
+ self.image = image.Image()
+ self.image.find_root('/', False)
+ self.image.load_config()
+ Bcfg2.Client.Tools.PkgTool.__init__(self, logger, cfg, setup)
+ self.cfg = cfg
+
+ def RefreshPackages(self):
+ self.installed = dict()
+ self.image.history.operation_name = "list"
+ self.image.load_catalogs(progress.NullProgressTracker())
+ for (pfmri, pinfo) in self.image.inventory([], False):
+ pname = pfmri.pkg_name
+ pversion = pfmri.version.get_short_version()
+ self.installed[pname] = pversion
+ if pinfo['upgradable']:
+ self.pending_updates.add(pname)
+
+ def VerifyPackage(self, entry, modlist):
+ '''Verify package for entry'''
+ pname = entry.get('name')
+ if not 'version' in entry.attrib:
+ self.logger.info("Cannot verify unversioned package %s" % (pname))
+ return False
+ if pname not in self.installed:
+ self.logger.debug("IPS: Package %s not installed" % pname)
+ return False
+ if entry.get('version') == 'auto':
+ if pname in self.pending_updates:
+ return False
+ elif entry.get('version') == 'any':
+ pass
+ else:
+ if entry.get('version') != self.installed[pname]:
+ self.logger.debug("IPS: Package %s: have %s want %s" \
+ % (pname, self.installed[pname],
+ entry.get('version')))
+ return False
+
+ # need to implement pkg chksum validation
+ return True
diff --git a/src/lib/Client/Tools/__init__.py b/src/lib/Client/Tools/__init__.py
index 79d273fb3..a4e150b9b 100644
--- a/src/lib/Client/Tools/__init__.py
+++ b/src/lib/Client/Tools/__init__.py
@@ -1,7 +1,7 @@
'''This contains all Bcfg2 Tool modules'''
__revision__ = '$Revision$'
-__all__ = ["Action", "APT", "Blast", "Chkconfig", "DebInit", "Encap",
+__all__ = ["Action", "APT", "Blast", "Chkconfig", "DebInit", "Encap", "IPS",
"FreeBSDInit", "FreeBSDPackage", "launchd", "Portage", "POSIX",
"RPM", "RPMng", 'rpmtools', "RcUpdate", "SMF", "SYSV", "Yum",
"YUMng"]