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

�
���^c@@s�dZddlmZmZmZddljjZddlm	Z	d�Z
dddeee
ddddd�
Zd�Zd�Zd	�Zd
�Zd�ZdS(u�
Manage KMS keys, key policies and grants.

.. versionadded:: 2015.8.0

Be aware that this interacts with Amazon's services, and so may incur charges.

This module uses ``boto``, which can be installed via package, or pip.

This module accepts explicit kms credentials but can also utilize
IAM roles assigned to the instance through Instance Profiles. Dynamic
credentials are then automatically obtained from AWS API and no further
configuration is necessary. More information available `here
<http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html>`_.

If IAM roles are not used you need to specify them either in a pillar file or
in the minion's config file:

.. code-block:: yaml

    elb.keyid: GKTADJGHEIQSXMKKRBJ08H
    elb.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

It's also possible to specify ``key``, ``keyid`` and ``region`` via a profile,
either passed in as a dict, or as a string to pull from pillars or minion
config:

.. code-block:: yaml

    myprofile:
        keyid: GKTADJGHEIQSXMKKRBJ08H
        key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
        region: us-east-1

.. code-block:: yaml

    Ensure mykey key exists:
      boto_kms.key_present:
        - name: mykey
        - region: us-east-1

    # Using a profile from pillars
    Ensure mykey key exists:
      boto_kms.key_present:
        - name: mykey
        - region: us-east-1
        - profile: myprofile

    # Passing in a profile
    Ensure mykey key exists:
      boto_key.key_present:
        - name: mykey
        - region: us-east-1
        - profile:
            keyid: GKTADJGHEIQSXMKKRBJ08H
            key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
i(tabsolute_importtprint_functiontunicode_literalsN(tSaltInvocationErrorcC@sdtkrdStS(u)
    Only load if boto is available.
    uboto_kms.describe_keyuboto_kms(t__salt__tFalse(((s8/usr/lib/python2.7/site-packages/salt/states/boto_kms.pyt__virtual__@scC@sO|std��n|r:t|t�r:td��nt|t�sXtd��nt|t�svtd��nt|t�s�td��ni|d6td6dd	6id
6}t||||||||	|
|�
}
tj|d
|
d
�|d
<dj|d	|
d	g�|d	<|
dsK|
d|d<|dt	krK|Sn|S(u,
    Ensure the KMS key exists. KMS keys can not be deleted, so this function
    must be used to ensure the key is enabled or disabled.

    name
        Name of the key.

    policy
        Key usage policy.

    description
        Description of the key.

    key_usage
        Specifies the intended use of the key. Can only be set on creation,
        defaults to ENCRYPT_DECRYPT, which is also the only supported option.

    grants
        A list of grants to apply to the key. Not currently implemented.

    manage_grants
        Whether or not to manage grants. False by default, which will not
        manage any grants.

    key_rotation
        Whether or not key rotation is enabled for the key. False by default.

    enabled
        Whether or not the key is enabled. True by default.

    region
        Region to connect to.

    key
        Secret key to be used.

    keyid
        Access key to be used.

    profile
        A dict with region, key and keyid, or a pillar key (string)
        that contains a dict with region, key and keyid.
    upolicy is a required argument.umanage_grants must be a list.u$manage_grants must be true or false.u#key_rotation must be true or false.uenabled must be true or false.unameuresultuucommentuchangesu (
Rt
isinstancetlisttbooltTruet_key_presentt
dictupdatetupdatetjoinR(tnametpolicytdescriptiont	key_usagetgrantst
manage_grantstkey_rotationtenabledtregiontkeytkeyidtprofiletrett_ret((s8/usr/lib/python2.7/site-packages/salt/states/boto_kms.pytkey_presentGs*8"!
c
C@sitd6dd6id6}
dj|�}td|||||	�}d|kr{t|
d<dj|dd	�|
d<|
S|ds�td
r�d|
d<d|
d<|
Std|||||||	�}
d|
kr�t|
d<d
j|
dd	�|
d<|
S|
d}|d}td||||||	�}d|krit|
d<dj||dd	�|
d<|
Sidd6|
dd<i|d6|
dd<dj|�|
d<nmtd|||||	�}d|kr�t|
d<dj|dd	�|
d<|
S|d}t||||||	�}tj|
d|d�|
d<dj	|
d|dg�|
d<|ds�|d|
d<|
dtkr�|
Snt
||||||	�}tj|
d|d�|
d<dj	|
d|dg�|
d<|ds|d|
d<|
dtkr|
Snt||||||	�}tj|
d|d�|
d<dj	|
d|dg�|
d<|ds�|d|
d<|
dtkr�|
Snt||||||	�}tj|
d|d�|
d<dj	|
d|dg�|
d<|ds|d|
d<n|
S(Nuresultuucommentuchangesu	alias/{0}uboto_kms.key_existsuerroru'Error when attempting to find key: {0}.umessageutestuKey is set to be created.uboto_kms.create_keyuFailed to create key: {0}ukey_metadatauKeyIduboto_kms.create_aliasuqFailed to create key alias for key_id {0}. This resource will be left dangling. Please clean manually. Error: {1}ukeyuoldunewuKey {0} created.uboto_kms.describe_keyuFailed to update key: {0}.u (
R
tformatRRt__opts__tNonet_key_descriptionRR
Rt_key_policyt_key_enabledt
_key_rotation(RRRRRRRRRRRtaliastrtrctkey_metadatat
kms_key_idtrntrdR((s8/usr/lib/python2.7/site-packages/salt/states/boto_kms.pyR�s�










!
!
!
!
c
C@s�itd6dd6id6}|d}|d|kr9|Stdr[d|d<d|d<|S|r�td	|||||�}d}	n"td
|||||�}d}	d|kr�t|d<d
j|dd�|d<ndj|	�|d<|S(NuresultuucommentuchangesuKeyIduEnabledutestu'Key set to have enabled status updated.uboto_kms.enable_keyuboto_kms.disable_keyuDisableduerroru)Failed to update key enabled status: {0}.umessageu{0} key.(R
RR RRR(
R(RRRRRRR)tretevent((s8/usr/lib/python2.7/site-packages/salt/states/boto_kms.pyR#s(



	
cC@s�itd6dd6id6}|d|kr/|StdrQd|d<d|d<|Std|d	|||||�}d
|kr�t|d<dj|d
d�|d<n
d
|d<|S(NuresultuucommentuchangesuDescriptionutestu$Key set to have description updated.uboto_kms.update_key_descriptionuKeyIduerroru&Failed to update key description: {0}.umessageuUpdated key description.(R
RR RRR(R(RRRRRRtrdu((s8/usr/lib/python2.7/site-packages/salt/states/boto_kms.pyR!s




cC@s~itd6dd6id6}|d}td|||||�}|d|krU|Stdrwd|d<d|d<|S|d	s�d
|d<d|d<|S|r�td|||||�}	ntd|||||�}	d|	kr@d
|	ddkrd
}
d|d<|
|d<|St|d<dj|	dd�|d<n:ii|d6d6i|d6d6|d<dj|�|d<|S(NuresultuucommentuchangesuKeyIdu boto_kms.get_key_rotation_statusutestu,Key set to have key rotation policy updated.uEnabledu2Key is disabled, not changing key rotation policy.uboto_kms.enable_key_rotationuerroruis disabledumessageu Failed to set key rotation: {0}.ukey_rotationuoldunewuSet key rotation policy to {0}.(R
RRR RR(R(RRRRRRR)trketrktmsg((s8/usr/lib/python2.7/site-packages/salt/states/boto_kms.pyR$.s>









c
C@s�itd6dd6id6}|d}td|d||||�}|d|krX|Std	r�d
j|d�|d<d|d<|Std|d|||||�}	d|	kr�t|d<d
j|d|	dd�|d<n
d|d<|S(NuresultuucommentuchangesuKeyIduboto_kms.get_key_policyudefaultu
key_policyutestu'{0} Key set to have key policy updated.uboto_kms.put_key_policyuerroru${0} Failed to update key policy: {1}umessageuUpdated key policy.(R
RRRR R(
R(RRRRRRR)trkptrpkp((s8/usr/lib/python2.7/site-packages/salt/states/boto_kms.pyR"Ys"



%
(t__doc__t
__future__RRRtsalt.utils.dictupdatetutilsRtsalt.exceptionsRRR RR
RRR#R!R$R"(((s8/usr/lib/python2.7/site-packages/salt/states/boto_kms.pyt<module>:s&	
G	f			+

Zerion Mini Shell 1.0