126 lines
3.3 KiB
Diff
126 lines
3.3 KiB
Diff
|
From 478871aebfcb2ddf1b1c2a47b4fccb820180c9ed Mon Sep 17 00:00:00 2001
|
||
|
From: Michael Calmer <mc@suse.de>
|
||
|
Date: Thu, 18 Feb 2016 12:39:52 +0100
|
||
|
Subject: [PATCH 19/22] add refresh option to more functions
|
||
|
|
||
|
---
|
||
|
salt/modules/zypper.py | 40 ++++++++++++++++++++++++++++++++++++----
|
||
|
1 file changed, 36 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git a/salt/modules/zypper.py b/salt/modules/zypper.py
|
||
|
index f5b09c0..9afdeef 100644
|
||
|
--- a/salt/modules/zypper.py
|
||
|
+++ b/salt/modules/zypper.py
|
||
|
@@ -1245,16 +1245,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()
|
||
|
|
||
|
|
||
|
@@ -1271,16 +1279,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')
|
||
|
@@ -1311,13 +1327,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.
|
||
|
|
||
|
@@ -1328,6 +1349,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')
|
||
|
@@ -1357,10 +1381,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
|
||
|
@@ -1371,6 +1400,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 = {}
|
||
|
--
|
||
|
2.1.4
|
||
|
|