%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/states/docker_image.pyo

�
���^c
@@s�dZddlmZmZmZddlZddlZddlZddl	m
Z
ddlmZddl
mZeje�ZdZdfZd	�Zeeeeeejjjeed
deed�Zeeed
�Zed�ZdS(uv
Management of Docker images

.. versionadded:: 2017.7.0

:depends: docker_ Python module

.. note::
    Older releases of the Python bindings for Docker were called docker-py_ in
    PyPI. All releases of docker_, and releases of docker-py_ >= 1.6.0 are
    supported. These python bindings can easily be installed using
    :py:func:`pip.install <salt.modules.pip.install>`:

    .. code-block:: bash

        salt myminion pip.install docker

    To upgrade from docker-py_ to docker_, you must first uninstall docker-py_,
    and then install docker_:

    .. code-block:: bash

        salt myminion pip.uninstall docker-py
        salt myminion pip.install docker

.. _docker: https://pypi.python.org/pypi/docker
.. _docker-py: https://pypi.python.org/pypi/docker-py

These states were moved from the :mod:`docker <salt.states.docker>` state
module (formerly called **dockerng**) in the 2017.7.0 release.

.. note::
    To pull from a Docker registry, authentication must be configured. See
    :ref:`here <docker-authentication>` for more information on how to
    configure access to docker registries in :ref:`Pillar <pillar>` data.
i(tabsolute_importtprint_functiontunicode_literalsN(tzip(tsix(tCommandExecutionErrorudocker_imageu
moby_imagecC@s#dtkrtSttjd�fS(u?
    Only load if the docker execution module is available
    udocker.version(t__salt__t__virtualname__tFalsetmissing_fun_string(((s</usr/lib/python2.7/site-packages/salt/states/docker_image.pyt__virtual__8suopensuse/pythonubasec

@si|d6id6td6dd6}t|tj�sFtj|�}ntg|||fD]}|d4k	rY|^qY�}|dkr�d|d<|S|dkr�|s�d|d<|St|tj�s�tj|�}nd	j||f�}n!|rd
j||�}n|}yt	d|�}WnBt
k
ri}|j�}d|krXd4}qj||d<|SnX|d4k	r�|s�t|d<d
j|�|d<|Sn|s�|r�d}n|r�d}nd}t
drd4|d<|d4k	r�|s�|d4krdj||�|d<|Sn|rPtjjjt	d�}ttt|j|j���}xT|j�D]F\}}||
jdi�krf|
jdi�j|�||<qfqfWy<||d<||d<||d<||d<t	d|�}Wn-tk
r}dj|||�|d<|SX|d4ks@|d|dd krO||d<qOn�|rt���fd�d5D�}y,t	d d!|d"|d#|	d$||�}Wn-tk
r�}d%j|||�|d<|SX|d4ks�|d|dd krO||d<qOnJ|r�y#t	d&d'|d!|d"|�}Wn-tk
r]}d(j|||�|d<|SX|d4ks||jd)g�rO||d<qOn�y t	d*|d+|d,|�}Wn*tk
r�}d-j||�|d<|SX|d4k	r|dd |jd)i�jd.d4g�d/krn4|d4ksB|jd)i�jd0�rO||d<nt}yt	d|�WnCt
k
r�}|j�}d|kr�d1j|||�}q�nX|r�||d<nCt|d<|ds�d2j||�|d<nd3j||�|d<|S(6u�
    .. versionchanged:: 2018.3.0
        The ``tag`` argument has been added. It is now required unless pulling
        from a registry.

    Ensure that an image is present. The image can either be pulled from a
    Docker registry, built from a Dockerfile, loaded from a saved image, or
    built by running SLS files against a base image.

    If none of the ``build``, ``load``, or ``sls`` arguments are used, then Salt
    will pull from the :ref:`configured registries <docker-authentication>`. If
    the specified image already exists, it will not be pulled unless ``force``
    is set to ``True``. Here is an example of a state that will pull an image
    from the Docker Hub:

    .. code-block:: yaml

        myuser/myimage:
          docker_image.present:
            - tag: mytag

    tag
        Tag name for the image. Required when using ``build``, ``load``, or
        ``sls`` to create the image, but optional if pulling from a repository.

        .. versionadded:: 2018.3.0

    build
        Path to directory on the Minion containing a Dockerfile

        .. code-block:: yaml

            myuser/myimage:
              docker_image.present:
                - build: /home/myuser/docker/myimage
                - tag: mytag

            myuser/myimage:
              docker_image.present:
                - build: /home/myuser/docker/myimage
                - tag: mytag
                - dockerfile: Dockerfile.alternative

        The image will be built using :py:func:`docker.build
        <salt.modules.dockermod.build>` and the specified image name and tag
        will be applied to it.

        .. versionadded:: 2016.11.0
        .. versionchanged:: 2018.3.0
            The ``tag`` must be manually specified using the ``tag`` argument.

    load
        Loads a tar archive created with :py:func:`docker.load
        <salt.modules.dockermod.load>` (or the ``docker load`` Docker CLI
        command), and assigns it the specified repo and tag.

        .. code-block:: yaml

            myuser/myimage:
              docker_image.present:
                - load: salt://path/to/image.tar
                - tag: mytag

        .. versionchanged:: 2018.3.0
            The ``tag`` must be manually specified using the ``tag`` argument.

    force : False
        Set this parameter to ``True`` to force Salt to pull/build/load the
        image even if it is already present.

    client_timeout
        Timeout in seconds for the Docker client. This is not a timeout for
        the state, but for receiving a response from the API.

    dockerfile
        Allows for an alternative Dockerfile to be specified.  Path to alternative
        Dockefile is relative to the build path for the Docker container.

        .. versionadded:: 2016.11.0

    sls
        Allow for building of image with :py:func:`docker.sls_build
        <salt.modules.dockermod.sls_build>` by specifying the SLS files with
        which to build. This can be a list or comma-seperated string.

        .. code-block:: yaml

            myuser/myimage:
              docker_image.present:
                - tag: latest
                - sls:
                    - webapp1
                    - webapp2
                - base: centos
                - saltenv: base

        .. versionadded: 2017.7.0
        .. versionchanged:: 2018.3.0
            The ``tag`` must be manually specified using the ``tag`` argument.

    base
        Base image with which to start :py:func:`docker.sls_build
        <salt.modules.dockermod.sls_build>`

        .. versionadded:: 2017.7.0

    saltenv
        Specify the environment from which to retrieve the SLS indicated by the
        `mods` parameter.

        .. versionadded:: 2017.7.0
        .. versionchanged:: 2018.3.0
            Now uses the effective saltenv if not explicitly passed. In earlier
            versions, ``base`` was assumed as a default.

    pillarenv
        Specify a Pillar environment to be used when applying states. This
        can also be set in the minion config file using the
        :conf_minion:`pillarenv` option. When neither the
        :conf_minion:`pillarenv` minion config option nor this CLI argument is
        used, all Pillar environments will be merged together.

        .. versionadded:: 2018.3.0

    pillar
        Custom Pillar values, passed as a dictionary of key-value pairs

        .. note::
            Values passed this way will override Pillar values set via
            ``pillar_roots`` or an external Pillar source.

        .. versionadded:: 2018.3.0
    unameuchangesuresultuucommentiu3Only one of 'build', 'load', or 'sls' is permitted.uOThe 'tag' argument is required if any one of 'build', 'load', or 'sls' is used.u:u{0}:{1}udocker.inspect_imageu404uImage {0} already presentubuiltuloadedupulledutestuImage {0} will be {1}udocker.buildukwargsupathu
repositoryutagu
dockerfileu*Encountered error building {0} as {1}: {2}uIdic@s-i|]#}�|dk	r�||�qS(N(tNone(t.0tk(t_locals(s</usr/lib/python2.7/site-packages/salt/states/docker_image.pys
<dictcomp>,s	usaltenvu	pillarenvupillarudocker.sls_buildt
repositoryttagtbasetmodsu5Encountered error using SLS {0} for building {1}: {2}udocker.loadtpathu)Encountered error loading {0} as {1}: {2}uLayersudocker.pulltinsecure_registrytclient_timeoutu"Encountered error pulling {0}: {1}uAlready_PullediuPulledu3Failed to inspect image '{0}' after it was {1}: {2}u.Image '{0}' was {1}, but there were no changesuImage '{0}' was {1}N(usaltenvu	pillarenvupillar(Rt
isinstanceRtstring_typest	text_typetlenRtjointformatRRt__str__tTruet__opts__tsalttutilstargstget_function_argspectdicttlistRtdefaultstitemstgett	Exceptiontlocals(tnameRtbuildtloadtforceRRt
dockerfiletslsRtsaltenvt	pillarenvtpillartkwargstrettxtnum_build_argst
full_imaget
image_infotexctmsgtactiontargspect
build_argsR
tvtimage_updatetsls_build_kwargsterror((Rs</usr/lib/python2.7/site-packages/salt/states/docker_image.pytpresentAs��

4

	

		

!&



$	
$

'



cC@s�i|d6id6td6dd6}|r>|r>d|d<|S|dk	rS|}n|re|g}ng}x:|D]2}td|�}|tk	rr|j|�qrqrW|s�t|d<t|�dkr�d	j|�|d<n
d
|d<|StdrNd|d<t|�dkr.dj|d
�|d<ndjdj|��|d<|Stdd||�}td�}	g|D]}
|
|	krx|
^qx}|r,g|D]}
|
|	kr�|
^q�r�||d<djdj|��|d<q�d|d<d|kr�|dcdjdj|d��7<q�n\||d<t|�dkrbdj|d
�|d<ndjdj|��|d<t|d<|S(u#
    Ensure that an image is absent from the Minion. Image names can be
    specified either using ``repo:tag`` notation, or just the repo name (in
    which case a tag of ``latest`` is assumed).

    images
        Run this state on more than one image at a time. The following two
        examples accomplish the same thing:

        .. code-block:: yaml

            remove_images:
              docker_image.absent:
                - names:
                  - busybox
                  - centos:6
                  - nginx

        .. code-block:: yaml

            remove_images:
              docker_image.absent:
                - images:
                  - busybox
                  - centos:6
                  - nginx

        However, the second example will be a bit quicker since Salt will do
        all the deletions in a single run, rather than executing the state
        separately on each image (as it would in the first example).

    force : False
        Salt will fail to remove any images currently in use by a container.
        Set this option to true to remove the image even if it is already
        present.

        .. note::

            This option can also be overridden by Pillar data. If the Minion
            has a pillar variable named ``docker.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.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.force.image_name`` will affect only the named image.
    unameuchangesuresultuucommentu+One of 'name' and 'images' must be providedudocker.resolve_tagiuImage {0} is not presentu$All specified images are not presentutestuImage {0} will be removediu)The following images will be removed: {0}u, u
