Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2015.8] Merge forward from 2015.5 to 2015.8 #34018

Merged
merged 17 commits into from
Jun 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion salt/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 16 additions & 12 deletions salt/modules/aptpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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']

Expand All @@ -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.

Expand All @@ -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):
Expand Down
16 changes: 7 additions & 9 deletions salt/modules/brew.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand Down
16 changes: 7 additions & 9 deletions salt/modules/ebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand All @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion salt/modules/macports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 7 additions & 7 deletions salt/modules/pacman.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 = ''
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/pkgutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 11 additions & 4 deletions salt/modules/solarisips.py
Original file line number Diff line number Diff line change
Expand Up @@ -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::

Expand Down
2 changes: 1 addition & 1 deletion salt/modules/win_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 8 additions & 2 deletions salt/modules/zypper.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def __call(self, *args, **kwargs):
__zypper__ = _Zypper()


def list_upgrades(refresh=True):
def list_upgrades(refresh=True, **kwargs):
'''
List all available package upgrades on this system

Expand All @@ -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')

Expand Down
8 changes: 7 additions & 1 deletion salt/netapi/rest_cherrypy/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@
# 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
Expand Down Expand Up @@ -2252,6 +2251,13 @@ def GET(self):
: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 {}
Expand Down
9 changes: 7 additions & 2 deletions salt/states/pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 6 additions & 4 deletions tests/integration/output/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -85,15 +87,15 @@ def test_output_unicodebad(self):
'''
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
Expand Down