mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
add refresh option to more functions
This commit is contained in:
parent
5836be3f59
commit
db0e0de2fd
1 changed files with 36 additions and 4 deletions
|
@ -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 = {}
|
||||
|
|
Loading…
Add table
Reference in a new issue