B
    ?F[7*                 @   sx   d dl mZ d dlmZ d dlmZ d dlZd dl	Z	G dd de
ZG dd de
ZG d	d
 d
e
ZG dd de
ZdS )    )ListElement)BlockDeviceMapping)	ResultSetNc               @   s.   e Zd Zd
ddZdd Zdd Zdd	 ZdS )EbsNc             C   s   || _ || _|| _d S )N)
connectionsnapshot_idvolume_size)selfr   r   r    r
   >lib/python3.7/site-packages/boto/ec2/autoscale/launchconfig.py__init__"   s    zEbs.__init__c             C   s   d| j | jf S )NzEbs(%s, %s))r   r   )r	   r
   r
   r   __repr__'   s    zEbs.__repr__c             C   s   d S )Nr
   )r	   nameattrsr   r
   r
   r   startElement*   s    zEbs.startElementc             C   s"   |dkr|| _ n|dkr|| _d S )NZ
SnapshotIdZ
VolumeSize)r   r   )r	   r   valuer   r
   r
   r   
endElement-   s    zEbs.endElement)NNN)__name__
__module____qualname__r   r   r   r   r
   r
   r
   r   r   !   s   
r   c               @   s.   e Zd ZdddZdd Zdd Zd	d
 ZdS )InstanceMonitoringNfalsec             C   s   || _ || _d S )N)r   enabled)r	   r   r   r
   r
   r   r   5   s    zInstanceMonitoring.__init__c             C   s
   d| j  S )NzInstanceMonitoring(%s))r   )r	   r
   r
   r   r   9   s    zInstanceMonitoring.__repr__c             C   s   d S )Nr
   )r	   r   r   r   r
   r
   r   r   <   s    zInstanceMonitoring.startElementc             C   s   |dkr|| _ d S )NZEnabled)r   )r	   r   r   r   r
   r
   r   r   ?   s    zInstanceMonitoring.endElement)Nr   )r   r   r   r   r   r   r   r
   r
   r
   r   r   4   s   
r   c               @   s.   e Zd Zd
ddZdd Zdd Zdd	 ZdS )r   Nc             C   s"   || _ || _|| _|| _|| _d S )N)r   device_namevirtual_nameebs	no_device)r	   r   r   r   r   r   r
   r
   r   r   H   s
    zBlockDeviceMapping.__init__c             C   s   d| j | jf S )NzBlockDeviceMapping(%s, %s))r   r   )r	   r
   r
   r   r   P   s    zBlockDeviceMapping.__repr__c             C   s   |dkrt | | _| jS d S )Nr   )r   r   )r	   r   r   r   r
   r
   r   r   T   s    
zBlockDeviceMapping.startElementc             C   s6   |dkr|| _ n"|dkr || _n|dkr2t|| _d S )NZ
DeviceNameZVirtualNameZNoDevice)r   r   boolr   )r	   r   r   r   r
   r
   r   r   Y   s    zBlockDeviceMapping.endElement)NNNNN)r   r   r   r   r   r   r   r
   r
   r
   r   r   G   s
    
r   c               @   s6   e Zd ZdddZdd Zd	d
 Zdd Zdd ZdS )LaunchConfigurationNm1.smallFTc             C   s   || _ || _|| _|
