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

�
���^c@@sidZddlmZmZmZddlZddlZddlZddl	Zddl
mZmZddl
mZddlmZddlmZeje�Zidd	6Zd
Zd�Zd�Zd
�Zd�Zd�Zed�Ze d�Z!ed�Z"dedd�Z$ddd�Z%ed�Z&ed�Z'd�Z(edd�Z)d�Z*dS(u�
Management of Solaris Zones

:maintainer:    Jorge Schrauwen <sjorge@blackdot.be>
:maturity:      new
:depends:       salt.modules.zoneadm, salt.modules.zonecfg
:platform:      solaris

.. versionadded:: 2017.7.0

Below are some examples of how to use this state.
Lets start with creating a zone and installing it.

.. code-block:: yaml

    omipkg1_configuration:
      zone.present:
        - name: omipkg1
        - brand: ipkg
        - zonepath: /zones/omipkg1
        - properties:
          - autoboot: true
          - ip-type: exclusive
          - cpu-shares: 50
        - resources:
          - attr:
            - name: owner
            - value: Jorge Schrauwen
            - type: string
          - attr:
            - name: description
            - value: OmniOS ipkg zone for testing
            - type: string
          - capped-memory:
            - physical: 64M
    omipkg1_installation:
      zone.installed:
        - name: omipkg1
        - require:
            - zone: omipkg1_configuration
    omipkg1_running:
      zone.booted:
        - name: omipkg1
        - require:
            - zone: omipkg1_installation

A zone without network access is not very useful. We could update
the zone.present state in the example above to add a network interface
or we could use a separate state for this.

.. code-block:: yaml

    omipkg1_network:
      zone.resource_present:
        - name: omipkg1
        - resource_type: net
        - resource_selector_property: mac-addr
        - resource_selector_value: "02:08:20:a2:a3:10"
        - physical: znic1
        - require:
            - zone: omipkg1_configuration

Since this is a single tenant system having the owner attribute is pointless.
Let's remove that attribute.

.. note::
    The following state run the omipkg1_configuration state will add it again!
    If the entire configuration is managed it would be better to add resource_prune
    and optionally the resource_selector_property properties to the resource.

.. code-block:: yaml

    omipkg1_strip_owner:
      zone.resource_present:
        - name: omipkg1
        - resource_type: attr
        - resource_selector_property: name
        - resource_selector_value: owner
        - require:
            - zone: omipkg1_configuration

Let's bump the zone's CPU shares a bit.

.. note::
    The following state run the omipkg1_configuration state will set it to 50 again.
    Update the entire zone configuration is managed you should update it there instead.

.. code-block:: yaml

    omipkg1_more_cpu:
      zone.property_present:
        - name: omipkg1
        - property: cpu-shares
        - value: 100

Or we can remove the limit altogether!

.. note::
    The following state run the omipkg1_configuration state will set it to 50 again.
    Update the entire zone configuration is managed you should set the
    property to None (nothing after the :) instead.

.. code-block:: yaml

    omipkg1_no_cpu:
      zone.property_absent:
        - name: omipkg1
        - property: cpu-shares

