�
��Xc@s�ddlZddlZddlmZmZddlmZddlm Z m
Z
mZddlm
Z
de
fd��YZdS(i����N(tArgtMutuallyExclusiveArgList(t
ArgumentError(tec2_block_device_mappingt
flexible_boolt
vpc_interface(t
EC2RequesttRunInstancesc"Bs�eZdZeddddd�edddd dd
ddd
d�dd�edddddgd
d�dd�edddddddd�eeddddd
d�dd�edddd
d�dd�edd dd!d
d�dd"��ed#dd$d%d�dd(�ed)d*dd+dd,�ed-d.dd/dd0�ed1dd2dd3dd4�ed5dd6dd7dd8�ed9d:dd;dd<ddd=edgdd>�ed?d@ddAddBdCdDddE�edFddGddBdCdDddH�edIddJd%d�ddM�edNddOddPddQ�edRddSd%d�ddU�edVddWddXddY�edZd[dd\d
d�dd]�ed^d=ed
d�dd_�ed`ddad
d�ddb�eedcddddaddd
d�dde�edfdgddhd=ed
d�ddi��edjdkddlddmddd=e ddn�edodpddqd
d�ddr�edsddtddBdCdDddu�gZ
dvdwdxdydzd{d|d}gZd~�Zd�Z
d��ZRS(�s#Launch instances of a machine imagetImageIdtmetavartIMAGEthelps)ID of the image to instantiate (required)s-ns--instance-counttdesttcounts MIN[-MAX]tdefaultt1troute_tosGnumber of instances to launch. If this number of
instances cannot be launched, no instances will launch.
If specified as a range (min-max), the server will
attempt to launch the maximum number, but no fewer
than the minimum number.s-gs--grouptactiontappends2security group(s) in which to launch the instancess-ks--keytKeyNametKEYPAIRsname of the key pair to uses-ds--user-datatDATAsXuser data to make available to instances in this
reservations--user-data-forcesdsame as -d/--user-data, but without checking if a
file by that name exists firsts-fs--user-data-filetFILEsdfile containing user data to make available to the
instances in this reservations--addressingtAddressingTypetchoicestpublictprivates�[Eucalyptus only, non-VPC only]
addressing scheme to launch the instance with. Use "private"
to run an instance with no public address.s-ts--instance-typetInstanceTypestype of instance to launchs-zs--availability-zonetZONEsPlacement.AvailabilityZones--kerneltKernelIdtKERNELs/ID of the kernel to launch the instance(s) withs --ramdiskt RamdiskIdtRAMDISKs0ID of the ramdisk to launch the instance(s) withs-bs--block-device-mappings
DEVICE=MAPPEDtBlockDeviceMappingttypes�define a block device mapping for the instances, in the
form DEVICE=MAPPED, where "MAPPED" is "none", "ephemeral(0-3)",
or
"[SNAP-ID]:[GiB]:[true|false]:[standard|VOLTYPE[:IOPS]]"s-ms --monitorsMonitoring.Enabledtstore_consttconstttrues.enable detailed monitoring for the instance(s)s--disable-api-terminationtDisableApiTerminations2prevent API users from terminating the instance(s)s&--instance-initiated-shutdown-behaviort!InstanceInitiatedShutdownBehaviortstopt terminatesJwhether to "stop" (default) or terminate EBS instances when they shut downs--placement-groupsPlacement.GroupNametPLGROUPs8name of a placement group to launch
intos --tenancysPlacement.Tenancyt dedicatedsG[VPC only]
"dedicated" to run on single-tenant hardwares--client-tokentClientTokentTOKENs/unique identifier to ensure request idempotencys-ss--subnettSUBNETsO[VPC only] subnet to create the instance's network
interface ins--associate-public-ip-addresssh[VPC only] whether or not to assign a
public address to the instance's network interfaces--private-ip-addresstADDRESSsb[VPC only] assign a specific primary private IP address
to an instance's interfaces--secondary-addresss--secondary-private-ip-addresss�[VPC only] assign a specific secondary private IP
address to an instance's network interface. Use this
option multiple times to add additional addresses.s--secondary-counts$--secondary-private-ip-address-counttCOUNTs�[VPC only] automatically
assign a specific number of secondary private IP addresses
to an instance's network interfaces-as--network-interfacetNetworkInterfacet INTERFACEsn[VPC only] add a network interface to the new instance. If the interface already exists, supply its ID and a numeric index for it, separated by ":", in the form "eni-NNNNNNNN:INDEX". To create a new interface, supply a numeric index and subnet ID for it, along with (in order) an optional description, a primary private IP address, a list of security group IDs to associate with the interface, whether to delete the interface upon instance termination ("true" or "false"), a number of secondary private IP addresses to create automatically, and a list of secondary private IP addresses to assign to the interface, separated by ":", in the form ":INDEX:SUBNET:[DESCRIPTION]:[PRIV_IP]:[GROUP1,GROUP2,...]:[true|false]:[SEC_IP_COUNT|:SEC_IP1,SEC_IP2,...]". You cannot specify both of the latter two. This option may be used multiple times. Each adds another network interface.s-ps
--iam-profiletIPROFILEs]name or ARN of the IAM instance profile to associate
with the new instance(s)s--ebs-optimizedtEbsOptimizeds(optimize the new instance(s) for EBS I/OtreservationSettinstancesSettgroupSetttagSettblockDeviceMappingtproductCodestnetworkInterfaceSettprivateIpAddressesSetcCs@tj|�|jjd�rgtjj|jd�rGtd��q�tj |jd�|j
d<n|jjd�r�tj |jd�|j
d<nM|jjd�r�t|jd��#}tj |j��|j
d<WdQXn|jjd�dkr<|jjd�}|r<|jjd|�||j
d<q<ndS( Nt user_datas�argument -d/--user-data: to pass the contents of a file as user data, use -f/--user-data-file. To pass the literal value '{0}' as user data even though it matches the name of a file, use --user-data-force.tUserDatatuser_data_forcetuser_data_fileRsec2-default-keypairsusing default key pair '%s'(Rt configuretargstgettostpathtisfileRtbase64t b64encodetparamstopentreadtNonetconfigtget_region_optiontlogtinfo(tselfR@tdefault_key_name((sG/usr/lib/python2.7/site-packages/euca2ools/commands/ec2/runinstances.pyRA�s(
cCs{|jdjd�}t|�dkr}y2t|d�|jd<t|d�|jd<Wq�tk
rytd��q�Xnst|�dkr�y2t|d�|jd<t|d�|jd<Wq�tk
r�td ��q�Xntd
��|jddks|jddkr%td��n|jd|jdkr~|jjd�|jj i|jdd6|jdd6�n|jj
d
�}|r�|jd�r�||jd<q�||jd<n|jj
d�s|jj
d�s|jj
d�dk r�i}xT|jdD]E}|jd�s9td��n|j
dg�|dj|�qW|jj
d�dk r�|jd|d<n|jj
d�r�i|jdd6dd6g|d<n|jj
d�r*g|jdD]}i|d6^q�}|j
d�sg|d<n|dj|�n|jj
d�rV|jd}||d <n|jj
d�r||jd|d!<n|r�d|d"<|jj
d�s�g|jd<n|jdj|�n|jjd#j|��n�x�|jdD]�}|jd�r=|jj
d�s&g|jd<n|jdj|�q�|jj
d$�s_g|jd$<n|jd$j|�q�WdS(%NR
t-iitMinCounttMaxCounts?argument -n/--instance-count: instance count must be an integerisXargument -n/--instance-count: instance count range must be must be comprised of integerssAargument -n/--instance-count: value must have format "1" or "1-2"s=argument -n/--instance-count: instance count must be positivesMinCount > MaxCount; swappingtiam_profilesarn:sIamInstanceProfile.ArnsIamInstanceProfile.NametsubnetR1tassociate_public_ip_addresstgroupssg-sBargument -g/--group: groups must be specified by ID when using VPCtSecurityGroupIdtAssociatePublicIpAddresstprivate_ip_addresstPrivateIpAddressR%tPrimarytPrivateIpAddressestsecondary_addresstsecondary_counttSecondaryPrivateIpAddressCounttSubnetIdtDeviceIndexs-built network interface from CLI options: {0}t
SecurityGroup(RBtsplittlentintRIt
ValueErrorRROtdebugtupdateRCt
startswithRLt
setdefaultRtextendtformat(RQtcountstiprofilet cli_ifaceRYtaddrtsec_ipstsec_ip_count((sG/usr/lib/python2.7/site-packages/euca2ools/commands/ec2/runinstances.pyt
preprocess�s�
&$$
cCs|j|�dS(N(tprint_reservation(RQtresult((sG/usr/lib/python2.7/site-packages/euca2ools/commands/ec2/runinstances.pytprint_result
sN(RR(sstopR)(RR+(t__name__t
__module__tDESCRIPTIONRRLRRRRhRtARGSt LIST_TAGSRARvRy(((sG/usr/lib/python2.7/site-packages/euca2ools/commands/ec2/runinstances.pyR%s� V(RGtos.pathRDtrequestbuilderRRtrequestbuilder.exceptionsRteuca2ools.commands.argtypesRRRteuca2ools.commands.ec2RR(((sG/usr/lib/python2.7/site-packages/euca2ools/commands/ec2/runinstances.pyt<module>s |