File 0018-unify-behavior-of-refresh.patch of Package salt.3314

From 29ab56413c60c958d5d62b1acdea5a97ce80fdb9 Mon Sep 17 00:00:00 2001
From: Michael Calmer <mc@suse.de>
Date: Thu, 18 Feb 2016 12:30:19 +0100
Subject: [PATCH 18/22] unify behavior of refresh

---
 salt/modules/zypper.py | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/salt/modules/zypper.py b/salt/modules/zypper.py
index f878c95..f5b09c0 100644
--- a/salt/modules/zypper.py
+++ b/salt/modules/zypper.py
@@ -74,6 +74,11 @@ def list_upgrades(refresh=True):
     '''
     List all available package upgrades on this system
 
+    refresh
+        force a refresh if set to True (default).
+        If set to False it depends on zypper if a refresh is
+        executed.
+
     CLI Example:
 
     .. code-block:: bash
@@ -175,6 +180,11 @@ def info_available(*names, **kwargs):
     '''
     Return the information of the named package available for the system.
 
+    refresh
+        force a refresh if set to True (default).
+        If set to False it depends on zypper if a refresh is
+        executed or not.
+
     CLI example:
 
     .. code-block:: bash
@@ -657,7 +667,7 @@ def mod_repo(repo, **kwargs):
 
 def refresh_db():
     '''
-    Just run a ``zypper refresh``, return a dict::
+    Force a repository refresh by calling ``zypper refresh --force``, return a dict::
 
         {'<database name>': Bool}
 
@@ -667,7 +677,7 @@ def refresh_db():
 
         salt '*' pkg.refresh_db
     '''
-    cmd = _zypper('refresh')
+    cmd = _zypper('refresh', '--force')
     ret = {}
     call = __salt__['cmd.run_all'](cmd, output_loglevel='trace')
     if call['retcode'] != 0:
@@ -704,7 +714,7 @@ def install(name=None,
             version=None,
             **kwargs):
     '''
-    Install the passed package(s), add refresh=True to run 'zypper refresh'
+    Install the passed package(s), add refresh=True to force a 'zypper refresh'
     before package is installed.
 
     name
@@ -721,7 +731,9 @@ def install(name=None,
             salt '*' pkg.install <package name>
 
     refresh
-        Whether or not to refresh the package database before installing.
+        force a refresh if set to True.
+        If set to False (default) it depends on zypper if a refresh is
+        executed.
 
     fromrepo
         Specify a package repository to install from.
@@ -769,6 +781,9 @@ def install(name=None,
         {'<package>': {'old': '<old-version>',
                        'new': '<new-version>'}}
     '''
+    if salt.utils.is_true(refresh):
+        refresh_db()
+
     try:
         pkg_params, pkg_type = __salt__['pkg_resource.parse_targets'](name, pkgs, sources, **kwargs)
     except MinionError as exc:
@@ -815,8 +830,6 @@ def install(name=None,
     else:
         fromrepoopt = ''
     cmd_install = _zypper()
-    if not refresh:
-        cmd_install.append('--no-refresh')
     cmd_install += ['install', '--name', '--auto-agree-with-licenses']
     if downloadonly:
         cmd_install.append('--download-only')
@@ -851,6 +864,11 @@ def upgrade(refresh=True):
     '''
     Run a full system upgrade, a zypper upgrade
 
+    refresh
+        force a refresh if set to True (default).
+        If set to False it depends on zypper if a refresh is
+        executed.
+
     Return a dict containing the new package names and versions::
 
         {'<package>': {'old': '<old-version>',
-- 
2.1.4

openSUSE Build Service is sponsored by