i(tabsolute_importtprint_functiontunicode_literalsN(t_parse_valuet#_zonecfg_resource_default_selectors(tCommandExecutionError(tOrderedDict(tmergeuimportuimport_uzonecC@s3dtkrdtkrtStdjt�fSdS(u(
    Provides zone state on Solaris
    uzonecfg.createuzoneadm.installu8{0} state module can only be loaded on Solaris platformsN(t__salt__tTruetFalsetformatt__virtualname__(((s4/usr/lib/python2.7/site-packages/salt/states/zone.pyt__virtual__�s
cC@s�i|d6id6dd6dd6}t|�}tddtdt�}||kr�td	|d
t�}||ks�||t|�krltdr�t|d<nAtd|||�}|d
|d<d|kr�|d|d<n|dr-t|�|d|<|ddkridj||�|d<qiq�|ddkr�|ddkridj||�|d<qiq�q�t|d<dj||�|d<nt|d<dj|�|d<|S(u�
    Ensure property has a certain value

    name : string
        name of the zone
    property : string
        name of property
    value : string
        value of property

    unameuchangesuresultuucommentuzoneadm.listt	installedt
configureduzonecfg.infotshow_allutestuzonecfg.set_propertyustatusumessagesumessageu'The property {0} is was updated to {1}.u+The property {0} is was not updated to {1}!u'The property {0} is already set to {1}.uBThe zone {0} is not in the configured, installed, or booted state.N(tNoneRRR	t__opts__RR
(tnametpropertytvaluetrettzonestzonecfgtzonecfg_res((s4/usr/lib/python2.7/site-packages/salt/states/zone.pytproperty_present�s6

"




cC@s�i|d6id6dd6dd6}tddtdt�}||kr�td	|d
t�}||kr�tdr�t|d<nTtd||�}td	|d
t�}|d
|d<d|kr�|d|d<n|drM||kr�d|d|<n)||||kr$|||d|<n|ddkr�dj|�|d<q�q�|ddkr�|ddkr�dj|�|d<q�q�q�t|d<dj|�|d<nt|d<dj|�|d<|S(u(
    Ensure property is absent

    name : string
        name of the zone
    property : string
        name of property

    .. note::
        This does a zoneacfg clear call. So the property may be reset to a default value!
        Does has the side effect of always having to be called.

    unameuchangesuresultuucommentuzoneadm.listRRuzonecfg.infoRutestuzonecfg.clear_propertyustatusumessagesumessageuThe property {0} was cleared!u%The property {0} did not get cleared!u The property {0} does not exist!uBThe zone {0} is not in the configured, installed, or booted state.N(RRR	RRR
(RRRRRRtzonecfg_new((s4/usr/lib/python2.7/site-packages/salt/states/zone.pytproperty_absent�s<






c
K@sDi|d6id6dd6dd6}tjjj|�}t|�}x.|j�D] \}}t||�||<qPWtddtdt�}||kr#td	|d
t�}	i}
|
j	|�||
d<||
d<||
d
<|r�||
|<n||	kr�x�|	|D]�}|s'|||kr
t|d<|rPdj
||�|d<ndj
|�|d<x�|D]�}tjd|||kr�||ndt||��|dkr�||kr�dj
t
||��||<n||kr�d|d<qj||t||�krjd|d<qjqjW|ddkr�tdrIt|d<n;td|
�}
|
d|d<d|
kr�|
d|d<n|drei|d|<|r�i|d||<nxc|dr�|ngD]K}|r�t||�|d|||<q�t||�|d||<q�W|ddkr�|rLdj
||�|d<qbdj
|�|d<q�q�|ddkr�|r�dj
||�|d<q�dj
|�|d<q�q�q
q
Wn|ddkr@tdr�t|d<nQd
|
kr�|
d
=ntd|
�}
|
d|d<d|
kr/|
d|d<n|dr�i|d|<|rbi|d||<nxc|dru|ngD]K}|r�t||�|d|||<qyt||�|d||<qyW|ddkrdj
||�|d<qq |ddkr dj
||�|d<q q@nt|d<dj
|�|d<|S( u�
    Ensure resource exists with provided properties

    name : string
        name of the zone
    resource_type : string
        type of resource
    resource_selector_property : string
        unique resource identifier
    resource_selector_value : string
        value for resource selection
    kwargs : string|int|...
        resource properties

    .. warning::
        Both resource_selector_property and resource_selector_value must be
        provided, some properties like ``name`` are already reserved by salt in
        states.

    .. note::
        You can set both resource_selector_property and resource_selector_value
        to None for resources that do not require them.

    unameuchangesuresultuucommentuzoneadm.listRRuzonecfg.infoRuzoneu
resource_typeuresource_selectoru#the {0} resource {1} is up to date.uthe {0} resource is up to date.u7zone.resource_preent - key=%s value=%s current_value=%suncpusu{0:.2f}utestuzonecfg.update_resourceustatusumessageu!The {0} resource {1} was updated.uThe {0} resource was updated.u%The {0} resource {1} was not updated.u!The {0} resource was not updated.uzonecfg.add_resourceuThe {0} resource {1} was added.u#The {0} resource {1} was not added.uBThe zone {0} is not in the configured, installed, or booted state.N(Rtsalttutilstargstclean_kwargsRtitemsRR	tupdateRtlogtdebugtfloatRR
(Rt
resource_typetresource_selector_propertytresource_selector_valuetkwargsRtktvRRtzonecfg_kwargstresourcetkeyR((s4/usr/lib/python2.7/site-packages/salt/states/zone.pytresource_presents�









	 



# 



# 
c	
C@s�i|d6id6dd6dd6}|r7t|�}nd}tddtdt�}||kretd	|d
t�}||kr/x�||D]�}tdr�t|d<q�|sYtdd
|d|dddd�}|d|d<|dr&d|d|<|ddkrVdj|�|d<qVq(d|krC|d|d<q(dj|�|d<q�|||kr�tdd
|d|d|d|�}|d|d<|dr�i|d|<d|d||<|ddkr%dj||�|d<q%q(d|kr|d|d<q(dj||�|d<q�q�Wn|ddkr�t|d<dj||�|d<q�nt|d<dj|�|d<|S(un
    Ensure resource is absent

    name : string
        name of the zone
    resource_type : string
        type of resource
    resource_selector_property : string
        unique resource identifier
    resource_selector_value : string
        value for resource selection

    .. warning::
        Both resource_selector_property and resource_selector_value must be provided, some properties
        like ```name``` are already reserved by salt in there states.

    .. note::
        You can set both resource_selector_property and resource_selector_value to None for
        resources that do not require them.

    unameuchangesuresultuucommentuzoneadm.listRRuzonecfg.infoRutestuzonecfg.remove_resourcetzoneR&tresource_keytresource_valueustatusuremoveduThe {0} resource was removed.umessagesumessageu!The {0} resource was not removed.u!The {0} resource {1} was removed.u%The {0} resource {1} was not removed.u The {0} resource {1} was absent.uBThe zone {0} is not in the configured, installed, or booted state.N(RRRR	RRR
(	RR&R'R(RRRR-R((s4/usr/lib/python2.7/site-packages/salt/states/zone.pytresource_absent�sr




	

	


cC@s�i|d6id6dd6dd6}tddt�}||kr�||dd	krut|d<d
j|�|d<q�tds�td||�}ntds�|d
r�t|d<d|d|<dj|�|d<q�t|d<dj|�|d<n�g|d<|djdj|��xB|D]:}||d|kr"|djdj||��q"q"Wt|d<dj|d�|d<|S(u�
    Ensure zone is booted

    name : string
        name of the zone
    single : boolean
        boot in single usermode

    unameuchangesuresultuucommentuzoneadm.listRustateurunninguZone {0} already bootedutestuzoneadm.bootustatusubooteduZone {0} booteduFailed to boot {0}u5The zone {0} is not in the installed or booted state.uuuiduAThe zone {0} has a uuid of {1}, please use the zone name instead!u
N(RRR	RRR
tappendtjoin(RtsingleRRtzoneadm_resR0((s4/usr/lib/python2.7/site-packages/salt/states/zone.pytbooteds:











cC@s�i|d6id6dd6dd6}tddt�}||kr
||dd	krut|d<d
j|�|d<q�tds�|r�td|�n
td
|�}ntds�|dr�t|d<d|d|<dj|�|d<q�t|d<dj|�|d<n�g|d<|djdj|��xB|D]:}||d|kr5|djdj||��q5q5Wt|d<dj|d�|d<|S(u�
    Ensure zone is halted

    name : string
        name of the zone
    graceful : boolean
        use shutdown instead of halt if true

    unameuchangesuresultuucommentuzoneadm.listRustateurunninguZone {0} already haltedutestuzoneadm.shutdownuzoneadm.haltustatusuhalteduZone {0} halteduFailed to halt {0}u+The zone {0} is not in the installed state.uuuiduAThe zone {0} has a uuid of {1}, please use the zone name instead!u
N(RRR	RRR
R4R5(RtgracefulRRR7R0((s4/usr/lib/python2.7/site-packages/salt/states/zone.pythalted;s:




)






cC@sdi|d6id6dd6dd6}tddtdt�}||kr�td	r�t|d<d
j||�|d<d|d|<td|�r�|r�t|d<i|d<d
j||�|d<q�q`tjjj	�}td||�td|�s�ytd||�WnRt
k
rbtd|�r?td|�nt|d<dj||�|d<q�Xt|d<dj||�|d<d|d|<q`td||�}|s�t|d<dj||�|d<td|�r�td|�q�q`|r�ytd||�WnRt
k
r`td|�r=td|�nt|d<dj||�|d<q�Xt|d<dj||�|d<d|d|<q`t|d<dj||�|d<td|�r`td|�q`n�g|d<|djdj|��xB|D]:}||d|kr|djdj||��qqWt|d<dj|d�|d<|S(u�
    Export a zones configuration

    name : string
        name of the zone
    path : string
        path of file to export too.
    replace : boolean
        replace the file if it exists

    unameuchangesuresultuucommentuzoneadm.listRRutestu)Zone configartion for {0} exported to {1}uexportedufile.file_existsu9File {0} exists, zone configuration for {1} not exported.uzonecfg.exportu	file.moveufile.removeu3Unable to export zone configuration for {0} to {1}!u/Zone configuration for {0} was exported to {1}.u
file.get_diffu7Zone configuration for {0} was already exported to {1}.u9Unable to be re-export zone configuration for {0} to {1}!u2Zone configuration for {0} was re-exported to {1}.uEZone configuration for {0} is different from the one exported to {1}!uThe zone {0} does not exist.uuuiduAThe zone {0} has a uuid of {1}, please use the zone name instead!u
N(
RRR	RRR
RRtfilestmkstempRR4R5(RtpathtreplaceRRtcfg_tmptcfg_diffR0((s4/usr/lib/python2.7/site-packages/salt/states/zone.pytexportqs�























c
C@s�i|d6id6dd6dd6}tddtdt�}||kr�td	r�t|d<d
j||�|d<d|d|<q�td|�r�td
||�}|ds�t|d<dj|�|d<q�t|d<d|d|<d
j||�|d<|j�dkr�td|t|�}|d|d<|drdd|d|<dj||�|d<q�g|d<|djdj||��d|kr�|dj|d�ndj|d�|d<n|j�dkr�td|||�}	|	d|d<|	dr0d|d|<dj||�|d<q�g|d<|djdj||��d|	kr{|dj|	d�ndj|d�|d<q�q�t|d<dj|�|d<nt|d<dj|�|d<|S(u�
    Import a zones configuration

    name : string
        name of the zone
    path : string
        path of the configuration file to import
    mode : string
        either import, install, or attach
    nodataset : boolean
        do not create a ZFS file system
    brand_opts : boolean
        brand specific options to pass

    .. note::
        The mode argument can be set to ``import``, ``install``, or ``attach``.
        ``import``: will only import the configuration
        ``install``: will import and then try to install the zone
        ``attach``: will import and then try to attach of the zone

    .. code-block:: yaml

        omipkg1:
          zone.import:
            - path: /foo/bar/baz
    unameuchangesuresultuucommentuzoneadm.listRRutestuZone {0} was imported from {1}.uimportedufile.file_existsuzonecfg.importustatusu,Unable to import zone configuration for {0}!uattachuzoneadm.attachuattacheduZone {0} was attached from {1}.u#Failed to attach zone {0} from {1}!umessageu
uinstalluzoneadm.installu	installedu Zone {0} was installed from {1}.u$Failed to install zone {0} from {1}!u/The file {0} does not exists, unable to import!u5Zone {0} already exists, not importing configuration.N(	RRR	RRR
tlowerR4R5(
RR=tmodet	nodatasett
brand_optsRRt
res_importt
res_attachtres_install((s4/usr/lib/python2.7/site-packages/salt/states/zone.pytimport_�sr
















cC@s6i|d6id6dd6gd6}|s1g}n|s@g}n|jti|d6��|jti|d6��tddtd	t�}td
r�d|d<|djdj|��n||krFtd
r�itd6}g|d<ntd
|||�}|drFt|d<d|d|<|djdj|��qFntd
st|d<t|t�r�x8|D]-}t|t�s�t	|�dkr�t
jd|�qpnx�|j�D]�\}	}
d}|
s�t
||	�}n|
rt||	|
�}n|r�|dr|dnt|d<|dj|d�t	|d�dkr�d|dkrpi|dd<nt|dd|d�|dd<q�q�q�WqpWnt|t�rxL|D]A}t|t�s�t	|�dkr�t
jd|�q�nx|j�D]�\}	}
td|dt�}
i}|	|d<t|
t�rmx$|
D]}|jt|��qMWnt}d}d|kr�|d}|d=nd|kr�|d}|d=n|r�|	tkr�t|	}nd}|rt||dd|d|r||nd�}nG||d<||kr>|||d<n
d|d<||d<t|�}|r|drx|dnt|d<|dj|d�t	|d�dkr�d|dkr�i|dd<nt|dd|d�|dd<q�qqWq�Wqnt|dt�r2dj|d�|d<n|S( u3
    Ensure a zone with certain properties and resources

    name : string
        name of the zone
    brand : string
        brand of the zone
    zonepath : string
        path of the zone
    properties : list of key-value pairs
        dict of properties
    resources : list of key-value pairs
        dict of resources

    .. note::
        If the zone does not exist it will not be installed.
        You can use the ```zone.installed``` state for this.

    .. note::
        Default resource selectors:
            - fs: dir
            - net: mac-addr
            - device: match
            - rctl: name
            - attr: name
            - dataset: name
            - admin: user

    .. warning::
        Properties and resource will not be removed when they
        are absent from the state!

        For properties, simple set them to ```None```.

        For resources, add the ```resource_prune``` property
        and set it to ```True```. Also specify the
        ```resource_selector_property``` if the default is not
        the one you want.

    unameuchangesuresultucommentubranduzonepathuzoneadm.listRRutestu9Cannot determine of changes would happen to the zone {0}.ustatusuzonecfg.createucreateduThe zone {0} was created.iu+zone.present - failed to parse property: %siupropertyu+zone.present - failed to parse resource: %suzonecfg.infoRu
resource_typeuresource_pruneuresource_selector_propertyR'R(uresource_selector_valueuresourceu
N(RR4RRR	RRt
isinstancetlisttlenR#twarningR!RRR
t
merge_dictR"tdictRR3R/R5(Rtbrandtzonepatht
propertiest	resourcesRRt
res_createtpropR.RtresR-Rtresource_cfgtrespvtresource_pruneR'((s4/usr/lib/python2.7/site-packages/salt/states/zone.pytpresentJs�)

		






 


"4
"










7cC@s�i|d6id6d d6dd6}tddtdt�}||kr�td	rt|d<d
|d|<dj|�|d<q�t|d<|ra||dd!kratd|�}td|�}|d|d<|dr�d|d|<dj|�|d<q#g|d<|djdj|��d|krG|dj|d�ndj|d�|d<n�||ddkr#td|�}|d|d<|dr�d|d|<dj|�|d<q#g|d<|djdj|��d|kr	|dj|d�ndj|d�|d<n|dr�td|�}|d|d<|dryd|d|<dj|�|d<q�g|d<|djdj|��d|kr�|dj|d�ndj|d�|d<q�nt|d<dj|�|d<|S("u�
    Ensure a zone is absent

    name : string
        name of the zone
    uninstall : boolean
        when true, uninstall instead of detaching the zone first.

    unameuchangesuresultuucommentuzoneadm.listRRutesturemoveduZone {0} was removed.ustateurunningu	installeduzoneadm.haltuzoneadm.uninstallustatusuuninstalleduThe zone {0} was uninstalled.uFailed to uninstall zone {0}!umessageu
uzoneadm.detachudetacheduThe zone {0} was detached.uFailed to detach zone {0}!uzonecfg.deleteudeleteduThe zone {0} was delete.uFailed to delete zone {0}!uZone {0} does not exist.N(urunningu	installed(RRR	RRR4R5(Rt	uninstallRRtres_haltt
res_uninstallt
res_detacht
res_delete((s4/usr/lib/python2.7/site-packages/salt/states/zone.pytabsent�s`













cC@sgi|d6id6dd6dd6}tddtdt�}||krF||d	d
kr&tdruitd6}ntd
||�}|d|d<|dr�d|d|<dj|�|d<qCg|d<|djdj|��d|kr|dj|d�ndj|d�|d<qct|d<dj|�|d<nt|d<dj|�|d<|S(u�
    Ensure zone is attached

    name : string
        name of the zone
    force : boolean
        force attach the zone

    unameuchangesuresultuucommentuzoneadm.listRRustateu
configuredutestustatusuzoneadm.attachuattacheduThe zone {0} was attached.uFailed to attach zone {0}!umessageu
uzone {0} already attached.uzone {0} is not configured!N(RRR	RRR4R5R
(RtforceRRRG((s4/usr/lib/python2.7/site-packages/salt/states/zone.pytattached"s0







cC@sdi|d6id6dd6dd6}tddtdt�}||krC||d	d
kr#tdruitd6}ntd
|�}|d|d<|dr�d|d|<dj|�|d<q@g|d<|djdj|��d|kr	|dj|d�ndj|d�|d<q`t|d<dj|�|d<nt|d<dj|�|d<|S(uN
    Ensure zone is detached

    name : string
        name of the zone

    unameuchangesuresultuucommentuzoneadm.listRRustateu
configuredutestustatusuzoneadm.detachudetacheduThe zone {0} was detached.uFailed to detach zone {0}!umessageu
uzone {0} already detached.uzone {0} is not configured!N(RRR	RRR4R5(RRRR^((s4/usr/lib/python2.7/site-packages/salt/states/zone.pytdetachedLs0






cC@sji|d6id6dd6dd6}tddtdt�}||krI||d	d
kr)tdruitd6}ntd
|||�}|d|d<|dr�d|d|<dj|�|d<qFg|d<|djdj|��d|kr|dj|d�ndj|d�|d<qft|d<dj|�|d<nt|d<dj|�|d<|S(u�
    Ensure zone is installed

    name : string
        name of the zone
    nodataset : boolean
        do not create a ZFS file system
    brand_opts : boolean
        brand specific options to pass

    unameuchangesuresultuucommentuzoneadm.listRRustateu
configuredutestustatusuzoneadm.installu	installeduThe zone {0} was installed.uFailed to install zone {0}!umessageu
uzone {0} already installed.uzone {0} is not configured!N(RRR	RRR4R5R
(RRDRERRRH((s4/usr/lib/python2.7/site-packages/salt/states/zone.pyRus0






cC@sdi|d6id6dd6dd6}tddtdt�}||krC||d	d
kr#tdruitd6}ntd
|�}|d|d<|dr�d|d|<dj|�|d<q@g|d<|djdj|��d|kr	|dj|d�ndj|d�|d<q`t|d<dj|�|d<nt|d<dj|�|d<|S(uQ
    Ensure zone is uninstalled

    name : string
        name of the zone

    unameuchangesuresultuucommentuzoneadm.listRRustateu
configuredutestustatusuzoneadm.uninstalluuninstalleduThe zone {0} was uninstalled.uFailed to uninstall zone {0}!umessageu
uzone {0} already uninstalled.uzone {0} is not configured!N(RRR	RRR4R5(RRRR]((s4/usr/lib/python2.7/site-packages/salt/states/zone.pytuninstalled�s0






(+t__doc__t
__future__RRRtloggingtsalt.utils.argsRtsalt.utils.atomicfiletsalt.utils.filestsalt.modules.zonecfgRRtsalt.exceptionsRtsalt.utils.odictRtsalt.utils.dictupdateRRNt	getLoggert__name__R#t__func_alias__RR
RRR/R3R
R8R	R:RARRIRZR`RbRcRRd(((s4/usr/lib/python2.7/site-packages/salt/states/zone.pyt<module>os8
		3	6	�	d66te�C*	),

Zerion Mini Shell 1.0