Merge remote-tracking branch 'upstream/develop' into rh_int_conf_opts

This commit is contained in:
Jerzy Drozdz 2015-07-09 15:43:24 +02:00
commit b95681efc1
16 changed files with 115 additions and 134 deletions

View File

@ -17,17 +17,17 @@ Download
Salt source releases are available for download via the following PyPI link:
https://pypi.python.org/pypi/salt
* https://pypi.python.org/pypi/salt
The installation document, found in the following link, outlines where to
obtain packages and installation specifics for platforms:
:doc:`Installation </topics/installation/index>`
* :doc:`Installation </topics/installation/index>`
The Salt Bootstrap project, found in the following repository, is a single
shell script, which automates the install correctly on multiple platforms:
https://github.com/saltstack/salt-bootstrap
* https://github.com/saltstack/salt-bootstrap
Get Started
===============

44
salt/auth/sharedsecret.py Normal file
View File

@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
'''Provide authentication using configured shared secret
.. code-block:: yaml
external_auth:
sharedsecret:
fred:
- .*
- '@jobs'
The shared secret should be added to the master configuration, for
example in /etc/salt/master.d/sharedsecret.conf (make sure that file
is only readable by the user running the master):
.. code-block:: yaml
sharedsecret: OIUHF_CHANGE_THIS_12h88
This auth module should be used with caution. It was initially
designed to work with a frontal that takes care of authentication (for
example kerberos) and places the shared secret in the HTTP headers to
the salt-api call. This salt-api call should really be done on
localhost to avoid someone eavesdropping on the shared secret.
See the documentation for cherrypy to setup the headers in your
frontal.
.. versionadded:: Beryllium
'''
# Import python libs
from __future__ import absolute_import
import logging
log = logging.getLogger(__name__)
def auth(username, sharedsecret, **kwargs):
'''
Shared secret authentication
'''
return sharedsecret == __opts__.get('sharedsecret')

View File

@ -282,10 +282,12 @@ class SyncClientMixin(object):
try:
verify_fun(self.functions, fun)
# Inject some useful globals to *all* the funciton's global
# Inject some useful globals to *all* the function's global
# namespace only once per module-- not per func
completed_funcs = []
for mod_name in six.iterkeys(self.functions):
_functions = copy.deepcopy(self.functions)
for mod_name in six.iterkeys(_functions):
if '.' not in mod_name:
continue
mod, _ = mod_name.split('.', 1)

View File

