%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_route53.pyc

�
���^c@@s'dZddlmZmZmZddlZddlZddlZddl	Zddl
mZddlm
Z
eje�Zd�Zd�Zddddddeeed�	Zd	�Zdddddeeed
�Zdedddddddddd�Zdddddd
�ZdS(uG
Manage Route53 records

.. versionadded:: 2014.7.0

Create and delete Route53 records. 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 route53 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

    route53.keyid: GKTADJGHEIQSXMKKRBJ08H
    route53.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

    mycnamerecord:
      boto_route53.present:
        - name: test.example.com.
        - value: my-elb.us-east-1.elb.amazonaws.com.
        - zone: example.com.
        - ttl: 60
        - record_type: CNAME
        - region: us-east-1
        - keyid: GKTADJGHEIQSXMKKRBJ08H
        - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

    # Using a profile from pillars
    myarecord:
      boto_route53.present:
        - name: test.example.com.
        - value: 1.1.1.1
        - zone: example.com.
        - ttl: 60
        - record_type: A
        - region: us-east-1
        - profile: myprofile

    # Passing in a profile
    myarecord:
      boto_route53.present:
        - name: test.example.com.
        - value: 1.1.1.1
        - zone: example.com.
        - ttl: 60
        - record_type: A
        - region: us-east-1
        - profile:
            keyid: GKTADJGHEIQSXMKKRBJ08H
            key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tSaltInvocationErrorcC@sdtkrdStS(u)
    Only load if boto is available.
    uboto_route53.get_recorduboto_route53(t__salt__tFalse(((s</usr/lib/python2.7/site-packages/salt/states/boto_route53.pyt__virtual__XscO@s
t||�S(N(tpresent(targstkwargs((s</usr/lib/python2.7/site-packages/salt/states/boto_route53.pyt
rr_present_sc
C@s�i|d6td6dd6id6}
t|t�rCdj|�}ng|jd�sa|jd�r�|jd	d
�d
}d0}tdd|dtd|d|	�}t|�d
kr�dj|�|
d<t	|
d<|
St|�d
krdj|�|
d<t	|
d<|
S|d}t
|dd1�}t
|dd1�}|jd�ra|}tj
d||�q�|d1kr�dj|�|
d<t	|
d<|
S|}tj
d||�ny2td|||t	||||	|||�}Wn1tk
r}dj|�|
d<t	|
d<|
SXt|t�r|rtdrQd j|�|
d<d1|
d<|
Std!||||||||||	|
||�
}|r�d1|
dd"<i|d6|d#6|d$6|d%6|d&6|
dd'<d(j|�|
d<q�t	|
d<d)j|�|
d<|
Sn�|r�t	}g|jd�D]}|jd*�^q }g|d#jd�D]}|jd*�^qO}|j�|j�||kr�t}n|r�||d&kr�t}n|r�tj|�tj|d%�kr�t}n|r�tdrd+j|�|
d<d1|
d<|
Std,||||||||||	|
||�
}|r�||
dd"<i|d6|d#6|d$6|d%6|d&6|
dd'<d-j|�|
d<q�t	|
d<d.j|�|
d<q�d/j|�|
d<n|
S(2uT
    Ensure the Route53 record is present.

    name
        Name of the record.

    value
        Value of the record.  As a special case, you can pass in:
            `private:<Name tag>` to have the function autodetermine the private IP
            `public:<Name tag>` to have the function autodetermine the public IP

    zone
        The zone to create the record in.

    record_type
        The record type (A, NS, MX, TXT, etc.)

    ttl
        The time to live for the record.

    identifier
        The unique identifier to use for this record.

    region
        The 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.

    wait_for_sync
        Wait for an INSYNC change status from Route53 before returning success.

    split_dns
        Route53 supports parallel public and private DNS zones with the same name.

    private_zone
        If using split_dns, specify if this is the private zone.
    unameuresultuucommentuchangesu,uprivate:upublic:u:iupendingu	rebootingurunningustoppingustoppeduboto_ec2.find_instancestnametreturn_objst	in_statestprofileu+Error: instance with Name tag {0} not foundu2Error: Name tag {0} matched more than one instanceiuprivate_ip_addressu
ip_addressu#Found private IP %s for instance %su6Error: No Public IP assigned to instance with Name {0}u"Found public IP %s for instance %suboto_route53.get_recordu
Error: {0}utestu#Route53 record {0} set to be added.uboto_route53.add_recorduolduvalueurecord_typeuttlu
identifierunewuAdded {0} Route53 record.u!Failed to add {0} Route53 record.u.u%Route53 record {0} set to be updated.uboto_route53.update_recorduUpdated {0} Route53 record.u$Failed to update {0} Route53 record.u{0} exists.(upendingu	rebootingurunningustoppingustoppedN(tTruet
isinstancetlisttjoint
startswithtsplitRtlentformatRtgetattrtNonetlogtinfoRtdictt__opts__trstriptsortRt	text_type(Rtvaluetzonetrecord_typetttlt
identifiertregiontkeytkeyidRt
wait_for_synct	split_dnstprivate_zonetrettname_tagRtrtinstancet
private_ipt	public_iptrecordterrtaddedtneed_to_updatetxt_valuest	_r_valuestupdated((s</usr/lib/python2.7/site-packages/salt/states/boto_route53.pyRcs�/"	








+/

		(	

	

cO@s
t||�S(N(tabsent(R	R
((s</usr/lib/python2.7/site-packages/salt/states/boto_route53.pyt	rr_absentsc
C@s!i|d6td6dd6id6}td|||t|||||	|
|�}|r
tdr�dj|�|d<d|d<|Std	||||t||||||	|
�}
|
r�||dd
<d|dd<dj|�|d<qt|d<d
j|�|d<ndj|�|d<|S(u
    Ensure the Route53 record is deleted.

    name
        Name of the record.

    zone
        The zone to delete the record from.

    record_type
        The record type (A, NS, MX, TXT, etc.)

    identifier
        An identifier to match for deletion.

    region
        The 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.

    wait_for_sync
        Wait for an INSYNC change status from Route53.

    split_dns
        Route53 supports a public and private DNS zone with the same
        names.

    private_zone
        If using split_dns, specify if this is the private zone.
    unameuresultuucommentuchangesuboto_route53.get_recordutestu%Route53 record {0} set to be deleted.uboto_route53.delete_recorduoldunewuDeleted {0} Route53 record.u$Failed to delete {0} Route53 record.u{0} does not exist.N(RRRRRR(RR"R#R%R&R'R(RR)R*R+R,R2tdeleted((s</usr/lib/python2.7/site-packages/salt/states/boto_route53.pyR:s42"


		
ucC@s�|r|n|}i|d6td6dd6id6}|rztjjj||f�sdtd��ntdd|d	|d
|d|	d|
d
|�jdg�}
|r�|
r�g|
D]}|d|kr�|^q�}
n|
s
d}tj	|�||d<t
|d<|St|
�dkrGtj	dg|
D]}|d^q,�d*S|
d}|rd|d}n|sz|d}qzntdd|d
|d|	d|
d
|�}t
}|s�t}n�tjj
j|ddd�|kr�t}nb|rLxY|jdi�j�D]<\}}|d|kr?|d|kr?t
}Pq	t}q	Wn|shdj|�|d<ntjd|�|r�|d*kr�tjtj��}ntdr�d j|�|d<d*|d<|Std!d|d"|d#|d$|d|d%|d
|d|	d|
d
|�
}|rad&j|�}tj|�||d<d*|dd'<||dd(<q�d)j|�|d<t
|d<n|S(+u�	
    Ensure a hosted zone exists with the given attributes. Note that most
    things cannot be modified once a zone is created - it must be deleted and
    re-spun to update these attributes:

    - private_zone (AWS API limitation).
    - comment (the appropriate call exists in the AWS API and in boto3, but has
      not, as of this writing, been added to boto2).
    - vpc_id (same story - we really need to rewrite this module with boto3)
    - vpc_name (really just a pointer to vpc_id anyway).
    - vpc_region (again, supported in boto3 but not boto2).

    If you need the ability to update these attributes, please use the newer
    boto3_route53 module instead.

    name
        The name of the state definition.

    domain_name
        The name of the domain. This must be fully-qualified, terminating with a period.  This is
        the name you have registered with your domain registrar.  It is also the name you will
        delegate from your registrar to the Amazon Route 53 delegation servers returned in response
        to this request.  Defaults to the value of name if not provided.

    private_zone
        Set True if creating a private hosted zone.

    caller_ref
        A unique string that identifies the request and that allows create_hosted_zone() calls to be
        retried without the risk of executing the operation twice.  This helps ensure idempotency
        across state calls, but can cause issues if a zone is deleted and then an attempt is made
        to recreate it with the same caller_ref.  If not provided, a unique UUID will be generated
        at each state run, which avoids the risk of the above (transient) error.  This option is
        generally not needed.  Maximum length of 128.

    comment
        Any comments you want to include about the hosted zone.

    vpc_id
        When creating a private hosted zone, either the VPC ID or VPC Name to associate with is
        required.  Exclusive with vpe_name.  Ignored when creating a non-private zone.

    vpc_name
        When creating a private hosted zone, either the VPC ID or VPC Name to associate with is
        required.  Exclusive with vpe_id.  Ignored when creating a non-private zone.

    vpc_region
        When creating a private hosted zone, the region of the associated VPC is required.  If not
        provided, an effort will be made to determine it from vpc_id or vpc_name, where possible.
        If this fails, you'll need to provide an explicit value for this option.  Ignored when
        creating a non-private zone.
    unameuresultuucommentuchangesuCEither vpc_name or vpc_id is required when creating a private zone.uboto_vpc.describe_vpcstvpc_idRR&R'R(RuvpcsuregionuCPrivate zone requested but a VPC matching given criteria not found.iuJPrivate zone requested but multiple VPCs matching given criteria found: %suidiu"boto_route53.describe_hosted_zonestdomain_nameu
HostedZoneuConfiguPrivateZoneuVPCsuVPCIdu	VPCRegionu'Hostd Zone {0} already in desired stateu�A Hosted Zone with name %s already exists, but with different settings.  Will attempt to create the one requested on the assumption this is what is desired.  This may fail...utestu(Route53 Hosted Zone {0} set to be added.uboto_route53.create_hosted_zonet
caller_reftcommentR+t
vpc_regionu$Hosted Zone {0} successfully createduoldunewuCreating Hosted Zone {0} failedN(Rtsalttutilstdatatexactly_oneRRtgetRterrorRRRtjsontloadstitemsRRRR tuuidtuuid4R(RR>R+R?R@R=tvpc_nameRAR&R'R(RR,tvpcstvtmsgtvpctdeetstcreatetdtres((s</usr/lib/python2.7/site-packages/salt/states/boto_route53.pythosted_zone_presentXs�7"
,





				%
	






cC@s*|r|n|}i|d6td6dd6id6}tdd|d|d	|d
|d|�}|s�dj|�|d<tj|d�|Std
r�dj|�|d<d|d<|Stdd|d|d	|d
|d|�r&dj|�|d<tj|d�||dd<d|dd<n|S(u
    Ensure the Route53 Hostes Zone described is absent

    name
        The name of the state definition.

    domain_name
        The FQDN (including final period) of the zone you wish absent.  If not
        provided, the value of name will be used.

    unameuresultuucommentuchangesu"boto_route53.describe_hosted_zonesR>R&R'R(RuHosted Zone {0} already absentutestu*Route53 Hosted Zone {0} set to be deleted.uboto_route53.delete_zoneR"uRoute53 Hosted Zone {0} deleteduoldunewN(RRRRRRR(RR>R&R'R(RR,RR((s</usr/lib/python2.7/site-packages/salt/states/boto_route53.pythosted_zone_absent�s,
"
	



	(t__doc__t
__future__RRRtloggingRKtsalt.utils.dataRBtsalt.utils.jsontsalt.extRtsalt.exceptionsRt	getLoggert__name__RRRRRRRR;R:RVRW(((s</usr/lib/python2.7/site-packages/salt/states/boto_route53.pyt<module>Hs4		�	F�	

Zerion Mini Shell 1.0