%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/smartos_imgadm.pyo

�
���^c@@sRdZddlmZmZmZddlZddlZddlZddl	Zej
e�Zidd6dd6dd	6Z
d
Zd�Zdd�Zded
�Zd�Zd�Zd�Zd�Zd�Zdd�Zded�Zed�Zd�Zd�Zed�Zd�Zed�Z ed�Z!d�Z"dd�Z#dS( u.
Module for running imgadm command on SmartOS
i(tabsolute_importtunicode_literalstprint_functionNulistulist_installeduupdateuupdate_installeduimportuimport_imageuimgadmcC@s>tjjj�r+tjjjd�r+tStdjt�fS(u)
    Provides imgadm only on SmartOS
    uimgadmu6{0} module can only be loaded on SmartOS compute nodes(	tsalttutilstplatformtis_smartos_globalzonetpathtwhicht__virtualname__tFalsetformat(((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pyt__virtual__scC@s6idd6|sdn|d6dd6dd6|}|S(	u)
    Translate exit status of imgadm
    uSuccessful completion.iuAn error occurred.iuUsage error.iuImage not installed.i((tretcodetstderrtret((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pyt_exit_status+s

cC@s�d}|r!d|kr!|}n�|r�d|kr�|dd}|dd}|dd}|dd}|dd}|d}|ddd	kr\d}d}	d}
xn|dd
D]^}|jd�r�|dd
|r�|jd�d
}
q�|dkr�|dd
|}	q�q�W|	r\|
r\dj|	|
�}djd|	d|
d|�}q\n|r�|r�i|d6|d6|d6|d6|d6|d6}q�|r�djd|d|d|�}q�n|S(NuErrorumanifestunameuversionuosudescriptionupublished_atusourceudocker-layerutagsudocker:tag:u:i����udocker:repou{}:{}u2Docker image imported from {repo}:{tag} on {date}.trepottagtdateu	publishedu{name}@{version} [{published}]tnametversiont	published(tNonet
startswithtsplitR(timagetdetailRRRtostdescriptionRtsourcetdocker_repot
docker_tagR((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pyt_parse_image_meta6sN	
!	
	cC@sj|rf|jd�}t|�dkrf|d}|d}t|jd��dkrc||fSqfndS(u7
    Split a smartos docker uuid into repo and tag
    u:iiiu/N(NN(RtlenR(tuuidRR((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pyt_split_docker_uuidhs

cC@sB|r>td�|jd�D��dddddgkr>tStS(ub
    Check if uuid is a valid smartos uuid

    Example: e69a0918-055d-11e5-8912-e3ceb6df4cf8
    cs@s|]}t|�VqdS(N(R"(t.0tx((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pys	<genexpr>|su-iii(tlistRtTrueR
(R#((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pyt_is_uuidvs:cC@st|�\}}|o|S(u_
    Check if uuid is a valid smartos docker uuid

    Example plexinc/pms-docker:plexpass
    (R$(R#RR((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pyt_is_docker_uuid�scC@s:i}d}td|�j�}|dj�}|dS(ul
    Return imgadm version

    CLI Example:

    .. code-block:: bash

        salt '*' imgadm.version
    uimgadm --versionucmd.runii����(t__salt__t
splitlinesR(Rtcmdtres((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pyR�s

cC@sqt|�r|St|�rmtdt�}x?|D]4}d||krNq2n||d|kr2|Sq2WndS(uZ
    Get the image uuid from an imported docker image

    .. versionadded:: 2019.2.0
    tverboseunameN(R)R*tlist_installedR(R(R#timagest
image_uuid((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pytdocker_to_uuid�s
ucC@s'dj|�j�}td|�iS(u�
    Gather info on unknown image(s) (locally installed)

    uuid : string
        optional uuid of image

    CLI Example:

    .. code-block:: bash

        salt '*' imgadm.update [uuid]
    uimgadm update {0}ucmd.run(RtrstripR+(R#R-((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pytupdate_installed�s
c	C@s�i}d}td|�}|d}|dkrFt|�|d<|Sx�tjjj|d�D]y}|dds`|dd	r�q`n|r�||dd
kr�q`n|dd}t||�}|r`|||<q`q`W|S(u
    Return a list of available images

    search : string
        search keyword
    verbose : boolean (False)
        toggle verbose output

    CLI Example:

    .. code-block:: bash

        salt '*' imgadm.avail [percona]
        salt '*' imgadm.avail verbose=True
    uimgadm avail -jucmd.run_alluretcodeiuErrorustdoutumanifestudisabledupublicunameuuuid(R+RRRtjsontloadsR!(	tsearchR/RR-R.R
RR#tdata((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pytavail�s"
 cC@s�i}d}td|�}|d}|dkrFt|�|d<|SxQtjjj|d�D]6}|dd}t||�}|r`|||<q`q`W|S(	uR
    Return a list of installed images

    verbose : boolean (False)
        toggle verbose output

    .. versionchanged:: 2019.2.0

        Docker images are now also listed

    CLI Example:

    .. code-block:: bash

        salt '*' imgadm.list
        salt '*' imgadm.list docker=True
        salt '*' imgadm.list verbose=True
    uimgadm list -jucmd.run_alluretcodeiuErrorustdoutumanifestuuuid(R+RRRR6R7R!(R/RR-R.R
RR#R9((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pyR0�s
 cC@s�i}t|�st|�r�dj|�}td|dt�}|d}|dkrst||d�|d<q�tjjj	|d�}nd	j|�|d<|S(
u�
    Show manifest of a given image

    uuid : string
        uuid of image

    CLI Example:

    .. code-block:: bash

        salt '*' imgadm.show e42f8c84-bbea-11e2-b920-078fab2aab1f
        salt '*' imgadm.show plexinc/pms-docker:plexpass
    uimgadm show {0}ucmd.run_alltpython_shelluretcodeiustderruErrorustdoutu{} is not a valid uuid.(
R)R*RR+R
RRRR6R7(R#RR-R.R
((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pytshow
s
cC@s�i}t|�r!t|�}nt|�r�dj|�}td|dt�}|d}|dkr�t||d�|d<q�tjj	j
|d�}nd	j|�|d<|S(
u�
    Return info on an installed image

    uuid : string
        uuid of image

    CLI Example:

    .. code-block:: bash

        salt '*' imgadm.get e42f8c84-bbea-11e2-b920-078fab2aab1f
        salt '*' imgadm.get plexinc/pms-docker:plexpass
    uimgadm get {0}ucmd.run_allR;uretcodeiustderruErrorustdoutu{} is not a valid uuid.(R*R3R)RR+R
RRRR6R7(R#RR-R.R
((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pytget(s
cC@s�i}dj|�}td|dt�}|d}|dkrUt|�|d<|St|�}tt|�|�}i||6S(u
    Import an image from the repository

    uuid : string
        uuid to import
    verbose : boolean (False)
        toggle verbose output

    CLI Example:

    .. code-block:: bash

        salt '*' imgadm.import e42f8c84-bbea-11e2-b920-078fab2aab1f [verbose=True]
    uimgadm import {0}ucmd.run_allR;uretcodeiuError(RR+R
RR3R!R=(R#R/RR-R.R
R9((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pytimport_imageIs
cC@s�i}dj|�}td|dt�}|d}|dkrUt|�|d<|Sg}xQ|dj�D]?}g|jd�D]}|r�|^q�}|j|d	�qlW|S(
u�
    Remove an installed image

    uuid : string
        Specifies uuid to import

    CLI Example:

    .. code-block:: bash

        salt '*' imgadm.delete e42f8c84-bbea-11e2-b920-078fab2aab1f
    uimgadm delete {0}ucmd.run_allR;uretcodeiuErrorustdoutu i(RR+R
RR,Rtappend(R#RR-R.R
tresultRtvar((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pytdeletees

(cC@s�i}d}td|�}|d}|dkrFt|�|d<|Si}x�|dj�D]~}g|jd�D]}|rs|^qs}i|dd	|djd
�!d6|d|djd
�d	d!d
6||d<q]W|r�|St|j��SdS(u�
    Remove unused images

    verbose : boolean (False)
        toggle verbose output

    CLI Example:

    .. code-block:: bash

        salt '*' imgadm.vacuum [verbose=True]
    uimgadm vacuum -fucmd.run_alluretcodeiuErrorustdoutu iiu@unamei����uversioniN(R+RR,RtindexR'tkeys(R/RR-R.R
R@RRA((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pytvacuum�s 

(2cC@s�i}d}td|�}|d}|dkrFt|�|d<|Sx6tjjj|d�D]}|||d<|d=q`W|s�t|�}n|S(u�
    Return a list of available sources

    verbose : boolean (False)
        toggle verbose output

    .. versionadded:: 2019.2.0

    CLI Example:

    .. code-block:: bash

        salt '*' imgadm.sources
    uimgadm sources -jucmd.run_alluretcodeiuErrorustdoutuurl(R+RRRR6R7R'(R/RR-R.R
tsrc((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pytsources�s
 cC@s`i}dj|�}td|�}|d}|dkrVt||d�|d<|Stt�S(u�
    Delete a source

    source : string
        source url to delete

    .. versionadded:: 2019.2.0

    CLI Example:

    .. code-block:: bash

        salt '*' imgadm.source_delete https://updates.joyent.com
    uimgadm sources -d {0}ucmd.run_alluretcodeiustderruError(RR+RRGR
(RRR-R.R
((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pyt
source_delete�s
uimgapicC@si}|d
kr"tjd�ndj||�}td|�}|d}|dkrut||d�|d	<|Stt�S(u`
    Add a new source

    source : string
        source url to add
    source_trype : string (imgapi)
        source type, either imgapi or docker

    .. versionadded:: 2019.2.0

    CLI Example:

    .. code-block:: bash

        salt '*' imgadm.source_add https://updates.joyent.com
        salt '*' imgadm.source_add https://docker.io docker
    uimgapiudockeru2Possible unsupported imgage source type specified!uimgadm sources -a {0} -t {1}ucmd.run_alluretcodeiustderruError(uimgapiudocker(tlogtwarningRR+RRGR
(Rtsource_typeRR-R.R
((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pyt
source_add�s
($t__doc__t
__future__RRRtloggingtsalt.utils.jsonRtsalt.utils.pathtsalt.utils.platformt	getLoggert__name__RIt__func_alias__R	RRRR
R!R$R)R*RR3R5R:R0R<R=R>RBRERGRHRL(((s?/usr/lib/python2.7/site-packages/salt/modules/smartos_imgadm.pyt<module>s<
	2			
		&$		!	"!	

Zerion Mini Shell 1.0