Merge branch '2018.3' into 51959_fix_acl_present_output

This commit is contained in:
Gareth J. Greenaway 2019-03-22 10:22:48 -07:00 committed by GitHub
commit 8c53890222
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 68 additions and 18 deletions

View file

@ -66,7 +66,7 @@ clean:
# User-friendly check for sphinx-build
check_sphinx-build:
@which $(SPHINXBUILD) >/dev/null 2>&1 || (echo "The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)" >&2; false)
@which $(SPHINXBUILD) >/dev/null 2>&1 || (echo "The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://www.sphinx-doc.org/en/master/)" >&2; false)
html: check_sphinx-build translations
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html

View file

@ -13,7 +13,7 @@ broadly, most of the narrative documentation is contained within the
:blob:`doc` subdirectory and most of the reference and API documentation is
written inline with Salt's Python code and extracted using a Sphinx extension.
.. _`Sphinx`: http://sphinx-doc.org/
.. _`Sphinx`: https://www.sphinx-doc.org/en/master/
.. _docs-style:
@ -187,7 +187,7 @@ Link to :ref:`glossary entries <glossary>` using the `term role`_. A
cross-reference should be added the first time a Salt-specific term is used in
a document.
.. _`term role`: http://sphinx-doc.org/markup/inline.html#role-term
.. _`term role`: https://www.sphinx-doc.org/en/master/glossary.html#term-role
.. code-block:: restructuredtext
@ -206,7 +206,7 @@ occasionally useful to manually add items to the index.
One method is to use the `index directive`_ above the document or section that
should appear in the index.
.. _`index directive`: http://sphinx-doc.org/markup/misc.html#directive-index
.. _`index directive`: https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html?highlight=index%20directive#index-generating-markup
.. code-block:: restructuredtext
@ -217,7 +217,7 @@ Another method is to use the `index role`_ inline with the text that should
appear in the index. The index entry is created and the target text is left
otherwise intact.
.. _`index role`: http://sphinx-doc.org/markup/misc.html#role-index
.. _`index role`: http://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#role-index
.. code-block:: restructuredtext
@ -252,7 +252,7 @@ to survive document renames or movement.
Note, the ``:doc:`` role should *not* be used to link documents together.
.. _`ref role`: http://sphinx-doc.org/markup/inline.html#role-ref
.. _`ref role`: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-ref
.. _docs-ref-modules:

View file

@ -283,7 +283,9 @@ Change to salt documentation directory, then:
:strong:`text`.
- The docs then are built within the :strong:`docs/_build/` folder. To update
the docs after making changes, run ``make`` again.
- The docs use `reStructuredText <http://sphinx-doc.org/rest.html>`_ for markup.
- The docs use `reStructuredText
<https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html>`_
for markup.
See a live demo at http://rst.ninjs.org/.
- The help information on each module or state is culled from the python code
that runs for that piece. Find them in ``salt/modules/`` or ``salt/states/``.

View file

@ -846,6 +846,13 @@ def _get_create_kwargs(skip_translate=None,
Take input kwargs and return a kwargs dict to pass to docker-py's
create_container() function.
'''
networks = kwargs.pop('networks', {})
if kwargs.get('network_mode', '') in networks:
networks = {kwargs['network_mode']: networks[kwargs['network_mode']]}
else:
networks = {}
kwargs = __utils__['docker.translate_input'](
salt.utils.docker.translate.container,
skip_translate=skip_translate,
@ -853,6 +860,9 @@ def _get_create_kwargs(skip_translate=None,
validate_ip_addrs=validate_ip_addrs,
**__utils__['args.clean_kwargs'](**kwargs))
if networks:
kwargs['networking_config'] = _create_networking_config(networks)
if client_args is None:
try:
client_args = get_client_args(['create_container', 'host_config'])
@ -2388,6 +2398,11 @@ def version():
return ret
def _create_networking_config(networks):
log.debug("creating networking config from {}".format(networks))
return _client_wrapper('create_networking_config',
{k: _client_wrapper('create_endpoint_config', **v) for k, v in networks.items()})
# Functions to manage containers
@_refresh_mine_cache
def create(image,

View file

@ -1673,6 +1673,8 @@ def running(name,
try:
networks = _parse_networks(networks)
if networks:
kwargs['networks'] = networks
image_id = _resolve_image(ret, image, client_timeout)
except CommandExecutionError as exc:
ret['result'] = False

View file

@ -5059,19 +5059,23 @@ def append(name,
if makedirs is True:
dirname = os.path.dirname(name)
if not __salt__['file.directory_exists'](dirname):
try:
_makedirs(name=name)
except CommandExecutionError as exc:
return _error(ret, 'Drive {0} is not mapped'.format(exc.message))
if __opts__['test']:
ret['comment'] = 'Directory {0} is set to be updated'.format(dirname)
ret['result'] = None
else:
if not __salt__['file.directory_exists'](dirname):
try:
_makedirs(name=name)
except CommandExecutionError as exc:
return _error(ret, 'Drive {0} is not mapped'.format(exc.message))
if salt.utils.platform.is_windows():
check_res, check_msg, ret['pchanges'] = _check_directory_win(dirname)
else:
check_res, check_msg, ret['pchanges'] = _check_directory(dirname)
if salt.utils.platform.is_windows():
check_res, check_msg, ret['pchanges'] = _check_directory_win(dirname)
else:
check_res, check_msg, ret['pchanges'] = _check_directory(dirname)
if not check_res:
return _error(ret, check_msg)
if not check_res:
return _error(ret, check_msg)
check_res, check_msg = _check_file(name)
if not check_res:

View file

@ -599,6 +599,33 @@ class DockerContainerTestCase(ModuleCase, SaltReturnAssertsMixin):
self.assertTrue('VAR2=value2' in ret['Config']['Env'])
self.assertTrue('VAR3=value3' not in ret['Config']['Env'])
@with_network(subnet='10.247.197.96/27', create=True)
@container_name
def test_static_ip_one_network(self, container_name, net):
'''
Ensure that if a network is created and specified as network_mode, that is the only network, and
the static IP is applied.
'''
requested_ip = '10.247.197.100'
kwargs = {
'name': container_name,
'image': self.image,
'network_mode': net.name,
'networks': [{net.name: [{'ipv4_address': requested_ip}]}],
'shutdown_timeout': 1,
}
# Create a container
ret = self.run_state('docker_container.running', **kwargs)
self.assertSaltTrueReturn(ret)
inspect_result = self.run_function('docker.inspect_container',
[container_name])
connected_networks = inspect_result['NetworkSettings']['Networks']
self.assertEqual(list(connected_networks.keys()), [net.name])
self.assertEqual(inspect_result['HostConfig']['NetworkMode'], net.name)
self.assertEqual(connected_networks[net.name]['IPAMConfig']['IPv4Address'], requested_ip)
def _test_running(self, container_name, *nets):
'''
DRY function for testing static IPs