docker.rmiR-udocker.list_tagsu0The following image(s) failed to be removed: {0}u)None of the specified images were removeduErrorsu,. The following errors were encountered: {0}u; uImage {0} was removedu&The following images were removed: {0}N(	RRRtappendRRRRR(R*timagesR-R4ttargetst	to_deletettargettresolved_tagtresultt	post_tagsR5tfailed((s</usr/lib/python2.7/site-packages/salt/states/docker_image.pytabsentzsb6


	





%%




cK@sL|dkr#t|d<t||�Si|d6id6td6dj|�d6S(u9
    The docker_image  watcher, called to invoke the watch command.

    .. note::
        This state exists to support special handling of the ``watch``
        :ref:`requisite <requisites>`. It should not be called directly.

        Parameters for this function should be set by the state being triggered.
    upresentuforceunameuchangesuresultu*watch requisite is not implemented for {0}ucomment(RRBRR(R*tsfunR3((s</usr/lib/python2.7/site-packages/salt/states/docker_image.pyt	mod_watch�s



(t__doc__t
__future__RRRtloggingtsalt.utils.dockerRtsalt.utils.argstsalt.ext.six.movesRtsalt.extRtsalt.exceptionsRt	getLoggert__name__tlogRt__virtual_aliases__R
RRR tdockertCLIENT_TIMEOUTRBRLRN(((s</usr/lib/python2.7/site-packages/salt/states/docker_image.pyt<module>%s4		
�.

Zerion Mini Shell 1.0