Add a --required switch to installpkg

Some packages are critical to the compose. If --required
is specified in the template's installpkg command, lorax
will exit if the package is not available.
This commit is contained in:
Martin Gracik 2012-06-01 14:42:55 +02:00
parent cc384f6e7a
commit 7446d0d1e2
1 changed files with 9 additions and 2 deletions

View File

@ -382,17 +382,24 @@ class LoraxTemplateRunner(object):
def installpkg(self, *pkgs):
'''
installpkg PKGGLOB [PKGGLOB ...]
installpkg [--required] PKGGLOB [PKGGLOB ...]
Request installation of all packages matching the given globs.
Note that this is just a *request* - nothing is *actually* installed
until the 'run_pkg_transaction' command is given.
'''
required = False
if pkgs[0] == '--required':
pkgs = pkgs[1:]
required = True
for p in pkgs:
try:
self.yum.install(pattern=p)
except Exception as e:
# FIXME: save exception and re-raise after the loop finishes
logger.warn("installpkg %s failed: %s",p,str(e))
logger.error("installpkg %s failed: %s",p,str(e))
if required:
sys.exit(1)
def removepkg(self, *pkgs):
'''