@ -44,7 +44,6 @@ from salt.exceptions import (
SaltCloudExecutionFailure,
SaltCloudExecutionTimeout
)
from salt.utils import warn_until
# Import Third Party Libs
try:
@ -80,22 +79,12 @@ def get_configured_provider():
'''
Return the first configured instance.
'''
configuration = config.is_provider_configured(
return config.is_provider_configured(
__opts__,
__active_provider_name__ or 'digital_ocean',
('personal_access_token',)
)
if configuration:
warn_until(
'Beryllium',
'The digital_ocean driver is deprecated and will be removed in Salt Beryllium. '
'Please convert your digital ocean provider configs to use the digital_ocean_v2 '
'driver.'
)
return configuration
def avail_locations(call=None):
'''

View File

@ -1172,7 +1172,8 @@ def _create_eni_if_necessary(interface):
params = {'SubnetId': interface['SubnetId']}
for k in ('Description', 'PrivateIpAddress',
'SecondaryPrivateIpAddressCount'):
'SecondaryPrivateIpAddressCount',
'SourceDestCheck'):
if k in interface:
params[k] = interface[k]

View File

@ -690,10 +690,14 @@ def reformat_node(item=None, full=False):
item[key] = None
# remove all the extra key value pairs to provide a brief listing
to_del = []
if not full:
for key in six.iterkeys(item): # iterate over a copy of the keys
if key not in desired_keys:
del item[key]
to_del.append(key)
for key in to_del:
del item[key]
if 'state' in item:
item['state'] = joyent_node_state(item['state'])

View File

@ -260,7 +260,7 @@ def parse_args_and_kwargs(func, args, data=None):
return load_args_and_kwargs(func, args, data=data)
def load_args_and_kwargs(func, args, data=None):
def load_args_and_kwargs(func, args, data=None, ignore_invalid=False):
'''
Detect the args and kwargs that need to be passed to a function call, and
check them against what was passed.
@ -314,7 +314,7 @@ def load_args_and_kwargs(func, args, data=None):
else:
_args.append(arg)
if invalid_kwargs:
if invalid_kwargs and not ignore_invalid:
raise SaltInvocationError(
'The following keyword arguments are not valid: {0}'
.format(', '.join(invalid_kwargs))

View File

@ -117,7 +117,7 @@ def version():
'''
k = 'lxc.version'
if not __context__.get(k, None):
cversion = __salt__['cmd.run_all']('lxc-ls --version')
cversion = __salt__['cmd.run_all']('lxc-info --version')
if not cversion['retcode']:
ver = distutils.version.LooseVersion(cversion['stdout'])
if ver < distutils.version.LooseVersion('1.0'):

View File

@ -97,7 +97,7 @@ def _validate_partition_boundary(boundary):
)
def probe(*devices, **kwargs):
def probe(*devices):
'''
Ask the kernel to update its local partition data. When no args are
specified all block devices are tried.
@ -113,13 +113,6 @@ def probe(*devices, **kwargs):
salt '*' partition.probe /dev/sda
salt '*' partition.probe /dev/sda /dev/sdb
'''
salt.utils.kwargs_warn_until(kwargs, 'Beryllium')
if 'device' in kwargs:
devices = tuple([kwargs['device']] + list(devices))
del kwargs['device']
if kwargs:
raise TypeError("probe() takes no keyword arguments")
for device in devices:
_validate_device(device)
@ -128,26 +121,6 @@ def probe(*devices, **kwargs):
return out
def part_list(device, unit=None):
'''
Deprecated. Calls partition.list.
CLI Examples:
.. code-block:: bash
salt '*' partition.part_list /dev/sda
salt '*' partition.part_list /dev/sda unit=s
salt '*' partition.part_list /dev/sda unit=kB
'''
salt.utils.warn_until(
'Beryllium',
'''The \'part_list\' function has been deprecated in favor of
\'list_\'. Please update your code and configs to reflect this.''')
return list_(device, unit)
def list_(device, unit=None):
'''
partition.list device unit

View File

@ -141,10 +141,6 @@ class NetapiClient(object):
:return: Returns the result from the runner module
'''
kwargs['fun'] = fun
if 'kwargs' not in kwargs:
kwargs['kwargs'] = {}
if 'args' not in kwargs:
kwargs['args'] = []
runner = salt.runner.RunnerClient(self.opts)
return runner.cmd_sync(kwargs, timeout=timeout)
@ -160,10 +156,6 @@ class NetapiClient(object):
:return: event data and a job ID for the executed function.
'''
kwargs['fun'] = fun
if 'kwargs' not in kwargs:
kwargs['kwargs'] = {}
if 'args' not in kwargs:
kwargs['args'] = []
runner = salt.runner.RunnerClient(self.opts)
return runner.cmd_async(kwargs)

View File

@ -1069,25 +1069,18 @@ class Jobs(LowDataAdapter):
- 2
- 6.9141387939453125e-06
'''
timeout = int(timeout) if timeout.isdigit() else None
lowstate = [{
'client': 'runner',
'fun': 'jobs.lookup_jid' if jid else 'jobs.list_jobs',
'jid': jid,
}]
if jid:
lowstate = [{
'client': 'runner',
'fun': 'jobs.lookup_jid',
'args': (jid,),
'timeout': timeout,
}, {
lowstate.append({
'client': 'runner',
'fun': 'jobs.list_job',
'args': (jid,),
'timeout': timeout,
}]
else:
lowstate = [{
'client': 'runner',
'fun': 'jobs.list_jobs',
'timeout': timeout,
}]
'jid': jid,
})
cherrypy.request.lowstate = lowstate
job_ret_info = list(self.exec_lowstate(

View File

@ -59,8 +59,24 @@ class RunnerClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object):
auth_creds = dict([(i, low.pop(i)) for i in [
'username', 'password', 'eauth', 'token', 'client',
] if i in low])
reformatted_low = {'fun': low.pop('fun')}
fun = low.pop('fun')
reformatted_low = {'fun': fun}
reformatted_low.update(auth_creds)
# Support old style calls where arguments could be specified in 'low' top level
if not low.get('args') and not low.get('kwargs'): # not specified or empty
verify_fun(self.functions, fun)
args, kwargs = salt.minion.load_args_and_kwargs(
self.functions[fun],
salt.utils.args.condition_input([], low),
self.opts,
ignore_invalid=True
)
low['args'] = args
low['kwargs'] = kwargs
if 'kwargs' not in low:
low['kwargs'] = {}
if 'args' not in low:
low['args'] = []
reformatted_low['kwarg'] = low
return reformatted_low

View File

@ -516,20 +516,29 @@ def present(
scaling_policies,
scaling_policies_from_pillar
)
updated, msg = __salt__['boto_asg.update'](name, launch_config_name,
availability_zones, min_size,
max_size, desired_capacity,
load_balancers,
default_cooldown,
health_check_type,
health_check_period,
placement_group,
vpc_zone_identifier, tags,
termination_policies,
suspended_processes,
scaling_policies, region,
notification_arn, notification_types,
key, keyid, profile)
updated, msg = __salt__['boto_asg.update'](
name,
launch_config_name,
availability_zones,
min_size,
max_size,
desired_capacity=desired_capacity,
load_balancers=load_balancers,
default_cooldown=default_cooldown,
health_check_type=health_check_type,
health_check_period=health_check_period,
placement_group=placement_group,
vpc_zone_identifier=vpc_zone_identifier,
tags=tags,
termination_policies=termination_policies,
suspended_processes=suspended_processes,
scaling_policies=scaling_policies,
notification_arn=notification_arn,
notification_types=notification_types,
region=region,
key=key,
keyid=keyid,
profile=profile)
if asg['launch_config_name'] != launch_config_name:
# delete the old launch_config_name
deleted = __salt__['boto_asg.delete_launch_configuration'](asg['launch_config_name'], region, key, keyid, profile)

View File

@ -394,6 +394,7 @@ def query(url,
auth_password=password,
body=data,
validate_cert=verify_ssl,
allow_nonstandard_methods=True,
**req_kwargs
)
except tornado.httpclient.HTTPError as exc:

View File

@ -720,6 +720,7 @@ class SaltDistribution(distutils.dist.Distribution):
'doc/man/salt-master.1',
'doc/man/salt-minion.1',
'doc/man/salt-run.1',
'doc/man/spm.1',
'doc/man/salt-ssh.1',
'doc/man/salt-syndic.1',
'doc/man/salt-unity.1'])

