Anons79 Mini Shell

Directory : /proc/self/root/lib/python2.7/site-packages/ansible/plugins/connection/
Upload File :
Current File : //proc/self/root/lib/python2.7/site-packages/ansible/plugins/connection/libvirt_lxc.pyo

�
�Udac@`s�ddlmZmZmZeZdZddlZddl	Z	ddl
Z	ddlZddlZddl
mZddlmZddlmZddlmZddlmZmZdd	lmZe�Zd
efd��YZdS(i(tabsolute_importtdivisiontprint_functions�
    author: Michael Scherer <[email protected]>
    connection: libvirt_lxc
    short_description: Run tasks in lxc containers via libvirt
    description:
        - Run commands or put/fetch files to an existing lxc container using libvirt
    version_added: "2.0"
    options:
      remote_addr:
        description:
            - Container identifier
        default: The set user as per docker's configuration
        vars:
            - name: ansible_host
            - name: ansible_libvirt_lxc_host
N(t	constants(tAnsibleError(tshlex_quote(tto_bytes(tConnectionBasetBUFSIZE(tDisplayt
ConnectioncB`s�eZdZdZeZdZeZd�Z	d�Z
d�Zd�Ze
jd�Zd
ed�Zd	�Zd
�Zd�Zd�ZRS(s Local lxc based connections tlibvirt_lxctrootcO`sTtt|�j||||�|jj|_|jd�|_|j|j�dS(Ntvirsh(	tsuperR
t__init__t
_play_contexttremote_addrtlxct_search_executableR
t
_check_domain(tselftplay_contextt	new_stdintargstkwargs((sJ/usr/lib/python2.7/site-packages/ansible/plugins/connection/libvirt_lxc.pyR7scC`s/tjj|�}|s+td�|�n|S(Ns%s command not found in PATH(t	distutilstspawntfind_executableR(Rt
executabletcmd((sJ/usr/lib/python2.7/site-packages/ansible/plugins/connection/libvirt_lxc.pyR?scC`sftj|jddddt|�gdtjdtj�}|j�|jrbtd|��ndS(Ns-qs-cslxc:///tdominfotstdouttstderrs"%s is not a lxc defined in libvirt(t
subprocesstPopenR
RtPIPEtcommunicatet
returncodeR(Rtdomaintp((sJ/usr/lib/python2.7/site-packages/ansible/plugins/connection/libvirt_lxc.pyREs
'
	cC`sBtt|�j�|js>tjdd|j�t|_ndS(s( connect to the lxc; nothing to do here sTHIS IS A LOCAL LXC DIRthostN(RR
t_connectt
_connectedtdisplaytvvvRtTrue(R((sJ/usr/lib/python2.7/site-packages/ansible/plugins/connection/libvirt_lxc.pyR*Ls	c
C`s�tjrtjj�dnd}|jddddg}tjrS|dg7}n||jd|d|g7}tjd	|fd
|j�g|D]}t|dd�^q�}t	j
|d
td|dt	jdt	j�}|S(s/ run a command on the chroot.  This is only needed for implementing
        put_file() get_file() so that we don't have to read the whole file
        into memory.

        compared to exec_command() it looses some niceties like being able to
        return the process's exit code immediately.
        is/bin/shs-qs-cslxc:///slxc-enter-namespaces--noseclabels--sEXEC %sR)terrorstsurrogate_or_stricttshelltstdinR R!(
tCtDEFAULT_EXECUTABLEtsplitR
tDEFAULT_LIBVIRT_LXC_NOSECLABELRR,R-RR"R#tFalseR$(RRR2Rt	local_cmdtiR(((sJ/usr/lib/python2.7/site-packages/ansible/plugins/connection/libvirt_lxc.pyt_buffered_exec_commandSs"	%cC`sVtt|�j|d|d|�|j|�}|j|�\}}|j||fS(s run a command on the chroot tin_datatsudoable(RR
texec_commandR:R%R&(RRR;R<R(R R!((sJ/usr/lib/python2.7/site-packages/ansible/plugins/connection/libvirt_lxc.pyR=js"cC`sC|jtjj�s3tjjtjj|�}ntjj|�S(s� Make sure that we put files into a standard path

            If a path is relative, then we need to choose where to put it.
            ssh chooses $HOME but we aren't guaranteed that a home dir will
            exist in any given chroot.  So for now we're choosing "/" instead.
            This also happens to be the former default.

            Can revisit using $HOME instead if it's a problem
        (t
startswithtostpathtseptjointnormpath(Rtremote_path((sJ/usr/lib/python2.7/site-packages/ansible/plugins/connection/libvirt_lxc.pyt_prefix_login_pathss
c
C`s�tt|�j||�tjd||fd|j�t|j|��}y
tt	|dd�d���}t
j|j��j
s�d}nd}y&|jd|t|fd	|�}Wntk
r�td
��nXy|j�\}}Wn1tk
r%tj�td||f��nX|jdkrTtd
||||f��nWdQXWn!tk
r~td|��nXdS(s# transfer a file from local to lxc sPUT %s TO %sR)R/R0trbs count=0tsdd of=%s bs=%s%sR2s3chroot connection requires dd command in the chroots failed to transfer file %s to %sis'failed to transfer file %s to %s:
%s
%sNs$file or module does not exist at: %s(RR
tput_fileR,R-RRREtopenRR?tfstattfilenotst_sizeR:RtOSErrorRR%t	Exceptiont	tracebackt	print_excR&tIOError(Rtin_pathtout_pathtin_filetcountR(R R!((sJ/usr/lib/python2.7/site-packages/ansible/plugins/connection/libvirt_lxc.pyRH�s* 	&


)
c
C`sitt|�j||�tjd||fd|j�t|j|��}y|jd|t	f�}Wnt
k
r�td��nXtt
|dd�d���}yB|jjt	�}x)|r�|j|�|jjt	�}q�WWn1tk
rtj�td||f��nX|j�\}}|jd	kr_td
||||f��nWdQXdS(s  fetch a file from lxc to local sFETCH %s TO %sR)sdd if=%s bs=%ss3chroot connection requires dd command in the chrootR/R0swb+s failed to transfer file %s to %sis'failed to transfer file %s to %s:
%s
%sN(RR
t
fetch_fileR,R-RRRER:RRMRRIRR treadtwriteRNRORPR%R&(RRRRSR(tout_filetchunkR R!((sJ/usr/lib/python2.7/site-packages/ansible/plugins/connection/libvirt_lxc.pyRV�s& 
	


cC`s tt|�j�t|_dS(s. terminate the connection; nothing to do here N(RR
tcloseR7R+(R((sJ/usr/lib/python2.7/site-packages/ansible/plugins/connection/libvirt_lxc.pyR[�sN(t__name__t
__module__t__doc__t	transportR.thas_pipeliningtdefault_userR7thas_ttyRRRR*R"R$R:tNoneR=RERHRVR[(((sJ/usr/lib/python2.7/site-packages/ansible/plugins/connection/libvirt_lxc.pyR
,s								(t
__future__RRRttypet
__metaclass__t
DOCUMENTATIONtdistutils.spawnRR?tos.pathR"ROtansibleRR3tansible.errorsRtansible.module_utils.six.movesRtansible.module_utils._textRtansible.plugins.connectionRRtansible.utils.displayR	R,R
(((sJ/usr/lib/python2.7/site-packages/ansible/plugins/connection/libvirt_lxc.pyt<module>s	

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]