mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge branch 'develop' of github.com:saltstack/salt into develop
This commit is contained in:
commit
6563bd18a1
@ -36,13 +36,14 @@ def _parse_yum(arg):
|
||||
out = __salt__['cmd.run_stdout'](cmd)
|
||||
YumOut = namedtuple('YumOut', ('name', 'version', 'status'))
|
||||
|
||||
try:
|
||||
results = map(YumOut._make,
|
||||
[i.split() for i in out.split('\n') if len(i.split()) == 3])
|
||||
except TypeError as exc:
|
||||
results = ()
|
||||
msg = "Could not parse yum output for: {0}".format(cmd)
|
||||
logger.debug(msg, exc_info=exc)
|
||||
results = []
|
||||
|
||||
for line in out.split('\n'):
|
||||
if len(line.split()) == 3:
|
||||
namearchstr, pkgver, pkgstatus = line.split()
|
||||
pkgname = namearchstr.rpartition('.')[0]
|
||||
|
||||
results.append(YumOut(pkgname, pkgver, pkgstatus))
|
||||
|
||||
return results
|
||||
|
||||
|
@ -11,8 +11,11 @@ declarations are typically rather simple:
|
||||
pkg:
|
||||
- installed
|
||||
'''
|
||||
import logging
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def installed(name):
|
||||
'''
|
||||
Verify that the package is installed, and only that it is installed. This
|
||||
@ -50,20 +53,28 @@ def latest(name):
|
||||
name
|
||||
The name of the package to maintain at the latest available version
|
||||
'''
|
||||
changes = {}
|
||||
version = LooseVersion(__salt__['pkg.version'](name))
|
||||
avail = LooseVersion(__salt__['pkg.available_version'](name))
|
||||
if avail > version:
|
||||
changes = __salt__['pkg.install'](name, True)
|
||||
if not changes:
|
||||
return {'name': name,
|
||||
'changes': changes,
|
||||
'result': False,
|
||||
'comment': 'Package ' + name + ' failed to install'}
|
||||
return {'name': name,
|
||||
'changes': changes,
|
||||
'result': True,
|
||||
'comment': 'Package ' + name + ' installed'}
|
||||
ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''}
|
||||
|
||||
version = __salt__['pkg.version'](name)
|
||||
avail = __salt__['pkg.available_version'](name)
|
||||
|
||||
try:
|
||||
has_newer = LooseVersion(avail) > LooseVersion(version)
|
||||
except AttributeError:
|
||||
logger.debug("Error comparing versions for '%s' (%s > %s)",
|
||||
name, avail, version, exc_info=True)
|
||||
|
||||
ret['comment'] = "No version could be retrieved for '{0}'".format(name)
|
||||
return ret
|
||||
|
||||
if has_newer:
|
||||
ret['changes'] = __salt__['pkg.install'](name, True)
|
||||
ret['comment'] = 'Package {0} failed to install'.format(name)
|
||||
|
||||
ret['result'] = True
|
||||
ret['comment'] = 'Package {0} installed'.format(name)
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def removed(name):
|
||||
|
Loading…
Reference in New Issue
Block a user