o .&aO@sdZddlmZdZdZdZddZdd Zd d Zd efd efdefgZ ddZ ddZ GdddeZ GdddeZ GdddeZGdddeZdS)a= This customization adds two new parameters to the ``ec2 run-instance`` command. The first, ``--secondary-private-ip-addresses`` allows a list of IP addresses within the specified subnet to be associated with the new instance. The second, ``--secondary-ip-address-count`` allows you to specify how many additional IP addresses you want but the actual address will be assigned for you. This functionality (and much more) is also available using the ``--network-interfaces`` complex argument. This just makes two of the most commonly used features available more easily. )CustomArgumenta$[EC2-VPC] A secondary private IP address for the network interface or instance. You can specify this multiple times to assign multiple secondary IP addresses. If you want additional private IP addresses but do not need a specific address, use the --secondary-private-ip-address-count option.z^[EC2-VPC] The number of secondary IP addresses to assign to the network interface or instance.zY[EC2-VPC] If specified a public IP address will be assigned to the new instance in a VPC.cKs\tdtd}||d<tdtd}||d<tdtddd}||d<tdtd dd}||d<dS) Nzsecondary-private-ip-addresses)name help_textz"secondary-private-ip-address-countzassociate-public-ip-address store_trueassociate_public_ip)rraction group_namezno-associate-public-ip-address store_false)#SecondaryPrivateIpAddressesArgument#SECONDARY_PRIVATE_IP_ADDRESSES_DOCS&SecondaryPrivateIpAddressCountArgument'SECONDARY_PRIVATE_IP_ADDRESS_COUNT_DOCS AssociatePublicIpAddressArgument ASSOCIATE_PUBLIC_IP_ADDRESS_DOCS"NoAssociatePublicIpAddressArgument)argument_tablekwargsargrH/usr/lib/python3/dist-packages/awscli/customizations/ec2/runinstances.py _add_params.s, rcKs6t|}|drdD]}||rd}t|q dSdS)Nnetwork_interfaces)secondary_private_ip_addresses"secondary_private_ip_address_countassociate_public_ip_addresszXMixing the --network-interfaces option with the simple, scalar options is not supported.)vars ValueError) parsed_argsrarg_dictkeymsgrrr _check_argsCsr!c sgd}d|vrb|ddtfdd|Drdd|vr&|dd<|d=d|vr3|dd<|d=d |vrF|d d d }|gd <|d =d |vrS|d d <|d =d|vrf|dd<|d=dSdSdSdS)N)PrivateIpAddressesSecondaryPrivateIpAddressCountAssociatePublicIpAddressNetworkInterfacesrc3s|]}|vVqdSNr).0param interfacerr fsz_fix_args..SubnetIdSecurityGroupIdsGroupsPrivateIpAddressTr/Primaryr"Ipv6AddressCount Ipv6Addresses)any)paramsrnetwork_interface_paramsip_addrrr)r _fix_argsSs2        r8z)building-argument-table.ec2.run-instancesz'operation-args-parsed.ec2.run-instancesz'before-parameter-build.ec2.RunInstancescCstD] \}}|||qdSr&)EVENTSregister) event_handlereventhandlerrrrregister_runinstancess r>cCsZd|vr ddig|d<|dkr#d|ddvr!||ddd<dSdS||dd|<dS)Nr% DeviceIndexrr"r)r5rvaluerrr_build_network_interfacessrAc@eZdZdddZddZdS)r NcCs|j|j|j|jdddS)N*)destdefaultnargs) add_argumentcli_namepy_name_defaultselfparserrHrrr add_to_parser  z1SecondaryPrivateIpAddressesArgument.add_to_parsercCs&|rdd|D}t|d|dSdS)NcSsg|]}|ddqS)Fr0r)r'vrrr szESecondaryPrivateIpAddressesArgument.add_to_params..r"rArL parametersr@rrr add_to_paramss z1SecondaryPrivateIpAddressesArgument.add_to_paramsr&__name__ __module__ __qualname__rNrUrrrrr   r c@rB)r NcCs|j|j|j|jtddS)N)rDrEtype)rGrHrIrJintrKrrrrNrOz4SecondaryPrivateIpAddressCountArgument.add_to_parsercCs|r t|d|dSdS)Nr#rRrSrrrrUs z4SecondaryPrivateIpAddressCountArgument.add_to_paramsr&rVrrrrr rZr c@eZdZddZdS)rcC|dur t|d|dSdS)NTr$rRrSrrrrU z.AssociatePublicIpAddressArgument.add_to_paramsNrWrXrYrUrrrrr rc@r])rcCr^)NFr$rRrSrrrrUr_z0NoAssociatePublicIpAddressArgument.add_to_paramsNr`rrrrrrarN)__doc__awscli.argumentsrr r rrr!r8r9r>rAr r rrrrrrs*  (