%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/states/boto_ec2.pyc

�
���^c+@@s�dZddlmZmZmZddlZddlmZmZddlm	Z	ddl
mZddlZ
ddljjZddlmZmZeje�Zd�Zeeeeeed	�Zeeeed
�Zeeeeeeeeeeeed�Zd�Zd
�Zeeeeed�Z edd�Z!eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed�*Z"eeeeeeeed�Z#eeeeeeeeed�	Z$eeeeed�Z%eeeeeeeeeeeeeeed�Z&eeeeeeeed�Z'eeeeeeed�Z(dS(u�
Manage EC2

.. versionadded:: 2015.8.0

This module provides an interface to the Elastic Compute Cloud (EC2) service
from AWS.

The below code creates a key pair:

.. code-block:: yaml

    create-key-pair:
      boto_ec2.key_present:
        - name: mykeypair
        - save_private: /root/
        - region: eu-west-1
        - keyid: GKTADJGHEIQSXMKKRBJ08H
        - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

.. code-block:: yaml

    import-key-pair:
       boto_ec2.key_present:
        - name: mykeypair
        - upload_public: 'ssh-rsa AAAA'
        - keyid: GKTADJGHEIQSXMKKRBJ08H
        - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

You can also use salt:// in order to define the public key.

.. code-block:: yaml

    import-key-pair:
       boto_ec2.key_present:
        - name: mykeypair
        - upload_public: salt://mybase/public_key.pub
        - keyid: GKTADJGHEIQSXMKKRBJ08H
        - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

The below code deletes a key pair:

.. code-block:: yaml

    delete-key-pair:
      boto_ec2.key_absent:
        - name: mykeypair
        - region: eu-west-1
        - keyid: GKTADJGHEIQSXMKKRBJ08H
        - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
