mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Rename references to docker-ng with dockerng
This should clear up confusion that may be caused by the virtual name being different from the module name.
This commit is contained in:
parent
422da165e4
commit
e285388b78
@ -14,7 +14,7 @@ needed to be made to the functions and return data. In the end, a complete
|
||||
rewrite was done.
|
||||
|
||||
The changes being too significant, it was decided that making a separate
|
||||
execution module and state module (called ``docker-ng``) would be the best
|
||||
execution module and state module (called ``dockerng``) would be the best
|
||||
option. This will give users a couple release cycles to modify their scripts,
|
||||
SLS files, etc. to use the new functionality, rather than forcing users to
|
||||
change everything immediately.
|
||||
@ -22,7 +22,7 @@ change everything immediately.
|
||||
In the **Carbon** release of Salt (slated for late summer/early fall 2015),
|
||||
this execution module will take the place of the default Docker execution
|
||||
module, and backwards-compatible naming will be maintained for a couple
|
||||
releases after that to allow users time to replace references to ``docker-ng``
|
||||
releases after that to allow users time to replace references to ``dockerng``
|
||||
with ``docker``.
|
||||
|
||||
|
||||
@ -108,52 +108,52 @@ Functions
|
||||
---------
|
||||
|
||||
- Information Gathering
|
||||
- :py:func:`docker-ng.depends <salt.modules.dockerng.depends>`
|
||||
- :py:func:`docker-ng.diff <salt.modules.dockerng.diff>`
|
||||
- :py:func:`docker-ng.exists <salt.modules.dockerng.exists>`
|
||||
- :py:func:`docker-ng.history <salt.modules.dockerng.history>`
|
||||
- :py:func:`docker-ng.images <salt.modules.dockerng.images>`
|
||||
- :py:func:`docker-ng.info <salt.modules.dockerng.info>`
|
||||
- :py:func:`docker-ng.inspect <salt.modules.dockerng.inspect>`
|
||||
- :py:func:`docker-ng.inspect_container
|
||||
- :py:func:`dockerng.depends <salt.modules.dockerng.depends>`
|
||||
- :py:func:`dockerng.diff <salt.modules.dockerng.diff>`
|
||||
- :py:func:`dockerng.exists <salt.modules.dockerng.exists>`
|
||||
- :py:func:`dockerng.history <salt.modules.dockerng.history>`
|
||||
- :py:func:`dockerng.images <salt.modules.dockerng.images>`
|
||||
- :py:func:`dockerng.info <salt.modules.dockerng.info>`
|
||||
- :py:func:`dockerng.inspect <salt.modules.dockerng.inspect>`
|
||||
- :py:func:`dockerng.inspect_container
|
||||
<salt.modules.dockerng.inspect_container>`
|
||||
- :py:func:`docker-ng.inspect_image <salt.modules.dockerng.inspect_image>`
|
||||
- :py:func:`docker-ng.list_containers
|
||||
- :py:func:`dockerng.inspect_image <salt.modules.dockerng.inspect_image>`
|
||||
- :py:func:`dockerng.list_containers
|
||||
<salt.modules.dockerng.list_containers>`
|
||||
- :py:func:`docker-ng.list_tags <salt.modules.dockerng.list_tags>`
|
||||
- :py:func:`docker-ng.logs <salt.modules.dockerng.logs>`
|
||||
- :py:func:`docker-ng.pid <salt.modules.dockerng.pid>`
|
||||
- :py:func:`docker-ng.port <salt.modules.dockerng.port>`
|
||||
- :py:func:`docker-ng.ps <salt.modules.dockerng.ps_>`
|
||||
- :py:func:`docker-ng.state <salt.modules.dockerng.state>`
|
||||
- :py:func:`docker-ng.search <salt.modules.dockerng.search>`
|
||||
- :py:func:`docker-ng.top <salt.modules.dockerng.top>`
|
||||
- :py:func:`docker-ng.version <salt.modules.dockerng.version>`
|
||||
- :py:func:`dockerng.list_tags <salt.modules.dockerng.list_tags>`
|
||||
- :py:func:`dockerng.logs <salt.modules.dockerng.logs>`
|
||||
- :py:func:`dockerng.pid <salt.modules.dockerng.pid>`
|
||||
- :py:func:`dockerng.port <salt.modules.dockerng.port>`
|
||||
- :py:func:`dockerng.ps <salt.modules.dockerng.ps_>`
|
||||
- :py:func:`dockerng.state <salt.modules.dockerng.state>`
|
||||
- :py:func:`dockerng.search <salt.modules.dockerng.search>`
|
||||
- :py:func:`dockerng.top <salt.modules.dockerng.top>`
|
||||
- :py:func:`dockerng.version <salt.modules.dockerng.version>`
|
||||
- Container Management
|
||||
- :py:func:`docker-ng.create <salt.modules.dockerng.create>`
|
||||
- :py:func:`docker-ng.copy_from <salt.modules.dockerng.copy_from>`
|
||||
- :py:func:`docker-ng.copy_to <salt.modules.dockerng.copy_to>`
|
||||
- :py:func:`docker-ng.export <salt.modules.dockerng.export>`
|
||||
- :py:func:`docker-ng.rm <salt.modules.dockerng.rm_>`
|
||||
- :py:func:`dockerng.create <salt.modules.dockerng.create>`
|
||||
- :py:func:`dockerng.copy_from <salt.modules.dockerng.copy_from>`
|
||||
- :py:func:`dockerng.copy_to <salt.modules.dockerng.copy_to>`
|
||||
- :py:func:`dockerng.export <salt.modules.dockerng.export>`
|
||||
- :py:func:`dockerng.rm <salt.modules.dockerng.rm_>`
|
||||
- Management of Container State
|
||||
- :py:func:`docker-ng.kill <salt.modules.dockerng.kill>`
|
||||
- :py:func:`docker-ng.pause <salt.modules.dockerng.pause>`
|
||||
- :py:func:`docker-ng.restart <salt.modules.dockerng.restart>`
|
||||
- :py:func:`docker-ng.start <salt.modules.dockerng.start>`
|
||||
- :py:func:`docker-ng.stop <salt.modules.dockerng.stop>`
|
||||
- :py:func:`docker-ng.unpause <salt.modules.dockerng.unpause>`
|
||||
- :py:func:`docker-ng.wait <salt.modules.dockerng.wait>`
|
||||
- :py:func:`dockerng.kill <salt.modules.dockerng.kill>`
|
||||
- :py:func:`dockerng.pause <salt.modules.dockerng.pause>`
|
||||
- :py:func:`dockerng.restart <salt.modules.dockerng.restart>`
|
||||
- :py:func:`dockerng.start <salt.modules.dockerng.start>`
|
||||
- :py:func:`dockerng.stop <salt.modules.dockerng.stop>`
|
||||
- :py:func:`dockerng.unpause <salt.modules.dockerng.unpause>`
|
||||
- :py:func:`dockerng.wait <salt.modules.dockerng.wait>`
|
||||
- Image Management
|
||||
- :py:func:`docker-ng.build <salt.modules.dockerng.build>`
|
||||
- :py:func:`docker-ng.commit <salt.modules.dockerng.commit>`
|
||||
- :py:func:`docker-ng.dangling <salt.modules.dockerng.dangling>`
|
||||
- :py:func:`docker-ng.import <salt.modules.dockerng.import_>`
|
||||
- :py:func:`docker-ng.load <salt.modules.dockerng.load>`
|
||||
- :py:func:`docker-ng.pull <salt.modules.dockerng.pull>`
|
||||
- :py:func:`docker-ng.push <salt.modules.dockerng.push>`
|
||||
- :py:func:`docker-ng.rmi <salt.modules.dockerng.rmi>`
|
||||
- :py:func:`docker-ng.save <salt.modules.dockerng.save>`
|
||||
- :py:func:`docker-ng.tag <salt.modules.dockerng.tag>`
|
||||
- :py:func:`dockerng.build <salt.modules.dockerng.build>`
|
||||
- :py:func:`dockerng.commit <salt.modules.dockerng.commit>`
|
||||
- :py:func:`dockerng.dangling <salt.modules.dockerng.dangling>`
|
||||
- :py:func:`dockerng.import <salt.modules.dockerng.import_>`
|
||||
- :py:func:`dockerng.load <salt.modules.dockerng.load>`
|
||||
- :py:func:`dockerng.pull <salt.modules.dockerng.pull>`
|
||||
- :py:func:`dockerng.push <salt.modules.dockerng.push>`
|
||||
- :py:func:`dockerng.rmi <salt.modules.dockerng.rmi>`
|
||||
- :py:func:`dockerng.save <salt.modules.dockerng.save>`
|
||||
- :py:func:`dockerng.tag <salt.modules.dockerng.tag>`
|
||||
|
||||
.. _docker-execution-driver:
|
||||
|
||||
@ -190,13 +190,13 @@ a little work.
|
||||
This execution module provides functions that shadow those from the :mod:`cmd
|
||||
<salt.modules.cmdmod>` module. They are as follows:
|
||||
|
||||
- :py:func:`docker-ng.retcode <salt.modules.dockerng.retcode>`
|
||||
- :py:func:`docker-ng.run <salt.modules.dockerng.run>`
|
||||
- :py:func:`docker-ng.run_all <salt.modules.dockerng.run_all>`
|
||||
- :py:func:`docker-ng.run_stderr <salt.modules.dockerng.run_stderr>`
|
||||
- :py:func:`docker-ng.run_stdout <salt.modules.dockerng.run_stdout>`
|
||||
- :py:func:`docker-ng.script <salt.modules.dockerng.script>`
|
||||
- :py:func:`docker-ng.script_retcode <salt.modules.dockerng.script_retcode>`
|
||||
- :py:func:`dockerng.retcode <salt.modules.dockerng.retcode>`
|
||||
- :py:func:`dockerng.run <salt.modules.dockerng.run>`
|
||||
- :py:func:`dockerng.run_all <salt.modules.dockerng.run_all>`
|
||||
- :py:func:`dockerng.run_stderr <salt.modules.dockerng.run_stderr>`
|
||||
- :py:func:`dockerng.run_stdout <salt.modules.dockerng.run_stdout>`
|
||||
- :py:func:`dockerng.script <salt.modules.dockerng.script>`
|
||||
- :py:func:`dockerng.script_retcode <salt.modules.dockerng.script_retcode>`
|
||||
|
||||
|
||||
Detailed Function Documentation
|
||||
@ -281,11 +281,11 @@ STOP_TIMEOUT = 10
|
||||
NOTSET = object()
|
||||
|
||||
# Define the module's virtual name
|
||||
__virtualname__ = 'docker-ng'
|
||||
__virtualname__ = 'dockerng'
|
||||
|
||||
'''
|
||||
The below two dictionaries contain information on the kwargs which are
|
||||
acceptable in the docker-ng.create and docker-ng.start functions, respectively.
|
||||
acceptable in the dockerng.create and dockerng.start functions, respectively.
|
||||
The aim is to make adding new arguments easy, and to keep all of the various
|
||||
information needed to validate the input organized nicely.
|
||||
|
||||
@ -303,9 +303,9 @@ argument name:
|
||||
there should be a function named in the format _valid_<string> (e.g.
|
||||
_valid_bool) within _validate_input().
|
||||
|
||||
3. path - Refers to the nested path in the docker-ng.inspect_container return
|
||||
3. path - Refers to the nested path in the dockerng.inspect_container return
|
||||
data where that value is stored. This will only be used by the _compare()
|
||||
function in salt/states/docker-ng.py.
|
||||
function in salt/states/dockerng.py.
|
||||
|
||||
4. default - Many of the CLI options will default to None, but for booleans and
|
||||
integer values (and some others) we want to ensure that someone isn't able
|
||||
@ -481,7 +481,7 @@ def __virtual__():
|
||||
return __virtualname__
|
||||
else:
|
||||
log.warning(
|
||||
'Insufficient Docker version for docker-ng (required: '
|
||||
'Insufficient Docker version for dockerng (required: '
|
||||
'{0}, installed: {1})'.format(
|
||||
'.'.join(docker_versioninfo),
|
||||
'.'.join(MIN_DOCKER)
|
||||
@ -599,7 +599,7 @@ def _clear_context():
|
||||
# an exception will be raised if the size of the dict is modified during
|
||||
# iteration.
|
||||
keep_context = (
|
||||
'docker.client', 'docker.exec_driver', 'docker-ng._pull_status',
|
||||
'docker.client', 'docker.exec_driver', 'dockerng._pull_status',
|
||||
'docker.docker_version', 'docker.docker_py_version'
|
||||
)
|
||||
for key in __context__.keys():
|
||||
@ -739,7 +739,7 @@ def _prep_pull():
|
||||
Populate __context__ with the current (pre-pull) image IDs (see the
|
||||
docstring for _pull_status for more information).
|
||||
'''
|
||||
__context__['docker-ng._pull_status'] = \
|
||||
__context__['dockerng._pull_status'] = \
|
||||
[x[:12] for x in images(all=True)]
|
||||
|
||||
|
||||
@ -806,7 +806,7 @@ def _image_wrapper(attr, *args, **kwargs):
|
||||
registry_auth_config.update(data)
|
||||
|
||||
err = (
|
||||
'{0} Docker credentials{1}. Please see the docker-ng remote '
|
||||
'{0} Docker credentials{1}. Please see the dockerng remote '
|
||||
'execution module documentation for information on how to '
|
||||
'configure authentication.'
|
||||
)
|
||||
@ -919,14 +919,14 @@ def _pull_status(data, item):
|
||||
if id_ not in pulled:
|
||||
pulled.append(id_)
|
||||
|
||||
if 'docker-ng._pull_status' not in __context__:
|
||||
if 'dockerng._pull_status' not in __context__:
|
||||
log.warning(
|
||||
'_pull_status context variable was not populated, information on '
|
||||
'downloaded layers may be inaccurate. Please report this to the '
|
||||
'SaltStack development team, and if possible include the image '
|
||||
'(and tag) that was being pulled.'
|
||||
)
|
||||
__context__['docker-ng._pull_status'] = NOTSET
|
||||
__context__['dockerng._pull_status'] = NOTSET
|
||||
status = item['status']
|
||||
if status == 'Already exists':
|
||||
_already_exists(item['id'])
|
||||
@ -935,9 +935,9 @@ def _pull_status(data, item):
|
||||
elif status.startswith('Status: '):
|
||||
data['Status'] = status[8:]
|
||||
elif status == 'Download complete':
|
||||
if __context__['docker-ng._pull_status'] is not NOTSET:
|
||||
if __context__['dockerng._pull_status'] is not NOTSET:
|
||||
id_ = item['id']
|
||||
if id_ in __context__['docker-ng._pull_status']:
|
||||
if id_ in __context__['dockerng._pull_status']:
|
||||
_already_exists(id_)
|
||||
else:
|
||||
_new_layer(id_)
|
||||
@ -1588,7 +1588,7 @@ def _validate_input(action,
|
||||
# Have to call this func using the __salt__ dunder (instead of just
|
||||
# version()) because this _validate_input() will be imported into the
|
||||
# state module, and the state module won't have a version() func.
|
||||
_version = __salt__['docker-ng.version']()
|
||||
_version = __salt__['dockerng.version']()
|
||||
if 'VersionInfo' not in _version:
|
||||
log.warning(
|
||||
'Unable to determine docker version. Feature version checking '
|
||||
@ -1691,8 +1691,8 @@ def depends(name):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.depends myimage
|
||||
salt myminion docker-ng.depends 0123456789ab
|
||||
salt myminion dockerng.depends myimage
|
||||
salt myminion dockerng.depends 0123456789ab
|
||||
'''
|
||||
# Resolve tag or short-SHA to full SHA
|
||||
image_id = inspect_image(name)['Id']
|
||||
@ -1737,7 +1737,7 @@ def diff(name):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.diff mycontainer
|
||||
salt myminion dockerng.diff mycontainer
|
||||
'''
|
||||
changes = _client_wrapper('diff', name)
|
||||
kind_map = {0: 'Changed', 1: 'Added', 2: 'Deleted'}
|
||||
@ -1771,7 +1771,7 @@ def exists(name):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.exists mycontainer
|
||||
salt myminion dockerng.exists mycontainer
|
||||
'''
|
||||
contextkey = 'docker.exists.{0}'.format(name)
|
||||
if contextkey in __context__:
|
||||
@ -1799,7 +1799,7 @@ def history(name, quiet=False):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ salt myminion docker-ng.history nginx:latest quiet=True
|
||||
$ salt myminion dockerng.history nginx:latest quiet=True
|
||||
myminion:
|
||||
- FROM scratch
|
||||
- ADD file:ef063ed0ae9579362871b9f23d2bc0781ef7cd4de6ac822052cf6c9c5a12b1e2 in /
|
||||
@ -1838,7 +1838,7 @@ def history(name, quiet=False):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.exists mycontainer
|
||||
salt myminion dockerng.exists mycontainer
|
||||
'''
|
||||
response = _client_wrapper('history', name)
|
||||
key_map = {
|
||||
@ -1897,8 +1897,8 @@ def images(verbose=False, **kwargs):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.images
|
||||
salt myminion docker-ng.images all=True
|
||||
salt myminion dockerng.images
|
||||
salt myminion dockerng.images all=True
|
||||
'''
|
||||
if 'docker.images' not in __context__:
|
||||
response = _client_wrapper('images', all=kwargs.get('all', False))
|
||||
@ -1951,7 +1951,7 @@ def info():
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.info
|
||||
salt myminion dockerng.info
|
||||
'''
|
||||
return _client_wrapper('info')
|
||||
|
||||
@ -1980,8 +1980,8 @@ def inspect(name):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.inspect mycontainer
|
||||
salt myminion docker-ng.inspect busybox
|
||||
salt myminion dockerng.inspect mycontainer
|
||||
salt myminion dockerng.inspect busybox
|
||||
'''
|
||||
try:
|
||||
return inspect_container(name)
|
||||
@ -2017,8 +2017,8 @@ def inspect_container(name):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.inspect_container mycontainer
|
||||
salt myminion docker-ng.inspect_container 0123456789ab
|
||||
salt myminion dockerng.inspect_container mycontainer
|
||||
salt myminion dockerng.inspect_container 0123456789ab
|
||||
'''
|
||||
return _client_wrapper('inspect_container', name)
|
||||
|
||||
@ -2041,9 +2041,9 @@ def inspect_image(name):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.inspect_image busybox
|
||||
salt myminion docker-ng.inspect_image centos:6
|
||||
salt myminion docker-ng.inspect_image 0123456789ab
|
||||
salt myminion dockerng.inspect_image busybox
|
||||
salt myminion dockerng.inspect_image centos:6
|
||||
salt myminion dockerng.inspect_image 0123456789ab
|
||||
'''
|
||||
ret = _client_wrapper('inspect_image', name)
|
||||
for param in ('Size', 'VirtualSize'):
|
||||
@ -2055,8 +2055,8 @@ def inspect_image(name):
|
||||
def list_containers(**kwargs):
|
||||
'''
|
||||
Returns a list of containers by name. This is different from
|
||||
:py:func:`docker-ng.ps <salt.modules.dockerng.ps_>` in that
|
||||
:py:func:`docker-ng.ps <salt.modules.dockerng.ps_>` returns its results
|
||||
:py:func:`dockerng.ps <salt.modules.dockerng.ps_>` in that
|
||||
:py:func:`dockerng.ps <salt.modules.dockerng.ps_>` returns its results
|
||||
organized by container ID.
|
||||
|
||||
all : False
|
||||
@ -2066,7 +2066,7 @@ def list_containers(**kwargs):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.inspect_image <image>
|
||||
salt myminion dockerng.inspect_image <image>
|
||||
'''
|
||||
ret = set()
|
||||
for item in six.itervalues(ps_(all=kwargs.get('all', False))):
|
||||
@ -2083,7 +2083,7 @@ def list_tags():
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.list_tags
|
||||
salt myminion dockerng.list_tags
|
||||
'''
|
||||
ret = set()
|
||||
for item in six.itervalues(images()):
|
||||
@ -2104,7 +2104,7 @@ def logs(name):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.logs mycontainer
|
||||
salt myminion dockerng.logs mycontainer
|
||||
'''
|
||||
return _client_wrapper('logs', name)
|
||||
|
||||
@ -2121,8 +2121,8 @@ def pid(name):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.pid mycontainer
|
||||
salt myminion docker-ng.pid 0123456789ab
|
||||
salt myminion dockerng.pid mycontainer
|
||||
salt myminion dockerng.pid 0123456789ab
|
||||
'''
|
||||
return inspect_container(name)['State']['Pid']
|
||||
|
||||
@ -2154,9 +2154,9 @@ def port(name, private_port=None):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.port mycontainer
|
||||
salt myminion docker-ng.port mycontainer 5000
|
||||
salt myminion docker-ng.port mycontainer 5000/udp
|
||||
salt myminion dockerng.port mycontainer
|
||||
salt myminion dockerng.port mycontainer 5000
|
||||
salt myminion dockerng.port mycontainer 5000/udp
|
||||
'''
|
||||
# docker.client.Client.port() doesn't do what we need, so just inspect the
|
||||
# container and get the information from there. It's what they're already
|
||||
@ -2213,8 +2213,8 @@ def ps_(**kwargs):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.ps
|
||||
salt myminion docker-ng.ps all=True
|
||||
salt myminion dockerng.ps
|
||||
salt myminion dockerng.ps all=True
|
||||
'''
|
||||
if 'docker.ps' not in __context__:
|
||||
response = _client_wrapper('containers', all=True)
|
||||
@ -2272,7 +2272,7 @@ def state(name):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.state mycontainer
|
||||
salt myminion dockerng.state mycontainer
|
||||
'''
|
||||
contextkey = 'docker.state.{0}'.format(name)
|
||||
if contextkey in __context__:
|
||||
@ -2319,8 +2319,8 @@ def search(name, official=False, trusted=False):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.search centos
|
||||
salt myminion docker-ng.search centos official=True
|
||||
salt myminion dockerng.search centos
|
||||
salt myminion dockerng.search centos official=True
|
||||
'''
|
||||
response = _client_wrapper('search', name)
|
||||
if not response:
|
||||
@ -2378,8 +2378,8 @@ def top(name):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.top mycontainer
|
||||
salt myminion docker-ng.top 0123456789ab
|
||||
salt myminion dockerng.top mycontainer
|
||||
salt myminion dockerng.top 0123456789ab
|
||||
'''
|
||||
response = _client_wrapper('top', name)
|
||||
|
||||
@ -2407,7 +2407,7 @@ def version():
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.version
|
||||
salt myminion dockerng.version
|
||||
'''
|
||||
ret = _client_wrapper('version')
|
||||
version_re = re.compile(VERSION_RE)
|
||||
@ -2573,9 +2573,9 @@ def create(image,
|
||||
.. code-block:: bash
|
||||
|
||||
# Create a data-only container
|
||||
salt myminion docker-ng.create myuser/mycontainer volumes="/mnt/vol1,/mnt/vol2"
|
||||
salt myminion dockerng.create myuser/mycontainer volumes="/mnt/vol1,/mnt/vol2"
|
||||
# Create a CentOS 7 container that will stay running once started
|
||||
salt myminion docker-ng.create centos:7 name=mycent7 interactive=True tty=True command=bash
|
||||
salt myminion dockerng.create centos:7 name=mycent7 interactive=True tty=True command=bash
|
||||
'''
|
||||
try:
|
||||
# Try to inspect the image, if it fails then we know we need to pull it
|
||||
@ -2602,7 +2602,7 @@ def create(image,
|
||||
create_kwargs[val['api_name']] = create_kwargs.pop(key)
|
||||
|
||||
log.debug(
|
||||
'docker-ng.create is using the following kwargs to create '
|
||||
'dockerng.create is using the following kwargs to create '
|
||||
'container \'{0}\' from image \'{1}\': {2}'
|
||||
.format(name, image, create_kwargs)
|
||||
)
|
||||
@ -2653,7 +2653,7 @@ def copy_from(name, source, dest, overwrite=False, makedirs=False):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.copy_from mycontainer /var/log/nginx/access.log /home/myuser
|
||||
salt myminion dockerng.copy_from mycontainer /var/log/nginx/access.log /home/myuser
|
||||
'''
|
||||
c_state = state(name)
|
||||
if c_state != 'running':
|
||||
@ -2772,7 +2772,7 @@ def copy_to(name,
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.copy_to mycontainer /tmp/foo /root/foo
|
||||
salt myminion dockerng.copy_to mycontainer /tmp/foo /root/foo
|
||||
'''
|
||||
return __salt__['container_resource.copy_to'](
|
||||
name,
|
||||
@ -2853,8 +2853,8 @@ def export(name,
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.export mycontainer /tmp/mycontainer.tar
|
||||
salt myminion docker-ng.export mycontainer /tmp/mycontainer.tar.xz push=True
|
||||
salt myminion dockerng.export mycontainer /tmp/mycontainer.tar
|
||||
salt myminion dockerng.export mycontainer /tmp/mycontainer.tar.xz push=True
|
||||
'''
|
||||
err = 'Path \'{0}\' is not absolute'.format(path)
|
||||
try:
|
||||
@ -2992,8 +2992,8 @@ def rm_(name, force=False, volumes=False):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.rm mycontainer
|
||||
salt myminion docker-ng.rm mycontainer force=True
|
||||
salt myminion dockerng.rm mycontainer
|
||||
salt myminion dockerng.rm mycontainer force=True
|
||||
'''
|
||||
if state(name) == 'running' and not force:
|
||||
raise CommandExecutionError(
|
||||
@ -3069,8 +3069,8 @@ def build(path=None,
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.build /path/to/docker/build/dir image=myimage:dev
|
||||
salt myminion docker-ng.build https://github.com/myuser/myrepo.git image=myimage:latest
|
||||
salt myminion dockerng.build /path/to/docker/build/dir image=myimage:dev
|
||||
salt myminion dockerng.build https://github.com/myuser/myrepo.git image=myimage:latest
|
||||
'''
|
||||
_prep_pull()
|
||||
|
||||
@ -3167,8 +3167,8 @@ def commit(name,
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.commit mycontainer myuser/myimage
|
||||
salt myminion docker-ng.commit mycontainer myuser/myimage:mytag
|
||||
salt myminion dockerng.commit mycontainer myuser/myimage
|
||||
salt myminion dockerng.commit mycontainer myuser/myimage:mytag
|
||||
'''
|
||||
repo_name, repo_tag = _get_repo_tag(image)
|
||||
time_started = time.time()
|
||||
@ -3232,8 +3232,8 @@ def dangling(prune=False, force=False):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.dangling
|
||||
salt myminion docker-ng.dangling prune=True
|
||||
salt myminion dockerng.dangling
|
||||
salt myminion dockerng.dangling prune=True
|
||||
'''
|
||||
all_images = images(all=True)
|
||||
dangling_images = [x[:12] for x in _get_top_level_images(all_images)
|
||||
@ -3289,9 +3289,9 @@ def import_(source,
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.import /tmp/cent7-minimal.tar.xz myuser/centos
|
||||
salt myminion docker-ng.import /tmp/cent7-minimal.tar.xz myuser/centos:7
|
||||
salt myminion docker-ng.import salt://dockerimages/cent7-minimal.tar.xz myuser/centos:7
|
||||
salt myminion dockerng.import /tmp/cent7-minimal.tar.xz myuser/centos
|
||||
salt myminion dockerng.import /tmp/cent7-minimal.tar.xz myuser/centos:7
|
||||
salt myminion dockerng.import salt://dockerimages/cent7-minimal.tar.xz myuser/centos:7
|
||||
'''
|
||||
repo_name, repo_tag = _get_repo_tag(image)
|
||||
path = __salt__['container_resource.cache_file'](source)
|
||||
@ -3336,7 +3336,7 @@ def import_(source,
|
||||
|
||||
def load(path, image=None):
|
||||
'''
|
||||
Load a tar archive that was created using :py:func:`docker-ng.save
|
||||
Load a tar archive that was created using :py:func:`dockerng.save
|
||||
<salt.modules.dockerng.save>` (or via the Docker CLI using ``docker
|
||||
save``).
|
||||
|
||||
@ -3349,7 +3349,7 @@ def load(path, image=None):
|
||||
|
||||
image : None
|
||||
If specified, the topmost layer of the newly-loaded image will be
|
||||
tagged with the specified repo and tag using :py:func:`docker-ng.tag
|
||||
tagged with the specified repo and tag using :py:func:`dockerng.tag
|
||||
<salt.modules.dockerng.tag_>`. The image name should be specified in
|
||||
``repo:tag`` notation. If just the repository name is passed, a tag
|
||||
name of ``latest`` will be assumed.
|
||||
@ -3377,8 +3377,8 @@ def load(path, image=None):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.load /path/to/image.tar
|
||||
salt myminion docker-ng.load salt://path/to/docker/saved/image.tar image=myuser/myimage:mytag
|
||||
salt myminion dockerng.load /path/to/image.tar
|
||||
salt myminion dockerng.load salt://path/to/docker/saved/image.tar image=myuser/myimage:mytag
|
||||
'''
|
||||
if image is not None:
|
||||
image = ':'.join(_get_repo_tag(image))
|
||||
@ -3437,7 +3437,7 @@ def layers(name):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.layers centos:7
|
||||
salt myminion dockerng.layers centos:7
|
||||
'''
|
||||
ret = []
|
||||
cmd = ['docker', 'history', '-q', name]
|
||||
@ -3496,8 +3496,8 @@ def pull(image,
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.pull centos
|
||||
salt myminion docker-ng.pull centos:6
|
||||
salt myminion dockerng.pull centos
|
||||
salt myminion dockerng.pull centos:6
|
||||
'''
|
||||
_prep_pull()
|
||||
|
||||
@ -3587,8 +3587,8 @@ def push(image,
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.push myuser/mycontainer
|
||||
salt myminion docker-ng.push myuser/mycontainer:mytag
|
||||
salt myminion dockerng.push myuser/mycontainer
|
||||
salt myminion dockerng.push myuser/mycontainer:mytag
|
||||
'''
|
||||
repo_name, repo_tag = _get_repo_tag(image)
|
||||
kwargs = {'tag': repo_tag,
|
||||
@ -3663,9 +3663,9 @@ def rmi(*names, **kwargs):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.rmi busybox
|
||||
salt myminion docker-ng.rmi busybox force=True
|
||||
salt myminion docker-ng.rmi foo bar baz
|
||||
salt myminion dockerng.rmi busybox
|
||||
salt myminion dockerng.rmi busybox force=True
|
||||
salt myminion dockerng.rmi foo bar baz
|
||||
'''
|
||||
pre_images = images(all=True)
|
||||
pre_tags = list_tags()
|
||||
@ -3784,8 +3784,8 @@ def save(name,
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.save centos:7 /tmp/cent7.tar
|
||||
salt myminion docker-ng.save 0123456789ab cdef01234567 /tmp/saved.tar
|
||||
salt myminion dockerng.save centos:7 /tmp/cent7.tar
|
||||
salt myminion dockerng.save 0123456789ab cdef01234567 /tmp/saved.tar
|
||||
'''
|
||||
err = 'Path \'{0}\' is not absolute'.format(path)
|
||||
try:
|
||||
@ -3928,8 +3928,8 @@ def tag_(name, image, force=False):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.tag 0123456789ab myrepo/mycontainer
|
||||
salt myminion docker-ng.tag 0123456789ab myrepo/mycontainer:mytag
|
||||
salt myminion dockerng.tag 0123456789ab myrepo/mycontainer
|
||||
salt myminion dockerng.tag 0123456789ab myrepo/mycontainer:mytag
|
||||
'''
|
||||
image_id = inspect_image(name)['Id']
|
||||
repo_name, repo_tag = _get_repo_tag(image)
|
||||
@ -3967,7 +3967,7 @@ def kill(name):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.kill mycontainer
|
||||
salt myminion dockerng.kill mycontainer
|
||||
'''
|
||||
return _change_state(name, 'kill', 'stopped')
|
||||
|
||||
@ -3996,7 +3996,7 @@ def pause(name):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.pause mycontainer
|
||||
salt myminion dockerng.pause mycontainer
|
||||
'''
|
||||
orig_state = state(name)
|
||||
if orig_state == 'stopped':
|
||||
@ -4037,8 +4037,8 @@ def restart(name, timeout=10):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.restart mycontainer
|
||||
salt myminion docker-ng.restart mycontainer timeout=20
|
||||
salt myminion dockerng.restart mycontainer
|
||||
salt myminion dockerng.restart mycontainer timeout=20
|
||||
'''
|
||||
ret = _change_state(name, 'restart', 'running', timeout=timeout)
|
||||
if ret['result']:
|
||||
@ -4068,7 +4068,7 @@ def signal_(name, signal):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.signal mycontainer SIGHUP
|
||||
salt myminion dockerng.signal mycontainer SIGHUP
|
||||
'''
|
||||
_client_wrapper('kill', name, signal=signal)
|
||||
return True
|
||||
@ -4102,7 +4102,7 @@ def start(name, validate_ip_addrs=True, **kwargs):
|
||||
|
||||
port_bindings
|
||||
Bind exposed ports which were exposed using the ``ports`` argument to
|
||||
:py:func:`docker-ng.create <salt.modules.dockerng.create>`. These
|
||||
:py:func:`dockerng.create <salt.modules.dockerng.create>`. These
|
||||
should be passed in the same way as the ``--publish`` argument to the
|
||||
``docker run`` CLI command:
|
||||
|
||||
@ -4142,7 +4142,7 @@ def start(name, validate_ip_addrs=True, **kwargs):
|
||||
|
||||
publish_all_ports : False
|
||||
Allocates a random host port for each port exposed using the ``ports``
|
||||
argument to :py:func:`docker-ng.create <salt.modules.dockerng.create>`.
|
||||
argument to :py:func:`dockerng.create <salt.modules.dockerng.create>`.
|
||||
|
||||
Example: ``publish_all_ports=True``
|
||||
|
||||
@ -4257,7 +4257,7 @@ def start(name, validate_ip_addrs=True, **kwargs):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.start mycontainer
|
||||
salt myminion dockerng.start mycontainer
|
||||
'''
|
||||
orig_state = state(name)
|
||||
if orig_state == 'paused':
|
||||
@ -4282,7 +4282,7 @@ def start(name, validate_ip_addrs=True, **kwargs):
|
||||
runtime_kwargs[val['api_name']] = runtime_kwargs.pop(key)
|
||||
|
||||
log.debug(
|
||||
'docker-ng.start is using the following kwargs to start container '
|
||||
'dockerng.start is using the following kwargs to start container '
|
||||
'\'{0}\': {1}'.format(name, runtime_kwargs)
|
||||
)
|
||||
return _change_state(name, 'start', 'running', **runtime_kwargs)
|
||||
@ -4319,9 +4319,9 @@ def stop(name, timeout=STOP_TIMEOUT, **kwargs):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.stop mycontainer
|
||||
salt myminion docker-ng.stop mycontainer unpause=True
|
||||
salt myminion docker-ng.stop mycontainer timeout=20
|
||||
salt myminion dockerng.stop mycontainer
|
||||
salt myminion dockerng.stop mycontainer unpause=True
|
||||
salt myminion dockerng.stop mycontainer timeout=20
|
||||
'''
|
||||
orig_state = state(name)
|
||||
if orig_state == 'paused':
|
||||
@ -4367,7 +4367,7 @@ def unpause(name):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.pause mycontainer
|
||||
salt myminion dockerng.pause mycontainer
|
||||
'''
|
||||
orig_state = state(name)
|
||||
if orig_state == 'stopped':
|
||||
@ -4407,7 +4407,7 @@ def wait(name):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.wait mycontainer
|
||||
salt myminion dockerng.wait mycontainer
|
||||
'''
|
||||
return _change_state(name, 'wait', 'stopped')
|
||||
|
||||
@ -4560,7 +4560,7 @@ def retcode(name,
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.retcode mycontainer 'ls -l /etc'
|
||||
salt myminion dockerng.retcode mycontainer 'ls -l /etc'
|
||||
'''
|
||||
return _run(name,
|
||||
cmd,
|
||||
@ -4617,7 +4617,7 @@ def run(name,
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.run mycontainer 'ls -l /etc'
|
||||
salt myminion dockerng.run mycontainer 'ls -l /etc'
|
||||
'''
|
||||
return _run(name,
|
||||
cmd,
|
||||
@ -4680,7 +4680,7 @@ def run_all(name,
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.run_all mycontainer 'ls -l /etc'
|
||||
salt myminion dockerng.run_all mycontainer 'ls -l /etc'
|
||||
'''
|
||||
return _run(name,
|
||||
cmd,
|
||||
@ -4738,7 +4738,7 @@ def run_stderr(name,
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.run_stderr mycontainer 'ls -l /etc'
|
||||
salt myminion dockerng.run_stderr mycontainer 'ls -l /etc'
|
||||
'''
|
||||
return _run(name,
|
||||
cmd,
|
||||
@ -4796,7 +4796,7 @@ def run_stdout(name,
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.run_stdout mycontainer 'ls -l /etc'
|
||||
salt myminion dockerng.run_stdout mycontainer 'ls -l /etc'
|
||||
'''
|
||||
return _run(name,
|
||||
cmd,
|
||||
@ -4870,9 +4870,9 @@ def script(name,
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.script mycontainer salt://docker_script.py
|
||||
salt myminion docker-ng.script mycontainer salt://scripts/runme.sh 'arg1 arg2 "arg 3"'
|
||||
salt myminion docker-ng.script mycontainer salt://scripts/runme.sh stdin='one\\ntwo\\nthree\\nfour\\nfive\\n' output_loglevel=quiet
|
||||
salt myminion dockerng.script mycontainer salt://docker_script.py
|
||||
salt myminion dockerng.script mycontainer salt://scripts/runme.sh 'arg1 arg2 "arg 3"'
|
||||
salt myminion dockerng.script mycontainer salt://scripts/runme.sh stdin='one\\ntwo\\nthree\\nfour\\nfive\\n' output_loglevel=quiet
|
||||
'''
|
||||
return _script(name,
|
||||
source,
|
||||
@ -4943,9 +4943,9 @@ def script_retcode(name,
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion docker-ng.script_retcode mycontainer salt://docker_script.py
|
||||
salt myminion docker-ng.script_retcode mycontainer salt://scripts/runme.sh 'arg1 arg2 "arg 3"'
|
||||
salt myminion docker-ng.script_retcode mycontainer salt://scripts/runme.sh stdin='one\\ntwo\\nthree\\nfour\\nfive\\n' output_loglevel=quiet
|
||||
salt myminion dockerng.script_retcode mycontainer salt://docker_script.py
|
||||
salt myminion dockerng.script_retcode mycontainer salt://scripts/runme.sh 'arg1 arg2 "arg 3"'
|
||||
salt myminion dockerng.script_retcode mycontainer salt://scripts/runme.sh stdin='one\\ntwo\\nthree\\nfour\\nfive\\n' output_loglevel=quiet
|
||||
'''
|
||||
return _script(name,
|
||||
source,
|
||||
|
@ -5,7 +5,7 @@ Management of Docker containers
|
||||
.. versionadded:: Beryllium
|
||||
|
||||
|
||||
This is the state module to accompany the :mod:`docker-ng
|
||||
This is the state module to accompany the :mod:`dockerng
|
||||
<salt.modules.dockerng>` execution module.
|
||||
|
||||
.. note::
|
||||
@ -40,7 +40,7 @@ import salt.ext.six as six
|
||||
log = logging.getLogger(__name__) # pylint: disable=invalid-name
|
||||
|
||||
# Define the module's virtual name
|
||||
__virtualname__ = 'docker-ng'
|
||||
__virtualname__ = 'dockerng'
|
||||
|
||||
NOTSET = object()
|
||||
|
||||
@ -49,7 +49,7 @@ def __virtual__():
|
||||
'''
|
||||
Only load if the dockerio execution module is available
|
||||
'''
|
||||
if 'docker-ng.version' in __salt__:
|
||||
if 'dockerng.version' in __salt__:
|
||||
global _validate_input # pylint: disable=global-statement
|
||||
_validate_input = salt.utils.namespaced_function(
|
||||
_validate_input, globals()
|
||||
@ -72,7 +72,7 @@ def _format_comments(comments):
|
||||
def _api_mismatch(param):
|
||||
'''
|
||||
Raise an exception if a config value can't be found at the expected
|
||||
location in a call to docker-ng.inspect_container
|
||||
location in a call to dockerng.inspect_container
|
||||
'''
|
||||
raise CommandExecutionError(
|
||||
'Unable to compare configuration for the \'{0}\' parameter. This may '
|
||||
@ -104,7 +104,7 @@ def _prep_input(kwargs):
|
||||
def _compare(actual, create_kwargs, runtime_kwargs):
|
||||
'''
|
||||
Compare the desired configuration against the actual configuration returned
|
||||
by docker-ng.inspect_container
|
||||
by dockerng.inspect_container
|
||||
'''
|
||||
_get = lambda path: (
|
||||
salt.utils.traverse_dict(actual, path, NOTSET, delimiter=':')
|
||||
@ -119,7 +119,7 @@ def _compare(actual, create_kwargs, runtime_kwargs):
|
||||
'parameter. Skipping.'.format(item)
|
||||
)
|
||||
continue
|
||||
log.trace('docker-ng.running: comparing ' + item)
|
||||
log.trace('dockerng.running: comparing ' + item)
|
||||
conf_path = valid_opts[item]['path']
|
||||
if isinstance(conf_path, tuple):
|
||||
actual_data = [_get(x) for x in conf_path]
|
||||
@ -130,9 +130,9 @@ def _compare(actual, create_kwargs, runtime_kwargs):
|
||||
actual_data = _get(conf_path)
|
||||
if actual_data is NOTSET:
|
||||
_api_mismatch(item)
|
||||
log.trace('docker-ng.running ({0}): desired value: {1}'
|
||||
log.trace('dockerng.running ({0}): desired value: {1}'
|
||||
.format(item, data))
|
||||
log.trace('docker-ng.running ({0}): actual value: {1}'
|
||||
log.trace('dockerng.running ({0}): actual value: {1}'
|
||||
.format(item, actual_data))
|
||||
|
||||
if actual_data is None and data is not None \
|
||||
@ -145,7 +145,7 @@ def _compare(actual, create_kwargs, runtime_kwargs):
|
||||
# Something unique here. Two fields to check, if both are False
|
||||
# then detach is True
|
||||
actual_detach = all(x is False for x in actual_data)
|
||||
log.trace('docker-ng.running ({0}): munged actual value: {1}'
|
||||
log.trace('dockerng.running ({0}): munged actual value: {1}'
|
||||
.format(item, actual_detach))
|
||||
if actual_detach != data:
|
||||
ret.update({item: {'old': actual_detach, 'new': data}})
|
||||
@ -164,7 +164,7 @@ def _compare(actual, create_kwargs, runtime_kwargs):
|
||||
continue
|
||||
else:
|
||||
actual_env[key] = val
|
||||
log.trace('docker-ng.running ({0}): munged actual value: {1}'
|
||||
log.trace('dockerng.running ({0}): munged actual value: {1}'
|
||||
.format(item, actual_env))
|
||||
env_diff = {}
|
||||
for key in data:
|
||||
@ -191,9 +191,9 @@ def _compare(actual, create_kwargs, runtime_kwargs):
|
||||
else:
|
||||
desired_ports.append('{0}/tcp'.format(port_def))
|
||||
desired_ports.sort()
|
||||
log.trace('docker-ng.running ({0}): munged actual value: {1}'
|
||||
log.trace('dockerng.running ({0}): munged actual value: {1}'
|
||||
.format(item, actual_ports))
|
||||
log.trace('docker-ng.running ({0}): munged desired value: {1}'
|
||||
log.trace('dockerng.running ({0}): munged desired value: {1}'
|
||||
.format(item, desired_ports))
|
||||
if actual_ports != desired_ports:
|
||||
ret.update({item: {'old': actual_ports,
|
||||
@ -285,9 +285,9 @@ def _compare(actual, create_kwargs, runtime_kwargs):
|
||||
desired_binds.append(bind_def)
|
||||
actual_binds.sort()
|
||||
desired_binds.sort()
|
||||
log.trace('docker-ng.running ({0}): munged actual value: {1}'
|
||||
log.trace('dockerng.running ({0}): munged actual value: {1}'
|
||||
.format(item, actual_binds))
|
||||
log.trace('docker-ng.running ({0}): munged desired value: {1}'
|
||||
log.trace('dockerng.running ({0}): munged desired value: {1}'
|
||||
.format(item, desired_binds))
|
||||
if actual_binds != desired_binds:
|
||||
ret.update({item: {'old': actual_binds,
|
||||
@ -340,9 +340,9 @@ def _compare(actual, create_kwargs, runtime_kwargs):
|
||||
# value for "volumes", just its keys.
|
||||
actual_data = sorted(actual_data)
|
||||
desired_data = sorted(data)
|
||||
log.trace('docker-ng.running ({0}): munged actual value: {1}'
|
||||
log.trace('dockerng.running ({0}): munged actual value: {1}'
|
||||
.format(item, actual_data))
|
||||
log.trace('docker-ng.running ({0}): munged desired value: {1}'
|
||||
log.trace('dockerng.running ({0}): munged desired value: {1}'
|
||||
.format(item, desired_data))
|
||||
if actual_data != desired_data:
|
||||
ret.update({item: {'old': actual_data,
|
||||
@ -378,7 +378,7 @@ def image_present(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
myuser/myimage:mytag:
|
||||
docker-ng.image_present
|
||||
dockerng.image_present
|
||||
|
||||
build
|
||||
Path to directory on the Minion containing a Dockerfile
|
||||
@ -386,22 +386,22 @@ def image_present(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
myuser/myimage:mytag:
|
||||
docker-ng.image_present:
|
||||
dockerng.image_present:
|
||||
- build: /home/myuser/docker/myimage
|
||||
|
||||
The image will be built using :py:func:`docker-ng.build
|
||||
The image will be built using :py:func:`dockerng.build
|
||||
<salt.modules.dockerng.build>` and the specified image name and tag
|
||||
will be applied to it.
|
||||
|
||||
load
|
||||
Loads a tar archive created with :py:func:`docker-ng.load
|
||||
Loads a tar archive created with :py:func:`dockerng.load
|
||||
<salt.modules.dockerng.load>` (or the ``docker load`` Docker CLI
|
||||
command), and assigns it the specified repo and tag.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
myuser/myimage:mytag:
|
||||
docker-ng.image_present:
|
||||
dockerng.image_present:
|
||||
- load: salt://path/to/image.tar
|
||||
|
||||
force : False
|
||||
@ -422,7 +422,7 @@ def image_present(name,
|
||||
|
||||
# Ensure that we have repo:tag notation
|
||||
image = ':'.join(_get_repo_tag(name))
|
||||
all_tags = __salt__['docker-ng.list_tags']()
|
||||
all_tags = __salt__['dockerng.list_tags']()
|
||||
|
||||
if image not in all_tags and not force:
|
||||
ret['result'] = True
|
||||
@ -431,7 +431,7 @@ def image_present(name,
|
||||
|
||||
if image in all_tags:
|
||||
try:
|
||||
image_info = __salt__['docker-ng.inspect_image'](name)
|
||||
image_info = __salt__['dockerng.inspect_image'](name)
|
||||
except Exception as exc:
|
||||
ret['comment'] = \
|
||||
'Unable to get info for image \'{0}\': {1}'.format(name, exc)
|
||||
@ -454,7 +454,7 @@ def image_present(name,
|
||||
|
||||
if build:
|
||||
try:
|
||||
image_update = __salt__['docker-ng.build'](path=build, image=image)
|
||||
image_update = __salt__['dockerng.build'](path=build, image=image)
|
||||
except Exception as exc:
|
||||
ret['comment'] = (
|
||||
'Encountered error building {0} as {1}: {2}'
|
||||
@ -466,7 +466,7 @@ def image_present(name,
|
||||
|
||||
elif load:
|
||||
try:
|
||||
image_update = __salt__['docker-ng.load'](path=load, image=image)
|
||||
image_update = __salt__['dockerng.load'](path=load, image=image)
|
||||
except Exception as exc:
|
||||
ret['comment'] = (
|
||||
'Encountered error loading {0} as {1}: {2}'
|
||||
@ -478,7 +478,7 @@ def image_present(name,
|
||||
|
||||
else:
|
||||
try:
|
||||
image_update = __salt__['docker-ng.pull'](
|
||||
image_update = __salt__['dockerng.pull'](
|
||||
image,
|
||||
insecure_registry=insecure_registry,
|
||||
client_timeout=client_timeout
|
||||
@ -493,7 +493,7 @@ def image_present(name,
|
||||
if image_info is None or image_update.get('Layers', {}).get('Pulled'):
|
||||
ret['changes'] = image_update
|
||||
|
||||
ret['result'] = image in __salt__['docker-ng.list_tags']()
|
||||
ret['result'] = image in __salt__['dockerng.list_tags']()
|
||||
|
||||
if not ret['result']:
|
||||
# This shouldn't happen, failure to pull should be caught above
|
||||
@ -521,7 +521,7 @@ def image_absent(name=None, images=None, force=False):
|
||||
.. code-block:: yaml
|
||||
|
||||
remove_images:
|
||||
docker-ng.image_absent:
|
||||
dockerng.image_absent:
|
||||
- names:
|
||||
- busybox
|
||||
- centos:6
|
||||
@ -530,7 +530,7 @@ def image_absent(name=None, images=None, force=False):
|
||||
.. code-block:: yaml
|
||||
|
||||
remove_images:
|
||||
docker-ng.image_absent:
|
||||
dockerng.image_absent:
|
||||
- images:
|
||||
- busybox
|
||||
- centos:6
|
||||
@ -548,19 +548,19 @@ def image_absent(name=None, images=None, force=False):
|
||||
.. note::
|
||||
|
||||
This option can also be overridden by Pillar data. If the Minion
|
||||
has a pillar variable named ``docker-ng.running.force`` which is
|
||||
has a pillar variable named ``dockerng.running.force`` which is
|
||||
set to ``True``, it will turn on this option. This pillar variable
|
||||
can even be set at runtime. For example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt myminion state.sls docker_stuff pillar="{docker-ng.force: True}"
|
||||
salt myminion state.sls docker_stuff pillar="{dockerng.force: True}"
|
||||
|
||||
If this pillar variable is present and set to ``False``, then it
|
||||
will turn off this option.
|
||||
|
||||
For more granular control, setting a pillar variable named
|
||||
``docker-ng.force.image_name`` will affect only the named image.
|
||||
``dockerng.force.image_name`` will affect only the named image.
|
||||
'''
|
||||
ret = {'name': name,
|
||||
'changes': {},
|
||||
@ -586,7 +586,7 @@ def image_absent(name=None, images=None, force=False):
|
||||
except TypeError:
|
||||
targets = [':'.join(_get_repo_tag(str(name)))]
|
||||
|
||||
pre_tags = __salt__['docker-ng.list_tags']()
|
||||
pre_tags = __salt__['dockerng.list_tags']()
|
||||
to_delete = [x for x in targets if x in pre_tags]
|
||||
log.debug('targets = {0}'.format(targets))
|
||||
log.debug('to_delete = {0}'.format(to_delete))
|
||||
@ -609,8 +609,8 @@ def image_absent(name=None, images=None, force=False):
|
||||
.format(', '.join(to_delete)))
|
||||
return ret
|
||||
|
||||
result = __salt__['docker-ng.rmi'](*to_delete, force=force)
|
||||
post_tags = __salt__['docker-ng.list_tags']()
|
||||
result = __salt__['dockerng.rmi'](*to_delete, force=force)
|
||||
post_tags = __salt__['dockerng.list_tags']()
|
||||
failed = [x for x in to_delete if x in post_tags]
|
||||
|
||||
if failed:
|
||||
@ -667,7 +667,7 @@ def running(name,
|
||||
the image needs to be built from a Dockerfile or loaded from a
|
||||
saved image, or if you would like to use requisites to trigger a
|
||||
replacement of the container when the image is updated, then the
|
||||
:py:func:`docker-ng.image_present
|
||||
:py:func:`dockerng.image_present
|
||||
<salt.modules.dockerng.image_present>` should be used to manage the
|
||||
image.
|
||||
|
||||
@ -677,8 +677,8 @@ def running(name,
|
||||
|
||||
stop_timeout : 10
|
||||
If the container needs to be replaced, the container will be stopped
|
||||
using :py:func:`docker-ng.stop <salt.modules.dockerng.stop>`. The value
|
||||
of this parameter will be passed to :py:func:`docker-ng.stop
|
||||
using :py:func:`dockerng.stop <salt.modules.dockerng.stop>`. The value
|
||||
of this parameter will be passed to :py:func:`dockerng.stop
|
||||
<salt.modules.dockerng.stop>` as the ``timeout`` value, telling Docker
|
||||
how long to wait for a graceful shutdown before killing the container.
|
||||
|
||||
@ -702,7 +702,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
mycontainer:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: busybox
|
||||
- watch_action: SIGHUP
|
||||
- watch:
|
||||
@ -731,7 +731,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- command: bash
|
||||
|
||||
@ -743,7 +743,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- hostname: web1
|
||||
|
||||
@ -755,7 +755,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- hostname: web1
|
||||
- network_mode: host
|
||||
@ -766,7 +766,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- hostname: domain.tld
|
||||
|
||||
@ -777,7 +777,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- interactive: True
|
||||
|
||||
@ -787,7 +787,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- tty: True
|
||||
|
||||
@ -797,7 +797,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- detach: False
|
||||
|
||||
@ -807,7 +807,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- user: foo
|
||||
|
||||
@ -819,7 +819,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- memory: 512M
|
||||
|
||||
@ -830,7 +830,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- memory_swap: 1G
|
||||
|
||||
@ -841,7 +841,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- mac_address: 01:23:45:67:89:0a
|
||||
|
||||
@ -851,7 +851,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- network_disabled: True
|
||||
|
||||
@ -861,7 +861,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- working_dir: /var/log/nginx
|
||||
|
||||
@ -871,7 +871,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- entrypoint: "mycmd --arg1 --arg2"
|
||||
|
||||
@ -880,7 +880,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- entrypoint:
|
||||
- mycmd
|
||||
@ -894,7 +894,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- environment:
|
||||
- VAR1: value
|
||||
@ -903,7 +903,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- environment:
|
||||
- VAR1=value
|
||||
@ -918,14 +918,14 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- ports: 1111,2222/udp
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- ports:
|
||||
- 1111
|
||||
@ -939,14 +939,14 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- volumes: /mnt/vol1,/mnt/vol2
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- volumes:
|
||||
- /mnt/vol1
|
||||
@ -958,7 +958,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- cpu_shares: 0.5
|
||||
|
||||
@ -970,7 +970,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- cpuset: "0,1"
|
||||
|
||||
@ -983,7 +983,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- binds: /srv/www:/var/www:ro,/etc/foo.conf:/usr/local/etc/foo.conf:rw
|
||||
|
||||
@ -992,7 +992,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- binds:
|
||||
- /srv/www:/var/www:ro
|
||||
@ -1005,7 +1005,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- binds:
|
||||
- /srv/www:/var/www:ro
|
||||
@ -1030,14 +1030,14 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- port_bindings: "5000:5000,2123:2123/udp,8080"
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- port_bindings:
|
||||
- 5000:5000
|
||||
@ -1057,7 +1057,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- lxc_conf:
|
||||
- lxc.utsname: docker
|
||||
@ -1075,7 +1075,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- ports: 8080
|
||||
- publish_all_ports: True
|
||||
@ -1089,14 +1089,14 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- links: web1:link1,web2:link2
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- links:
|
||||
- web1:link1
|
||||
@ -1109,14 +1109,14 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- dns: 8.8.8.8,8.8.4.4
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- dns:
|
||||
- 8.8.8.8
|
||||
@ -1133,14 +1133,14 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- dns_search: foo1.domain.tld,foo2.domain.tld
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- dns_search:
|
||||
- foo1.domain.tld
|
||||
@ -1154,14 +1154,14 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- volumes_from: foo
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- volumes_from:
|
||||
- foo
|
||||
@ -1185,7 +1185,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- network_mode: null
|
||||
|
||||
@ -1199,12 +1199,12 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- restart_policy: on-failure:5
|
||||
|
||||
bar:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- restart_policy: always
|
||||
|
||||
@ -1216,14 +1216,14 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- cap_add: SYS_ADMIN,MKNOD
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- cap_add:
|
||||
- SYS_ADMIN
|
||||
@ -1241,14 +1241,14 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- cap_drop: SYS_ADMIN,MKNOD
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- cap_drop:
|
||||
- SYS_ADMIN
|
||||
@ -1266,14 +1266,14 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- extra_hosts: web1:10.9.8.7,web2:10.9.8.8
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- extra_hosts:
|
||||
- web1:10.9.8.7
|
||||
@ -1294,7 +1294,7 @@ def running(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
foo:
|
||||
docker-ng.running:
|
||||
dockerng.running:
|
||||
- image: bar/baz:latest
|
||||
- pid_mode: host
|
||||
|
||||
@ -1316,11 +1316,11 @@ def running(name,
|
||||
except TypeError:
|
||||
image = ':'.join(_get_repo_tag(str(image)))
|
||||
|
||||
if name not in __salt__['docker-ng.list_containers'](all=True):
|
||||
if name not in __salt__['dockerng.list_containers'](all=True):
|
||||
pre_config = {}
|
||||
else:
|
||||
try:
|
||||
pre_config = __salt__['docker-ng.inspect_container'](name)
|
||||
pre_config = __salt__['dockerng.inspect_container'](name)
|
||||
if 'Config' in pre_config and 'Image' in pre_config['Config']:
|
||||
current_image = ':'.join(
|
||||
_get_repo_tag(pre_config['Config']['Image'])
|
||||
@ -1381,7 +1381,7 @@ def running(name,
|
||||
_prep_input(create_kwargs)
|
||||
# Perform data type validation and, where necessary, munge
|
||||
# the data further so it is in a format that can be passed
|
||||
# to docker-ng.start.
|
||||
# to dockerng.start.
|
||||
_validate_input('runtime',
|
||||
runtime_kwargs,
|
||||
validate_ip_addrs=validate_ip_addrs)
|
||||
@ -1401,7 +1401,7 @@ def running(name,
|
||||
|
||||
# Perform data type validation and, where necessary, munge
|
||||
# the data further so it is in a format that can be passed
|
||||
# to docker-ng.create.
|
||||
# to dockerng.create.
|
||||
_validate_input('create',
|
||||
create_kwargs,
|
||||
validate_ip_addrs=validate_ip_addrs)
|
||||
@ -1435,13 +1435,13 @@ def running(name,
|
||||
runtime_kwargs)
|
||||
if changes_needed:
|
||||
log.debug(
|
||||
'docker-ng.running: Analysis of container \'{0}\' '
|
||||
'dockerng.running: Analysis of container \'{0}\' '
|
||||
'reveals the following changes need to be made: '
|
||||
'{1}'.format(name, changes_needed)
|
||||
)
|
||||
else:
|
||||
log.debug(
|
||||
'docker-ng.running: Container \'{0}\' already '
|
||||
'dockerng.running: Container \'{0}\' already '
|
||||
'matches the desired configuration'.format(name)
|
||||
)
|
||||
except Exception as exc:
|
||||
@ -1477,13 +1477,13 @@ def running(name,
|
||||
if not pre_config:
|
||||
pre_state = None
|
||||
else:
|
||||
pre_state = __salt__['docker-ng.state'](name)
|
||||
pre_state = __salt__['dockerng.state'](name)
|
||||
|
||||
if new_container:
|
||||
if pre_config:
|
||||
# Container exists, stop if necessary, then remove and recreate
|
||||
if pre_state != 'stopped':
|
||||
result = __salt__['docker-ng.stop'](name,
|
||||
result = __salt__['dockerng.stop'](name,
|
||||
timeout=stop_timeout,
|
||||
unpause=True)['result']
|
||||
if result is not True:
|
||||
@ -1495,7 +1495,7 @@ def running(name,
|
||||
return ret
|
||||
|
||||
# Remove existing container
|
||||
removed_ids = __salt__['docker-ng.rm'](name)
|
||||
removed_ids = __salt__['dockerng.rm'](name)
|
||||
if not removed_ids:
|
||||
comments.append('Failed to remove container {0}'.format(name))
|
||||
ret['comment'] = _format_comments(comments)
|
||||
@ -1505,10 +1505,10 @@ def running(name,
|
||||
# changes dict.
|
||||
ret['changes']['removed'] = removed_ids
|
||||
|
||||
if image not in __salt__['docker-ng.list_tags']():
|
||||
if image not in __salt__['dockerng.list_tags']():
|
||||
try:
|
||||
# Pull image
|
||||
pull_result = __salt__['docker-ng.pull'](
|
||||
pull_result = __salt__['dockerng.pull'](
|
||||
image,
|
||||
client_timeout=client_timeout,
|
||||
)
|
||||
@ -1521,7 +1521,7 @@ def running(name,
|
||||
|
||||
try:
|
||||
# Create new container
|
||||
create_result = __salt__['docker-ng.create'](
|
||||
create_result = __salt__['dockerng.create'](
|
||||
image,
|
||||
name=name,
|
||||
# Already validated input
|
||||
@ -1541,7 +1541,7 @@ def running(name,
|
||||
if new_container or pre_state != 'running':
|
||||
try:
|
||||
# Start container
|
||||
__salt__['docker-ng.start'](
|
||||
__salt__['dockerng.start'](
|
||||
name,
|
||||
# Already validated input earlier, no need to repeat it
|
||||
validate_ip_addrs=False,
|
||||
@ -1556,7 +1556,7 @@ def running(name,
|
||||
ret['comment'] = _format_comments(comments)
|
||||
return ret
|
||||
|
||||
post_state = __salt__['docker-ng.state'](name)
|
||||
post_state = __salt__['dockerng.state'](name)
|
||||
if pre_state != post_state:
|
||||
# If the container changed states at all, note this change in the
|
||||
# return dict.
|
||||
@ -1564,19 +1564,19 @@ def running(name,
|
||||
|
||||
if changes_needed:
|
||||
try:
|
||||
post_config = __salt__['docker-ng.inspect_container'](name)
|
||||
post_config = __salt__['dockerng.inspect_container'](name)
|
||||
changes_still_needed = _compare(post_config,
|
||||
create_kwargs,
|
||||
runtime_kwargs)
|
||||
if changes_still_needed:
|
||||
log.debug(
|
||||
'docker-ng.running: Analysis of container \'{0}\' after '
|
||||
'dockerng.running: Analysis of container \'{0}\' after '
|
||||
'creation/replacement reveals the following changes still '
|
||||
'need to be made: {1}'.format(name, changes_still_needed)
|
||||
)
|
||||
else:
|
||||
log.debug(
|
||||
'docker-ng.running: Changes successfully applied to '
|
||||
'dockerng.running: Changes successfully applied to '
|
||||
'container \'{0}\''.format(name)
|
||||
)
|
||||
except Exception as exc:
|
||||
@ -1621,7 +1621,7 @@ def running(name,
|
||||
if not new_container:
|
||||
if send_signal:
|
||||
try:
|
||||
__salt__['docker-ng.signal'](name, signal=watch_action)
|
||||
__salt__['dockerng.signal'](name, signal=watch_action)
|
||||
except CommandExecutionError as exc:
|
||||
comments.append(
|
||||
'Failed to signal container: {0}'.format(exc)
|
||||
@ -1680,7 +1680,7 @@ def stopped(name=None,
|
||||
.. code-block:: yaml
|
||||
|
||||
stopped_containers:
|
||||
docker-ng.stopped:
|
||||
dockerng.stopped:
|
||||
- names:
|
||||
- foo
|
||||
- bar
|
||||
@ -1689,7 +1689,7 @@ def stopped(name=None,
|
||||
.. code-block:: yaml
|
||||
|
||||
stopped_containers:
|
||||
docker-ng.stopped:
|
||||
dockerng.stopped:
|
||||
- containers:
|
||||
- foo
|
||||
- bar
|
||||
@ -1737,7 +1737,7 @@ def stopped(name=None,
|
||||
containers = {}
|
||||
for target in targets:
|
||||
try:
|
||||
c_state = __salt__['docker-ng.state'](target)
|
||||
c_state = __salt__['dockerng.state'](target)
|
||||
except CommandExecutionError:
|
||||
containers.setdefault('absent', []).append(target)
|
||||
else:
|
||||
@ -1787,7 +1787,7 @@ def stopped(name=None,
|
||||
|
||||
stop_errors = []
|
||||
for target in to_stop:
|
||||
changes = __salt__['docker-ng.stop'](target,
|
||||
changes = __salt__['dockerng.stop'](target,
|
||||
timeout=stop_timeout,
|
||||
unpause=unpause)
|
||||
if changes['result'] is True:
|
||||
@ -1827,10 +1827,10 @@ def absent(name, force=False):
|
||||
.. code-block:: yaml
|
||||
|
||||
mycontainer:
|
||||
docker-ng.absent
|
||||
dockerng.absent
|
||||
|
||||
multiple_containers:
|
||||
docker-ng.absent:
|
||||
dockerng.absent:
|
||||
- names:
|
||||
- foo
|
||||
- bar
|
||||
@ -1841,25 +1841,25 @@ def absent(name, force=False):
|
||||
'result': False,
|
||||
'comment': ''}
|
||||
|
||||
if name not in __salt__['docker-ng.list_containers'](all=True):
|
||||
if name not in __salt__['dockerng.list_containers'](all=True):
|
||||
ret['result'] = True
|
||||
ret['comment'] = 'Container \'{0}\' does not exist'.format(name)
|
||||
return ret
|
||||
|
||||
pre_state = __salt__['docker-ng.state'](name)
|
||||
pre_state = __salt__['dockerng.state'](name)
|
||||
if pre_state != 'stopped' and not force:
|
||||
ret['comment'] = ('Container is running, set force to True to '
|
||||
'forcibly remove it')
|
||||
return ret
|
||||
|
||||
try:
|
||||
ret['changes']['removed'] = __salt__['docker-ng.rm'](name, force=force)
|
||||
ret['changes']['removed'] = __salt__['dockerng.rm'](name, force=force)
|
||||
except Exception as exc:
|
||||
ret['comment'] = ('Failed to remove container \'{0}\': {1}'
|
||||
.format(name, exc))
|
||||
return ret
|
||||
|
||||
if name in __salt__['docker-ng.list_containers'](all=True):
|
||||
if name in __salt__['dockerng.list_containers'](all=True):
|
||||
ret['comment'] = 'Failed to remove container \'{0}\''.format(name)
|
||||
else:
|
||||
if force and pre_state != 'stopped':
|
||||
|
Loading…
Reference in New Issue
Block a user