Merge branch '2015.5' into '2015.8'

Conflicts:
  - salt/modules/aptpkg.py
  - salt/modules/ebuild.py
  - salt/modules/zypper.py
  - salt/states/pkg.py
  - tests/integration/output/output.py
This commit is contained in:
rallytime 2016-06-14 15:47:35 -06:00
commit 77f44f3087
13 changed files with 81 additions and 54 deletions

View file

@ -173,7 +173,8 @@ def minion_mods(
__opts__ = salt.config.minion_config('/etc/salt/minion')
__grains__ = salt.loader.grains(__opts__)
__opts__['grains'] = __grains__
__salt__ = salt.loader.minion_mods(__opts__)
__utils__ = salt.loader.utils(__opts__)
__salt__ = salt.loader.minion_mods(__opts__, utils=__utils__)
__salt__['test.ping']()
'''
# TODO Publish documentation for module whitelisting

View file

@ -1177,7 +1177,7 @@ def list_pkgs(versions_as_list=False,
return ret
def _get_upgradable(dist_upgrade=True):
def _get_upgradable(dist_upgrade=True, **kwargs):
'''
Utility function to get upgradable packages
@ -1190,17 +1190,21 @@ def _get_upgradable(dist_upgrade=True):
cmd.append('dist-upgrade')
else:
cmd.append('upgrade')
call = __salt__['cmd.run_all'](cmd, output_loglevel='trace', python_shell=False)
fromrepo = _get_repo(**kwargs)
if fromrepo:
cmd.extend(['-o', 'APT::Default-Release={0}'.format(fromrepo)])
call = __salt__['cmd.run_all'](cmd,
python_shell=False,
output_loglevel='trace')
if call['retcode'] != 0:
comment = ''
if 'stderr' in call:
comment += call['stderr']
if 'stdout' in call:
comment += call['stdout']
raise CommandExecutionError(
'{0}'.format(comment)
)
msg = 'Failed to get upgrades'
for key in ('stderr', 'stdout'):
if call[key]:
msg += ': ' + call[key]
break
raise CommandExecutionError(msg)
else:
out = call['stdout']
@ -1223,7 +1227,7 @@ def _get_upgradable(dist_upgrade=True):
return ret
def list_upgrades(refresh=True, dist_upgrade=True):
def list_upgrades(refresh=True, dist_upgrade=True, **kwargs):
'''
List all available package upgrades.
@ -1243,7 +1247,7 @@ def list_upgrades(refresh=True, dist_upgrade=True):
'''
if salt.utils.is_true(refresh):
refresh_db()
return _get_upgradable(dist_upgrade)
return _get_upgradable(dist_upgrade, **kwargs)
def upgrade_available(name):

View file

@ -333,7 +333,7 @@ def install(name=None, pkgs=None, taps=None, options=None, **kwargs):
return salt.utils.compare_dicts(old, new)
def list_upgrades(refresh=True):
def list_upgrades(refresh=True, **kwargs): # pylint: disable=W0613
'''
Check whether or not an upgrade is available for all packages
@ -349,14 +349,12 @@ def list_upgrades(refresh=True):
cmd = 'brew outdated'
call = _call_brew(cmd)
if call['retcode'] != 0:
comment = ''
if 'stderr' in call:
comment += call['stderr']
if 'stdout' in call:
comment += call['stdout']
raise CommandExecutionError(
'{0}'.format(comment)
)
msg = 'Failed to get upgrades'
for key in ('stderr', 'stdout'):
if call[key]:
msg += ': ' + call[key]
break
raise CommandExecutionError(msg)
else:
out = call['stdout']
return out.splitlines()

View file

@ -268,14 +268,12 @@ def _get_upgradable(backtrack=3):
python_shell=False)
if call['retcode'] != 0:
comment = ''
if 'stderr' in call:
comment += call['stderr']
if 'stdout' in call:
comment += call['stdout']
raise CommandExecutionError(
'{0}'.format(comment)
)
msg = 'Failed to get upgrades'
for key in ('stderr', 'stdout'):
if call[key]:
msg += ': ' + call[key]
break
raise CommandExecutionError(msg)
else:
out = call['stdout']
@ -298,7 +296,7 @@ def _get_upgradable(backtrack=3):
return ret
def list_upgrades(refresh=True, backtrack=3):
def list_upgrades(refresh=True, backtrack=3, **kwargs): # pylint: disable=W0613
'''
List all available package upgrades.

View file

@ -332,7 +332,7 @@ def install(name=None, refresh=False, pkgs=None, **kwargs):
return salt.utils.compare_dicts(old, new)
def list_upgrades(refresh=True):
def list_upgrades(refresh=True, **kwargs): # pylint: disable=W0613
'''
Check whether or not an upgrade is available for all packages

View file

@ -118,7 +118,7 @@ def upgrade_available(name):
return latest_version(name) != ''
def list_upgrades(refresh=False):
def list_upgrades(refresh=False, **kwargs): # pylint: disable=W0613
'''
List all available package upgrades on this system
@ -129,14 +129,14 @@ def list_upgrades(refresh=False):
salt '*' pkg.list_upgrades
'''
upgrades = {}
options = ['-S', '-p', '-u', '--print-format "%n %v"']
cmd = ['pacman', '-S', '-p', '-u', '--print-format', '%n %v']
if refresh:
options.append('-y')
cmd.append('-y')
cmd = ('pacman {0}').format(' '.join(options))
call = __salt__['cmd.run_all'](cmd, output_loglevel='trace')
call = __salt__['cmd.run_all'](cmd,
python_shell=False,
output_loglevel='trace')
if call['retcode'] != 0:
comment = ''
@ -150,7 +150,7 @@ def list_upgrades(refresh=False):
else:
out = call['stdout']
for line in iter(out.splitlines()):
for line in out.splitlines():
comps = line.split(' ')
if len(comps) != 2:
continue

View file

@ -65,7 +65,7 @@ def upgrade_available(name):
return ''
def list_upgrades(refresh=True):
def list_upgrades(refresh=True, **kwargs): # pylint: disable=W0613
'''
List all available package upgrades on this system

View file

@ -129,12 +129,19 @@ def upgrade_available(name):
return ret
def list_upgrades(refresh=False):
def list_upgrades(refresh=False, **kwargs): # pylint: disable=W0613
'''
Lists all packages available for update.
When run in global zone, it reports only upgradable packages for the global zone.
When run in non-global zone, it can report more upgradable packages than "pkg update -vn" because "pkg update" hides packages that require newer version of pkg://solaris/entire (which means that they can be upgraded only from global zone). Simply said: if you see pkg://solaris/entire in the list of upgrades, you should upgrade the global zone to get all possible updates.
You can force full pkg DB refresh before listing.
When run in global zone, it reports only upgradable packages for the global
zone.
When run in non-global zone, it can report more upgradable packages than
``pkg update -vn``, because ``pkg update`` hides packages that require
newer version of ``pkg://solaris/entire`` (which means that they can be
upgraded only from the global zone). If ``pkg://solaris/entire`` is found
in the list of upgrades, then the global zone should be updated to get all
possible updates. Use ``refresh=True`` to refresh the package database.
CLI Example::

View file

@ -139,7 +139,7 @@ def upgrade_available(name):
return latest_version(name) != ''
def list_upgrades(refresh=True):
def list_upgrades(refresh=True, **kwargs): # pylint: disable=W0613
'''
List all available package upgrades on this system

View file

@ -283,7 +283,7 @@ class _Zypper(object):
__zypper__ = _Zypper()
def list_upgrades(refresh=True):
def list_upgrades(refresh=True, **kwargs):
'''
List all available package upgrades on this system
@ -302,7 +302,13 @@ def list_upgrades(refresh=True):
refresh_db()
ret = dict()
for update_node in __zypper__.nolock.xml.call('list-updates').getElementsByTagName('update'):
cmd = ['list-updates']
if 'fromrepo' in kwargs:
repo_name = kwargs['fromrepo']
if not isinstance(repo_name, six.string_types):
repo_name = str(repo_name)
cmd.extend(['--repo', repo_name])
for update_node in __zypper__.nolock.xml.call(*cmd).getElementsByTagName('update'):
if update_node.getAttribute('kind') == 'package':
ret[update_node.getAttribute('name')] = update_node.getAttribute('edition')

View file

@ -253,7 +253,6 @@ from multiprocessing import Process, Pipe
# Import third-party libs
# pylint: disable=import-error
import cherrypy
from cherrypy.lib import cpstats
import yaml
import salt.ext.six as six
# pylint: enable=import-error
@ -2252,6 +2251,13 @@ class Stats(object):
:status 406: |406|
'''
if hasattr(logging, 'statistics'):
# Late import
try:
from cherrypy.lib import cpstats
except ImportError:
logger.error('Import of cherrypy.cpstats failed. Possible '
'upstream bug here: https://github.com/cherrypy/cherrypy/issues/1444')
return {}
return cpstats.extrapolate_statistics(logging.statistics)
return {}

View file

@ -1995,14 +1995,19 @@ def uptodate(name, refresh=False, **kwargs):
ret['comment'] = 'State pkg.uptodate is not available'
return ret
# emerge --update doesn't appear to support repo notation
if 'fromrepo' in kwargs and __grains__['os'] == 'Gentoo':
ret['comment'] = '\'fromrepo\' argument not supported on this platform'
return ret
if isinstance(refresh, bool):
try:
packages = __salt__['pkg.list_upgrades'](refresh=refresh)
packages = __salt__['pkg.list_upgrades'](refresh=refresh, **kwargs)
except Exception as exc:
ret['comment'] = str(exc)
return ret
else:
ret['comment'] = 'refresh must be a boolean'
ret['comment'] = 'refresh must be either True or False'
return ret
if not packages:

View file

@ -6,15 +6,17 @@
# Import Salt Libs
from __future__ import absolute_import
import os
import copy
import traceback
# Import Salt Testing Libs
from salttesting.helpers import ensure_in_syspath
from salttesting.mixins import RUNTIME_VARS
ensure_in_syspath('../../')
# Import Salt libs
import integration
import salt.config
from salt.output import display_output
@ -85,15 +87,15 @@ class OutputReturnTest(integration.ShellCase):
'''
Tests outputter reliability with utf8
'''
opts = copy.deepcopy(self.minion_opts)
opts = salt.config.minion_config(os.path.join(RUNTIME_VARS.TMP_CONF_DIR, 'minion'))
opts['output_file'] = os.path.join(
self.minion_opts['root_dir'], 'outputtest')
opts['root_dir'], 'outputtest')
data = {'foo': {'result': False,
'aaa': 'azerzaeréééé',
'comment': u'ééééàààà'}}
try:
# this should not raises UnicodeEncodeError
display_output(data, opts=self.minion_opts)
display_output(data, opts=opts)
self.assertTrue(True)
except Exception:
# display trace in error message for debugging on jenkins