| _|| _|p$g }t|| _|| _|	| _d| _	|| _
|| _d| _	|| _|| _|| _d| _|| _|| _|| _|| _|| _|| _|| _|pg }t|| _|dk	r|j| _dS )al	  
        A launch configuration.

        :type name: str
        :param name: Name of the launch configuration to create.

        :type image_id: str
        :param image_id: Unique ID of the Amazon Machine Image (AMI) which was
            assigned during registration.

        :type key_name: str
        :param key_name: The name of the EC2 key pair.

        :type security_groups: list
        :param security_groups: Names or security group id's of the security
            groups with which to associate the EC2 instances or VPC instances,
            respectively.

        :type user_data: str
        :param user_data: The user data available to launched EC2 instances.

        :type instance_type: str
        :param instance_type: The instance type

        :type kernel_id: str
        :param kernel_id: Kernel id for instance

        :type ramdisk_id: str
        :param ramdisk_id: RAM disk id for instance

        :type block_device_mappings: list
        :param block_device_mappings: Specifies how block devices are exposed
            for instances

        :type instance_monitoring: bool
        :param instance_monitoring: Whether instances in group are launched
            with detailed monitoring.

        :type spot_price: float
        :param spot_price: The spot price you are bidding.  Only applies
            if you are building an autoscaling group with spot instances.

        :type instance_profile_name: string
        :param instance_profile_name: The name or the Amazon Resource
            Name (ARN) of the instance profile associated with the IAM
            role for the instance.

        :type ebs_optimized: bool
        :param ebs_optimized: Specifies whether the instance is optimized
            for EBS I/O (true) or not (false).


        :type associate_public_ip_address: bool
        :param associate_public_ip_address: Used for Auto Scaling groups that launch instances into an Amazon Virtual Private Cloud.
            Specifies whether to assign a public IP address to each instance launched in a Amazon VPC.

        :type classic_link_vpc_id: str
        :param classic_link_vpc_id: ID of ClassicLink enabled VPC.

        :type classic_link_vpc_security_groups: list
        :param classic_link_vpc_security_groups: Security group
            id's of the security groups with which to associate the
            ClassicLink VPC instances.
        N)r   r   instance_typeblock_device_mappingskey_namer   security_groupsimage_id
ramdisk_idcreated_time	kernel_id	user_datainstance_monitoring
spot_priceinstance_profile_namelaunch_configuration_arnebs_optimizedassociate_public_ip_addressvolume_typedelete_on_terminationiopsuse_block_device_typesclassic_link_vpc_id classic_link_vpc_security_groups)r	   r   r   r$   r"   r#   r(   r    r'   r%   r!   r)   r*   r+   r-   r.   r/   r0   r1   r2   r3   r4   Z
sec_groupsZclassic_link_vpc_sec_groupsr
   r
   r   r   c   s8    J

zLaunchConfiguration.__init__c             C   s
   d| j  S )NzLaunchConfiguration:%s)r   )r	   r
   r
   r   r      s    zLaunchConfiguration.__repr__c             C   sf   |dkr| j S |dkr| jS |dkrJ| jr4t | _ntdtfg| _| jS |dkrbt| | _| jS d S )NZSecurityGroupsZClassicLinkVPCSecurityGroupsZBlockDeviceMappingsmemberr   )	r#   r4   r2   BDMr!   r   r   r   r)   )r	   r   r   r   r
   r
   r   r      s    

z LaunchConfiguration.startElementc             C   s  |dkr|| _ n|dkr$|| _n|dkr6|| _n|dkrH|| _np|dkrbtj|| _nV|dkrt|| _nD|dkr|| _	n2|dkryt
|| _W n tk
r   || _Y nX n|d	kr|| _n|d
kr|| _n|dkrt|| _n|dkr|| _n|dkr&| dkrdnd| _n|dkrJ| dkrBdnd| _nn|dkr\|| _n\|dkr| dkr|d| _nd| _n4|dkrt|| _n|dkr|| _nt| || d S )NZInstanceTypeZLaunchConfigurationNameZKeyNameZImageIdZCreatedTimeZKernelIdZ	RamdiskIdZUserDataZLaunchConfigurationARNr   Z	SpotPriceZIamInstanceProfileZEbsOptimizedtrueTFZAssociatePublicIpAddressZ
VolumeTypeZDeleteOnTerminationZIopsZClassicLinkVPCId)r    r   r"   r$   botoZutilsZparse_tsr&   r'   r%   base64Z	b64decoder(   	TypeErrorr,   r)   floatr*   r+   lowerr-   r.   r/   r0   intr1   r3   setattr)r	   r   r   r   r
   r
   r   r      sT    












zLaunchConfiguration.endElementc             C   s   | j | jS )z# Delete this launch configuration. )r   Zdelete_launch_configurationr   )r	   r
   r
   r   delete  s    zLaunchConfiguration.delete)NNNNNNr   NNNFNNFNNTNFNN)r   r   r   r   r   r   r   r?   r
   r
   r
   r   r   b   s            
`.r   )Zboto.ec2.elb.listelementr   Zboto.ec2.blockdevicemappingr   r6   Zboto.resultsetr   Z
boto.utilsr8   r9   objectr   r   r   r
   r
   r
   r   <module>   s   