mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Add kwargs to pre-flight check
This commit is contained in:
parent
4a45348d6b
commit
ac33d130f6
@ -101,7 +101,7 @@ def _process_emerge_err(stderr):
|
||||
return ret
|
||||
|
||||
|
||||
def checkdb(*names):
|
||||
def check_db(*names, **kwargs):
|
||||
'''
|
||||
.. versionadded:: 0.17.0
|
||||
|
||||
@ -120,12 +120,14 @@ def checkdb(*names):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' pkg.checkdb <package1> <package2> <package3>
|
||||
salt '*' pkg.check_db <package1> <package2> <package3>
|
||||
'''
|
||||
### NOTE: kwargs is not used here but needs to be present due to it being
|
||||
### required in the check_db function in other package providers.
|
||||
ret = {}
|
||||
for name in names:
|
||||
if name in ret:
|
||||
log.warning('pkg.checkdb: Duplicate package name {0!r} '
|
||||
log.warning('pkg.check_db: Duplicate package name {0!r} '
|
||||
'submitted'.format(name))
|
||||
continue
|
||||
if '/' not in name:
|
||||
|
@ -81,7 +81,11 @@ def _fulfills_version_spec(versions, oper, desired_version):
|
||||
return False
|
||||
|
||||
|
||||
def _find_install_targets(name=None, version=None, pkgs=None, sources=None):
|
||||
def _find_install_targets(name=None,
|
||||
version=None,
|
||||
pkgs=None,
|
||||
sources=None,
|
||||
**kwargs):
|
||||
'''
|
||||
Inspect the arguments to pkg.installed and discover what packages need to
|
||||
be installed. Return a dict of desired packages
|
||||
@ -144,7 +148,7 @@ def _find_install_targets(name=None, version=None, pkgs=None, sources=None):
|
||||
targets = [x for x in desired if x not in cur_pkgs]
|
||||
else:
|
||||
# Perform platform-specific pre-flight checks
|
||||
problems = _preflight_check(desired)
|
||||
problems = _preflight_check(desired, **kwargs)
|
||||
comments = []
|
||||
if problems.get('no_suggest'):
|
||||
comments.append(
|
||||
@ -262,14 +266,16 @@ def _get_desired_pkg(name, desired):
|
||||
'' if not desired[name] else desired[name])
|
||||
|
||||
|
||||
def _preflight_check(desired):
|
||||
def _preflight_check(desired, fromrepo, **kwargs):
|
||||
'''
|
||||
Perform platform-specifc checks on desired packages
|
||||
'''
|
||||
if 'pkg.checkdb' not in __salt__:
|
||||
if 'pkg.check_db' not in __salt__:
|
||||
return {}
|
||||
ret = {'suggest': {}, 'no_suggest': []}
|
||||
pkginfo = __salt__['pkg.checkdb'](*desired.keys())
|
||||
pkginfo = __salt__['pkg.check_db'](
|
||||
*desired.keys(), fromrepo=fromrepo, **kwargs
|
||||
)
|
||||
for pkgname in pkginfo:
|
||||
if pkginfo[pkgname]['found'] is False:
|
||||
if pkginfo[pkgname]['suggestions']:
|
||||
@ -402,7 +408,8 @@ def installed(
|
||||
if not isinstance(version, basestring) and version is not None:
|
||||
version = str(version)
|
||||
|
||||
result = _find_install_targets(name, version, pkgs, sources)
|
||||
result = _find_install_targets(name, version, pkgs, sources,
|
||||
fromrepo=fromrepo, **kwargs)
|
||||
try:
|
||||
desired, targets = result
|
||||
except ValueError:
|
||||
|
Loading…
Reference in New Issue
Block a user