%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZddl	Z
ddlZ
ddlm
Z
ddlmZddlmZddlmZy6ddlZddlmZdd	lmZeZWnek
r�eZnXydd
lmZeZWnek
r-eZnXd/Z d
Z!ej"e#�Z$eZ%dZ&d0Z'd�Z(ddd�Z*d�Z+d�Z,d�Z-d�Z.d�Z/d�Z0d�Z1d�Z2d�Z3d�Z4d�Z5d�Z6d�Z7dd �Z8dd!�Z9dd"�Z:dd#�Z;dd$�Z<dd%�Z=dd&�Z>dd'�Z?dd(�Z@d)�ZAdd*�ZBd+�ZCd,�ZDd-�ZEd.�ZFdS(1uQ

Module to import docker-compose via saltstack

.. versionadded:: 2016.3.0

:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all

Introduction
------------
This module allows one to deal with docker-compose file in a directory.

This is  a first version only, the following commands are missing at the moment
but will be built later on if the community is interested in this module:

- run
- logs
- port
- scale

Installation Prerequisites
--------------------------

This execution module requires at least version 1.4.0 of both docker-compose_ and
Docker_. docker-compose can easily be installed using :py:func:`pip.install
<salt.modules.pip.install>`:

.. code-block:: bash

    salt myminion pip.install docker-compose>=1.5.0

.. _docker-compose: https://pypi.python.org/pypi/docker-compose
.. _Docker: https://www.docker.com/


How to use this module?
-----------------------
In order to use the module if you have no docker-compose file on the server you
can issue the command create, it takes two arguments the path where the
docker-compose.yml will be stored and the content of this latter:

.. code-block:: text

    # salt-call -l debug dockercompose.create /tmp/toto '
    database:
    image: mongo:3.0
    command: mongod --smallfiles --quiet --logpath=/dev/null
    '

Then you can execute a list of method defined at the bottom with at least one
argument (the path where the docker-compose.yml will be read) and an optional
python list which corresponds to the services names:

.. code-block:: bash

    # salt-call -l debug dockercompose.up /tmp/toto
    # salt-call -l debug dockercompose.restart /tmp/toto '[database]'
    # salt-call -l debug dockercompose.stop /tmp/toto
    # salt-call -l debug dockercompose.rm /tmp/toto

Docker-compose method supported
-------------------------------
- up
- restart
- stop
- start
- pause
- unpause
- kill
- rm
- ps
- pull
- build

Functions
---------
- docker-compose.yml management
    - :py:func:`dockercompose.create <salt.modules.dockercompose.create>`
    - :py:func:`dockercompose.get <salt.modules.dockercompose.get>`
- Manage containers
    - :py:func:`dockercompose.restart <salt.modules.dockercompose.restart>`
    - :py:func:`dockercompose.stop <salt.modules.dockercompose.stop>`
    - :py:func:`dockercompose.pause <salt.modules.dockercompose.pause>`
    - :py:func:`dockercompose.unpause <salt.modules.dockercompose.unpause>`
    - :py:func:`dockercompose.start <salt.modules.dockercompose.start>`
    - :py:func:`dockercompose.kill <salt.modules.dockercompose.kill>`
    - :py:func:`dockercompose.rm <salt.modules.dockercompose.rm>`
    - :py:func:`dockercompose.up <salt.modules.dockercompose.up>`
- Manage containers image:
    - :py:func:`dockercompose.pull <salt.modules.dockercompose.pull>`
    - :py:func:`dockercompose.build <salt.modules.dockercompose.build>`
- Gather information about containers:
    - :py:func:`dockercompose.ps <salt.modules.dockercompose.ps>`
- Manage service definitions:
    - :py:func:`dockercompose.service_create <salt.modules.dockercompose.ps>`
    - :py:func:`dockercompose.service_upsert <salt.modules.dockercompose.ps>`
    - :py:func:`dockercompose.service_remove <salt.modules.dockercompose.ps>`
    - :py:func:`dockercompose.service_set_tag <salt.modules.dockercompose.ps>`

