%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/zonecfg.pyc

�
���^c@@s}dZddlmZmZmZddlZddlZddlZddl	Zddl
ZddlZddlZddl
mZddlmZeje�ZdZidd6Zd	d
ddd
ddgZddgZi
dddddgd6dddddddgd
6ddgd6dd gd	6ddd gd6dgd6d!d"gd
6d!gd6dd#d$gd6d%d&gd'6Zidd6dd
6dd6dd	6dd6dd6d%d'6Zejjjd(��Zd)�Zd*�Zd+�Z d,�Z!d-�Z"e#d.�Z$d/�Z%d0�Z&dd1�Z(d2�Z)d3�Z*d4�Z+d5�Z,d6�Z-d7�Z.d8�Z/d9�Z0e#d:�Z1dS(;u:
Module for Solaris 10's zonecfg

:maintainer:    Jorge Schrauwen <sjorge@blackdot.be>
:maturity:      new
:platform:      OmniOS,OpenIndiana,SmartOS,OpenSolaris,Solaris 10
:depend:        salt.modules.file

.. versionadded:: 2017.7.0

.. warning::
    Oracle Solaris 11's zonecfg is not supported by this module!
i(tabsolute_importtprint_functiontunicode_literalsN(tOrderedDict(tsixuzonecfguimportuimport_urctlunetufsudeviceu
dedicated-cpuudatasetuattru
capped-cpuu
capped-memoryudiruspecialurawutypeuoptionsuaddressuallowed-addressu
global-nicumac-addruphysicalupropertyuvlan-id defrouterumatchunameuvalueuncpusu
importanceuswapulockeduuseruauthsuadmincC@sJtddkstStdd�}|dr2tS|ddkrFtStS(u3
    Check if we are running in the globalzone
    ukerneluSunOSucmd.run_alluzonenameuretcodeustdoutuglobal(t
__grains__tFalset__salt__tTrue(tzonename((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pyt_is_globalzoneRs
cC@srt�r_tjjjd�r_tddkr2tStddkr_ttd�d	kr_tSntd
j	t�fS(u�
    We are available if we are have zonecfg and are the global zone on
    Solaris 10, OmniOS, OpenIndiana, OpenSolaris, or Smartos.
    uzonecfguosuOpenSolarisuSmartOSuOmniOSuOpenIndianauOracle Solarisuosmajorreleasei
u6{0} module can only be loaded in a solaris globalzone.(uOpenSolarisuSmartOSuOmniOSuOpenIndiana(
R
tsalttutilstpathtwhichRt__virtualname__tintRtformat(((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pyt__virtual__cs&cC@s[|jdd�}|j�}x-|D]%}|jd�r%|j|�q%q%Wdj|�S(u*Internal helper to sanitize message outputu	zonecfg: uuOn lineu
(treplacet
splitlinest
startswithtremovetjoin(tmessagetline((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pyt_clean_messageus
cC@st|t�r|rdSdSt|tj�r�tjd�}|j�}|jd�r�|jd�r�|j	|dd!�ddd	�S|jd
�r�|jd�r�i}x�|j	|dd!�ddd	�D]�}|j	d�}d
|dkr|dj
d
d�|d<n|dj�r>t|d�||d<q�|ddkr_t
||d<q�|ddkr�t||d<q�|d||d<q�W|Sd
|kr�|j
d
d�}n|j�r�t|�S|dkr�t
S|dkr�tS|Sn|SdS(uCInternal helper for parsing configuration values into python valuesutrueufalseu((?:[^,"']|"[^"]*"|'[^']*')+)u[u]ii����Niu(u)u=u"ui(t
isinstancetboolRtstring_typestretcompiletstripRtendswithtsplitRtisdigitRRR(tvaluet
listparsertrvaltpair((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pyt_parse_values>!*
cC@s�t|t�r�g}|jd�xN|j�D]@\}}|j|�|jd�|j|�|jd�q/W|jd�djd�|D��jdd�St|t�r�g}|jd�x�|D]�}t|t�r4t|�}xQ|j�D]3\}}|j|�|jd�|j|�q�Wn
|j|�|jd�q�W|jd�djd�|D��jdd�Sd	|kr�d
j|�S|SdS(uKInternal helper for converting pythonic values to configuration file valuesu(u=u,u)ucs@s|]}tj|�VqdS(N(Rt	text_type(t.0tv((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pys	<genexpr>�su,)cs@s|]}tj|�VqdS(N(RR)(R*R+((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pys	<genexpr>�su u"{0}"N(	RtdicttappendtitemsRRtlistRR(R$t	new_valuetkR+titem((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pyt_sanitize_value�s2




#





#c	C@sftd|�rbtjjj|d��5}tjddjtjjj	|j
����WdQXndS(u'Internal helper for debugging cfg filesufile.file_existsuru zonecfg - configuration file:
%suN(RRRtfilestfopentlogtdebugRtdatatdecodet	readlines(tcfg_filetfp_((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pyt	_dump_cfg�s
cC@s�itd6}tjjj�}tjjj|ddd��X}|j|rRdnd�|jdjt|���|jdjt|���Wd	QXt	d
|�s�t	d|dd
kr�|ndj|�dd�nt
|�t	ddjd|d|��}|ddk|d<|dr1|dn|d|d<|ddkrY|d=nt|d�|d<t	d|�r�t	d|�n|S(ua
    Create an in-memory configuration for the specified zone.

    zone : string
        name of zone
    brand : string
        brand name
    zonepath : string
        path of zone
    force : boolean
        overwrite configuration

    CLI Example:

    .. code-block:: bash

        salt '*' zonecfg.create deathscythe ipkg /zones/deathscythe
    ustatusuw+tmodei�u
create -b -F
u
create -b
uset brand={0}
uset zonepath={0}
Nufile.directory_existsufile.makedirs_permsi����u/u{0}/u0700ucmd.run_alluzonecfg -z {zone} -f {cfg}tzonetcfguretcodeiustdoutustderrumessageuufile.file_existsufile.remove(RRRR4tmkstemptfpopentwriteRR3RR=R(R?tbrandtzonepathtforcetretR;R<tres((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pytcreate�s(
!"6
"
cC@s�itd6}t|�tddjd|d|��}|ddk|d<|dra|dn|d	|d
<|d
dkr�|d
=nt|d
�|d
<|S(uR
    Create an in-memory configuration from a template for the specified zone.

    zone : string
        name of zone
    template : string
        name of template

    .. warning::
        existing config will be overwritten!

    CLI Example:

    .. code-block:: bash

        salt '*' zonecfg.create_from_template leo tallgeese
    ustatusucmd.run_allu%zonecfg -z {zone} create -t {tmpl} -FR?ttmpluretcodeiustdoutustderrumessageu(RR=RRR(R?ttemplateRGRH((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pytcreate_from_templates

"
cC@s�itd6}tddjd|��}|ddk|d<|drQ|dn|d|d	<|d	d
kry|d	=nt|d	�|d	<|S(u�
    Delete the specified configuration from memory and stable storage.

    zone : string
        name of zone

    CLI Example:

    .. code-block:: bash

        salt '*' zonecfg.delete epyon
    ustatusucmd.run_alluzonecfg -z {zone} delete -FR?uretcodeiustdoutustderrumessageu(RRRR(R?RGRH((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pytdelete*s

"
cC@s�itd6}tddjd|d|r8dj|�nd��}|dd	k|d<|drl|d
n|d|d<|ddkr�|d=nt|d�|d<|S(
u'
    Export the configuration from memory to stable storage.

    zone : string
        name of zone
    path : string
        path of file to export to

    CLI Example:

    .. code-block:: bash

        salt '*' zonecfg.export epyon
        salt '*' zonecfg.export epyon /zones/epyon.cfg
    ustatusucmd.run_alluzonecfg -z {zone} export{path}R?R
u -f {0}uuretcodeiustdoutustderrumessage(RRRR(R?R
RGRH((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pytexportGs
!"
cC@s�itd6}t|�tddjd|d|��}|ddk|d<|dra|dn|d	|d
<|d
dkr�|d
=nt|d
�|d
<|S(u
    Import the configuration to memory from stable storage.

    zone : string
        name of zone
    path : string
        path of file to export to

    CLI Example:

    .. code-block:: bash

        salt '*' zonecfg.import epyon /zones/epyon.cfg
    ustatusucmd.run_alluzonecfg -z {zone} -f {path}R?R
uretcodeiustdoutustderrumessageu(RR=RRR(R?R
RGRH((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pytimport_hs

"
cC@s�itd6}d}|dkr?t|d<dj|�|d<n�tjjj�}tjjj|ddd���}|dkrt	|t
�s�t	|t�r�t|�}nt	|t
�r�tj|�j�ntj|�}|jd	j||t|���n(|dkr+|jd
j||��nWdQX|r�t|�tdd
jd|d|��}|ddk|d<|dr�|dn|d|d<|ddkr�|d=nt|d�|d<td|�r�td|�q�n|S(u�
    internal handler for set and clear_property

    methode : string
        either set, add, or clear
    zone : string
        name of zone
    key : string
        name of property
    value : string
        value of property

    ustatususetuclearuunkown methode {0}!umessageuw+R>i�u{0} {1}={2}
u{0} {1}
Nucmd.run_alluzonecfg -z {zone} -f {path}R?R
uretcodeiustdoutustderruufile.file_existsufile.remove(usetuclear(RtNoneRRRRR4RARBRR,R/R3RRR)tlowerRCR=RR(tmethodeR?tkeyR$RGR;R<RH((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pyt	_property�s6

!3%"
"
cC@std|||�S(u
    Set a property

    zone : string
        name of zone
    key : string
        name of property
    value : string
        value of property

    CLI Example:

    .. code-block:: bash

        salt '*' zonecfg.set_property deathscythe cpu-shares 100
    uset(RT(R?RSR$((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pytset_property�s
cC@std||d�S(u�
    Clear a property

    zone : string
        name of zone
    key : string
        name of property

    CLI Example:

    .. code-block:: bash

        salt '*' zonecfg.clear_property deathscythe cpu-shares
    uclearN(RTRP(R?RS((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pytclear_property�s
cK@s�itd6}tjjj|�}xK|D]C}t||t�sUt||t�r)t||�||<q)q)W|dkr�t	|d<dj
|�|d<|S|dkr�|r�||kr�t	|d<dj
|�|d<|Stjjj�}tjjj
|ddd	���}|dkr4|jd
j
|��n�|dkr�|r�||}	t|	t�snt|	t�r}t|	�}	nt|	t�r�tj|	�j�ntj|	�}	|jdj
||t|	���q�|jdj
|��nx�tj|�D]�\}}
|d kr(||kr(q�nt|
t�sFt|
t�rUt|	�}	nt|
t�rytj|
�j�ntj|
�}	|t|kr�|jd
j
|t|	���q�|jdj
|t|	���q�W|jd�WdQX|r�t|�tddj
d|d|��}|ddk|d<|drJ|dn|d|d<|ddkrr|d=nt|d�|d<td|�r�td|�q�n|S(!u'
    internal resource hanlder

    methode : string
        add or update
    zone : string
        name of zone
    resource_type : string
        type of resource
    resource_selector : string
        unique resource identifier
    **kwargs : string|int|...
        resource properties

    ustatusuadduupdateuunknown methode {0}umessageu-resource selector {0} not found in parametersuw+R>i�uadd {0}
uselect {0} {1}={2}
uselect {0}
uset {0}={1}
uadd {0} {1}
uend
Nucmd.run_alluzonecfg -z {zone} -f {path}R?R
uretcodeiustdoutustderruufile.file_existsufile.remove(uadduupdate(uupdate(uadd(uupdate(uupdate(RRRtargstclean_kwargsRR,R/R3RRR4RARBRCRRR)RQt	iteritemst_zonecfg_resource_settersR=RR(RRR?t
resource_typetresource_selectortkwargsRGR1R;R<R$R+RH((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pyt	_resource�s`

&

!
3%3"#
"
cK@std||d|�S(u_
    Add a resource

    zone : string
        name of zone
    resource_type : string
        type of resource
    kwargs : string|int|...
        resource properties

    CLI Example:

    .. code-block:: bash

        salt '*' zonecfg.add_resource tallgeese rctl name=zone.max-locked-memory value='(priv=privileged,limit=33554432,action=deny)'
    uaddN(R^RP(R?R[R]((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pytadd_resource=scK@std||||�S(u
    Add a resource

    zone : string
        name of zone
    resource_type : string
        type of resource
    resource_selector : string
        unique resource identifier
    kwargs : string|int|...
        resource properties

    .. note::
        Set resource_selector to None for resource that do not require one.

    CLI Example:

    .. code-block:: bash

        salt '*' zonecfg.update_resource tallgeese rctl name name=zone.max-locked-memory value='(priv=privileged,limit=33554432,action=deny)'
    uupdate(R^(R?R[R\R]((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pytupdate_resourceQsc
C@sEitd6}tjjj�}tjjj|ddd��H}|rk|jdj||t|���n|jdj|��WdQX|rAt	|�t
dd	jd
|d|��}|dd
k|d<|dr�|dn|d|d<|ddkr	|d=nt|d�|d<t
d|�rAt
d|�qAn|S(u�
    Remove a resource

    zone : string
        name of zone
    resource_type : string
        type of resource
    resource_key : string
        key for resource selection
    resource_value : string
        value for resource selection

    .. note::
        Set resource_selector to None for resource that do not require one.

    CLI Example:

    .. code-block:: bash

        salt '*' zonecfg.remove_resource tallgeese rctl name zone.max-locked-memory
    ustatusuw+R>i�uremove {0} {1}={2}
uremove {0}
Nucmd.run_alluzonecfg -z {zone} -f {path}R?R
uretcodeiustdoutustderrumessageuufile.file_existsufile.remove(RRRR4RARBRCRR3R=RR(R?R[tresource_keytresource_valueRGR;R<RH((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pytremove_resourcejs&
!%
"
c	C@s�i}tddjd|��}|ddkr�d}i}x.|djd�D]}d|krjqRn|jd	�r�|s�qRn|j�d
d!}n|j�jd�d}d	|kr�|d
}n|tkr0|r�||j|�n|r!|}i}||kr-g||<q-qkd}i}qR|t	kr~|rV||j|�n|}i}||krkg||<qkqR|jd�r�|j�jd	�r�|s�qRn|j�d
d!}n|d
krVd
|kr�i||<nt
|j�|j�jd�d
�}d|krCd|krC|d|||d<q�tj
d|�qkt
|j�|j�jd�d
�||<qR|r�||j|�nd}i}|d
kr>d
|kr�i||<nt
|j�|j�jd�d
�}d|kr+d|kr+|d|||d<qktj
d|�qRt
|j�|j�jd�d
�||<qRW|r�||j|�q�n|S(u
    Display the configuration from memory

    zone : string
        name of zone
    show_all : boolean
        also include calculated values like capped-cpu, cpu-shares, ...

    CLI Example:

    .. code-block:: bash

        salt '*' zonecfg.info tallgeese
    ucmd.run_alluzonecfg -z {zone} infoR?uretcodeiustdoutu
u:u[ii����u	upropertyunameuvalueu,zonecfg.info - not sure how to deal with: %sN(RRRPR"RtrstripR t"_zonecfg_info_resources_calculatedR-t_zonecfg_info_resourcesR(tindexR6twarning(	R?tshow_allRGRHtresnametresdataRRStkv((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pytinfo�sz
	
)0
)1(2t__doc__t
__future__RRRtloggingRtsalt.utils.argsRtsalt.utils.datatsalt.utils.decoratorstsalt.utils.filestsalt.utils.pathtsalt.utils.odictRtsalt.extRt	getLoggert__name__R6Rt__func_alias__RfReRZt#_zonecfg_resource_default_selectorsRt
decoratorstmemoizeR
RRR(R3R=RRIRLRMRPRNRORTRURVR^R_R`RcRm(((s8/usr/lib/python2.7/site-packages/salt/modules/zonecfg.pyt<module>sz
		





		
	)	!	
3	$	!	!	5			O			5

Zerion Mini Shell 1.0