Merge branch '2015.8' into 'develop'

Conflicts:
- salt/cloud/clouds/vmware.py
- salt/modules/freebsdpkg.py
- salt/modules/virtualenv_mod.py
- salt/states/boto_asg.py
- tests/integration/__init__.py
- tests/runtests.py
This commit is contained in:
rallytime 2015-11-06 09:34:31 -07:00
commit cded9ac01d
21 changed files with 268 additions and 89 deletions

View file

@ -175821,7 +175821,7 @@ New in version 2015.5.0.
.sp
Set \fBpreserve: True\fP to preserve user/group ownership and mode
after copying. Default is \fBFalse\fP\&. If \fBpreseve\fP is set to \fBTrue\fP,
after copying. Default is \fBFalse\fP\&. If \fBpreserve\fP is set to \fBTrue\fP,
then user/group/mode attributes will be ignored.
.TP
.B user

View file

@ -38,7 +38,9 @@ override the ordering defined in the files, and the ``order`` option described
below will also override the order in which states are defined in sls files.
If the classic ordering is preferred (lexicographic), then set
``state_auto_order`` to ``False`` in the master configuration file.
``state_auto_order`` to ``False`` in the master configuration file. Otherwise,
``state_auto_order`` defaults to ``True``.
.. _ordering_requisites:

View file

@ -191,3 +191,53 @@ Driver Support
- Container creation
- Image listing (LXC templates)
- Running container information (IP addresses, etc.)
Systemd Check
-------------
.. versionadded:: 2015.8.2
Some container templates might not have systemd installed resulting in errors during
container creation time. To prevent this please set the ``uses_systemd`` option to ``False``.
Option `uses_systemd` defaults to `True`.
.. code-block:: yaml
ubuntu-lxc:
provider: dev-lxc
lxc_profile:
template: download
options:
release: trusty
arch: amd64
image: ubuntu
script_args: -P
uses_systemd: False
network_profile: ubuntu
minion:
master: localhost
Bootstrap Delay
---------------
.. versionchanged:: 2015.8.0
The ``bootstrap_delay`` config option lets you specify the time to wait (in seconds) between container creation
and salt bootstrap execution. It is useful to ensure that all essential services have started before the
bootstrap script is executed. By default there's no wait time between container creation and bootstrap.
.. code-block:: yaml
ubuntu-lxc:
provider: dev-lxc
lxc_profile:
template: download
options:
release: trusty
arch: amd64
image: ubuntu
script_args: -P
bootstrap_delay: 62
network_profile: ubuntu
minion:
master: localhost

View file