Detailed Function Documentation
-------------------------------
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(t
attrgetter(tjson(tyaml(tget_project(tConvergenceStrategy(tOneOffFilteriiu([\d.]+)u
dockercomposeudocker-compose.ymludocker-compose.yamlcC@s�trwtjttjtj��}|rwtg|j	d�j
d�D]}t|�^qF�}|tkrtt
SqwntdfS(Niu.uTThe dockercompose execution module not loaded: compose python library not available.(tHAS_DOCKERCOMPOSEtretmatcht
VERSION_RERt	text_typetcomposet__version__ttupletgrouptsplittinttMIN_DOCKERCOMPOSEt__virtualname__tFalse(Rtxtversion((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyt__virtual__�s7
cC@sPi|d6|d6}|dk	r-||d<n|dk	rLtrL||d<n|S(u�
    Standardizes all responses

    :param status:
    :param message:
    :param data:
    :param debug_msg:
    :return:
    ustatusumessageureturnudebugN(tNonetdebug(tstatustmessagetdatat	debug_msgtresult((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyt__standardize_result�s



cC@sVtjj|�r|Sx9tD]1}tjj||�}tjj|�r|SqWdS(uG
    Determines the filepath to use

    :param path:
    :return:
    N(tostpathtisfiletDEFAULT_DC_FILENAMEStjoin(R$tdc_filenamet	file_path((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyt__get_docker_file_path�s
c
C@s�tjj|�s.ttdj|�dd�Syttjj	j
|d��V}tjj|�}id|6}x-|D]%}||ctjjj
|�7<qrWWdQXWn*tk
r�ttdj|�dd�SXttdj|�|d�S(ua
    Read the compose file if it exists in the directory

    :param file_path:
    :return:
    uPath {} is not presenturuNuCould not read {0}uReading content of {0}(R#R$R%R"RtformatRtsalttutilstfilestfopentbasenametstringutilst
to_unicodetEnvironmentErrortTrue(R)tflt	file_nameR!tline((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyt__read_docker_compose_file�s"


-
cC@s�t|�}|dkr@dj|�}dtt|dd�fStjj|�stdttdj|�dd�fSy4tj	j
j|d��}tj
|�}WdQXWnmtk
r�dttdj|�dd�fStjk
r}dj||�}dtt|dd�fSX|sFdj|�}dtt|dd�fSd|kr_i|d<ni|d	6tjj|�d
6}|dfS(uU
    Read the compose file and load its' contents

    :param path:
    :return:
    u)Could not find docker-compose file at {0}uPath {} is not presenturNuCould not read {0}uCould not parse {0} {1}uGot empty compose file at {0}uservicesucompose_contentu	file_name(R*RR+R"RR#R$R%R,R-R.R/RtloadR3t	YAMLErrorR0(R$R)tmsgR5tloadedtyerrR!((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyt__load_docker_compose�s<
	

	


cC@sky/tj|dddt�}t|||�SWn5tk
rf}dj||�}tt|dd�SXdS(u]
    Dumps

    :param path:
    :param content: the not-yet dumped content
    :return:
    tindentitdefault_flow_styleuCould not dump {0} {1}N(Rt	safe_dumpRt__write_docker_composet	TypeErrorR+R"R(R$tcontenttalready_existedtdumpedtt_errR;((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyt__dump_docker_compose
s	cC@s|j�jd�r0|}tjj|�}n|}tjj|td�}tjj|�tkrwtj	|�nyAt
jjj
|d��#}|jt
jjj|��WdQXWn*tk
r�ttdj|�dd�SXt|�}t|t�r|stj|�n|S|S(u�
    Write docker-compose to a path
    in order to use it with docker-compose ( config check )

    :param path:

    docker_compose
        contains the docker-compose file

    :return:
    u.ymlu.yamliuwNuCould not write {0}(u.ymlu.yaml(tlowertendswithR#R$tdirnameR'R&tisdirRtmkdirR,R-R.R/twriteR1tto_strR3R"R+Rt__load_project_from_file_patht
isinstancetdicttremove(R$tdocker_composeRER)tdir_nameR5tproject((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyRBs(&
cC@sDt|�}|dkr:dj|�}tt|dd�St|�S(uP
    Load a docker-compose project from path

    :param path:
    :return:
    u)Could not find docker-compose file at {0}N(R*RR+R"RRP(R$R)R;((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyt__load_project>s
cC@sUy4tdtjj|�dtjj|�g�}Wntk
rP}t|�SX|S(uU
    Load a docker-compose project from file path

    :param path:
    :return:
    tproject_dirtconfig_path(RR#R$RKR0t	Exceptiont__handle_except(R)RVtinst((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyRPNscC@st|�\}}|r%dd|fSt|t�rA||dfS|j�jd�r�ytj|�}Wqtjk
r�}dj	||�}ddt
t|dd�fSXnWytj
|�}WnAtjk
r}dj	||�}ddt
t|dd�fSX||dfS(u

    Will load the compose file located at path
    Then determines the format/contents of the sent definition

    err or results are only set if there were any

    :param path:
    :param definition:
    :return tuple(compose_result, loaded_definition, err):
    u{uCould not parse {0} {1}N(R>RRQRRtstript
startswithRtdeserializetDeserializationErrorR+R"RRR9R:(R$t
definitiontcompose_resultterrtloaded_definitiontjerrR;R=((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyt__load_compose_definitions]s&

cC@s@t||d|�}t|t�r)|Stt||dd�S(u�
    Utility function to dump the compose result to a file.

    :param path:
    :param compose_result:
    :param success_msg: the message to give upon success
    :return:
    ucompose_contentN(RHRQRRR"R4R(R$Rbtsuccess_msgREtret((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyt__dump_compose_file~s			cC@s3ttdjtj�dd�dj|�d�S(uV
    Handle exception and return a standard result

    :param inst:
    :return:
    u!Docker-compose command {0} failediiu{0}N(R"RR+tinspecttstackR(R\((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyR[�scC@s�i}|j|j|�tj�}x�|D]z}||\}}|dkrZd||<q+|dkrsd||<q+|dkr�d||<q+|dkr+d||<q+q+W|S(	ul
    Get action executed for each container

    :param project:
    :param service_names:
    :return:
    ucreateuCreating containerurecreateuRe-creating containerustartuStarting containerunoopuContainer is up to date(t_get_convergence_planstget_servicesRtchanged(RVt
service_namesRhtplanstconttactiont	container((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyRl�s



cC@s�t|�}|dkr4ttdj|�dd�St|�}|dsN|St|�}t|t�rzt|dd<nt	|dd<|S(u	
    Get the content of the docker-compose file into a directory

    path
        Path where the docker-compose file is stored on the server

    CLI Example:

    .. code-block:: bash

        salt myminion dockercompose.get /path/where/docker-compose/stored
    uPath {} is not presentustatusureturnuvalidN(
R*RR"RR+R8RWRQRRR4(R$R)tsalt_resultRV((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pytget�s


cC@s^|r1t||dt�}t|t�rD|Snttddd�Sttdi|d6d�S(uH
    Create and validate a docker-compose file into a directory

    path
        Path where the docker-compose file will be stored on the server

    docker_compose
        docker_compose file

    CLI Example:

    .. code-block:: bash

        salt myminion dockercompose.create /path/where/docker-compose/stored content
    REuSCreating a docker-compose project failed, you must send a valid docker-compose fileu,Successfully created the docker-compose fileucompose.base_dirN(RBRRQRRR"RR4(R$RTRh((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pytcreate�s	

cC@s`t|�}t|t�r|Sy|j|�Wntk
rL}t|�SXttddd�S(u�
    Pull image for containers in the docker-compose file, service_names is a
    python list, if omitted pull all images

    path
        Path where the docker-compose file is stored on the server
    service_names
        If specified will pull only the image for the specified services

    CLI Example:

    .. code-block:: bash

        salt myminion dockercompose.pull /path/where/docker-compose/stored
        salt myminion dockercompose.pull /path/where/docker-compose/stored '[janus]'
    u6Pulling containers images via docker-compose succeededN(	RWRQRRtpullRZR[R"R4R(R$RoRVR\((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyRw�s	cC@s`t|�}t|t�r|Sy|j|�Wntk
rL}t|�SXttddd�S(u
    Build image for containers in the docker-compose file, service_names is a
    python list, if omitted build images for all containers. Please note
    that at the moment the module does not allow you to upload your Dockerfile,
    nor any other file you could need with your docker-compose.yml, you will
    have to make sure the files you need are actually in the directory specified
    in the `build` keyword

    path
        Path where the docker-compose file is stored on the server
    service_names
        If specified will pull only the image for the specified services

    CLI Example:

    .. code-block:: bash

        salt myminion dockercompose.build /path/where/docker-compose/stored
        salt myminion dockercompose.build /path/where/docker-compose/stored '[janus]'
    u7Building containers images via docker-compose succeededN(	RWRQRRtbuildRZR[R"R4R(R$RoRVR\((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyRxs	cC@s�t|�}i}i}t|t�r+|Sy�|j|�tr�xu|j�D]d}|dksy|jd�d|krN|j�|j	�||jd�<d||jd�<qNqNWnWnt
k
r�}t|�SXtt
d||�S(u�
    Restart container(s) in the docker-compose file, service_names is a python
    list, if omitted restart all containers

    path
        Path where the docker-compose file is stored on the server

    service_names
        If specified will restart only the specified services

    CLI Example:

    .. code-block:: bash

        salt myminion dockercompose.restart /path/where/docker-compose/stored
        salt myminion dockercompose.restart /path/where/docker-compose/stored '[janus]'
    uNameiu	restartedu(Restarting containers via docker-composeN(RWRQRRtrestartRt
containersRRutinspect_if_not_inspectedRjRZR[R"R4(R$RoRVt	debug_retR!RsR\((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyRy2s 
%
!cC@s�t|�}i}i}t|t�r+|Sy�|j|�tr�x{|jdt�D]d}|dks|jd�d|krT|j	�|j
�||jd�<d||jd�<qTqTWnWntk
r�}t|�SXt
td||�S(u�
    Stop running containers in the docker-compose file, service_names is a python
    list, if omitted stop all containers

    path
        Path where the docker-compose file is stored on the server
    service_names
        If specified will stop only the specified services

    CLI Example:

    .. code-block:: bash

        salt myminion dockercompose.stop /path/where/docker-compose/stored
        salt myminion dockercompose.stop  /path/where/docker-compose/stored '[janus]'
    tstoppeduNameiustoppedu&Stopping containers via docker-composeN(RWRQRRtstopRRzR4RRuR{RjRZR[R"(R$RoRVR|R!RsR\((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyR~Xs 
%
!cC@s�t|�}i}i}t|t�r+|Sy�|j|�tr�xu|j�D]d}|dksy|jd�d|krN|j�|j	�||jd�<d||jd�<qNqNWnWnt
k
r�}t|�SXtt
d||�S(u�
    Pause running containers in the docker-compose file, service_names is a python
    list, if omitted pause all containers

    path
        Path where the docker-compose file is stored on the server
    service_names
        If specified will pause only the specified services

    CLI Example:

    .. code-block:: bash

        salt myminion dockercompose.pause /path/where/docker-compose/stored
        salt myminion dockercompose.pause /path/where/docker-compose/stored '[janus]'
    uNameiupausedu%Pausing containers via docker-composeN(RWRQRRtpauseRRzRRuR{RjRZR[R"R4(R$RoRVR|R!RsR\((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyR}s 
%
!cC@s�t|�}i}i}t|t�r+|Sy�|j|�tr�xu|j�D]d}|dksy|jd�d|krN|j�|j	�||jd�<d||jd�<qNqNWnWnt
k
r�}t|�SXtt
d||�S(u�
    Un-Pause containers in the docker-compose file, service_names is a python
    list, if omitted unpause all containers

    path
        Path where the docker-compose file is stored on the server
    service_names
        If specified will un-pause only the specified services

    CLI Example:

    .. code-block:: bash

        salt myminion dockercompose.pause /path/where/docker-compose/stored
        salt myminion dockercompose.pause /path/where/docker-compose/stored '[janus]'
    uNameiuunpausedu(Un-Pausing containers via docker-composeN(RWRQRRtunpauseRRzRRuR{RjRZR[R"R4(R$RoRVR|R!RsR\((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyR��s 
%
!cC@s�t|�}i}i}t|t�r+|Sy�|j|�tr�xu|j�D]d}|dksy|jd�d|krN|j�|j	�||jd�<d||jd�<qNqNWnWnt
k
r�}t|�SXtt
d||�S(u�
    Start containers in the docker-compose file, service_names is a python
    list, if omitted start all containers

    path
        Path where the docker-compose file is stored on the server
    service_names
        If specified will start only the specified services

    CLI Example:

    .. code-block:: bash

        salt myminion dockercompose.start /path/where/docker-compose/stored
        salt myminion dockercompose.start /path/where/docker-compose/stored '[janus]'
    uNameiustartedu&Starting containers via docker-composeN(RWRQRRtstartRRzRRuR{RjRZR[R"R4(R$RoRVR|R!RsR\((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyR��s 
%
!cC@s�t|�}i}i}t|t�r+|Sy�|j|�tr�x{|jdt�D]d}|dks|jd�d|krT|j	�|j
�||jd�<d||jd�<qTqTWnWntk
r�}t|�SXt
td||�S(u�
    Kill containers in the docker-compose file, service_names is a python
    list, if omitted kill all containers

    path
        Path where the docker-compose file is stored on the server
    service_names
        If specified will kill only the specified services

    CLI Example:

    .. code-block:: bash

        salt myminion dockercompose.kill /path/where/docker-compose/stored
        salt myminion dockercompose.kill /path/where/docker-compose/stored '[janus]'
    R}uNameiukilledu%Killing containers via docker-composeN(RWRQRRtkillRRzR4RRuR{RjRZR[R"(R$RoRVR|R!RsR\((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyR��s 
%
!cC@s`t|�}t|t�r|Sy|j|�Wntk
rL}t|�SXttddd�S(u�
    Remove stopped containers in the docker-compose file, service_names is a python
    list, if omitted remove all stopped containers

    path
        Path where the docker-compose file is stored on the server
    service_names
        If specified will remove only the specified stopped services

    CLI Example:

    .. code-block:: bash

        salt myminion dockercompose.rm /path/where/docker-compose/stored
        salt myminion dockercompose.rm /path/where/docker-compose/stored '[janus]'
    u.Removing stopped containers via docker-composeN(	RWRQRRtremove_stoppedRZR[R"R4R(R$RoRVR\((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pytrmscC@s3t|�}i}t|t�r%|Strht|jd
dt�|jd
tj	�dt
d��}n:t|jd
dt�|jd
dt�dt
d��}x{|D]s}|j}t|�dkr�dj
|d �}ni|jd6|jd6|d	6|jd
6|jd6||j<q�Wttd|d
�S(u
    List all running containers and report some information about them

    path
        Path where the docker-compose file is stored on the server

    CLI Example:

    .. code-block:: bash

        salt myminion dockercompose.ps /path/where/docker-compose/stored
    R}tkeyunametone_offiu{0} ...iuiducommandustateuportsu!Listing docker-compose containersN(RWRQRRtUSE_FILTERCLASStsortedRzRR4R	tonlyRthuman_readable_commandtlenR+tidtnamethuman_readable_statethuman_readable_portsR"(R$RVR!RzRstcommand((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pytps.s0
	


cC@s�i}t|�}t|t�r%|Sy�t||�}|j|�}tr�x\|D]Q}|dks~|jd�d|krS|j�|j	�||jd�<qSqSWnWnt
k
r�}t|�SXtt
d||�S(u
    Create and start containers defined in the docker-compose.yml file
    located in path, service_names is a python list, if omitted create and
    start all containers

    path
        Path where the docker-compose file is stored on the server
    service_names
        If specified will create and start only the specified services

    CLI Example:

    .. code-block:: bash

        salt myminion dockercompose.up /path/where/docker-compose/stored
        salt myminion dockercompose.up /path/where/docker-compose/stored '[janus]'
    uNameiu$Adding containers via docker-composeN(RWRQRRRltupRRRuR{RjRZR[R"R4(R$RoR|RVR!RhRsR\((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyR�Ys
%
'cC@s�t||�\}}}|r"|S|dd}||kr^dj|�}tt|dd�S|||<t||dj|�dt�S(uN
    Create the definition of a docker-compose service
    This fails when the service already exists
    This does not pull or up the service
    This wil re-write your yaml file. Comments will be lost. Indentation is set to 2 spaces

    path
        Path where the docker-compose file is stored on the server
    service_name
        Name of the service to create
    definition
        Service definition as yaml or json string

    CLI Example:

    .. code-block:: bash

        salt myminion dockercompose.service_create /path/where/docker-compose/stored service_name definition
    ucompose_contentuservicesuService {0} already existsuService {0} createdREN(RfR+R"RRRiR4(R$tservice_nameRaRbRdRctservicesR;((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pytservice_create~s
	cC@s�t||�\}}}|r"|S|dd}||kr^dj|�}tt|dd�S|||<t||dj|�dt�S(u)
    Create or update the definition of a docker-compose service
    This does not pull or up the service
    This wil re-write your yaml file. Comments will be lost. Indentation is set to 2 spaces

    path
        Path where the docker-compose file is stored on the server
    service_name
        Name of the service to create
    definition
        Service definition as yaml or json string

    CLI Example:

    .. code-block:: bash

        salt myminion dockercompose.service_upsert /path/where/docker-compose/stored service_name definition
    ucompose_contentuservicesuService {0} already existsu!Service definition for {0} is setREN(RfR+R"RRRiR4(R$R�RaRbRdRcR�R;((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pytservice_upsert�s
	cC@s{t|�\}}|r|S|dd}||krRttdj|�dd�S||=t||dj||�dt�S(u�
    Remove the definition of a docker-compose service
    This does not rm the container
    This wil re-write your yaml file. Comments will be lost. Indentation is set to 2 spaces

    path
        Path where the docker-compose file is stored on the server
    service_name
        Name of the service to remove

    CLI Example:

    .. code-block:: bash

        salt myminion dockercompose.service_remove /path/where/docker-compose/stored service_name
    ucompose_contentuservicesuService {0} did not existsuService {0} is removed from {1}REN(R>R"RR+RRiR4(R$R�RbRcR�((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pytservice_remove�s
	cC@s�t|�\}}|r|S|dd}||krRttdj|�dd�Sd||kr~ttdj|�dd�S||djd�d}dj||�||d<t||d	j||�d
t�S(u+
    Change the tag of a docker-compose service
    This does not pull or up the service
    This wil re-write your yaml file. Comments will be lost. Indentation is set to 2 spaces

    path
        Path where the docker-compose file is stored on the server
    service_name
        Name of the service to remove
    tag
        Name of the tag (often used as version) that the service image should have

    CLI Example:

    .. code-block:: bash

        salt myminion dockercompose.service_create /path/where/docker-compose/stored service_name tag
    ucompose_contentuservicesuService {0} did not existsuimageu0Service {0} did not contain the variable "image"u:iu{0}:{1}uService {0} is set to tag "{1}"REN(R>R"RR+RRRiR4(R$R�ttagRbRcR�timage((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pytservice_set_tag�s"

	(iii(udocker-compose.ymludocker-compose.yaml(Gt__doc__t
__future__RRRRjtloggingR#Rtsalt.utils.filesR,tsalt.utils.stringutilstsalt.extRtoperatorRtsalt.serializersRt
salt.utilsRRtcompose.cli.commandRtcompose.serviceRR4R
tImportErrorRtcompose.projectR	R�RR
t	getLoggert__name__tlogRRR&RRR"R*R8R>RHRBRWRPRfRiR[RlRuRvRwRxRyR~RR�R�R�R�R�R�R�R�R�R�(((s>/usr/lib/python2.7/site-packages/salt/modules/dockercompose.pyt<module>jsv





				(		#			!		
			 "&%%%%%	+%	!	 	

Zerion Mini Shell 1.0