Merge pull request #31439 from rallytime/fix-31370

Fix lowpkg.info function for Ubuntu 12 - make sure we have a pkg name
This commit is contained in:
Mike Place 2016-02-24 09:24:46 -07:00
commit e553f18dc4
3 changed files with 31 additions and 8 deletions

View file

@ -2233,7 +2233,12 @@ def owner(*paths):
def info_installed(*names):
'''
Return the information of the named package(s), installed on the system.
Return the information of the named package(s) installed on the system.
.. versionadded:: 2015.8.1
names
The names of the packages for which to return information.
CLI example:

View file

@ -247,17 +247,17 @@ def file_dict(*packages):
def _get_pkg_info(*packages):
'''
Return list of package informations. If 'packages' parameter is empty,
Return list of package information. If 'packages' parameter is empty,
then data about all installed packages will be returned.
:param packages: Specified packages.
:return:
'''
if __grains__['os'] == 'Ubuntu' and __grains__['osrelease_info'] <= (12, 4):
if __grains__['os'] == 'Ubuntu' and __grains__['osrelease_info'] < (12, 4):
bin_var = '${binary}'
else:
bin_var = '${binary:Package}'
bin_var = '${Package}'
ret = []
cmd = "dpkg-query -W -f='package:" + bin_var + "\\n" \
@ -366,16 +366,19 @@ def _get_pkg_ds_avail():
def info(*packages):
'''
Return a detailed package(s) summary information.
If no packages specified, all packages will be returned.
Returns a detailed summary of package information for provided package names.
If no packages are specified, all packages will be returned.
:param packages:
:return:
.. versionadded:: 2015.8.1
packages
The names of the packages for which to return information.
CLI example:
.. code-block:: bash
salt '*' lowpkg.info
salt '*' lowpkg.info apache2 bash
'''
# Get the missing information from the /var/lib/dpkg/available, if it is there.

View file

@ -6,6 +6,7 @@ from __future__ import absolute_import
from salttesting.helpers import (
destructiveTest,
requires_network,
requires_salt_modules,
ensure_in_syspath
)
ensure_in_syspath('../../')
@ -171,6 +172,20 @@ class PkgModuleTest(integration.ModuleCase,
os_grain = self.run_function('grains.item', ['os'])['os']
self.skipTest('{0} is unavailable on {1}'.format(func, os_grain))
@requires_salt_modules('pkg.info_installed')
def test_pkg_info(self):
'''
Test returning useful information on Ubuntu systems.
'''
func = 'pkg.info_installed'
os_family = self.run_function('grains.item', ['os_family'])['os_family']
if os_family == 'Debian':
ret = self.run_function(func, ['bash-completion', 'cron'])
keys = ret.keys()
self.assertIn('bash-completion', keys)
self.assertIn('cron', keys)
if __name__ == '__main__':
from integration import run_tests