View File

@ -84,7 +84,7 @@ class PartedTestCase(TestCase):
@patch('salt.modules.parted._validate_device', MagicMock())
def test_probe_w_single_arg(self):
parted.probe("/dev/sda")
parted.probe('/dev/sda')
self.cmdrun.assert_called_once_with('partprobe -- /dev/sda')
@patch('salt.modules.parted._validate_device', MagicMock())
@ -92,50 +92,6 @@ class PartedTestCase(TestCase):
parted.probe('/dev/sda', '/dev/sdb')
self.cmdrun.assert_called_once_with('partprobe -- /dev/sda /dev/sdb')
@staticmethod
def check_kwargs_warn_until_devices(device_kwargs):
def check_args(kwargs, version):
assert kwargs == device_kwargs
assert version == 'Beryllium'
parted.salt.utils.kwargs_warn_until.side_effect = check_args
@patch('salt.utils.kwargs_warn_until')
@patch('salt.modules.parted._validate_device', MagicMock())
def test_probe_w_device_kwarg(self, *args, **kwargs):
device_kwargs = {'device': '/dev/sda'}
parted.probe(**device_kwargs)
self.check_kwargs_warn_until_devices(device_kwargs)
self.cmdrun.assert_called_once_with('partprobe -- /dev/sda')
@patch('salt.utils.kwargs_warn_until')
@patch('salt.modules.parted._validate_device', MagicMock())
def test_probe_w_device_kwarg_and_arg(self, *args, **kwargs):
'''device arg is concatenated with positional args'''
device_kwargs = {'device': '/dev/sda'}
parted.probe("/dev/sdb", **device_kwargs)
self.check_kwargs_warn_until_devices(device_kwargs)
self.cmdrun.assert_called_once_with('partprobe -- /dev/sda /dev/sdb')
@patch('salt.utils.kwargs_warn_until')
def test_probe_w_extra_kwarg(self, *args, **kwargs):
device_kwargs = {'foo': 'bar'}
self.assertRaises(TypeError, parted.probe, **device_kwargs)
self.check_kwargs_warn_until_devices(device_kwargs)
self.assertFalse(self.cmdrun.called)
# Test part_list function
@patch('salt.modules.parted.list_')
@patch('salt.utils.warn_until')
def test_part_list(self, *args, **kwargs):
'''Function should call new function and raise deprecation warning'''
parted.part_list("foo", "bar")
parted.list_.assert_called_once_with("foo", "bar")
parted.salt.utils.warn_until.assert_called_once_with(
'Beryllium',
'''The \'part_list\' function has been deprecated in favor of
\'list_\'. Please update your code and configs to reflect this.''')
# Test _list function
@staticmethod