add refresh option to more functions

This commit is contained in:
Michael Calmer 2016-02-18 12:39:52 +01:00
parent 5836be3f59
commit db0e0de2fd

View file

@ -1244,16 +1244,24 @@ def _get_patterns(installed_only=None):
return patterns
def list_patterns():
def list_patterns(refresh=False):
'''
List all known patterns from available repos.
refresh
force a refresh if set to True.
If set to False (default) it depends on zypper if a refresh is
executed.
CLI Examples:
.. code-block:: bash
salt '*' pkg.list_patterns
'''
if salt.utils.is_true(refresh):
refresh_db()
return _get_patterns()
@ -1270,16 +1278,24 @@ def list_installed_patterns():
return _get_patterns(installed_only=True)
def search(criteria):
def search(criteria, refresh=False):
'''
List known packags, available to the system.
refresh
force a refresh if set to True.
If set to False (default) it depends on zypper if a refresh is
executed.
CLI Examples:
.. code-block:: bash
salt '*' pkg.search <criteria>
'''
if salt.utils.is_true(refresh):
refresh_db()
doc = dom.parseString(__salt__['cmd.run'](_zypper('--xmlout', 'se', criteria),
output_loglevel='trace'))
solvables = doc.getElementsByTagName('solvable')
@ -1310,13 +1326,18 @@ def _get_first_aggregate_text(node_list):
return '\n'.join(out)
def list_products(all=False):
def list_products(all=False, refresh=False):
'''
List all available or installed SUSE products.
all
List all products available or only installed. Default is False.
refresh
force a refresh if set to True.
If set to False (default) it depends on zypper if a refresh is
executed.
Includes handling for OEM products, which read the OEM productline file
and overwrite the release value.
@ -1327,6 +1348,9 @@ def list_products(all=False):
salt '*' pkg.list_products
salt '*' pkg.list_products all=True
'''
if salt.utils.is_true(refresh):
refresh_db()
ret = list()
OEM_PATH = "/var/lib/suseRegister/OEM"
cmd = _zypper('-x', 'products')
@ -1356,10 +1380,15 @@ def list_products(all=False):
return ret
def download(*packages):
def download(refresh=False, *packages):
"""
Download packages to the local disk.
refresh
force a refresh if set to True.
If set to False (default) it depends on zypper if a refresh is
executed.
CLI example:
.. code-block:: bash
@ -1370,6 +1399,9 @@ def download(*packages):
if not packages:
raise CommandExecutionError("No packages has been specified.")
if salt.utils.is_true(refresh):
refresh_db()
doc = dom.parseString(__salt__['cmd.run'](
_zypper('-x', 'download', *packages), output_loglevel='trace'))
pkg_ret = {}