%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_iot.pyo

�
���^c@@sDdZddlmZmZmZddlZddlZddlZddlZddl	Z
ddlZ
ddlm
Z
eje�Zd�Zddddd�Zddddd�Zddddd�Zddddd	�Zddddd
�Zddddd�Zdeddddd
�Zddddd�ZdS(ur
Manage IoT Objects
==================

.. versionadded:: 2016.3.0

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

:depends:
    - boto
    - boto3

The dependencies listed above can be installed via package or pip.

This module accepts explicit vpc 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

    vpc.keyid: GKTADJGHEIQSXMKKRBJ08H
    vpc.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 policy exists:
        boto_iot.policy_present:
            - policyName: mypolicy
            - policyDocument:
                Version: "2012-10-17"
                Statement:
                  Action:
                    - iot:Publish
                  Resource:
                    - "*"
                  Effect: "Allow"
            - region: us-east-1
            - keyid: GKTADJGHEIQSXMKKRBJ08H
            - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

    Ensure topic rule exists:
        boto_iot.topic_rule_present:
            - ruleName: myrule
            - sql: "SELECT * FROM 'iot/test'"
            - description: 'test rule'
            - ruleDisabled: false
            - actions:
              - lambda:
                  functionArn: "arn:aws:us-east-1:1234:function/functionname"
            - region: us-east-1
            - keyid: GKTADJGHEIQSXMKKRBJ08H
            - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

i(tabsolute_importtprint_functiontunicode_literalsN(tsixcC@sdtkrdStS(u)
    Only load if boto is available.
    uboto_iot.policy_existsuboto_iot(t__salt__tFalse(((s8/usr/lib/python2.7/site-packages/salt/states/boto_iot.pyt__virtual__ZscC@s�i|d6td6dd6id6}tdd|d|d	|d
|d|�}	d|	kr�t|d<d
j|	dd�|d<|S|	jd�r�t|d<dj|�|d<|Stdr�dj|�|d<d|d<|Stdd|d|d|d|d	|d
|d|�}	|	jd�sLt|d<d
j|	dd�|d<|Stdd|d|d	|d
|d|�}
idd6|dd<|
|dd<dj|�|d<|S(u[
    Ensure thing type exists.

    .. versionadded:: 2016.11.0

    name
        The name of the state definition

    thingTypeName
        Name of the thing type

    thingTypeDescription
        Description of the thing type

    searchableAttributesList
        List of string attributes that are searchable for
        the thing type

    region
        Region to connect to.

    key
        Secret key to be used.

    keyid
        Access key to be used

    profile
        A dict with region, key, keyid, or a pillar key (string) that
        contains a dict with region, key, and keyid

    unameuresultuucommentuchangesuboto_iot.thing_type_existst
thingTypeNametregiontkeytkeyidtprofileuerroru!Failed to create thing type: {0}.umessageuexistsu-Thing type with given name {0} already existsutestu$Thing type {0} is set to be created.uboto_iot.create_thing_typetthingTypeDescriptiontsearchableAttributesListucreateduboto_iot.describe_thing_typeu
thing_typeuoldunewuThing Type {0} created.N(tTrueRRtformattgett__opts__tNone(tnameRRR
RR	R
Rtrettrt	_describe((s8/usr/lib/python2.7/site-packages/salt/states/boto_iot.pytthing_type_presentasH#








cC@s�i|d6td6dd6id6}tdd|d|d	|d
|d|�}d|kr�t|d<d
j|dd�|d<|S|r�|dr�dj|�|d<|S|d}|jd�}	|	jdt�}
tdr|
r�d}nd}dj||�|d<d&|d<|Sd}|
tkr�tdd|dtd|d	|d
|d|�}
d|
kr t|d<dj|
dd�|d<|Sn�|	jd�}|r |jd�}|dkr�|| }ntjj	|d�}tjj
�|}|jdkrd}q d|j}n|rFtj
d |�tj|�ntd!d|d|d	|d
|d|�}|d"s�t|d<d
j|dd�|d<|S||dd#<id&d6|dd$<d%j|�|d<|S('u�
    Ensure thing type with passed properties is absent.

    .. versionadded:: 2016.11.0

    name
        The name of the state definition.

    thingTypeName
        Name of the thing type.

    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.

    unameuresultuucommentuchangesuboto_iot.describe_thing_typeRRR	R
