mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Renamed check_sig to checksum and some refactoring
This commit is contained in:
parent
d56e3f4258
commit
80fe303e38
2 changed files with 7 additions and 15 deletions
|
@ -604,7 +604,7 @@ def version_cmp(ver1, ver2):
|
|||
return salt.utils.version_cmp(ver1, ver2)
|
||||
|
||||
|
||||
def check_sig(*paths):
|
||||
def checksum(*paths):
|
||||
'''
|
||||
Return if the signature of a RPM file is valid.
|
||||
|
||||
|
@ -612,8 +612,8 @@ def check_sig(*paths):
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' lowpkg.check_sig /path/to/package1.rpm
|
||||
salt '*' lowpkg.check_sig /path/to/package1.rpm /path/to/package2.rpm
|
||||
salt '*' lowpkg.checksum /path/to/package1.rpm
|
||||
salt '*' lowpkg.checksum /path/to/package1.rpm /path/to/package2.rpm
|
||||
'''
|
||||
ret = {}
|
||||
|
||||
|
@ -626,13 +626,7 @@ def check_sig(*paths):
|
|||
if not __salt__['file.file_exists'](package_file):
|
||||
continue
|
||||
|
||||
check_cmd = ["rpm", "-K", "--quiet", package_file]
|
||||
check_args = {
|
||||
'ignore_retcode': True,
|
||||
'output_loglevel': 'trace',
|
||||
'python_shell': False,
|
||||
}
|
||||
if __salt__['cmd.retcode'](check_cmd, **check_args) == 0:
|
||||
if not __salt__['cmd.retcode'](["rpm", "-K", "--quiet", package_file], ignore_retcode=True, output_loglevel='trace', python_shell=False):
|
||||
ret[package_file] = True
|
||||
|
||||
return ret
|
||||
|
|
|
@ -1534,15 +1534,13 @@ def download(*packages, **kwargs):
|
|||
'repository-alias': repo.getAttribute("alias"),
|
||||
'path': dld_result.getElementsByTagName("localfile")[0].getAttribute("path"),
|
||||
}
|
||||
if not __salt__['lowpkg.check_sig'](pkg_info['path']):
|
||||
continue
|
||||
pkg_ret[_get_first_aggregate_text(dld_result.getElementsByTagName("name"))] = pkg_info
|
||||
if __salt__['lowpkg.checksum'](pkg_info['path']):
|
||||
pkg_ret[_get_first_aggregate_text(dld_result.getElementsByTagName("name"))] = pkg_info
|
||||
|
||||
if pkg_ret:
|
||||
failed = [pkg for pkg in packages if pkg not in pkg_ret]
|
||||
if failed:
|
||||
pkg_ret['_error'] = ('The following package(s) failed to download: {0}'
|
||||
.format(', '.join(failed)))
|
||||
pkg_ret['_error'] = ('The following package(s) failed to download: {0}'.format(', '.join(failed)))
|
||||
return pkg_ret
|
||||
|
||||
raise CommandExecutionError("Unable to download packages: {0}.".format(', '.join(packages)))
|
||||
|
|
Loading…
Add table
Reference in a new issue