i(tabsolute_importtprint_functiontunicode_literalsN(ttimetsleep(tsix(trange(tSaltInvocationErrortCommandExecutionErrorcC@sdtkrdStSdS(u)
    Only load if boto is available.
    uboto_ec2.get_keyuboto_ec2N(t__salt__tFalse(((s8/usr/lib/python2.7/site-packages/salt/states/boto_ec2.pyt__virtual__Esc
C@s5i|d6td6dd6id6}td|||||�}tjd|�|dk	r�d|kr�ytd	|�}Wq�tk
r�}	tj|	�d
j|�|d<t|d<|SXn|stdr�dj|�|d<d|d<|S|ro|rotd
||||||�}
|
rOt|d<dj|�|d<|
|dd<qt|d<dj|�|d<q1|r�|r�td||||||�}|r�t|d<dj|�|d<d|dd<||dd<qt|d<dj|�|d<q1t|d<d|d<nt|d<dj|�|d<|S(u%
    Ensure key pair is present.
    unameuresultuucommentuchangesuboto_ec2.get_keyuexists is %susalt://ucp.get_file_struFile {0} not found.utestu!The key {0} is set to be created.uboto_ec2.create_keyuThe key {0} is created.unewuCould not create key {0} uboto_ec2.import_keyuoldu0You can either upload or download a private key uThe key name {0} already existsN(	tTrueR	tlogtdebugtNonetIOErrortformatR
t__opts__(tnametsave_privatet
upload_publictregiontkeytkeyidtprofiletrettexiststetcreatedtimported((s8/usr/lib/python2.7/site-packages/salt/states/boto_ec2.pytkey_presentOsX










		




cC@si|d6td6dd6id6}td|||||�}|r�tdrodj|�|d<d|d<|Std	|||||�}tjd
|�|r�t|d<dj|�|d<||dd<qt|d<d
j|�|d<nt|d<dj|�|d<|S(u
    Deletes a key pair
    unameuresultuucommentuchangesuboto_ec2.get_keyutestu!The key {0} is set to be deleted.uboto_ec2.delete_keyuexists is %suThe key {0} is deleted.uolduCould not delete key {0} uThe key name {0} does not existN(RR	RRRR
RR
(RRRRRRRtdeleted((s8/usr/lib/python2.7/site-packages/salt/states/boto_ec2.pyt
key_absent�s.




	


c
C@s�tjjj||f�s*td��n|s?td��nt|t�s]td��nt|t�s{td��ni|d6td6dd6id	6}
t	d
d|d|	d
|
d|d|�}d|kr�t
|
d<dj|dd�|
d<|
S|ds*tdrud|
d<|rAdj
|
ddg�|
d<n|rgdj
|
ddg�|
d<ndI|
d<|
St	d|d|d|d|d|d|d|	d
|
d|d|�	}d|kr�t
|
d<dj|dd�|
d<|
S|d|d<dj|�|
d<|dd |
d	d <n
t|dd!||	|
||�}tj|
d	|d	�|
d	<|d|
d<|ds�|d|
d<|
dt
kr�|
Snt|d||	|
||�}tj|
d	|d	�|
d	<dj
|
d|dg�|
d<|ds4|d|
d<|
dt
kr4|
Snt|dd"||	|
||�}tj|
d	|d	�|
d	<dj
|
d|dg�|
d<|ds�|d|
d<|
S|rgd#|dkrGtdr�dj
|
dd$g�|
d<qd|d%krd%ndI}t	d&d'|d|	d
|
d|d|�}|rt	d(d)dId*dId+dId,|d-d.|dd ddId/t
d|	d
|
d|d|�}|sDt	d0d+dId,|d-d|	d
|
d|d|�}t
|
d<d1j|r�d2nd3�}dj
|
d|g�|
d<|
Sqdt
|
d<dj
|
dd4g�|
d<|
Sqgdj
|
dd5g�|
d<n|r�x|D]}d|kr�d6}t|��ntjd7|�dI}d8}d9|d:<t
}d;|kr�|jd;�}n|rBd<|dkr|dd<|d=<qTd>|kr-|d>|d=<qTd?}t|��n|dd@|d=<dA|krr|jdA�}n|d8kr�dB|kr�||dB<ndC|kr�|
|dC<ndD|kr�||dD<ndE|kr�|	|dE<q�ntdFj
|dGg�|�}tjdH|�tj|
d	|d	�|
d	<dj
|
d|dg�|
d<|dst|d|
d<|
dt
kr�|
SqtqtWn|
S(Ju�
    Ensure the EC2 ENI exists.

    .. versionadded:: 2016.3.0

    name
        Name tag associated with the ENI.

    subnet_id
        The VPC subnet ID the ENI will exist within.

    subnet_name
        The VPC subnet name the ENI will exist within.

    private_ip_address
        The private ip address to use for this ENI. If this is not specified
        AWS will automatically assign a private IP address to the ENI. Must be
        specified at creation time; will be ignored afterward.

    description
        Description of the key.

    groups
        A list of security groups to apply to the ENI.

    source_dest_check
        Boolean specifying whether source/destination checking is enabled on
        the ENI.

    allocate_eip
        allocate and associate an EIP to the ENI. Could be 'standard' to
        allocate Elastic IP to EC2 region or 'vpc' to get it for a
        particular VPC

        .. versionchanged:: 2016.11.0

    arecords
        A list of arecord dicts with attributes needed for the DNS add_record state.
        By default the boto_route53.add_record state will be used, which requires: name, zone, ttl, and identifier.
        See the boto_route53 state for information about these attributes.
        Other DNS modules can be called by specifying the provider keyword.
        By default, the private ENI IP address will be used, set 'public: True' in the arecord dict to use the ENI's public IP address

        .. versionadded:: 2016.3.0

    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.
    u@One (but not both) of subnet_id or subnet_name must be provided.ugroups is a required argument.ugroups must be a list.u!source_dest_check must be a bool.unameuresultuucommentuchangesuboto_ec2.get_network_interfaceRRRRRuerroru'Error when attempting to find eni: {0}.umessageutestuENI is set to be created.u u4An EIP is set to be allocated/assocaited to the ENI.u A records are set to be created.u!boto_ec2.create_network_interfacet	subnet_idtsubnet_nametprivate_ip_addresstdescriptiontgroupsuFailed to create ENI: {0}uCreated ENI {0}uidudescriptionusource_dest_checkuallocationIdu8An EIP is set to be allocated and assocaited to the ENI.uvpcuboto_ec2.allocate_eip_addresstdomainuboto_ec2.associate_eip_addresstinstance_idt
instance_namet	public_ipt
allocation_idu
allocation_idtnetwork_interface_idtallow_reassociationuboto_ec2.release_eip_addressuHFailed to assocaite the allocated EIP address with the ENI.  The EIP {0}uwas successfully released.uwas NOT RELEASED.u!Failed to allocate an EIP addressu1An EIP is already allocated/assocaited to the ENIu+The arecord must contain a "name" property.uprocessing arecord %suboto_route53uAurecord_typeupublicupublicIpuvalueu	public_ipusUnable to add an A record for the public IP address, a public IP address does not seem to be allocated to this ENI.uprivate_ip_addressuprovideruprofileukeyukeyiduregionu.upresentu"ret from dns_provider.present = %sN(tsalttutilstdatatexactly_oneRt
isinstancetlisttboolRR	R
RRtjoinRt_eni_attributet
dictupdatetupdatet_eni_groupsR
RtpopRt
__states__(RR"R#R$R%R&tsource_dest_checktallocate_eiptarecordsRRRRRtrt
result_createt_retR't	eip_alloctmsgtarecordtdns_providertpublic_ip_arecord((s8/usr/lib/python2.7/site-packages/salt/states/boto_ec2.pyteni_present�sH"
!



  

	
!
!

 	
	
	

 




!
c
C@s	itd6dd6id6}|||kr/|StdrZdj|�|d<d|d<|Stdd|d	d
|d|d|d
|d|d|�}d|kr�d}	t|d<|	j||dd�|d<n3dj|�|d<i||d6|d6|d|<|S(NuresultuucommentuchangesutestuENI set to have {0} updated.u+boto_ec2.modify_network_interface_attributeR,uidtattrtvalueRRRRuerroruFailed to update ENI {0}: {1}.umessageuUpdated ENI {0}.uoldunew(RRRRR	R
(
tmetadataRHRIRRRRRt
result_updateRC((s8/usr/lib/python2.7/site-packages/salt/states/boto_ec2.pyR6�s&


!
!cC@spitd6dd6id6}g|dD]}|d^q&}|j�td|d|d	d
|d|d|d
|�}	|	s�d|d<t|d<n|	j�||	kr�|Stdr�d|d<d|d<|Stdd|dddd|	d
|d|d|d
|�}
d|
krFd}t|d<|j|
dd�|d<n&d|d<i|d6|	d6|dd<|S(Nuresultuucommentuchangesugroupsuidu"boto_secgroup.convert_to_group_idstvpc_iduvpc_idRRRRu0Could not find secgroup ids for provided groups.utestuENI set to have groups updated.u+boto_ec2.modify_network_interface_attributeR,RHRIuerroru!Failed to update ENI groups: {1}.umessageuUpdated ENI groups.uoldunew(RtsortR	R
RRR(RJR&RRRRRtgt	group_idst_groupsRKRC((s8/usr/lib/python2.7/site-packages/salt/states/boto_ec2.pyR9�s8!
"	






!

cC@s�i|d6td6dd6id6}tdd|d|d	|d
|d|�}d|kr�t|d<d
j|dd�|d<|S|ds�tdr�d|d<d"|d<|Sntdr	d|d<|r�d|dkr�dj|ddg�|d<nd"|d<|Sd|ddkr�tdd|dtd|d	|d
|d|�}d|kr�t|d<dj|dd�|d<|Sntdd|d|d	|d
|d|�}	d|	kr�t|d<dj|	dd�|d<|Sdj|�|d<d"|dd<|r�d|dkr�tddd"d|ddd|d	|d
|d|�}
|
s�dj|ddg�|d<t|d<|Sdj|dd g�|d<t|dd!<n|S(#u�
    Ensure the EC2 ENI is absent.

    .. versionadded:: 2016.3.0

    name
        Name tag associated with the ENI.

    release_eip
        True/False - release any EIP associated with the ENI

    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_ec2.get_network_interfaceRRRRRuerroru'Error when attempting to find eni: {0}.umessageutestuENI is set to be deleted.uallocationIdu u.Allocated/associated EIP is set to be releaseduidu
attachmentu!boto_ec2.detach_network_interfacetforceuFailed to detach ENI: {0}u!boto_ec2.delete_network_interfaceuFailed to delete ENI: {0}uDeleted ENI {0}uboto_ec2.release_eip_addressR*R+u+Failed to release EIP allocated to the ENI.u
EIP released.ueip releasedN(RR	R
RRRR5(Rtrelease_eipRRRRRR?t
result_detacht
result_deleteRA((s8/usr/lib/python2.7/site-packages/salt/states/boto_ec2.pyt
eni_absent�sh"
!






 




	
i,c	K@sQi|d6td6dd6id6}tdd|d||�sbd	jd|�|d<t|d<|Sd
jd|�|d<i||6|dd<|s�|St�}x�trLtdd|d
t|�}|r�|djdkr�Pnt�||kr?|rdjd|dj�|d<ndjd|�|d<t|d<|Std�q�W|S(uS
    Create a snapshot from the given instance

    .. versionadded:: 2016.3.0
    unameuresultuucommentuchangesuboto_ec2.create_imagetami_nameR)u#Failed to create new AMI {ami_name}uCreated new AMI {ami_name}unewuboto_ec2.find_imagestreturn_objsiu	availableu(AMI still in state {state} after timeouttstateu1AMI with name {ami_name} not found after timeout.i(RR	RR
RRXR(	RRVR)twait_until_availabletwait_timeout_secondstkwargsRt	starttimetimages((s8/usr/lib/python2.7/site-packages/salt/states/boto_ec2.pytsnapshot_created&s2


		 
c+DHC@sdi|d6td6dd6id6}+t},dk}-i}.tjjj||f�s^td��n|$sp|%sp|&r�tjjj|$|%|&f�r�td��n|r�td
d|d|'d|(d|)d|*d|-�}/|/skt},qkn�tdd|r�|n|d|'d|(d|)d|*d|-�}0t|0�s9t},n2t|0�dkrat	j
d�dl}n
|0d}|,r"tdr�dj
|�|+d<dl|+d<|+S|r�i|d6|'d6|(d6|)d6|*d6}1td |1�}2t|2�r�|2d}q�|}ntd!||r|n|d"|d#|d$|d%|d&|	d'|
d(|d)|d*|
d+|d,|d-|d.|d/|d0|d1|d2|d3|d4|d5|d6|d7|d8|d9|d:|d;|d<|d=| d>|!d|'d|(d|)d|*�!}3|3s�d?|3kr"t|+d<d@j
|r|n|�|+d<|+S|3d?}iidA6idB6|+d<dl|+ddAd?<||+ddBd?<|&rtdr�dC|+d<dl|+d<|+S|
s�|r�dDndl}4tdEdF|4d|'d|(d|)d|*�}3|3s�t|+d<dG|+d<|+S|3dH}%t	jdI|3dJ�q"t	jdK�n|$s.|%r!dL}5dM}6xyt|5�D]k}7tdNdO|$dP|%d|'d|(d|)d|*�}3|3r�PqGt	jdQ|5|6|$p�|%�tj|6�qGW|3s�t|+d<dRj
|$p�|%�|+d<|+S|3ddJ}8|3djd?�rS|3dd?|krt|+d<dSj
|$r4|$n|%|3dd?�|+d<|+Sq!tdr~dTj
|�|+d<dl|+d<|+StdUd|dV|$dW|%d|'d|(d|)d|*�}3|3r�dB|+dkr�i|+ddB<n|8|+ddBdJ<q!t|+d<dXj
|r
|n|�|+d<|+Sn|"r�x�tj|"�D]p\}9}:tdY|9d|d|'d|(d|)d|*�};t|;t�s�in|;};|;j|9�|:kr�q7q7tdr�dZj
|9|;j|9�|:�|.|9<q7ny;td[d\|9d]|:d|d|'d|(d|)d|*�}3Wn7tk
rM}<t|+d<d^j
|9|:|�|+d<|+SX|+drb|+dniidA6idB6|+d<|;j|9�|+ddA|9<|:|+ddB|9<q7Wntdr|.r�|.|+ddB<dl|+d<qd_j
|r�|n|�|+d<t|+d<n|r`|dlk	r`t|�}ttd`dai|db6d|'d|(d|)d|*�j|i��}=t|=j��}>t|j��}?t|>|?�}@tg|?|>D]}7|7||7f^q��}Atg|D]4}7|j|7�|=j|7�kr�|7||7f^q��}B|Aj|B�|As(	|@r`tdr�	dA|+dkrP	|+ddAni|+ddA<dB|+dkr|	|+ddBni|+ddB<|=|+ddAdc<||+ddBdc<|+dcddj
|r�	|n|�7<q]|@rZ
tdedf|d"|@d|'d|(d|)d|*�sZ
dgj
|r
|n|�}Ct	j|C�|+dcdh|C7<t|+d<|+Sn|Ar�
tdidf|d"|Ad|'d|(d|)d|*�s�
djj
|r�
|n|�}Ct	j|C�|+dcdh|C7<t|+d<|+SndA|+dkr�
|+ddAni|+ddA<dB|+dkr(|+ddBni|+ddB<|=|+ddAdc<||+ddBdc<q`n|+S(mu�
    Ensure an EC2 instance is running with the given attributes and state.

    name
        (string) - The name of the state definition.  Recommended that this
        match the instance_name attribute (generally the FQDN of the instance).
    instance_name
        (string) - The name of the instance, generally its FQDN.  Exclusive with
        'instance_id'.
    instance_id
        (string) - The ID of the instance (if known).  Exclusive with
        'instance_name'.
    image_id
        (string) – The ID of the AMI image to run.
    image_name
        (string) – The name of the AMI image to run.
    tags
        (dict) - Tags to apply to the instance.
    key_name
        (string) – The name of the key pair with which to launch instances.
    security_groups
        (list of strings) – The names of the EC2 classic security groups with
        which to associate instances
    user_data
        (string) – The Base64-encoded MIME user data to be made available to the
        instance(s) in this reservation.
    instance_type
        (string) – The EC2 instance size/type.  Note that only certain types are
        compatible with HVM based AMIs.
    placement
        (string) – The Availability Zone to launch the instance into.
    kernel_id
        (string) – The ID of the kernel with which to launch the instances.
    ramdisk_id
        (string) – The ID of the RAM disk with which to launch the instances.
    vpc_id
        (string) - The ID of a VPC to attach the instance to.
    vpc_name
        (string) - The name of a VPC to attach the instance to.
    monitoring_enabled
        (bool) – Enable detailed CloudWatch monitoring on the instance.
    subnet_id
        (string) – The ID of the subnet within which to launch the instances for
        VPC.
    subnet_name
        (string) – The name of the subnet within which to launch the instances
        for VPC.
    private_ip_address
        (string) – If you’re using VPC, you can optionally use this parameter to
        assign the instance a specific available IP address from the subnet
        (e.g., 10.0.0.25).
    block_device_map
        (boto.ec2.blockdevicemapping.BlockDeviceMapping) – A BlockDeviceMapping
        data structure describing the EBS volumes associated with the Image.
    disable_api_termination
        (bool) – If True, the instances will be locked and will not be able to
        be terminated via the API.
    instance_initiated_shutdown_behavior
        (string) – Specifies whether the instance stops or terminates on
        instance-initiated shutdown. Valid values are:

        - 'stop'
        - 'terminate'

    placement_group
        (string) – If specified, this is the name of the placement group in
        which the instance(s) will be launched.
    client_token
        (string) – Unique, case-sensitive identifier you provide to ensure
        idempotency of the request. Maximum 64 ASCII characters.
    security_group_ids
        (list of strings) – The IDs of the VPC security groups with which to
        associate instances.
    security_group_names
        (list of strings) – The names of the VPC security groups with which to
        associate instances.
    additional_info
        (string) – Specifies additional information to make available to the
        instance(s).
    tenancy
        (string) – The tenancy of the instance you want to launch. An instance
        with a tenancy of ‘dedicated’ runs on single-tenant hardware and can
        only be launched into a VPC. Valid values are:”default” or “dedicated”.
        NOTE: To use dedicated tenancy you MUST specify a VPC subnet-ID as well.
    instance_profile_arn
        (string) – The Amazon resource name (ARN) of the IAM Instance Profile
        (IIP) to associate with the instances.
    instance_profile_name
        (string) – The name of the IAM Instance Profile (IIP) to associate with
        the instances.
    ebs_optimized
        (bool) – Whether the instance is optimized for EBS I/O. This
        optimization provides dedicated throughput to Amazon EBS and a tuned
        configuration stack to provide optimal EBS I/O performance. This
        optimization isn’t available with all instance types.
    network_interfaces
        (boto.ec2.networkinterface.NetworkInterfaceCollection) – A
        NetworkInterfaceCollection data structure containing the ENI
        specifications for the instance.
    network_interface_name
         (string) - The name of Elastic Network Interface to attach

        .. versionadded:: 2016.11.0

    network_interface_id
         (string) - The id of Elastic Network Interface to attach

        .. versionadded:: 2016.11.0

    attributes
        (dict) - Instance attributes and value to be applied to the instance.
        Available options are:

        - instanceType - A valid instance type (m1.small)
        - kernel - Kernel ID (None)
        - ramdisk - Ramdisk ID (None)
        - userData - Base64 encoded String (None)
        - disableApiTermination - Boolean (true)
        - instanceInitiatedShutdownBehavior - stop|terminate
        - blockDeviceMapping - List of strings - ie: [‘/dev/sda=false’]
        - sourceDestCheck - Boolean (true)
        - groupSet - Set of Security Groups or IDs
        - ebsOptimized - Boolean (false)
        - sriovNetSupport - String - ie: ‘simple’

    target_state
        (string) - The desired target state of the instance.  Available options
        are:

        - running
        - stopped

        Note that this option is currently UNIMPLEMENTED.
    public_ip:
        (string) - The IP of a previously allocated EIP address, which will be
        attached to the instance.  EC2 Classic instances ONLY - for VCP pass in
        an allocation_id instead.
    allocation_id:
        (string) - The ID of a previously allocated EIP address, which will be
        attached to the instance.  VPC instances ONLY - for Classic pass in
        a public_ip instead.
    allocate_eip:
        (bool) - Allocate and attach an EIP on-the-fly for this instance.  Note
        you'll want to releaase this address when terminating the instance,
        either manually or via the 'release_eip' flag to 'instance_absent'.
    region
        (string) - Region to connect to.
    key
        (string) - Secret key to be used.
    keyid
        (string) - Access key to be used.
    profile
        (variable) - A dict with region, key and keyid, or a pillar key (string)
        that contains a dict with region, key and keyid.

    .. versionadded:: 2016.3.0
    unameuresultuucommentuchangesupendingu	rebootingurunningustoppingustoppedu7Exactly one of image_id OR image_name must be provided.uHAt most one of public_ip, allocation_id OR allocate_eip may be provided.uboto_ec2.existsR(RRRRt	in_statesuboto_ec2.find_instancesRiuTMultiple instances matching criteria found - cannot determine a singular instance-idiutestu&The instance {0} is set to be created.uami_nameuregionukeyukeyiduprofileuboto_ec2.find_imagesuboto_ec2.runttagstkey_nametsecurity_groupst	user_datat
instance_typet	placementt	kernel_idt
ramdisk_idRLtvpc_nametmonitoring_enabledR"R#R$tblock_device_maptdisable_api_terminationt$instance_initiated_shutdown_behaviortplacement_grouptclient_tokentsecurity_group_idstsecurity_group_namestadditional_infottenancytinstance_profile_arntinstance_profile_namet
ebs_optimizedtnetwork_interfacestnetwork_interface_nameR,uinstance_iduFailed to create instance {0}.uoldunewuNew EIP would be allocated.uvpcuboto_ec2.allocate_eip_addressR'uFailed to allocate new EIP.u
allocation_idu"New EIP with address %s allocated.u	public_ipuEIP not requested.i
iuboto_ec2.get_eip_address_infot	addressestallocation_idsu8Waiting up to %s secs for new EIP %s to become availableuFailed to lookup EIP {0}.u0EIP {0} is already associated with instance {1}.uInstance {0} to be updated.uboto_ec2.associate_eip_addressR*R+u%Failed to attach EIP to instance {0}.uboto_ec2.get_attributeuDThe instance attribute {0} is set to be changed from '{1}' to '{2}'.uboto_ec2.set_attributet	attributetattribute_valueu3Failed to set attribute {0} to {1} on instance {2}.u$Instance {0} is in the correct stateuboto_ec2.get_all_tagstfiltersuresource-idutagsu(  Tags would be updated on instance {0}.uboto_ec2.delete_tagstresource_idsu)Error while deleting tags on instance {0}u  uboto_ec2.create_tagsu)Error while creating tags on instance {0}(upendingu	rebootingurunningustoppingustoppedN(RR
R.R/R0R1RR	tlenR
RRRRtinfoRRRtgetRt	iteritemsR2tdicttsettkeysR3R8terror(DRR)R(timage_idt
image_nameR`RaRbRcRdReRfRgRLRhRiR"R#R$RjRkRlRmRnRoRpRqRrRsRtRuRvRwR,t
attributesttarget_stateR*R+R=RRRRRt_createtrunning_statest
changed_attrsRt	instancestargst	image_idsR?R'ttriestsecstttiptktvtcurrRt	curr_tagstcurrenttdesiredtremovetaddtreplaceRC((s8/usr/lib/python2.7/site-packages/salt/states/boto_ec2.pytinstance_presentMs��

1		
	



	





	











,


*-G

,,	

	

,,c	C@s�i|d6td6dd6id6}	d7}
|s�yGtdd|rG|n|d
|d|d|d|d|
d|�}Wq�tk
r�}d8|	d<dj|p�|�|	d<|	SXntdd|d
|d|d|d|dtd|�}t|�st|	d<dj|�|	d<|	S|d}
tddd|d
|d|d|d|�}|jd�tkr�t|	d<dj|�|	d<|	Stdr�dj|�|	d<d8|	d<|	Stdd|d|d
|d|d|d|�}|st|	d<dj|�|	d<|	Si|d 6|	dd!<d8|	dd"<|r�t	|
d#d8�}|r�i|d$6|d%6|d&6|d'6}d8}d8}d8}t	|
d(d8�rtd)d*||�}t|�r�d+|dkr�|dd+}|djd,�}qt|	d<d-j|�|	d<|	Sn	|
j
}|rCtd.d/||�sCtjd0|�qCntd1d2|d3||�r�tj
d4|py|dd5�|p�|dd5|	dd!d5<q�t|	d<d6j|�|	d<|	Sq�n|	S(9u�
    Ensure an EC2 instance does not exist (is stopped and removed).

    .. versionchanged:: 2016.11.0

    name
        (string) - The name of the state definition.
    instance_name
        (string) - The name of the instance.
    instance_id
        (string) - The ID of the instance.
    release_eip
        (bool)   - Release any associated EIPs during termination.
    region
        (string) - Region to connect to.
    key
        (string) - Secret key to be used.
    keyid
        (string) - Access key to be used.
    profile
        (variable) - A dict with region, key and keyid, or a pillar key (string)
        that contains a dict with region, key and keyid.
    filters
        (dict) - A dict of additional filters to use in matching the instance to
        delete.

    YAML example fragment:

    .. code-block:: yaml

        - filters:
            vpc-id: vpc-abcdef12
    unameuresultuucommentuchangesupendingu	rebootingurunningustoppingustoppeduboto_ec2.get_idRRRRRR_R|u2Couldn't determine current status of instance {0}.uboto_ec2.find_instancesR(RWuInstance {0} is already gone.iuboto_ec2.get_attributeudisableApiTerminationu4Termination of instance {0} via the API is disabled.utestu&The instance {0} is set to be deleted.uboto_ec2.terminateu!Failed to terminate instance {0}.uinstance_iduoldunewu
ip_addressuregionukeyukeyiduprofileuvpc_iduboto_ec2.get_eip_address_infoRxu
allocation_iduassociation_idu-Can't determine AllocationId for address {0}.u!boto_ec2.disassociate_eip_addresstassociation_iduFailed to disassociate EIP %s.uboto_ec2.release_eip_addressR+R*uReleased EIP address %su	public_ipuFailed to release EIP {0}.(upendingu	rebootingurunningustoppingustoppedN(RR	RRRR~R�R
Rtgetattrt
ip_addressR
twarningR(RR)R(RRRRRRR|RR�RR�tinstancet	no_can_doR?R�t	base_argsR*talloc_idtassoc_id((s8/usr/lib/python2.7/site-packages/salt/states/boto_ec2.pytinstance_absent�s�&









"
	
		#

c
C@s�i|d6td6dd6id6}
i}d.}tjjj||||f�s^td��n|sj|r�|r�td��n|r�|ji|d
6�n|r�|ji|d6�n|rtdd|d|d|d|d|	d|�}|sdj|�|
d<|
Sn|r.|ji|d6�n|rK|ji|d6�ni|d6|d6|d6|	d6}
tdd||
�}t	|�dkr�d |
d<|
St	|�dkr�d!j|�}t
j|�||
d<t|
d<|
S|d"}t
j
d#|�td$r.d%j|�|
d<d/|
d<|
Std&d'|d(t|
�r�d)j|�|
d<ii|d*6d+6id/d*6d,6|
d<nd-j|�|
d<t|
d<|
S(0u�
    Ensure the EC2 volume is detached and absent.

    .. versionadded:: 2016.11.0

    name
        State definition name.

    volume_name
        Name tag associated with the volume.  For safety, if this matches more than
        one volume, the state will refuse to apply.

    volume_id
        Resource ID of the volume.

    instance_name
        Only remove volume if it is attached to instance with this Name tag.
        Exclusive with 'instance_id'.  Requires 'device'.

    instance_id
        Only remove volume if it is attached to this instance.
        Exclusive with 'instance_name'.  Requires 'device'.

    device
        Match by device rather than ID.  Requires one of 'instance_name' or
        'instance_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.

    unameuresultuucommentuchangesupendingu	rebootingurunningustoppingustoppedu^Exactly one of 'volume_name', 'volume_id', 'instance_name', or 'instance_id' must be provided.uYParameter 'device' is required when either 'instance_name' or 'instance_id' is specified.u	volume-idutag:Nameuboto_ec2.get_idRRRRRR_uDInstance with Name {0} not found.  Assuming associated volumes gone.uattachment.instance-iduattachment.deviceuregionukeyukeyiduprofileuboto_ec2.get_all_volumesR|iu;Volume matching criteria not found, assuming already absentuBMore than one volume matched criteria, can't continue in state {0}iuMatched Volume ID %sutestu$The volume {0} is set to be deleted.uboto_ec2.delete_volumet	volume_idRQuVolume {0} deleted.u	volume_iduoldunewuError deleting volume {0}.(upendingu	rebootingurunningustoppingustoppedN(RR.R/R0R1RR8R	RR~R
R�R
RRR(Rtvolume_nameR�R)R(tdeviceRRRRRR|R�R�tvolsRCtvol((s8/usr/lib/python2.7/site-packages/salt/states/boto_ec2.pyt
volume_absent^sb,

!

"






)
c
C@s.i|d6td6dd6id6}i|d6|d6|d6|d	6|d
6|d6}tdr�t|d
<td|�}	|	dr�|	jd�r�d|d<|	d|d<d|d<q�nd|d<t|d<|Std|�}	|	dr|	jd�r*d|d<|	d|d<q*nd|d<t|d<|S(u
    Ensure EC2 volume(s) matching the given filters have the defined tags.

    .. versionadded:: 2016.11.0

    name
        State definition name.

    tag_maps
        List of dicts of filters and tags, where 'filters' is a dict suitable for passing
        to the 'filters' argument of boto_ec2.get_all_volumes(), and 'tags' is a dict of
        tags to be set on volumes as matched by the given filters.  The filter syntax is
        extended to permit passing either a list of volume_ids or an instance_name (with
        instance_name being the Name tag of the instance to which the desired volumes are
        mapped).  Each mapping in the list is applied separately, so multiple sets of
        volumes can be all tagged differently with one call to this function.

    YAML example fragment:

    .. code-block:: yaml

        - filters:
            attachment.instance_id: i-abcdef12
          tags:
            Name: dev-int-abcdef12.aws-foo.com
        - filters:
            attachment.device: /dev/sdf
          tags:
            ManagedSnapshots: true
            BillingGroup: bubba.hotep@aws-foo.com
        - filters:
            instance_name: prd-foo-01.aws-foo.com
          tags:
            Name: prd-foo-01.aws-foo.com
            BillingGroup: infra-team@aws-foo.com
        - filters:
            volume_ids: [ vol-12345689, vol-abcdef12 ]
          tags:
            BillingGroup: infra-team@aws-foo.com

    authoritative
        Should un-declared tags currently set on matched volumes be deleted?  Boolean.

    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.

    unameuresultuucommentuchangesutag_mapsu
authoritativeuregionukeyukeyiduprofileutestudry_runuboto_ec2.set_volumes_tagsusuccessuTags would be updated.u'Error validating requested volume tags.u
Tags applied.u%Error updating requested volume tags.N(RRR	R�RR
(
Rttag_mapst
authoritativeRRRRRR�R?((s8/usr/lib/python2.7/site-packages/salt/states/boto_ec2.pytvolumes_tagged�s2<











cC@sfi|d6td6dd6id6}i}i}dE}tjjj||f�s^td��ntjjj||f�s�td	��n|dFkr�td
��ni|d6|
d6|d
6|d6}|rtdd|d||�}|stdj|���qntdd|dt|�}|d}|r�i}|j	i|d6�tdd||�}t
|�dkr�dj||�}t|��nt
|�dkr�tdr�dj|||�|d<dF|d<|Stdd|jd |d!|d"|d#|	d$|
d%|d&t|�}d|kr6|d}ntd'j|���td(d)ii|gd*6d+6i|d,6d-6g|�}|d.t
kr�td/j|||d���ndF|d0<||d0<q�|d}ntdd1|gdt|�}t
|�dkr"td2j|���n|d}|j|jkretd3j||j||j���n|j}|dFk	r}|jdFk	r}||jkr�||jkr�d4j|||�|d<|Stdrd5j|j|j|||�|d<dF|d<|Std6d7|d8t|�rYd9j||j|j�|d<|j|d:<|j|d;<q�td<j||j|j���n||d:<dF|d;<tdr�d=j|||�|d<dF|d<|Std>d7|d|d?||�r?d@j|ddAj|||�g�|d<||d:<||d;<i|dB6|dC6|d<n#dDj|||�|d<t
|d<|S(Gu_	
    Ensure the EC2 volume is present and attached.

    ..

    name
        State definition name.

    volume_name
        The Name tag value for the volume. If no volume with that matching name tag is found,
        a new volume will be created. If multiple volumes are matched, the state will fail.

    volume_id
        Resource ID of the volume. Exclusive with 'volume_name'.

    instance_name
        Attach volume to instance with this Name tag.
        Exclusive with 'instance_id'.

    instance_id
        Attach volume to instance with this ID.
        Exclusive with 'instance_name'.

    device
        The device on the instance through which the volume is exposed (e.g. /dev/sdh)

    size
        The size of the new volume, in GiB. If you're creating the volume from a snapshot
        and don't specify a volume size, the default is the snapshot size. Optionally specified
        at volume creation time; will be ignored afterward. Requires 'volume_name'.

    snapshot_id
        The snapshot ID from which the new Volume will be created. Optionally specified
        at volume creation time; will be ignored afterward. Requires 'volume_name'.

    volume_type
        The type of the volume. Optionally specified at volume creation time; will be ignored afterward.
        Requires 'volume_name'.
        Valid volume types for AWS can be found here:
        http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html

    iops
        The provisioned IOPS you want to associate with this volume. Optionally specified
        at volume creation time; will be ignored afterward. Requires 'volume_name'.

    encrypted
        Specifies whether the volume should be encrypted. Optionally specified
        at volume creation time; will be ignored afterward. Requires 'volume_name'.

    kms_key_id
        If encrypted is True, this KMS Key ID may be specified to encrypt volume with this key.
        Optionally specified at volume creation time; will be ignored afterward.
        Requires 'volume_name'.
        e.g.: arn:aws:kms:us-east-1:012345678910:key/abcd1234-a123-456a-a12b-a123b4cd56ef

    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.

    unameuresultuucommentuchangesurunningustoppedu=Exactly one of 'volume_name', 'volume_id',  must be provided.uBExactly one of 'instance_name', or 'instance_id' must be provided.uParameter 'device' is required.uregionukeyukeyiduprofileuboto_ec2.get_idRR_u!Instance with Name {0} not found.uboto_ec2.find_instancesR(RWiutag:Nameuboto_ec2.get_all_volumesR|iuIMore than one volume matched volume name {0}, can't continue in state {1}utestuGThe volume with name {0} is set to be created and attached on {1}({2}).uboto_ec2.create_volumet	zone_nametsizetsnapshot_idtvolume_typetiopst	encryptedt
kms_key_idtwait_for_creationu$Error creating volume with name {0}.uboto_ec2.set_volumes_tagsR�u
volume_idsufiltersuNameutagsusuccessu6Error updating requested volume {0} with name {1}. {2}u	volume_idt
volume_idsuVolume {0} do not existu7Volume {0} in {1} cannot attach to instance {2} in {3}.u'The volume {0} is attached on {1}({2}).uKThe volume {0} is set to be detached from {1}({2} and attached on {3}({4}).uboto_ec2.detach_volumeR�twait_for_detachementu%Volume {0} is detached from {1}({2}).uinstance_idudeviceuIThe volume {0} is already attached on instance {1}({2}). Failed to detachu1The volume {0} is set to be attached on {1}({2}).uboto_ec2.attach_volumeR�u u#Volume {0} is attached on {1}({2}).uoldunewu0Error attaching volume {0} to instance {1}({2}).(urunningustoppedN(RR.R/R0R1RRR	RR8R~RReR
tzonetattach_dataR(R�tdevicR5(RR�R�R)R(R�R�R�R�R�R�R�RRRRRtold_dicttnew_dictR�R�R�R�R|R�RCt_rtR�R�((s8/usr/lib/python2.7/site-packages/salt/states/boto_ec2.pytvolume_present s�J

"

		



		



			


	
	


	



	

c	C@setjjj||f�s*td��n|s?td��ni|d6td6dd6igd6gd6d	6}	i|d6|d
6|d6|d6|d
6|d6}
td|
�}|r|jdi�jd�rx2|ddD]}|	d	dj|d�q�Wng}
x2|D]*}||	d	dkr|
j|�qqW|
r/t	ds�i|d
6|
d6|d6|d6|d6|d
6|d6}td|�td|
�}|r�|jdi�jdd�r�x2|ddD]}|	d	dj|d�q�Wng}x2|D]*}||	d	dkr|j|�qqW|r�t|	d<djddj
|	d	d�ddj
|
�ddj
|��|	d<n djddj
|
��|	d<|	d	d|	d	dkr,i|	d	<q,qadjddj
|	d	d�ddj
|
��|	d<i|	d	<d|	d<n2djddj
|	d	d��|	d<i|	d	<|	S(ux
    Ensure an ENI has secondary private ip addresses associated with it

    name
        (String) - State definition name
    network_interface_id
        (String) - The EC2 network interface id, example eni-123456789
    private_ip_addresses
        (List or String) - The secondary private ip address(es) that should be present on the ENI.
    allow_reassignment
        (Boolean) - If true, will reassign a secondary private ip address associated with another
        ENI. If false, state will fail if the secondary private ip address is associated with
        another ENI.
    region
        (string) - Region to connect to.
    key
        (string) - Secret key to be used.
    keyid
        (string) - Access key to be used.
    profile
        (variable) - A dict with region, key and keyid, or a pillar key (string) that contains a
        dict with region, key and keyid.
    uPExactly one of 'network_interface_name', 'network_interface_id' must be provideduCYou must provide the private_ip_addresses to associate with the ENIunameuresultuucommentuoldunewuchangesunetwork_interface_iduregionukeyukeyiduprofileuboto_ec2.get_network_interfaceuprivate_ip_addressesuprivate_ip_addressutestuallow_reassignmentu$boto_ec2.assign_private_ip_addressesuKips on eni: {0}
attempted to add: {1}
could not add the following ips: {2}
u
	- uadded ips: {0}u-ips on eni: {0}
ips that would be added: {1}
uips on eni: {0}N(R.R/R0R1RRR	R�tappendRRR
RR5(RRwR,tprivate_ip_addressestallow_reassignmentRRRRRtget_eni_argsteniteni_pipt
ips_to_addt
private_iptassign_ips_argst
ips_not_added((s8/usr/lib/python2.7/site-packages/salt/states/boto_ec2.pytprivate_ips_present�s|
! 


$ 



"
cC@s�tjjj||f�s*td��n|s?td��nt|t�sZ|g}ni|d6td6dd6igd6gd6d	6}i|d6|d
6|d6|d6|d
6|d6}	td|	�}
d}|
r=|
j
di�j
d�r=xI|
ddD]6}|d	dj|d�|dr|d}qqWng}
x�|D]�}||d	dkrt|
j|�n||krJt|d<dj
|ddj|d	d�ddj|��|d<i|d	<|SqJW|
r�tdspi|d
6|
d6|d6|d6|d
6|d6}td|�td|	�}
|
r�|
j
di�j
dd�r�x2|
ddD]}|d	dj|d�qhWng}x2|D]*}||d	dkr�|j|�q�q�W|r$t|d<dj
ddj|d	d�ddj|
�ddj|��|d<n dj
ddj|
��|d<|d	d|d	dkr�i|d	<q�q�dj
ddj|d	d�ddj|
��|d<i|d	<d|d<n2dj
ddj|d	d��|d<i|d	<|S(u�
    Ensure an ENI does not have secondary private ip addresses associated with it

    name
        (String) - State definition name
    network_interface_id
        (String) - The EC2 network interface id, example eni-123456789
    private_ip_addresses
        (List or String) - The secondary private ip address(es) that should be absent on the ENI.
    region
        (string) - Region to connect to.
    key
        (string) - Secret key to be used.
    keyid
        (string) - Access key to be used.
    profile
        (variable) - A dict with region, key and keyid, or a pillar key (string) that contains a
        dict with region, key and keyid.
    uPExactly one of 'network_interface_name', 'network_interface_id' must be provideduEYou must provide the private_ip_addresses to unassociate with the ENIunameuresultuucommentunewuolduchangesunetwork_interface_iduregionukeyukeyiduprofileuboto_ec2.get_network_interfaceuprivate_ip_addressesuprivate_ip_addressuprimaryulYou cannot unassign the primary private ip address ({0}) on an eni
ips on eni: {1}
attempted to remove: {2}
u
	- utestu&boto_ec2.unassign_private_ip_addressesuQips on eni: {0}
attempted to remove: {1}
could not remove the following ips: {2}
uremoved ips: {0}u/ips on eni: {0}
ips that would be removed: {1}
uips on network interface: {0}N(R.R/R0R1RR2R3RR	RR�R�R
RR5R(RRwR,R�RRRRRR�R�tprimary_private_ipR�t
ips_to_removeR�R�tips_not_removed((s8/usr/lib/python2.7/site-packages/salt/states/boto_ec2.pytprivate_ips_absentes�
!





$ 

 

"
()t__doc__t
__future__RRRtloggingRRtsalt.extRtsalt.ext.six.movesRtsalt.utils.dataR.tsalt.utils.dictupdateR/R7tsalt.exceptionsRRt	getLoggert__name__R
RRRR!RRGR6R9R
RUR^R�R�R�R�R�R�R�(((s8/usr/lib/python2.7/site-packages/salt/states/boto_ec2.pyt<module>4s�	
	8"�		%X'								��}	f	Z	�{

Zerion Mini Shell 1.0