@ -1,3 +1,5 @@
.. _contributing:
============
Contributing
============
@ -42,8 +44,9 @@ Fork a Repo Guide_>`_ and is well worth reading.
feature Y". Multiple unrelated fixes and/or features should be
isolated into separate branches.
If you're working on a fix, create your branch from the oldest release
branch having the bug. See :ref:`Which Salt Branch? <which-salt-branch>`.
If you're working on a bug or documentation fix, create your branch from
the oldest release branch that contains the bug or requires the documentation
update. See :ref:`Which Salt Branch? <which-salt-branch>`.
.. code-block:: bash
@ -163,14 +166,15 @@ Which Salt branch?
==================
GitHub will open pull requests against Salt's main branch, ``develop``, by
default. Ideally features should go into ``develop`` and bug fixes should go
into the oldest supported release branch affected by the bug. See
default. Ideally, features should go into ``develop`` and bug fixes and
documentation changes should go into the oldest supported release branch
affected by the bug or documentation update. See
:ref:`Sending a GitHub pull request <github-pull-request>`.
If you have a bug fix and have already forked your working branch from
``develop`` and do not know how to rebase your commits against another branch,
then submit it to ``develop`` anyway and we'll be sure to backport it to the
correct place.
If you have a bug fix or doc change and have already forked your working
branch from ``develop`` and do not know how to rebase your commits against
another branch, then submit it to ``develop`` anyway and we'll be sure to
back-port it to the correct place.
The current release branch
--------------------------

View file

@ -298,6 +298,26 @@ cross-referenced using two custom roles, ``conf_master``, and ``conf_minion``.
single minion.
.. _docs-ref-fixes:
Documentation Changes and Fixes
===============================
Documentation changes and fixes should be made against the earliest supported
release branch that the update applies to. The practice of updating a release
branch instead of making all documentation changes against Salt's main, default
branch, ``develop``, is necessary in order for the docs to be as up-to-date as
possible when the docs are built.
The workflow mentioned above is also inline with the recommendations outlined
in Salt's :ref:`contributing` page. You can read more about how to choose where
to submit documentation fixes by reading the :ref:`which-salt-branch` section.
For an explanation of how to submit changes against various branches, see the
:ref:`github-pull-request` section. Specifically, see the section describing
how to``Create a new branch`` and the steps that follow.
.. _docs-building:
Building the documentation

View file

@ -333,7 +333,8 @@ def _add_new_network_adapter_helper(network_adapter_label, network_name, adapter
if not switch_type:
err_msg = "The switch type to be used by '{0}' has not been specified".format(network_adapter_label)
else:
err_msg = "Cannot create '{0}'. Invalid/unsupported switch type '{1}'".format(network_adapter_label, switch_type)
err_msg = "Cannot create '{0}'. Invalid/unsupported switch type '{1}'".format(network_adapter_label,
switch_type)
raise SaltCloudSystemExit(err_msg)
network_spec.device.key = random_key
@ -1266,11 +1267,9 @@ def list_hosts(kwargs=None, call=None):
hosts = []
host_properties = ["name"]
host_list = salt.utils.vmware.get_mors_with_properties(_get_si(),
vim.HostSystem,
host_properties)
for host in host_list:
hosts.append(host["name"])

View file

@ -768,6 +768,12 @@ VALID_OPTS = {
# HTTP request max file content size.
'http_max_body': int,
# Delay in seconds before executing bootstrap (salt cloud)
'bootstrap_delay': int,
# Does this lxc template have systemd installed?
'uses_systemd': bool,
}
# default configurations
@ -1254,6 +1260,8 @@ CLOUD_CONFIG_DEFAULTS = {
'log_fmt_console': _DFLT_LOG_FMT_CONSOLE,
'log_fmt_logfile': _DFLT_LOG_FMT_LOGFILE,
'log_granular_levels': {},
'bootstrap_delay': None,
'uses_systemd': True,
}
DEFAULT_API_OPTS = {

View file

@ -36,9 +36,9 @@ Connection module for Amazon Route53
.. code-block:: yaml
myprofile:
keyid: GKTADJGHEIQSXMKKRBJ08H
key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
region: us-east-1
keyid: GKTADJGHEIQSXMKKRBJ08H
key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
region: us-east-1
:depends: boto
'''

View file

@ -473,11 +473,9 @@ def _rehash():
Recomputes internal hash table for the PATH variable. Use whenever a new
command is created during the current session.
'''
shell = __salt__['environ.get']('SHELL', output_loglevel='trace')
shell = __salt__['environ.get']('SHELL')
if shell.split('/')[-1] in ('csh', 'tcsh'):
__salt__['cmd.run'](['rehash'],
output_loglevel='trace',
python_shell=False)
__salt__['cmd.shell']('rehash', output_loglevel='trace')
def file_list(*packages):

View file

@ -15,6 +15,7 @@ import collections
from functools import reduce
# Import 3rd-party libs
import salt.utils.compat
from salt.utils.odict import OrderedDict
import yaml
import salt.ext.six as six
@ -238,8 +239,15 @@ def setvals(grains, destructive=False):
grains[key] = val
__grains__[key] = val
# Cast defaultdict to dict; is there a more central place to put this?
yaml_reps = copy.deepcopy(yaml.representer.SafeRepresenter.yaml_representers)
yaml_multi_reps = copy.deepcopy(yaml.representer.SafeRepresenter.yaml_multi_representers)
try:
yaml_reps = copy.deepcopy(yaml.representer.SafeRepresenter.yaml_representers)
yaml_multi_reps = copy.deepcopy(yaml.representer.SafeRepresenter.yaml_multi_representers)
except (TypeError, NameError):
# This likely means we are running under Python 2.6 which cannot deepcopy
# bound methods. Fallback to a modification of deepcopy which can support
# this behavior.
yaml_reps = salt.utils.compat.deepcopy_bound(yaml.representer.SafeRepresenter.yaml_representers)
yaml_multi_reps = salt.utils.compat.deepcopy_bound(yaml.representer.SafeRepresenter.yaml_multi_representers)
yaml.representer.SafeRepresenter.add_representer(collections.defaultdict,
yaml.representer.SafeRepresenter.represent_dict)
yaml.representer.SafeRepresenter.add_representer(OrderedDict,

View file

@ -1142,6 +1142,7 @@ def init(name,
bootstrap_args=None,
bootstrap_shell=None,
bootstrap_url=None,
uses_systemd=True,
**kwargs):
'''
Initialize a new container.
@ -1295,6 +1296,9 @@ def init(name,
unconditional_install
Run the script even if the container seems seeded
uses_systemd
Set to true if the lxc template has systemd installed
CLI Example:
.. code-block:: bash
@ -1615,7 +1619,8 @@ def init(name,
bootstrap_delay=bootstrap_delay,
bootstrap_url=bootstrap_url,
bootstrap_shell=bootstrap_shell,
bootstrap_args=bootstrap_args)
bootstrap_args=bootstrap_args,
uses_systemd=uses_systemd)
except (SaltInvocationError, CommandExecutionError) as exc:
ret['comment'] = 'Bootstrap failed: ' + exc.strerror
ret['result'] = False
@ -3319,7 +3324,7 @@ def test_bare_started_state(name, path=None):
return ret
def wait_started(name, path=None, timeout=300):
def wait_started(name, path=None, timeout=300, uses_systemd=True):
'''
Check that the system has fully inited
@ -3347,7 +3352,7 @@ def wait_started(name, path=None, timeout=300):
raise CommandExecutionError(
'Container {0} is not running'.format(name))
ret = False
if running_systemd(name, path=path):
if uses_systemd and running_systemd(name, path=path):
test_started = test_sd_started_state
logger = log.error
else:
@ -3403,7 +3408,8 @@ def bootstrap(name,
path=None,
bootstrap_delay=None,
bootstrap_args=None,
bootstrap_shell=None):
bootstrap_shell=None,
uses_systemd=True):
'''
Install and configure salt in a container.
@ -3464,7 +3470,7 @@ def bootstrap(name,
[approve_key=(True|False)] [install=(True|False)]
'''
wait_started(name, path=path)
wait_started(name, path=path, uses_systemd=uses_systemd)
if bootstrap_delay is not None:
try:
time.sleep(bootstrap_delay)

View file

@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
'''
Create virtualenv environments
Create virtualenv environments.
.. versionadded:: 0.17.0
'''
from __future__ import absolute_import
@ -105,9 +107,20 @@ def create(path,
.. deprecated:: 2014.1.0
``user`` should be used instead
use_vt
use_vt : False
Use VT terminal emulation (see ouptut while installing)
.. versionadded:: 2015.5.0
saltenv : 'base'
Specify a different environment. The default environment is ``base``.
.. versionadded:: 2014.1.0
.. note::
The ``runas`` argument is deprecated as of 2014.1.0. ``user`` should be
used instead.
CLI Example:
.. code-block:: bash
@ -383,6 +396,8 @@ def get_resource_path(venv,
.. deprecated:: Boron
.. versionadded:: 2015.5.0
venv
Path to the virtualenv.
package_or_requirement
@ -472,6 +487,8 @@ def get_resource_content(venv,
.. deprecated:: Boron
.. versionadded:: 2015.5.0
venv
Path to the virtualenv.
package_or_requirement

View file

@ -18,6 +18,7 @@ from datetime import datetime
try:
import win32net
import win32api
import win32con
import pywintypes
from ctypes import windll
HAS_WIN32NET_MODS = True
@ -309,7 +310,8 @@ def set_computer_name(name):
if name:
name = name.decode('utf-8')
if windll.kernel32.SetComputerNameW(name):
if windll.kernel32.SetComputerNameExW(win32con.ComputerNamePhysicalDnsHostname,
name):
ret = {'Computer Name': {'Current': get_system_info()['name']}}
pending = get_pending_computer_name()
if pending not in (None, False):

View file

@ -312,6 +312,11 @@ def init(names, host=None, saltcloud_mode=False, quiet=False, **kwargs):
if saltcloud_mode:
kw = copy.deepcopy(kw)
kw['name'] = name
saved_kwargs = {}
if 'bootstrap_delay' in kw:
saved_kwargs['bootstrap_delay'] = kw['bootstrap_delay']
if 'uses_systemd' in kw:
saved_kwargs['uses_systemd'] = kw['uses_systemd']
kw = client.cmd(
host, 'lxc.cloud_init_interface', args + [kw],
expr_form='list', timeout=600).get(host, {})
@ -320,6 +325,7 @@ def init(names, host=None, saltcloud_mode=False, quiet=False, **kwargs):
kw['seed'] = seeds.get(name, seed_arg)
if not kw['seed']:
kw.pop('seed_cmd', '')
kw.update(saved_kwargs)
cmds.append(
(host,
name,

View file

@ -41,7 +41,6 @@ config:
boto_rds.present:
- name: myrds
- allocated_storage: 5
- storage_type: gp2
- db_instance_class: db.t2.micro
- engine: MySQL
- master_username: myuser
@ -59,17 +58,36 @@ def __virtual__():
return 'boto_rds' if 'boto_rds.exists' in __salt__ else False
def present(name, allocated_storage, storage_type, db_instance_class, engine,
master_username, master_user_password, db_name=None,
db_security_groups=None, vpc_security_group_ids=None,
availability_zone=None, db_subnet_group_name=None,
preferred_maintenance_window=None, db_parameter_group_name=None,
backup_retention_period=None, preferred_backup_window=None,
port=None, multi_az=None, engine_version=None,
auto_minor_version_upgrade=None, license_model=None, iops=None,
option_group_name=None, character_set_name=None,
publicly_accessible=None, wait_status=None, tags=None, region=None,
key=None, keyid=None, profile=None):
def present(name,
allocated_storage,
db_instance_class,
engine,
master_username,
master_user_password,
db_name=None,
db_security_groups=None,
vpc_security_group_ids=None,
availability_zone=None,
db_subnet_group_name=None,
preferred_maintenance_window=None,
db_parameter_group_name=None,
backup_retention_period=None,
preferred_backup_window=None,
port=None,
multi_az=None,
engine_version=None,
auto_minor_version_upgrade=None,
license_model=None,
iops=None,
option_group_name=None,
character_set_name=None,
publicly_accessible=None,
wait_status=None,
tags=None,
region=None,
key=None,
keyid=None,
profile=None):
'''
Ensure RDS instance exists.
@ -80,9 +98,6 @@ def present(name, allocated_storage, storage_type, db_instance_class, engine,
The amount of storage (in gigabytes) to be initially allocated for the
database instance.
storage_type
The storage type you want to use, available: standard, gp2 and io1
db_instance_class
The compute and memory capacity of the Amazon RDS DB instance.
@ -184,7 +199,7 @@ def present(name, allocated_storage, storage_type, db_instance_class, engine,
'comment': '',
'changes': {}
}
_ret = _rds_present(name, allocated_storage, storage_type,
_ret = _rds_present(name, allocated_storage,
db_instance_class, engine,
master_username, master_user_password, db_name,
db_security_groups, vpc_security_group_ids,
@ -204,7 +219,7 @@ def present(name, allocated_storage, storage_type, db_instance_class, engine,
return ret
def _rds_present(name, allocated_storage, storage_type, db_instance_class,
def _rds_present(name, allocated_storage, db_instance_class,
engine, master_username, master_user_password, db_name=None,
db_security_groups=None, vpc_security_group_ids=None,
availability_zone=None, db_subnet_group_name=None,
@ -228,7 +243,7 @@ def _rds_present(name, allocated_storage, storage_type, db_instance_class,
ret['result'] = None
return ret
created = __salt__['boto_rds.create'](name, allocated_storage,
storage_type, db_instance_class,
db_instance_class,
engine, master_username,
master_user_password, db_name,
db_security_groups,

View file

@ -29,46 +29,46 @@ passed in as a dict, or as a string to pull from pillars or minion config:
.. code-block:: yaml
myprofile:
keyid: GKTADJGHEIQSXMKKRBJ08H
key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
region: us-east-1
keyid: GKTADJGHEIQSXMKKRBJ08H
key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
region: us-east-1
.. code-block:: yaml
mycnamerecord:
boto_route53.present:
- name: test.example.com.
- value: my-elb.us-east-1.elb.amazonaws.com.
- zone: example.com.
- ttl: 60
- record_type: CNAME
- region: us-east-1
- keyid: GKTADJGHEIQSXMKKRBJ08H
- key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
boto_route53.present:
- name: test.example.com.
- value: my-elb.us-east-1.elb.amazonaws.com.
- zone: example.com.
- ttl: 60
- record_type: CNAME
- region: us-east-1
- keyid: GKTADJGHEIQSXMKKRBJ08H
- key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
# Using a profile from pillars
myarecord:
boto_route53.present:
- name: test.example.com.
- value: 1.1.1.1
- zone: example.com.
- ttl: 60
- record_type: A
- region: us-east-1
- profile: myprofile
boto_route53.present:
- name: test.example.com.
- value: 1.1.1.1
- zone: example.com.
- ttl: 60
- record_type: A
- region: us-east-1
- profile: myprofile
# Passing in a profile
myarecord:
boto_route53.present:
- name: test.example.com.
- value: 1.1.1.1
- zone: example.com.
- ttl: 60
- record_type: A
- region: us-east-1
- profile:
keyid: GKTADJGHEIQSXMKKRBJ08H
key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
boto_route53.present:
- name: test.example.com.
- value: 1.1.1.1
- zone: example.com.
- ttl: 60
- record_type: A
- region: us-east-1
- profile:
keyid: GKTADJGHEIQSXMKKRBJ08H
key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
'''
# Import Python Libs

View file

@ -3771,7 +3771,7 @@ def copy(
.. versionadded:: 2015.5.0
Set ``preserve: True`` to preserve user/group ownership and mode
after copying. Default is ``False``. If ``preseve`` is set to ``True``,
after copying. Default is ``False``. If ``preserve`` is set to ``True``,
then user/group/mode attributes will be ignored.
user

View file

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
'''
Setup of Python virtualenv sandboxes
====================================
Setup of Python virtualenv sandboxes.
.. versionadded:: 0.17.0
'''
from __future__ import absolute_import

View file

@ -6,6 +6,8 @@ Compatibility functions for utils
# Import python libs
from __future__ import absolute_import
import sys
import copy
import types
# Import salt libs
import salt.loader
@ -20,3 +22,27 @@ def pack_dunder(name):
mod = sys.modules[name]
if not hasattr(mod, '__utils__'):
setattr(mod, '__utils__', salt.loader.utils(mod.__opts__))
def deepcopy_bound(name):
'''
Compatibility helper function to allow copy.deepcopy copy bound methods
which is broken on Python 2.6, due to the following bug:
https://bugs.python.org/issue1515
Warnings:
- This method will mutate the global deepcopy dispatcher, which means that
this function is NOT threadsafe!
- Not Py3 compatible. The intended use case is deepcopy compat for Py2.6
'''
def _deepcopy_method(x, memo):
return type(x)(x.im_func, copy.deepcopy(x.im_self, memo), x.im_class) # pylint: disable=W1699
try:
pre_dispatch = copy._deepcopy_dispatch
copy._deepcopy_dispatch[types.MethodType] = _deepcopy_method
ret = copy.deepcopy(name)
finally:
copy._deepcopy_dispatch = pre_dispatch
return ret

View file

@ -6,6 +6,7 @@ Set up the Salt integration test suite
# Import Python libs
from __future__ import absolute_import, print_function
import platform
import os
import re
import sys
@ -72,7 +73,11 @@ except ImportError:
import yaml
import salt.ext.six as six
if os.uname()[0] == 'Darwin':
if salt.utils.is_windows():
import win32api
if platform.uname()[0] == 'Darwin':
SYS_TMP_DIR = '/tmp'
else:
SYS_TMP_DIR = os.environ.get('TMPDIR', tempfile.gettempdir())
@ -444,9 +449,14 @@ class TestDaemon(object):
os.environ['SSH_DAEMON_RUNNING'] = 'True'
roster_path = os.path.join(FILES, 'conf/_ssh/roster')
shutil.copy(roster_path, TMP_CONF_DIR)
with salt.utils.fopen(os.path.join(TMP_CONF_DIR, 'roster'), 'a') as roster:
roster.write(' user: {0}\n'.format(pwd.getpwuid(os.getuid()).pw_name))
roster.write(' priv: {0}/{1}'.format(TMP_CONF_DIR, 'key_test'))
if salt.utils.is_windows():
with salt.utils.fopen(os.path.join(TMP_CONF_DIR, 'roster'), 'a') as roster:
roster.write(' user: {0}\n'.format(win32api.GetUserName()))
roster.write(' priv: {0}/{1}'.format(TMP_CONF_DIR, 'key_test'))
else:
with salt.utils.fopen(os.path.join(TMP_CONF_DIR, 'roster'), 'a') as roster:
roster.write(' user: {0}\n'.format(pwd.getpwuid(os.getuid()).pw_name))
roster.write(' priv: {0}/{1}'.format(TMP_CONF_DIR, 'key_test'))
@classmethod
def config(cls, role):
@ -488,7 +498,10 @@ class TestDaemon(object):
shutil.rmtree(TMP_CONF_DIR)
os.makedirs(TMP_CONF_DIR)
print(' * Transplanting configuration files to \'{0}\''.format(TMP_CONF_DIR))
running_tests_user = pwd.getpwuid(os.getuid()).pw_name
if salt.utils.is_windows():
running_tests_user = win32api.GetUserName()
else:
running_tests_user = pwd.getpwuid(os.getuid()).pw_name
master_opts = salt.config._read_conf_file(os.path.join(CONF_DIR, 'master'))
master_opts['user'] = running_tests_user
tests_know_hosts_file = os.path.join(TMP_CONF_DIR, 'salt_ssh_known_hosts')

View file

@ -8,7 +8,6 @@ Discover all instances of unittest.TestCase in this directory.
# Import python libs
from __future__ import absolute_import, print_function
import os
import resource
import tempfile
import time
@ -16,6 +15,10 @@ import time
from integration import TestDaemon, TMP # pylint: disable=W0403
from integration import INTEGRATION_TEST_DIR
from integration import CODE_DIR as SALT_ROOT
import salt.utils
if not salt.utils.is_windows():
import resource
# Import Salt Testing libs
from salttesting.parser import PNUM, print_header
@ -255,7 +258,8 @@ class SaltTestsuiteParser(SaltCoverageTestingParser):
return self.run_suite(path, display_name)
def start_daemons_only(self):
self.prep_filehandles()
if not salt.utils.is_windows():
self.prep_filehandles()
try:
print_header(
' * Setting up Salt daemons for interactive use',
@ -360,7 +364,8 @@ class SaltTestsuiteParser(SaltCoverageTestingParser):
# passing only `unit.<whatever>` to --name.
# We don't need the tests daemon running
return [True]
self.prep_filehandles()
if not salt.utils.is_windows():
self.prep_filehandles()
try:
print_header(