B
    è?F[þ  ã            
   @   s:  d dl Zd dlmZmZ d dlmZ d dlmZ ddddd	d
ddddg
Z	G dd„ de
ƒZedkr6eƒ Zi Ze e¡ ejjed ed jdZedƒ xeD ]Ze ¡  qžW eddedZe e¡Zedƒ e ¡  eejƒZeed  Zeded ef ƒ ej d¡Ze ¡   ¡ dkr.e !ed ¡ nedƒ dS )é    N)ÚStringPropertyÚIntegerProperty)Úpropget)Úsixzm1.smallzm1.largez	m1.xlargez	c1.mediumz	c1.xlargez	m2.xlargez
m2.2xlargez
m2.4xlargezcc1.4xlargezt1.microc               @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )ÚBuyReservationc             C   s8   |  dd ¡s4tddtjjd}tj |tjjd|d< d S )NÚregionz
EC2 Region)ÚnameÚverbose_nameÚchoices)r
   )Úgetr   ÚbotoÚec2Zregionsr   )ÚselfÚparamsÚprop© r   ú6lib/python3.7/site-packages/boto/ec2/buyreservation.pyÚ
get_region"   s    zBuyReservation.get_regionc             C   s,   |  dd ¡s(tddtd}t  |¡|d< d S )NÚinstance_typezInstance Type)r   r	   r
   )r   r   ÚInstanceTypesr   )r   r   r   r   r   r   Úget_instance_type(   s    z BuyReservation.get_instance_typec             C   s*   |  dd ¡s&tddd}t  |¡|d< d S )NÚquantityzNumber of Instances)r   r	   )r   r   r   )r   r   r   r   r   r   Úget_quantity.   s    zBuyReservation.get_quantityc             C   s0   |  dd ¡s,tdd| jjd}t  |¡|d< d S )NÚzonezEC2 Availability Zone)r   r	   r
   )r   r   r   Zget_all_zonesr   )r   r   r   r   r   r   Úget_zone3   s    zBuyReservation.get_zonec             C   s:   |   |¡ |d  ¡ | _|  |¡ |  |¡ |  |¡ d S )Nr   )r   Zconnectr   r   r   r   )r   r   r   r   r   r   9   s
    


zBuyReservation.getN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   r   r   r       s
   r   Ú__main__r   r   )r   Zavailability_zonez;
The following Reserved Instances Offerings are available:
ÚofferingZOffering)r   r	   r
   z
You have chosen this offering:r   zL!!! You are about to purchase %d of these offerings for a total of $%.2f !!!z5Are you sure you want to do this?  If so, enter YES: ZyeszPurchase cancelled)"Zboto.ec2r   Zboto.sdb.db.propertyr   r   Zboto.manager   Zboto.compatr   r   Úobjectr   r   Úobjr   r   r   Z$get_all_reserved_instances_offeringsr   Z	offeringsÚprintr   Zdescriber   ÚfloatZfixed_priceZ
unit_priceZtotal_priceZmovesÚinputZanswerÚstripÚlowerZpurchaser   r   r   r   Ú<module>   s:    




