ó ¡ôXc@s†ddlZddlmZddlZddlmZmZmZddlm Z ddl Z ddl Z defd„ƒYZ dS(iÿÿÿÿN(tArg(t IAMRequestt AS_ACCOUNTtarg_user(tGetUsertCreateAccessKeyc Bs’eZdZeddƒeddddddddƒed d dddd ƒed d ddddddƒegZd„Zd„Z d„Z RS(s"Create a new access key for a userthelpsLuser the new key will belong to (default: current user)s-ws--write-configtactiont store_truetroute_tos—output access keys and region information in the form of a euca2ools.ini(5) configuration file instead of by themselvess-ds--domains…the DNS domain to use for region information in configuration file output (default: based on IAM URL)s-ls--set-default-users®set this user as the default user for the region in euca2ools.ini(5) configuration file output. This option is only useful when used with -w.c Cs3|jjdƒr/tjjjj|jjƒ}|jjdƒs¿|j j dƒd}t d„|j dƒDƒƒrœdj |jjƒ}t j|IJq¿|j j ddƒd|jd;st.swarning: IAM URL {0} refers to a specific IP; for a complete configuration file supply the region's DNS domain with -d/--domainis region {0}s{scheme}://{service}.{domain}/tschemetservices{0}-urls verify-tlss verify-sslt AccessKeytUserNametroots{0}:{1}suser {0}skey-idt AccessKeyIds secret-keytSecretAccessKeys account-idtset_default_usertusert configfile(targstgettsixtmovesturllibtparseturlparseRtendpointtnetloctsplittalltformattsyststderrt configparsertSafeConfigParsertconfigtregiont add_sectiontsortedt euca2oolstutiltgenerate_service_namesRtsettget_region_optiontNonetget_user_account_id( tselftresulttparsedtdnsnametmsgRt region_nametregion_sectionRturlt user_namet account_idt user_section((sJ/usr/lib/python2.7/site-packages/euca2ools/commands/iam/createaccesskey.pyt postprocess6sV#"*           cCsG|jjdƒr)|djtjƒn|ddGH|ddGHdS(NR RRRR(RRtwriteR'tstdout(R6R7((sJ/usr/lib/python2.7/site-packages/euca2ools/commands/iam/createaccesskey.pyt print_resultqs cCs®tj|d|jdd|jjdƒƒ}y|jƒ}WnNtjjk rŽ}|jdkrˆdj |j ƒ}t j |IJdS‚nX|dd}|jdƒdS( NRtDelegateAccounti“s,warning: unable to retrieve account ID ({0})tUsertArnR i(Rt from_othertparamsRtmainR/t exceptionstAWSErrort status_codeR&tmessageR'R(R4R$(R6treqtresponseterrR:tarn((sJ/usr/lib/python2.7/site-packages/euca2ools/commands/iam/createaccesskey.pyR5xs  N( t__name__t __module__t DESCRIPTIONRRR4RtARGSRARDR5(((sJ/usr/lib/python2.7/site-packages/euca2ools/commands/iam/createaccesskey.pyR%s  ; (R'trequestbuilderRRteuca2ools.commands.iamRRRteuca2ools.commands.iam.getuserRteuca2ools.exceptionsR/teuca2ools.utilR(((sJ/usr/lib/python2.7/site-packages/euca2ools/commands/iam/createaccesskey.pyts