Ruerroru!Failed to delete thing type: {0}.umessageu
thing_typeuThing Type {0} does not exist.uthingTypeMetadatau
deprecatedutesturemovedudeprecated and removedu Thing Type {0} is set to be {1}.i,uboto_iot.deprecate_thing_typet
undoDeprecateu$Failed to deprecate thing type: {0}.udeprecationDateu+i����u%Y-%m-%d %H:%M:%S.%fiubwait for %s seconds per AWS (5 minutes after deprecation time) before we can delete iot thing typeuboto_iot.delete_thing_typeudeleteduoldunewuThing Type {0} deleted.N(RRRRRRRtfindtdatetimetstrptimetutcnowtsecondstlogtwarningttimetsleep(RRRR	R
RRRt_existing_thing_typet_thing_type_metadatat_deprecatedt_change_desct_delete_wait_timert
_deprecatet_deprecation_date_strt	_tz_indext_deprecation_datet_elapsed_time_deltaR((s8/usr/lib/python2.7/site-packages/salt/states/boto_iot.pytthing_type_absent�s|





	



			


cC@s�i|d6td6dd6id6}tdd|d|d	|d
|d|�}d|kr�t|d<d
j|dd�|d<|S|jd�s�tdr�dj|�|d<d$|d<|Stdd|d|d|d	|d
|d|�}|jd�s%t|d<d
j|dd�|d<|Std|d|d	|d
|d|�}	id$d6|dd<|	|dd<dj|�|d<|Stjj	|ddj|�g�|d<i|d<tdd|d|d	|d
|d|�d}	t
|	dtj�rt
jjj|	d�}
n
|	d}
t
|tj�rOt
jjj|�}nt
jjj|
|�}t|�r�tdr�dj|�}||d<d$|d<|Stjj	|ddg�|d<t
jjj|�}tdd|d|dtd|d	|d
|d|�}|jd�sRt|d<d j|dd�|d<i|d<|Std!d|d"|	d#d|d	|d
|d|�||djdi�d<|	d|djdi�d<n|S(%uR
    Ensure policy exists.

    name
        The name of the state definition

    policyName
        Name of the policy.

    policyDocument
        The JSON document that describes the policy. The length of the
        policyDocument must be a minimum length of 1, with a maximum length of
        2048, excluding whitespace.

    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.
    unameuresultuucommentuchangesuboto_iot.policy_existst
policyNameRR	R
RuerroruFailed to create policy: {0}.umessageuexistsutestu Policy {0} is set to be created.uboto_iot.create_policytpolicyDocumentucreateduboto_iot.describe_policyupolicyuoldunewuPolicy {0} created.uPolicy {0} is present.upolicyDocumentuPolicy {0} set to be modified.uPolicy to be modifieduboto_iot.create_policy_versiontsetAsDefaultuFailed to update policy: {0}.uboto_iot.delete_policy_versiontpolicyVersionIdudefaultVersionIdN(RRRRRRRtostlineseptjoint
isinstanceRtstring_typestsalttutilstjsontloadstdatat
compare_dictstbooltdumpst
setdefault(RR-R.RR	R
RRRRtdescribeDicttmsg((s8/usr/lib/python2.7/site-packages/salt/states/boto_iot.pytpolicy_present+s�






)




 



!c
C@s>i|d6td6dd6id6}td|d|d|d	|d
|�}d|krt|d<dj|dd
�|d<|S|r�|dr�dj|�|d<|Stdr�dj|�|d<d|d<|Std|d|d|d	|d
|�}|r�x�|jdg�D]�}	|	jdt�r1qntd|d|	jd�d|d|d	|d
|�}|dst|d<dj|dd
�|d<|SqWntd|d|d|d	|d
|�}|ds�t|d<dj|dd
�|d<|Si|d6|dd<idd6|dd<dj|�|d<|S(u�
    Ensure policy with passed properties is absent.

    name
        The name of the state definition.

    policyName
        Name of the policy.

    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.
    unameuresultuucommentuchangesuboto_iot.policy_existsRR	R
RuerroruFailed to delete policy: {0}.umessageuexistsuPolicy {0} does not exist.utestu Policy {0} is set to be removed.uboto_iot.list_policy_versionsupolicyVersionsuisDefaultVersionuboto_iot.delete_policy_versionR0u	versionIdudeleteduboto_iot.delete_policyupolicyuoldunewuPolicy {0} deleted.N(RRRRRRR(
RR-RR	R
RRRtversionstversion((s8/usr/lib/python2.7/site-packages/salt/states/boto_iot.pyt
policy_absent�sV












c
C@s�i|d6td6dd6id6}tdd|d|d	|d
|d|�}d|kr�t|d<d
j|dd�|d<|St}	x9|jdg�D]%}
|
jd�|kr�t}	Pq�q�W|	s�tdr�dj||�|d<d|d<|Stdd|d|d|d	|d
|d|�}|jd�sat|d<d
j|dd�|d<|Sitd6|dd<itd6|dd<dj||�|d<|Stjj	|ddj|�g�|d<i|d<|S(u�
    Ensure policy is attached to the given principal.

    name
        The name of the state definition

    policyName
        Name of the policy.

    principal
        The principal which can be a certificate ARN or a Cognito ID.

    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.
    unameuresultuucommentuchangesu boto_iot.list_principal_policiest	principalRR	R
RuerroruFailed to attach policy: {0}.umessageupoliciesu
policyNameutestu(Policy {0} is set to be attached to {1}.u boto_iot.attach_principal_policyR-uattacheduoldunewuPolicy {0} attached to {1}.uPolicy {0} is attached.N(
RRRRRRRR1R2R3(RR-RERR	R
RRRtattachedtpolicy((s8/usr/lib/python2.7/site-packages/salt/states/boto_iot.pytpolicy_attached�sF





)
c
C@s�i|d6td6dd6id6}tdd|d|d	|d
|d|�}d|kr�t|d<d
j|dd�|d<|St}	x9|jdg�D]%}
|
jd�|kr�t}	Pq�q�W|	r�tdr�dj||�|d<d|d<|Stdd|d|d|d	|d
|d|�}|jd�sat|d<dj|dd�|d<|Sitd6|dd<itd6|dd<dj||�|d<|Stjj	|ddj|�g�|d<i|d<|S(u�
    Ensure policy is attached to the given principal.

    name
        The name of the state definition.

    policyName
        Name of the policy.

    principal
        The principal which can be a certificate ARN or a Cognito ID.

    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.
    unameuresultuucommentuchangesu boto_iot.list_principal_policiesRERR	R
RuerroruFailed to detached policy: {0}.umessageupoliciesu
policyNameutestu*Policy {0} is set to be detached from {1}.u boto_iot.detach_principal_policyR-udetacheduFailed to detach policy: {0}.uattacheduoldunewuPolicy {0} detached from {1}.uPolicy {0} is detached.N(
RRRRRRRR1R2R3(RR-RERR	R
RRRRFRG((s8/usr/lib/python2.7/site-packages/salt/states/boto_iot.pytpolicy_detached0sF





)
uc
C@s�i|d6td6dd6id6}
tdd|d|d	|d
|d|	�}d|kr�t|
d<d
j|dd�|
d<|
S|jd�s�tdr�dj|�|
d<d'|
d<|
Stdd|d|d|d|d|d|d	|d
|d|	�	}|jd�s7t|
d<d
j|dd�|
d<|
Std|d|d	|d
|d|	�}id'd6|
dd<||
dd<dj|�|
d<|
Stjj	|
ddj|�g�|
d<i|
d<tdd|d|d	|d
|d|	�d}t
|tj�r%t
jjj|�}nt}
|d|k|d|k}t|�r�t}
||
djdi�d<|d|
djdi�d<nxmd(D]e}||t�|kr�t}
t�||
djdi�|<|||
djdi�|<q�q�W|
r�tdrGd"j|�}i|
d<||
d<d'|
d<|
Stjj	|
dd#g�|
d<td$d|d|d|d|d|d|d	|d
|d|	�	}|jd%�s�t|
d<d&j|dd�|
d<i|
d<q�n|
S()ur
    Ensure topic rule exists.

    name
        The name of the state definition

    ruleName
        Name of the rule.

    sql
        The SQL statement used to query the topic.

    actions
        The actions associated with the rule.

    description
        The description of the rule.

    ruleDisable
        Specifies whether the rule is disabled.

    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.
    unameuresultuucommentuchangesuboto_iot.topic_rule_existstruleNameRR	R
RuerroruFailed to create rule: {0}.umessageuexistsutestuRule {0} is set to be created.uboto_iot.create_topic_ruletsqltactionstdescriptiontruleDisableducreateduboto_iot.describe_topic_ruleuruleuoldunewuRule {0} created.uRule {0} is present.uactionsusqludescriptionuruleDisableduRule {0} set to be modified.uRule to be modifieduboto_iot.replace_topic_ruleureplaceduFailed to update rule: {0}.N(usqludescriptionuruleDisabled(RRRRRRRR1R2R3R4RR5R6R7R8R9R<R>tlocals(RRJRKRLRMRNRR	R
RRRRtneed_updatetvarR@((s8/usr/lib/python2.7/site-packages/salt/states/boto_iot.pyttopic_rule_presentws�%






)
!
!%



 
cC@sni|d6td6dd6id6}td|d|d|d	|d
|�}d|krt|d<dj|dd
�|d<|S|r�|dr�dj|�|d<|Stdr�dj|�|d<d|d<|Std|d|d|d	|d
|�}|ds-t|d<dj|dd
�|d<|Si|d6|dd<idd6|dd<dj|�|d<|S(u�
    Ensure topic rule with passed properties is absent.

    name
        The name of the state definition.

    ruleName
        Name of the policy.

    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.
    unameuresultuucommentuchangesuboto_iot.topic_rule_existsRR	R
RuerroruFailed to delete rule: {0}.umessageuexistsuRule {0} does not exist.utestuRule {0} is set to be removed.uboto_iot.delete_topic_ruleudeleteduruleuoldunewuRule {0} deleted.N(RRRRRR(RRJRR	R
RRR((s8/usr/lib/python2.7/site-packages/salt/states/boto_iot.pyttopic_rule_absent�s8








(t__doc__t
__future__RRRRtloggingR1R tsalt.utils.dataR6tsalt.utils.jsontsalt.extRt	getLoggert__name__RRRRR,RARDRHRIRRRRS(((s8/usr/lib/python2.7/site-packages/salt/states/boto_iot.pyt<module>Hs(		SvmRFFu

Zerion Mini Shell 1.0