����JFIFXX�����    $.' ",#(7),01444'9=82<.342  2!!22222222222222222222222222222222222222222222222222����"��4�� ���,�PG"Z_�4�˷����kjز�Z�,F+��_z�,�© �����zh6�٨�ic�fu���#ډb���_�N�?��wQ���5-�~�I���8����TK<5o�Iv-�����k�_U_�����~b�M��d����Ӝ�U�Hh��?]��E�w��Q���k�{��_}qFW7HTՑ��Y��F�?_�'ϔ��_�Ջt��=||I ��6�έ"�����D���/[�k�9���Y�8ds|\���Ҿp6�Ҵ���]��.����6�z<�v��@]�i%��$j��~�g��J>��no����pM[me�i$[����s�o�ᘨ�˸ nɜG-�ĨU�ycP�3.DB�li�;��hj���x7Z^�N�h������N3u{�:j�x�힞��#M&��jL P@_���� P��&��o8������9�����@Sz6�t7#O�ߋ �s}Yf�T���lmr����Z)'N��k�۞p����w\�Tȯ?�8`�O��i{wﭹW�[�r�� ��Q4F�׊���3m&L�=��h3����z~��#�\�l :�F,j@�� ʱ�wQT����8�"kJO���6�֚l����}���R�>ډK���]��y����&����p�}b��;N�1�m�r$�|��7�>e�@B�TM*-iH��g�D�)� E�m�|�ؘbҗ�a��Ҿ����t4���o���G��*oCN�rP���Q��@z,|?W[0�����:�n,jWiE��W��$~/�hp\��?��{(�0���+�Y8rΟ�+����>S-S����VN;�}�s?.����� w�9��˟<���Mq4�Wv'��{)0�1mB��V����W[�����8�/<� �%���wT^�5���b��)iM� pg�N�&ݝ��VO~�q���u���9� ����!��J27����$O-���! �:�%H��� ـ����y�ΠM=t{!S�� oK8������t<����è:a������[�����ա�H���~��w��Qz`�po�^ ����Q��n� �,uu�C�$ ^���,������8�#��:�6��e�|~���!�3�3.�\0��q��o�4`.|� ����y�Q�`~;�d�ׯ,��O�Zw�������`73�v�܋�<���Ȏ�� ـ4k��5�K�a�u�=9Yd��$>x�A�&�� j0� ���vF��� Y�|�y��� ~�6�@c��1vOp�Ig����4��l�OD���L����� R���c���j�_�uX6��3?nk��Wy�f;^*B� ��@�~a�`��Eu������+���6�L��.ü>��}y���}_�O�6�͐�:�YrG�X��kG�����l^w���~㒶sy��Iu�!� W ��X��N�7BV��O��!X�2����wvG�R�f�T#�����t�/?���%8�^�W�aT��G�cL�M���I��(J����1~�8�?aT ���]����AS�E��(��*E}� 2��#I/�׍qz��^t�̔���b�Yz4x���t�){ OH��+(E��A&�N�������XT��o��"�XC��'���)}�J�z�p� ��~5�}�^����+�6����w��c��Q�|Lp�d�H��}�(�.|����k��c4^�"�����Z?ȕ ��a<�L�!039C� �Eu�C�F�Ew�ç ;�n?�*o���B�8�bʝ���'#Rqf���M}7����]����s2tcS{�\icTx;�\��7K���P���ʇ Z O-��~��c>"��?�������P��E��O�8��@�8��G��Q�g�a�Վ���󁶠�䧘��_%#r�>�1�z�a��eb��qcPѵ��n���#L��� =��׀t� L�7�`��V���A{�C:�g���e@�w1 Xp3�c3�ġ����p��M"'-�@n4���fG��B3�DJ�8[Jo�ߐ���gK)ƛ��$���� ���8�3�����+���� �����6�ʻ���� ���S�kI�*KZlT _`���?��K����QK�d����B`�s}�>���`��*�>��,*@J�d�oF*����弝��O}�k��s��]��y�ߘ��c1G�V���<=�7��7����6�q�PT��tXԀ�!9*4�4Tހ3XΛex�46���Y��D ����� �BdemDa����\�_l,��G�/���֌7���Y�](�xTt^%�GE�����4�}bT���ڹ�����;Y)���B�Q��u��>J/J �⮶.�XԄ��j�ݳ�+E��d ��r�5�_D�1 ��o�� �B�x�΢�#���<��W�����8���R6�@g�M�.��� dr�D��>(otU��@x=��~v���2� ӣ�d�oBd��3�eO�6�㣷�����ݜ6��6Y��Qz`��S��{���\P�~z m5{J/L��1������<�e�ͅPu�b�]�ϔ���'������f�b� Zpw��c`"��i���BD@:)ִ�:�]��hv�E�w���T�l��P���"Ju�}��وV J��G6��. J/�Qgl߭�e�����@�z�Zev2u�)]կ�����7x���s�M�-<ɯ�c��r�v�����@��$�ޮ}lk���a���'����>x��O\�ZFu>�����ck#��&:��`�$�ai�>2Δ����l���oF[h��lE�ܺ�Πk:)���`�� $[6�����9�����kOw�\|���8}������ބ:��񶐕��I�A1/�=�2[�,�!��.}gN#�u����b��� ~��݊��}34q����d�E��Lc��$��"�[q�U�硬g^��%B �z���r�pJ�ru%v\h1Y�ne`ǥ:g���pQM~�^�Xi� ��`S�:V29.�P���V�?B�k�� AEvw%�_�9C�Q����wKekPؠ�\�;Io d�{ ߞo�c1eP����\� `����E=���@K<�Y���eڼ�J���w����{av�F�'�M�@/J��+9p���|]�����Iw &`��8���&M�hg��[�{��Xj��%��Ӓ�$��(����ʹN���<>�I���RY���K2�NPlL�ɀ)��&e����B+ь����( � �JTx���_?EZ� }@ 6�U���뙢ط�z��dWI�n` D����噥�[��uV��"�G&Ú����2g�}&m��?ċ�"����Om#��������� ��{�ON��"S�X��Ne��ysQ���@Fn��Vg���dX�~nj�]J�<�K]:��FW��b�������62�=��5f����JKw��bf�X�55��~J �%^����:�-�QIE��P��v�nZum� z � ~ə ���� ���ة����;�f��\v���g�8�1��f24;�V���ǔ�)����9���1\��c��v�/'Ƞ�w�������$�4�R-��t���� e�6�/�ġ �̕Ecy�J���u�B���<�W�ַ~�w[B1L۲�-JS΂�{���΃������A��20�c#��@ 0!1@AP"#2Q`$3V�%45a6�FRUq��� ����^7ׅ,$n�������+��F�`��2X'��0vM��p�L=������5��8������u�p~���.�`r�����\���O��,ư�0oS ��_�M�����l���4�kv\JSd���x���SW�<��Ae�IX����������$I���w�:S���y���›R��9�Q[���,�5�;�@]�%���u�@ *ro�lbI �� ��+���%m:�͇ZV�����u�̉����θau<�fc�.����{�4Ա� �Q����*�Sm��8\ujqs]{kN���)qO�y�_*dJ�b�7���yQqI&9�ԌK!�M}�R�;������S�T���1���i[U�ɵz�]��U)V�S6���3$K{�ߊ<�(� E]Զ[ǼENg�����'�\?#)Dkf��J���o��v���'�%ƞ�&K�u�!��b�35LX�Ϸ��63$K�a�;�9>,R��W��3�3� d�JeTYE.Mϧ��-�o�j3+y��y^�c�������VO�9NV\nd�1 ��!͕_)a�v;����թ�M�lWR1��)El��P;��yوÏ�u 3�k�5Pr6<�⒲l�!˞*��u־�n�!�l:����UNW ��%��Chx8vL'��X�@��*��)���̮��ˍ��� ���D-M�+J�U�kvK����+�x8��cY������?�Ԡ��~3mo��|�u@[XeY�C�\Kp�x8�oC�C�&����N�~3-H���� ��MX�s�u<`���~"WL��$8ξ��3���a�)|:@�m�\���^�`�@ҷ)�5p+��6���p�%i)P M���ngc�����#0Aruz���RL+xSS?���ʮ}()#�t��mˇ!��0}}y����<�e� �-ή�Ԩ��X������ MF���ԙ~l L.3���}�V뽺�v�����멬��Nl�)�2����^�Iq��a��M��qG��T�����c3#������3U�Ǎ���}��לS�|qa��ڃ�+���-��2�f����/��bz��ڐ�� �ݼ[2�ç����k�X�2�* �Z�d���J�G����M*9W���s{��w���T��x��y,�in�O�v��]���n����P�$�JB@=4�OTI�n��e�22a\����q�d���%�$��(���:���: /*�K[PR�fr\nڙdN���F�n�$�4�[�� U�zƶ����� �mʋ���,�ao�u 3�z� �x��Kn����\[��VFmbE;�_U��&V�Gg�]L�۪&#n%�$ɯ�dG���D�TI=�%+AB�Ru#��b4�1�»x�cs�YzڙJG��f��Il��d�eF'T� iA��T���uC�$����Y��H?����[!G`}���ͪ� �纤Hv\������j�Ex�K���!���OiƸ�Yj�+u-<���'q����uN�*�r\��+�]���<�wOZ.fp�ێ��,-*)V?j-kÊ#�`�r��dV����(�ݽBk�����G�ƛk�QmUڗe��Z���f}|����8�8��a���i��3'J�����~G_�^���d�8w������ R�`(�~�.��u���l�s+g�bv���W���lGc}��u���afE~1�Ue������Z�0�8�=e�� f@/�jqEKQQ�J��oN��J���W5~M>$6�Lt�;$ʳ{���^��6�{����v6���ķܰg�V�cnn �~z�x�«�,2�u�?cE+Ș�H؎�%�Za�)���X>uW�Tz�Nyo����s���FQƤ��$��*�&�LLXL)�1�" L��eO��ɟ�9=���:t��Z���c��Ž���Y?�ӭV�wv�~,Y��r�ۗ�|�y��GaF�����C�����.�+� ���v1���fήJ�����]�S��T��B��n5sW}y�$��~z�'�c ��8 ��� ,! �p��VN�S��N�N�q��y8z˱�A��4��*��'������2n<�s���^ǧ˭P�Jޮɏ�U�G�L�J�*#��<�V��t7�8����TĜ>��i}K%,���)[��z�21z ?�N�i�n1?T�I�R#��m-�����������������1����lA�`��fT5+��ܐ�c�q՝��ʐ��,���3�f2U�եmab��#ŠdQ�y>\��)�SLY����w#��.���ʑ�f��� ,"+�w�~�N�'�c�O�3F�������N<���)j��&��,-� �љ���֊�_�zS���TǦ����w�>��?�������n��U仆�V���e�����0���$�C�d���rP �m�׈e�Xm�Vu� �L��.�bֹ��� �[Դaզ���*��\y�8�Է:�Ez\�0�Kq�C b��̘��cө���Q��=0Y��s�N��S.���3.���O�o:���#���v7�[#߫ ��5�܎�L���Er4���9n��COWlG�^��0k�%<���ZB���aB_���������'=��{i�v�l�$�uC���mƎҝ{�c㱼�y]���W�i ��ߧc��m�H� m�"�"�����;Y�ߝ�Z�Ǔ�����:S#��|}�y�,/k�Ld� TA�(�AI$+I3��;Y*���Z��}|��ӧO��d�v��..#:n��f>�>���ȶI�TX��� 8��y����"d�R�|�)0���=���n4��6ⲑ�+��r<�O�܂~zh�z����7ܓ�HH�Ga롏���nCo�>������a ���~]���R���̲c?�6(�q�;5%� |�uj�~z8R=X��I�V=�|{v�Gj\gc��q����z�؋%M�ߍ����1y��#��@f^���^�>N�����#x#۹��6�Y~�?�dfPO��{��P�4��V��u1E1J �*|���%���JN��`eWu�zk M6���q t[�� ��g�G���v��WIG��u_ft����5�j�"�Y�:T��ɐ���*�;� e5���4����q$C��2d�}���� _S�L#m�Yp��O�.�C�;��c����Hi#֩%+) �Ӎ��ƲV���SYź��g |���tj��3�8���r|���V��1#;.SQ�A[���S������#���`n�+���$��$I �P\[�@�s��(�ED�z���P��])8�G#��0B��[ى��X�II�q<��9�~[Z멜�Z�⊔IWU&A>�P~�#��dp<�?����7���c��'~���5 ��+$���lx@�M�dm��n<=e�dyX��?{�|Aef ,|n3�<~z�ƃ�uۧ�����P��Y,�ӥQ�*g�#먙R�\���;T��i,��[9Qi歉����c>]9�� ��"�c��P�� �Md?٥��If�ت�u��k��/����F��9�c*9��Ǎ:�ØF���z�n*�@|I�ށ9����N3{'��[�'ͬ�Ҳ4��#}��!�V� Fu��,�,mTIk���v C�7v���B�6k�T9��1�*l� '~��ƞF��lU��'�M ����][ΩũJ_�{�i�I�n��$���L�� j��O�dx�����kza۪��#�E��Cl����x˘�o�����V���ɞ�ljr��)�/,�߬h�L��#��^��L�ф�,íMƁe�̩�NB�L�����iL����q�}��(��q��6IçJ$�W�E$��:������=#����(�K�B����zђ <��K(�N�۫K�w��^O{!����)�H���>x�������lx�?>Պ�+�>�W���,Ly!_�D���Ō�l���Q�!�[ �S����J��1��Ɛ�Y}��b,+�Lo�x�ɓ)����=�y�oh�@�꥟/��I��ѭ=��P�y9��� �ۍYӘ�e+�p�Jnϱ?V\SO%�(�t� ���=?MR�[Ș�����d�/ ��n�l��B�7j� ��!�;ӥ�/�[-���A�>�dN�sLj ��,ɪv��=1c�.SQ�O3�U���ƀ�ܽ�E����������̻��9G�ϷD�7(�}��Ävӌ\�y�_0[w ���<΍>����a_��[0+�L��F.�޺��f�>oN�T����q;���y\��bՃ��y�jH�<|q-eɏ�_?_9+P���Hp$�����[ux�K w�Mw��N�ی'$Y2�=��q���KB��P��~������Yul:�[<����F1�2�O���5=d����]Y�sw:���Ϯ���E��j,_Q��X��z`H1,#II ��d�wr��P˂@�ZJV����y$�\y�{}��^~���[:N����ߌ�U�������O��d�����ؾe��${p>G��3c���Ė�lʌ�� ת��[��`ϱ�-W����dg�I��ig2��� ��}s ��ؤ(%#sS@���~���3�X�nRG�~\jc3�v��ӍL��M[JB�T��s3}��j�Nʖ��W����;7��ç?=X�F=-�=����q�ߚ���#���='�c��7���ڑW�I(O+=:uxq�������������e2�zi+�kuG�R��������0�&e�n���iT^J����~\jy���p'dtG��s����O��3����9* �b#Ɋ�� p������[Bws�T�>d4�ۧs���nv�n���U���_�~,�v����ƜJ1��s�� �QIz��)�(lv8M���U=�;����56��G���s#�K���MP�=��LvyGd��}�VwWBF�'�à �?MH�U�g2�� ����!�p�7Q��j��ڴ����=��j�u��� Jn�A s���uM������e��Ɔ�Ҕ�!)'��8Ϣ�ٔ��ޝ(��Vp���צ֖d=�IC�J�Ǡ{q������kԭ�߸���i��@K����u�|�p=..�*+����x�����z[Aqġ#s2a�Ɗ���RR�)*HRsi�~�a &f��M��P����-K�L@��Z��Xy�'x�{}��Zm+���:�)�) IJ�-i�u���� ���ܒH��'�L(7�y�GӜq���� j��� 6ߌg1�g�o���,kر���tY�?W,���p���e���f�OQS��!K�۟cҒA�|ս�j�>��=⬒��˧L[�� �߿2JaB~R��u�:��Q�] �0H~���]�7��Ƽ�I���(}��cq '�ήET���q�?f�ab���ӥvr� �)o��-Q��_'����ᴎo��K������;��V���o��%���~OK ����*��b�f:���-ťIR��`B�5!RB@���ï�� �u �̯e\�_U�_������� g�ES��3�������QT��a����x����U<~�c?�*�#]�MW,[8O�a�x��]�1bC|踤�P��lw5V%�)�{t�<��d��5���0i�XSU��m:��Z�┵�i�"��1�^B�-��P�hJ��&)O��*�D��c�W��vM��)����}���P��ܗ-q����\mmζZ-l@�}��a��E�6��F�@��&Sg@���ݚ�M����� ȹ 4����#p�\H����dYDo�H���"��\��..R�B�H�z_�/5˘����6��KhJR��P�mƶi�m���3�,#c�co��q�a)*Pt����R�m�k�7x�D�E�\Y�閣_X�<���~�)���c[[�BP����6�Yq���S��0����%_����;��Àv�~�| VS؇ ��'O0��F0��\���U�-�d@�����7�SJ*z��3n��y��P����O���������m�~�P�3|Y��ʉr#�C�<�G~�.,! ���bqx���h~0=��!ǫ�jy����l�O,�[B��~��|9��ٱ����Xly�#�i�B��g%�S��������tˋ���e���ې��\[d�t)��.+u�|1 ������#�~Oj����hS�%��i.�~X���I�H�m��0n���c�1uE�q��cF�RF�o���7� �O�ꮧ� ���ۛ{��ʛi5�rw?׌#Qn�TW��~?y$��m\�\o����%W� ?=>S�N@�� �Ʈ���R����N�)�r"C�:��:����� �����#��qb��Y�. �6[��2K����2u�Ǧ�HYR��Q�MV��� �G�$��Q+.>�����nNH��q�^��� ����q��mM��V��D�+�-�#*�U�̒ ���p욳��u:�������IB���m���PV@O���r[b= �� ��1U�E��_Nm�yKbN�O���U�}�the�`�|6֮P>�\2�P�V���I�D�i�P�O;�9�r�mAHG�W�S]��J*�_�G��+kP�2����Ka�Z���H�'K�x�W�MZ%�O�YD�Rc+o��?�q��Ghm��d�S�oh�\�D�|:W������UA�Qc yT�q������~^�H��/��#p�CZ���T�I�1�ӏT����4��"�ČZ�����}��`w�#�*,ʹ�� ��0�i��課�Om�*�da��^gJ݅{���l�e9uF#T�ֲ��̲�ٞC"�q���ߍ ոޑ�o#�XZTp����@ o�8��(jd��xw�]�,f���`~�|,s��^����f�1���t��|��m�򸄭/ctr��5s��7�9Q�4�H1꠲BB@l9@���C�����+�wp�xu�£Yc�9��?`@#�o�mH�s2��)�=��2�.�l����jg�9$�Y�S�%*L������R�Y������7Z���,*=�䷘$�������arm�o�ϰ���UW.|�r�uf����IGw�t����Zwo��~5 ��YյhO+=8fF�)�W�7�L9lM�̘·Y���֘YLf�큹�pRF���99.A �"wz��=E\Z���'a� 2��Ǚ�#;�'}�G���*��l��^"q��+2FQ� hj��kŦ��${���ޮ-�T�٭cf�|�3#~�RJ����t��$b�(R��(����r���dx� >U b�&9,>���%E\� Ά�e�$��'�q't��*�א���ެ�b��-|d���SB�O�O��$�R+�H�)�܎�K��1m`;�J�2�Y~9��O�g8=vqD`K[�F)k�[���1m޼c��n���]s�k�z$@��)!I �x՝"v��9=�ZA=`Ɠi �:�E��)`7��vI��}d�YI�_ �o�:ob���o ���3Q��&D&�2=�� �Ά��;>�h����y.*ⅥS������Ӭ�+q&����j|UƧ����}���J0��WW< ۋS�)jQR�j���Ư��rN)�Gű�4Ѷ(�S)Ǣ�8��i��W52���No˓� ۍ%�5brOn�L�;�n��\G����=�^U�dI���8$�&���h��'���+�(������cȁ߫k�l��S^���cƗjԌE�ꭔ��gF���Ȓ��@���}O���*;e�v�WV���YJ\�]X'5��ղ�k�F��b 6R�o՜m��i N�i����>J����?��lPm�U��}>_Z&�KK��q�r��I�D�Չ~�q�3fL�:S�e>���E���-G���{L�6p�e,8��������QI��h��a�Xa��U�A'���ʂ���s�+טIjP�-��y�8ۈZ?J$��W�P� ��R�s�]��|�l(�ԓ��sƊi��o(��S0��Y� 8�T97.�����WiL��c�~�dxc�E|�2!�X�K�Ƙਫ਼�$((�6�~|d9u+�qd�^3�89��Y�6L�.I�����?���iI�q���9�)O/뚅����O���X��X�V��ZF[�یgQ�L��K1���RҖr@v�#��X�l��F���Нy�S�8�7�kF!A��sM���^rkp�jP�DyS$N���q��nxҍ!U�f�!eh�i�2�m���`�Y�I�9r�6� �TF���C}/�y�^���Η���5d�'��9A-��J��>{�_l+�`��A���[�'��յ�ϛ#w:݅�%��X�}�&�PSt�Q�"�-��\縵�/����$Ɨh�Xb�*�y��BS����;W�ջ_mc�����vt?2}1�;qS�d�d~u:2k5�2�R�~�z+|HE!)�Ǟl��7`��0�<�,�2*���Hl-��x�^����'_TV�gZA�'j� ^�2Ϊ��N7t�����?w�� �x1��f��Iz�C-Ȗ��K�^q�;���-W�DvT�7��8�Z�������� hK�(P:��Q- �8�n�Z���܃e貾�<�1�YT<�,�����"�6{/ �?�͟��|1�:�#g��W�>$����d��J��d�B��=��jf[��%rE^��il:��B���x���Sּ�1հ��,�=��*�7 fcG��#q� �eh?��2�7�����,�!7x��6�n�LC�4x��},Geǝ�tC.��vS �F�43��zz\��;QYC,6����~;RYS/6���|2���5���v��T��i����������mlv��������&� �nRh^ejR�LG�f���? �ۉҬܦƩ��|��Ȱ����>3����!v��i�ʯ�>�v��オ�X3e���_1z�Kȗ\<������!�8���V��]��?b�k41�Re��T�q��mz��TiOʦ�Z��Xq���L������q"+���2ۨ��8}�&N7XU7Ap�d�X��~�׿��&4e�o�F��� �H����O���č�c�� 懴�6���͉��+)��v;j��ݷ�� �UV�� i��� j���Y9GdÒJ1��詞�����V?h��l����l�cGs�ځ�������y�Ac�����\V3�? �� ܙg�>qH�S,�E�W�[�㺨�uch�⍸�O�}���a��>�q�6�n6����N6�q������N ! 1AQaq�0@����"2BRb�#Pr���3C`��Scst���$4D���%Td�� ?���N����a��3��m���C���w��������xA�m�q�m���m������$����4n淿t'��C"w��zU=D�\R+w�p+Y�T�&�պ@��ƃ��3ޯ?�Aﶂ��aŘ���@-�����Q�=���9D��ռ�ѻ@��M�V��P��܅�G5�f�Y<�u=,EC)�<�Fy'�"�&�չ�X~f��l�KԆV��?�� �W�N����=(� �;���{�r����ٌ�Y���h{�١������jW����P���Tc�����X�K�r��}���w�R��%��?���E��m�� �Y�q|����\lEE4���r���}�lsI�Y������f�$�=�d�yO����p�����yBj8jU�o�/�S��?�U��*������ˍ�0������u�q�m [�?f����a�� )Q�>����6#������� ?����0UQ����,IX���(6ڵ[�DI�MNލ�c&���υ�j\��X�R|,4��� j������T�hA�e��^���d���b<����n�� �즇�=!���3�^�`j�h�ȓr��jẕ�c�,ٞX����-����a�ﶔ���#�$��]w�O��Ӫ�1y%��L�Y<�wg#�ǝ�̗`�x�xa�t�w��»1���o7o5��>�m뭛C���Uƃߜ}�C���y1Xνm�F8�jI���]����H���ۺиE@I�i;r�8ӭ����V�F�Շ| ��&?�3|x�B�MuS�Ge�=Ӕ�#BE5G�����Y!z��_e��q�р/W>|-�Ci߇�t�1ޯќd�R3�u��g�=0 5��[?�#͏��q�cf���H��{ ?u�=?�?ǯ���}Z��z���hmΔ�BFTW�����<�q�(v� ��!��z���iW]*�J�V�z��gX֧A�q�&��/w���u�gYӘa���; �i=����g:��?2�dž6�ى�k�4�>�Pxs����}������G�9��3 ���)gG�R<>r h�$��'nc�h�P��Bj��J�ҧH� -��N1���N��?��~��}-q!=��_2hc�M��l�vY%UE�@|�v����M2�.Y[|y�"Eï��K�ZF,�ɯ?,q�?v�M 80jx�"�;�9vk�����+ ֧�� �ȺU��?�%�vcV��mA�6��Qg^M����A}�3�nl� QRN�l8�kkn�'�����(��M�7m9و�q���%ޟ���*h$Zk"��$�9��: �?U8�Sl��,,|ɒ��xH(ѷ����Gn�/Q�4�P��G�%��Ա8�N��!� �&�7�;���eKM7�4��9R/%����l�c>�x;������>��C�:�����t��h?aKX�bhe�ᜋ^�$�Iհ �hr7%F$�E��Fd���t��5���+�(M6�t����Ü�UU|zW�=a�Ts�Tg������dqP�Q����b'�m���1{|Y����X�N��b �P~��F^F:����k6�"�j!�� �I�r�`��1&�-$�Bevk:y���#yw��I0��x��=D�4��tU���P�ZH��ڠ底taP��6����b>�xa����Q�#� WeF��ŮNj�p�J* mQ�N����*I�-*�ȩ�F�g�3 �5��V�ʊ�ɮ�a��5F���O@{���NX��?����H�]3��1�Ri_u��������ѕ�� ����0��� F��~��:60�p�͈�S��qX#a�5>���`�o&+�<2�D����: �������ڝ�$�nP���*)�N�|y�Ej�F�5ټ�e���ihy�Z �>���k�bH�a�v��h�-#���!�Po=@k̆IEN��@��}Ll?j�O������߭�ʞ���Q|A07x���wt!xf���I2?Z��<ץ�T���cU�j��]��陎Ltl �}5�ϓ��$�,��O�mˊ�;�@O��jE��j(�ا,��LX���LO���Ц�90�O �.����a��nA���7������j4 ��W��_ٓ���zW�jcB������y՗+EM�)d���N�g6�y1_x��p�$Lv:��9�"z��p���ʙ$��^��JԼ*�ϭ����o���=x�Lj�6�J��u82�A�H�3$�ٕ@�=Vv�]�'�qEz�;I˼��)��=��ɯ���x �/�W(V���p�����$ �m�������u�����񶤑Oqˎ�T����r��㠚x�sr�GC��byp�G��1ߠ�w e�8�$⿄����/�M{*}��W�]˷.�CK\�ުx���/$�WPw���r� |i���&�}�{�X� �>��$-��l���?-z���g����lΆ���(F���h�vS*���b���߲ڡn,|)mrH[���a�3�ר�[1��3o_�U�3�TC�$��(�=�)0�kgP���� ��u�^=��4 �WYCҸ:��vQ�ר�X�à��tk�m,�t*��^�,�}D*� �"(�I��9R����>`�`��[~Q]�#af��i6l��8���6�:,s�s�N6�j"�A4���IuQ��6E,�GnH��zS�HO�uk�5$�I�4��ؤ�Q9�@��C����wp�BGv[]�u�Ov���0I4���\��y�����Q�Ѹ��~>Z��8�T��a��q�ޣ;z��a���/��S��I:�ܫ_�|������>=Z����8:�S��U�I�J��"IY���8%b8���H��:�QO�6�;7�I�S��J��ҌAά3��>c���E+&jf$eC+�z�;��V����� �r���ʺ������my�e���aQ�f&��6�ND��.:��NT�vm�<- u���ǝ\MvZY�N�NT��-A�>jr!S��n�O 1�3�Ns�%�3D@���`������ܟ 1�^c<���� �a�ɽ�̲�Xë#�w�|y�cW�=�9I*H8�p�^(4���՗�k��arOcW�tO�\�ƍR��8����'�K���I�Q�����?5�>[�}��yU�ײ -h��=��% q�ThG�2�)���"ו3]�!kB��*p�FDl�A���,�eEi�H�f�Ps�����5�H:�Փ~�H�0Dت�D�I����h�F3�������c��2���E��9�H��5�zԑ�ʚ�i�X�=:m�xg�hd(�v����׊�9iS��O��d@0ڽ���:�p�5�h-��t�&���X�q�ӕ,��ie�|���7A�2���O%P��E��htj��Y1��w�Ѓ!����  ���� ࢽ��My�7�\�a�@�ţ�J �4�Ȼ�F�@o�̒?4�wx��)��]�P��~�����u�����5�����7X ��9��^ܩ�U;Iꭆ 5 �������eK2�7(�{|��Y׎ �V��\"���Z�1� Z�����}��(�Ǝ"�1S���_�vE30>���p;� ΝD��%x�W�?W?v����o�^V�i�d��r[��/&>�~`�9Wh��y�;���R��� ;;ɮT��?����r$�g1�K����A��C��c��K��l:�'��3 c�ﳯ*"t8�~l��)���m��+U,z��`(�>yJ�?����h>��]��v��ЍG*�{`��;y]��I�T� ;c��NU�fo¾h���/$���|NS���1�S�"�H��V���T���4��uhǜ�]�v;���5�͠x��'C\�SBpl���h}�N����� A�Bx���%��ޭ�l��/����T��w�ʽ]D�=����K���ž�r㻠l4�S�O?=�k �M:� ��c�C�a�#ha���)�ѐxc�s���gP�iG��{+���x���Q���I= �� z��ԫ+ �8"�k�ñ�j=|����c ��y��CF��/��*9ж�h{ �?4�o� ��k�m�Q�N�x��;�Y��4膚�a�w?�6�>e]�����Q�r�:����g�,i"�����ԩA�*M�<�G��b�if��l^M��5� �Ҩ�{����6J��ZJ�����P�*�����Y���ݛu�_4�9�I8�7���������,^ToR���m4�H��?�N�S�ѕw��/S��甍�@�9H�S�T��t�ƻ���ʒU��*{Xs�@����f�����֒Li�K{H�w^���������Ϥm�tq���s� ���ք��f:��o~s��g�r��ט� �S�ѱC�e]�x���a��) ���(b-$(�j>�7q�B?ӕ�F��hV25r[7 Y� }L�R��}����*sg+��x�r�2�U=�*'WS��ZDW]�WǞ�<��叓���{�$�9Ou4��y�90-�1�'*D`�c�^o?(�9��u���ݐ��'PI&� f�Jݮ�������:wS����jfP1F:X �H�9dԯ���˝[�_54 �}*;@�ܨ�� ð�yn�T���?�ןd�#���4rG�ͨ��H�1�|-#���Mr�S3��G�3�����)�.᧏3v�z֑��r����$G"�`j �1t��x0<Ɔ�Wh6�y�6��,œ�Ga��gA����y��b��)��h�D��ß�_�m��ü �gG;��e�v��ݝ�nQ� ��C����-�*��o���y�a��M��I�>�<���]obD��"�:���G�A��-\%LT�8���c�)��+y76���o�Q�#*{�(F�⽕�y����=���rW�\p���۩�c���A���^e6��K������ʐ�cVf5$�'->���ՉN"���F�"�UQ@�f��Gb~��#�&�M=��8�ט�JNu9��D��[̤�s�o�~������ G��9T�tW^g5y$b��Y'��س�Ǵ�=��U-2 #�MC�t(�i� �lj�@Q 5�̣i�*�O����s�x�K�f��}\��M{E�V�{�υ��Ƈ�����);�H����I��fe�Lȣr�2��>��W�I�Ȃ6������i��k�� �5�YOxȺ����>��Y�f5'��|��H+��98pj�n�.O�y�������jY��~��i�w'������l�;�s�2��Y��:'lg�ꥴ)o#'Sa�a�K��Z� �m��}�`169�n���"���x��I ��*+� }F<��cГ���F�P�������ֹ*�PqX�x۩��,� ��N�� �4<-����%����:��7����W���u�`����� $�?�I��&����o��o��`v�>��P��"��l���4��5'�Z�gE���8���?��[�X�7(��.Q�-��*���ތL@̲����v��.5���[��=�t\+�CNܛ��,g�SQnH����}*F�G16���&:�t��4ُ"A��̣��$�b �|����#rs��a�����T�� ]�<�j��BS�('$�ɻ� �wP;�/�n��?�ݜ��x�F��yUn�~mL*-�������Xf�wd^�a�}��f�,=t�׵i�.2/wpN�Ep8�OР���•��R�FJ� 55TZ��T �ɭ�<��]��/�0�r�@�f��V��V����Nz�G��^���7hZi����k��3�,kN�e|�vg�1{9]_i��X5y7� 8e]�U����'�-2,���e"����]ot�I��Y_��n�(JҼ��1�O ]bXc���Nu�No��pS���Q_���_�?i�~�x h5d'�(qw52] ��'ޤ�q��o1�R!���`ywy�A4u���h<קy���\[~�4�\ X�Wt/� 6�����n�F�a8��f���z �3$�t(���q��q�x��^�XWeN'p<-v�!�{�(>ӽDP7��ո0�y)�e$ٕv�Ih'Q�EA�m*�H��RI��=:��� ���4牢) �%_iN�ݧ�l]� �Nt���G��H�L��� ɱ�g<���1V�,�J~�ٹ�"K��Q�� 9�HS�9�?@��k����r�;we݁�]I�!{ �@�G�[�"��`���J:�n]�{�cA�E����V��ʆ���#��U9�6����j�#Y�m\��q�e4h�B�7��C�������d<�?J����1g:ٳ���=Y���D�p�ц� ׈ǔ��1�]26؜oS�'��9�V�FVu�P�h�9�xc�oq�X��p�o�5��Ա5$�9W�V(�[Ak�aY錎qf;�'�[�|���b�6�Ck��)��#a#a˙��8���=äh�4��2��C��4tm^ �n'c���]GQ$[Wҿ��i���vN�{Fu ��1�gx��1┷���N�m��{j-,��x�� Ūm�ЧS�[�s���Gna���䑴�� x�p 8<������97�Q���ϴ�v�aϚG��Rt�Һ׈�f^\r��WH�JU�7Z���y)�vg=����n��4�_)y��D'y�6�]�c�5̪�\� �PF�k����&�c;��cq�$~T�7j ���nç]�<�g ":�to�t}�159�<�/�8������m�b�K#g'I'.W�����6��I/��>v��\�MN��g���m�A�yQL�4u�Lj�j9��#44�t��l^�}L����n��R��!��t��±]��r��h6ٍ>�yҏ�N��fU�� ���� Fm@�8}�/u��jb9������he:A�y�ծw��GpΧh�5����l}�3p468��)U��d��c����;Us/�֔�YX�1�O2��uq�s��`hwg�r~�{ R��mhN��؎*q 42�*th��>�#���E����#��Hv�O����q�}�����6�e��\�,Wk�#���X��b>��p}�դ��3���T5��†��6��[��@�P�y*n��|'f�֧>�lư΂�̺����SU�'*�q�p�_S�����M�� '��c�6�����m�� ySʨ;M��r���Ƌ�m�Kxo,���Gm�P��A�G�:��i��w�9�}M(�^�V��$ǒ�ѽ�9���|���� �a����J�SQ�a���r�B;����}���ٻ֢�2�%U���c�#�g���N�a�ݕ�'�v�[�OY'��3L�3�;,p�]@�S��{ls��X�'���c�jw�k'a�.��}�}&�� �dP�*�bK=ɍ!����;3n�gΊU�ߴmt�'*{,=SzfD� A��ko~�G�aoq�_mi}#�m�������P�Xhύ����mxǍ�΂���巿zf��Q���c���|kc�����?���W��Y�$���_Lv����l߶��c���`?����l�j�ݲˏ!V��6����U�Ђ(A���4y)H���p�Z_�x��>���e��R��$�/�`^'3qˏ�-&Q�=?��CFVR �D�fV�9��{�8g�������n�h�(P"��6�[�D���< E�����~0<@�`�G�6����Hг�cc�� �c�K.5��D��d�B���`?�XQ��2��ٿyqo&+�1^� DW�0�ꊩ���G�#��Q�nL3��c���������/��x ��1�1[y�x�პCW��C�c�UĨ80�m�e�4.{�m��u���I=��f�����0QRls9���f���������9���~f�����Ǩ��a�"@�8���ȁ�Q����#c�ic������G��$���G���r/$W�(��W���V�"��m�7�[m�A�m����bo��D� j����۳� l���^�k�h׽����� ��#� iXn�v��eT�k�a�^Y�4�BN��ĕ��0 !01@Q"2AaPq3BR������?���@4�Q�����T3,���㺠�W�[=JK�Ϟ���2�r^7��vc�:�9 �E�ߴ�w�S#d���Ix��u��:��Hp��9E!�� V 2;73|F��9Y���*ʬ�F��D����u&���y؟��^EA��A��(ɩ���^��GV:ݜDy�`��Jr29ܾ�㝉��[���E;Fzx��YG��U�e�Y�C���� ����v-tx����I�sם�Ę�q��Eb�+P\ :>�i�C'�;�����k|z�رn�y]�#ǿb��Q��������w�����(�r|ӹs��[�D��2v-%��@;�8<a���[\o[ϧw��I!��*0�krs)�[�J9^��ʜ��p1)� "��/_>��o��<1����A�E�y^�C��`�x1'ܣn�p��s`l���fQ��):�l����b>�Me�jH^?�kl3(�z:���1ŠK&?Q�~�{�ٺ�h�y���/�[��V�|6��}�KbX����mn[-��7�5q�94�������dm���c^���h� X��5��<�eޘ>G���-�}�دB�ޟ� ��|�rt�M��V+�]�c?�-#ڛ��^ǂ}���Lkr���O��u�>�-D�ry� D?:ޞ�U��ǜ�7�V��?瓮�"�#���r��չģVR;�n���/_� ؉v�ݶe5d�b9��/O��009�G���5n�W����JpA�*�r9�>�1��.[t���s�F���nQ� V 77R�]�ɫ8����_0<՜�IF�u(v��4��F�k�3��E)��N:��yڮe��P�`�1}�$WS��J�SQ�N�j�ٺ��޵�#l���ј(�5=��5�lǏmoW�v-�1����v,W�mn��߀$x�<����v�j(����c]��@#��1������Ǔ���o'��u+����;G�#�޸��v-lη��/(`i⣍Pm^���ԯ̾9Z��F��������n��1��� ��]�[��)�'������:�֪�W��FC����� �B9،!?���]��V��A�Վ�M��b�w��G F>_DȬ0¤�#�QR�[V��kz���m�w�"��9ZG�7'[��=�Q����j8R?�zf�\a�=��O�U����*oB�A�|G���2�54 �p��.w7� �� ��&������ξxGHp� B%��$g�����t�Џ򤵍z���HN�u�Я�-�'4��0��;_��3 !01"@AQa2Pq#3BR������?��ʩca��en��^��8���<�u#��m*08r��y�N"�<�Ѳ0��@\�p��� �����Kv�D��J8�Fҽ� �f�Y��-m�ybX�NP����}�!*8t(�OqѢ��Q�wW�K��ZD��Δ^e��!� ��B�K��p~�����e*l}z#9ң�k���q#�Ft�o��S�R����-�w�!�S���Ӥß|M�l޶V��!eˈ�8Y���c�ЮM2��tk���� ������J�fS����Ö*i/2�����n]�k�\���|4yX�8��U�P.���Ы[���l��@"�t�<������5�lF���vU�����W��W��;�b�cД^6[#7@vU�xgZv��F�6��Q,K�v��� �+Ъ��n��Ǣ��Ft���8��0��c�@�!�Zq s�v�t�;#](B��-�nῃ~���3g������5�J�%���O������n�kB�ĺ�.r��+���#�N$?�q�/�s�6��p��a����a��J/��M�8��6�ܰ"�*������ɗud"\w���aT(����[��F��U՛����RT�b���n�*��6���O��SJ�.�ij<�v�MT��R\c��5l�sZB>F��<7�;EA��{��E���Ö��1U/�#��d1�a�n.1ě����0�ʾR�h��|�R��Ao�3�m3 ��%�� ���28Q� ��y��φ���H�To�7�lW>����#i`�q���c����a��� �m,B�-j����݋�'mR1Ήt�>��V��p���s�0IbI�C.���1R�ea�����]H�6����������4B>��o��](��$B���m�����a�!=��?�B� K�Ǿ+�Ծ"�n���K��*��+��[T#�{E�J�S����Q�����s�5�:�U�\wĐ�f�3����܆&�)����I���Ԇw��E T�lrTf6Q|R�h:��[K�� �z��c֧�G�C��%\��_�a�84��HcO�bi��ؖV��7H �)*ģK~Xhչ0��4?�0��� �E<���}3���#���u�?�� ��|g�S�6ꊤ�|�I#Hڛ� �ա��w�X��9��7���Ŀ%�SL��y6č��|�F�a 8���b��$�sק�h���b9RAu7�˨p�Č�_\*w��묦��F ����4D~�f����|(�"m���NK��i�S�>�$d7SlA��/�²����SL��|6N�}���S�˯���g��]6��; �#�.��<���q'Q�1|KQ$�����񛩶"�$r�b:���N8�w@��8$�� �AjfG|~�9F ���Y��ʺ��Bwؒ������M:I岎�G��`s�YV5����6��A �b:�W���G�q%l�����F��H���7�������Fsv7��k�� 403WebShell
403Webshell
Server IP : 213.165.242.4  /  Your IP : 216.73.216.78
Web Server : Apache
System : Linux amsngx344.inmotionhosting.com 4.18.0-553.40.1.lve.el8.x86_64 #1 SMP Wed Feb 12 18:54:57 UTC 2025 x86_64
User : aquafi9 ( 1305)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /opt/imh-python/lib/python3.9/site-packages/libcloud/compute/drivers/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/imh-python/lib/python3.9/site-packages/libcloud/compute/drivers/__pycache__/ec2.cpython-39.pyc
a

q�h�X�&@s�
dZddlmZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
mZmZddl
mZmZmZmZddlmZddlmZdd	lmZdd
lmZmZddlmZddlmZmZmZdd
lm Z ddl!m"Z"m#Z#m$Z$m%Z%ddl!m&Z&m'Z'm(Z(ddl!m)Z)ddl*m+Z+m,Z,m-Z-m.Z.ddl/m0Z0m1Z1gd�Z2dZ3de3Z4dZ5de5Z6dZ7dZ8ddgd�d�e1d<dd d!ddd"�d#d$d%d&dd"�d'd(d)d*dd"�d+d,d-d.dd"�d/d0d1d2dd"�d3d4d%d5dd"�d6d7d8d2dd"�d9d:d)d;dd"�d<d7d8d=dd"�d>d?d@dAdd"�dBdCdDdEdd"�dFdGdHdIdd"�dJdKdLd*dd"�dMdNdOd.dd"�dPdQdRd2dd"�dSdTdUd&dd"�dVdWdXd*dd"�dYdZd[d.dd"�d\d]d^d2dd"�d_d`d1dadd"�dbdcddd2dd"�dedfdgdhdd"�didjdkd2dd"�dldmdnddd"�dodpdDddd"�dqdmd@ddd"�drdpdsddd"�dtdudvdwdd"�dxdydgdadd"�dzd{d|d}dd"�d~dd�d�dd"�d�d�d�d2dd"�d�d�d�dhdd"�d��!Z9d�d�d�gd��d��d�d�d�gd��d��d�d�d�gd��d��d�d�d�gd��d��d�d�d�gd��d��d��Z:d�d�d�gd��d��d�d�d�gd��d��d�d�d�gd��d��d�d�d�gd��d��d�d�d�gd��d��d��Z;d�ed��d�e<d��d�e<d��d�e<d��d��d�e<d��d�e<d��d�e=d��d�e<d��d�e<d��d�e=d��d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d��d�e<d��d�e<d��d�e<d��d�e<d��dŜd�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d͜d�e<d��d�e<d��d�e<d��d�e=d��d�e<d��d�ed��d�e<d��d՜d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e=d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�e<d��d�d�e<d��d�e<d��d�e<d��d�e<d��d�e=d��d�e>d��d�e>d��d�e=d��d�e<d��d�e<d��d�e<d��d�e<d��d�d�e<d��d�e<d��d�e<d��d�d�e<d��d�e<d��d�e<d��d�e<d��d�ed��d��d�e<d��d�e=d��d�e<d��d�e<d��d��d�e<d��d�d��d�d���de=d��d�e<d���ded��d�e<d���d�d�d�d���ded���de<d���de<d���de<d���d	e<d���d
��dd�e<d��i�d�Z?�d
ed���de<d���de=d���de=d���de<d��d�e=d��d�ed���de<d���de=d���de=d���de<d��d�e<d���d�Z@e1�A�ZB�d�d�eBD�ZBg�d�ZCG�d�d��de$�ZDG�d�d��de�ZEG�d�d��de�ZFG�d �d!��d!eG�ZHG�d"�d#��d#e"�ZIG�d$�d%��d%eG�ZJG�d&�d'��d'eG�ZKG�d(�d)��d)eG�ZLG�d*�d+��d+eG�ZMG�d,�d-��d-eG�ZNG�d.�d/��d/eG�ZOG�d0�d1��d1eG�ZPG�d2�d3��d3eG�ZQG�d4�d5��d5eG�ZRG�d6�d7��d7eG�ZSG�d8�d9��d9eG�ZTG�d:�d;��d;eG�ZUG�d<�d=��d=e#�ZVG�d>�d?��d?eV�ZWG�d@�dA��dAe�ZXG�dB�dC��dCeF�ZYG�dD�dE��dEeV�ZZG�dF�dG��dGeF�Z[G�dH�dI��dIeV�Z\G�dJ�dK��dKeF�Z]G�dL�dM��dMeV�Z^G�dN�dO��dOe^�Z_G�dP�dQ��dQe^�Z`dS(Rz6
Amazon EC2, Eucalyptus, Nimbus and Outscale drivers.
�)�ListN)�ET)�b�
basestring�
ensure_string)�fixxpath�findtext�findattr�findall)�get_pubkey_ssh2_fingerprint)�get_pubkey_comment)�
parse_date)�AWSBaseResponse�SignedAWSConnection)�DEFAULT_SIGNATURE_VERSION)�InvalidCredsError�MalformedResponseError�
LibcloudError)�Provider)�Node�
NodeDriver�NodeLocation�NodeSize)�	NodeImage�
StorageVolume�VolumeSnapshot)�KeyPair)�	NodeState�KeyPairDoesNotExistError�StorageVolumeState�VolumeSnapshotState)�INSTANCE_TYPES�REGION_DETAILS)�API_VERSION�	NAMESPACEr!�OUTSCALE_INSTANCE_TYPES�OUTSCALE_SAS_REGION_DETAILS�OUTSCALE_INC_REGION_DETAILS�DEFAULT_EUCA_API_VERSION�EUCA_NAMESPACE�
EC2NodeDriver�BaseEC2NodeDriver�NimbusNodeDriver�
EucNodeDriver�OutscaleSASNodeDriver�OutscaleINCNodeDriver�EC2NodeLocation�EC2ReservedNode�EC2SecurityGroup�EC2ImportSnapshotTask�EC2PlacementGroup�
EC2Network�EC2NetworkSubnet�EC2NetworkInterface�
EC2RouteTable�EC2Route�EC2SubnetAssociation�ExEC2AvailabilityZone�IdempotentParamErrorz
2016-11-15z http://ec2.amazonaws.com/doc/%s/z3.3.0�http://msgs.eucalyptus.com/%sz
2016-04-01z/http://api.outscale.com/wsdl/fcuext/2014-04-15/Zcustom�2)�m1.small�m1.large�	m1.xlarge)�country�signature_version�instance_types�nimbus�t1.microzMicro Instanceig)�id�name�ram�disk�	bandwidthr?zStandard Small Instancei���	m1.mediumzStandard Medium Instanceii�r@zStandard Large InstanceiiHrAzStandard Extra Large Instancei<i��	c1.mediumz!Compute Optimized Medium InstanceiT�	c1.xlargez&Compute Optimized Extra Large Instancei�c3.largez Compute Optimized Large Instance� �	c3.xlarge�P�
c3.2xlargez-Compute Optimized Double Extra Large Instancei�;��
c3.4xlargez0Compute Optimized Quadruple Extra Large Instanceixi@�
c3.8xlargez,Compute Optimized Eight Extra Large Instancei�i��	m2.xlargez High Memory Extra Large InstanceifD�
m2.2xlargez'High Memory Double Extra Large Instanceï�
m2.4xlargez*High Memory Quadruple Extra Large Instancei��	nv1.smallzGPU Small Instancei��
nv1.mediumzGPU Medium Instancei��	nv1.largezGPU Large Instancei��
nv1.xlargezGPU Extra Large Instancei�;�
g2.2xlargezGPU Double Extra Large Instance�<�cc1.4xlargez.Cluster Compute Quadruple Extra Large Instancei`�cc2.8xlargez*Cluster Compute Eight Extra Large Instanceii 
�
hi1.xlargez!High Storage Extra Large Instancei<�	m3.xlargez+High Storage Optimized Extra Large Instancei�;�
m3.2xlargez2High Storage Optimized Double Extra Large Instance�
m3s.xlarge�m3s.2xlargei�w�cr1.8xlargez+Memory Optimized Eight Extra Large Instancei�����os1.2xlargezKMemory Optimized, High Storage, Passthrough NIC Double Extra Large Instance�os1.4xlargezNMemory Optimized, High Storage, Passthrough NIC Quadruple Extra Large Instancei�x�os1.8xlargezJMemory Optimized, High Storage, Passthrough NIC Eight Extra Large Instancei�i��oc1.4xlargez'Outscale Quadruple Extra Large Instancei�_�oc2.8xlargez#Outscale Eight Extra Large Instancei��)!rFr?rMr@rArNrOrPrRrTrVrWrXrYrZr[r\r]r^r_rarbrcrdrerfrgrhrjrkrmrnrozapi-ppd.outscale.comZosc_sas_eu_west_3ZFRANCE)rFr?rMr@rArNrOrXrYrZr[r\r]r^rarbrdrerhrm)�endpoint�api_namerBrDzapi.eu-west-1.outscale.comZosc_sas_eu_west_1zfcu.eu-west-2.outscale.comZosc_sas_eu_west_2zapi.us-east-1.outscale.comZosc_sas_us_east_1ZUSAzfcu.us-east-2.outscale.comZosc_sas_us_east_2)�	eu-west-3�	eu-west-1�	eu-west-2�	us-east-1�	us-east-2Zosc_inc_eu_west_1)rFr?rMr@rArNrOrXrYrZz	p2.xlargez
p2.8xlargezp2.16xlarger[r\r]r^rarbrdrerhrmZosc_inc_eu_west_2Zosc_inc_eu_west_3Zosc_inc_us_east_1Zosc_inc_us_east_2)rsrtrrrurvzebs/attachTime)�xpath�transform_funczebs/deleteOnTerminationz
ebs/statuszebs/volumeId)�attach_time�delete�status�	volume_idzebs/snapshotIdzebs/volumeSizezebs/volumeTypezebs/iops)�snapshot_idr|Zvolume_sizerz�volume_type�iopsZallocationId�
associationId�networkInterfaceIdZnetworkInterfaceOwnerIdZ	privateIp)�
allocation_id�association_id�interface_id�owner_id�
private_ipZ
imageStateZimageOwnerIdZimageOwnerAliasZisPublic�architectureZ	imageTypeZ
imageLocation�platform�descriptionZrootDeviceTypeZvirtualizationType�
hypervisorZkernelIdZ	ramdiskIdZ
enaSupportZsriovNetSupport)�stater�Zowner_aliasZ	is_publicr�Z
image_type�image_locationr�r��root_device_type�virtualization_typer��	kernel_id�
ramdisk_id�ena_support�sriov_net_supportr�Z
dhcpOptionsIdZinstanceTenancyZ	isDefault)r�Zdhcp_options_id�instance_tenancy�
is_default�subnetId�vpcIdZavailabilityZone�ownerIdZ
macAddressz$privateIpAddressesSet/privateDnsNameZsourceDestCheck)�	subnet_id�vpc_id�zoner�r�Zmac_addressZprivate_dns_name�source_dest_checkzattachment/attachmentIdzattachment/instanceIdzattachment/instanceOwnerIdzattachment/deviceIndexzattachment/statuszattachment/attachTimezattachment/deleteOnTermination)�
attachment_id�instance_idr��device_indexr{ryrzzplacement/availabilityZoneZclientTokenZdnsNameziamInstanceProfile/id�imageId�
instanceIdZinstanceLifecyclezplacement/tenancyZinstanceType�keyNameZamiLaunchIndex�
launchTimezmonitoring/state�privateDnsNameZrootDeviceName�reason�instanceState/nameZebsOptimized)�availabilityr��client_tokenZdns_namer�Ziam_profile�image_idr�Zinstance_lifecycler��
instance_type�key_nameZlaunch_indexZlaunch_timer�Z
monitoringr��private_dnsr�r��root_device_namer�r�r{r�r��
ebs_optimizedr��start�end�durationZ
usagePriceZ
fixedPriceZ
instanceCountZproductDescriptionZcurrencyCodeZofferingType)r�r�r�r�r�Zusage_priceZfixed_priceZinstance_countr�r�Z
currency_codeZ
offering_typeZgroupDescription)r�r�r��volumeIdr{�progress�	startTime)r|r�r�r��
start_time�	cidrBlockZavailableIpAddressCount)�
cidr_blockZ
available_ipsr�r�zattachmentSet/item/device�
snapshotIdcCst|�p
dS�N)�str)�v�r���/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/libcloud/compute/drivers/ec2.py�<lambda>6�r�rZ
createTime�	encryptedcCsddd��|�S)NTF)�true�false)�get)�xr�r�r�r�Jr�zattachmentSet/item/attachTimezattachmentSet/item/statuszattachmentSet/item/instanceIdz&attachmentSet/item/deleteOnTerminationZ
volumeType)�devicer}rr�Zcreate_timer�r�ryZattachment_statusr�rzr~r�)�ebs_instance_block_device�
ebs_volume�
elastic_ip�image�network�network_interface�network_interface_attachment�node�
reserved_node�security_group�snapshot�subnet�volume�route_tableZendTimeZmodificationStateZoriginalIopsZoriginalSizeZoriginalVolumeTypeZ
statusMessageZ
targetIopsZ
targetSizeZtargetVolumeType��end_time�modification_state�
original_iops�
original_size�original_volume_typer�r��status_message�target_iops�target_size�target_volume_typer|cCsg|]}|dkr|�qS)rEr�)�.0�rr�r�r��
<listcomp>�r�r�)�standard�io1Zgp2Zst1Zsc1cs$eZdZ�fdd�Zdd�Z�ZS)r0cs tt|��||||�||_dSr�)�superr0�__init__�availability_zone)�selfrGrHrB�driverr���	__class__r�r�r��szEC2NodeLocation.__init__cCsd|j|j|j|j|jjfS)NzM<EC2NodeLocation: id=%s, name=%s, country=%s, availability_zone=%s driver=%s>)rGrHrBr�r��r�r�r�r��__repr__�s

��zEC2NodeLocation.__repr__)�__name__�
__module__�__qualname__r�r��
__classcell__r�r�r�r�r0�sr0c@seZdZdZdd�ZdS)�EC2Responsez;
    EC2 specific response parsing and error handling.
    c	CsPg}d}|jdkr0|jdt|��|kr0t|��zt�|j�}Wn"tybtd|jtd��Yn0|�	d�D]�}t
|�\}}|�d|j|jf�|jdkr�t|d��|jd	kr�t|d��|jd
kr�t|d��|jdkr�t|d��|jdk�rt
|d��|jd
krnt�d|j�}|�r0|��d}nd}t||jjd��qnd�|�S)NzFailure: 403 Forbiddeni�zFailed to parse XML)�bodyr�zErrors/Errorz%s: %sZInvalidClientTokenId���ZSignatureDoesNotMatchZAuthFailureZ
OptInRequiredZIdempotentParameterMismatchzInvalidKeyPair.NotFoundz
.*\'(.+?)\'.*r)rHr��
)r{r��lenrr�XML�	Exceptionrr*r
�list�append�textr<�re�match�groupsr�
connectionr��join)	r�Zerr_list�msgr��err�code�messager�rHr�r�r��parse_error�s@ �




�zEC2Response.parse_errorN)r�r�r��__doc__rr�r�r�r�r��sr�c@s(eZdZdZeZeddZeZ	dZ
dS)�
EC2Connectionz=
    Represents a single connection to the EC2 Endpoint.
    rurpZec2N)r�r�r�rr#�versionr"�hostr�ZresponseCls�service_namer�r�r�r�r�s
rc@s eZdZdZdd�Zdd�ZdS)r;zy
    Extension class which stores information about an EC2 availability zone.

    Note: This class is EC2 specific.
    cCs||_||_||_dSr��rH�
zone_state�region_name)r�rHr	r
r�r�r�r��szExEC2AvailabilityZone.__init__cCsd|j|j|jfS)Nz?<ExEC2AvailabilityZone: name=%s, zone_state=%s, region_name=%s>rr�r�r�r�r��s�zExEC2AvailabilityZone.__repr__N�r�r�r�rr�r�r�r�r�r�r;�sr;cs*eZdZdZd�fdd�	Zdd�Z�ZS)r1z�
    Class which stores information about EC2 reserved instances/nodes
    Inherits from Node and passes in None for name and private/public IPs

    Note: This class is EC2 specific.
    Nc	s"tt|�j|d|dd||d�dS)N)rGrHr��
public_ips�private_ipsr��extra)r�r1r�)r�rGr�r��sizer�rr�r�r�r�s
�zEC2ReservedNode.__init__cCs
d|jS)Nz<EC2ReservedNode: id=%s>�rGr�r�r�r�r�szEC2ReservedNode.__repr__)NNN)r�r�r�rr�r�r�r�r�r�r�r1�sr1c@s"eZdZdZddd�Zdd�ZdS)r2z^
    Represents information about a Security group

    Note: This class is EC2 specific.
    NcCs&||_||_||_||_|pi|_dSr�)rGrH�
ingress_rules�egress_rulesr)r�rGrHrrrr�r�r�r�s
zEC2SecurityGroup.__init__cCsd|j|jfS)Nz!<EC2SecurityGroup: id=%s, name=%s�rGrHr�r�r�r�r�s
�zEC2SecurityGroup.__repr__)Nrr�r�r�r�r2
s
r2c@s eZdZdZdd�Zdd�ZdS)r3zn
    Represents information about a describe_import_snapshot_task.

    Note: This class is EC2 specific.
    cCs||_||_dSr��r{r�)r�r{r�r�r�r�r�$szEC2ImportSnapshotTask.__init__cCsd|j|jfS)Nz+<EC2SecurityGroup: status=%s, snapshotId=%srr�r�r�r�r�(s
�zEC2ImportSnapshotTask.__repr__Nrr�r�r�r�r3sr3c@s"eZdZdZddd�Zdd�ZdS)	r4z_
    Represents information about a Placement Grous

    Note: This class is EC2 specific.
    �clusterNcCs||_||_|pi|_dSr�)rH�strategyr)r�rHr�rrr�r�r�r�3szEC2PlacementGroup.__init__cCsd|j|jfS)Nz&<EC2PlacementGroup: name=%s, state=%s>)rHrr�r�r�r�r�8s�zEC2PlacementGroup.__repr__)rNrr�r�r�r�r4-s
r4c@s"eZdZdZddd�Zdd�ZdS)r5zs
    Represents information about a VPC (Virtual Private Cloud) network

    Note: This class is EC2 specific.
    NcCs ||_||_||_|pi|_dSr�)rGrHr�r)r�rGrHr�rr�r�r�r�DszEC2Network.__init__cCsd|j|jfS)Nz<EC2Network: id=%s, name=%srr�r�r�r�r�Js
�zEC2Network.__repr__)Nrr�r�r�r�r5=s
r5c@s"eZdZdZddd�Zdd�ZdS)r6zr
    Represents information about a VPC (Virtual Private Cloud) subnet

    Note: This class is EC2 specific.
    NcCs ||_||_||_|pi|_dSr��rGrHr�r�r�rGrHr�rr�r�r�r�VszEC2NetworkSubnet.__init__cCsd|j|jfS)Nz!<EC2NetworkSubnet: id=%s, name=%srr�r�r�r�r�\szEC2NetworkSubnet.__repr__)Nrr�r�r�r�r6Os
r6c@s"eZdZdZddd�Zdd�ZdS)r7z�
    Represents information about a VPC network interface

    Note: This class is EC2 specific. The state parameter denotes the current
    status of the interface. Valid values for state are attaching, attached,
    detaching and detached.
    NcCs ||_||_||_|pi|_dSr�rrr�r�r�r�iszEC2NetworkInterface.__init__cCsd|j|jfS)Nz$<EC2NetworkInterface: id=%s, name=%srr�r�r�r�r�os
�zEC2NetworkInterface.__repr__)Nrr�r�r�r�r7`s
r7c@s"eZdZdZddd�Zdd�ZdS)�	ElasticIPa�
    Represents information about an elastic IP address

    :param      ip: The elastic IP address
    :type       ip: ``str``

    :param      domain: The domain that the IP resides in (EC2-Classic/VPC).
                        EC2 classic is represented with standard and VPC
                        is represented with vpc.
    :type       domain: ``str``

    :param      instance_id: The identifier of the instance which currently
                             has the IP associated.
    :type       instance_id: ``str``

    Note: This class is used to support both EC2 and VPC IPs.
          For VPC specific attributes are stored in the extra
          dict to make promotion to the base API easier.
    NcCs ||_||_||_|pi|_dSr�)�ip�domainr�r)r�rrr�rr�r�r�r��szElasticIP.__init__cCsd|j|j|jfS)Nz-<ElasticIP: ip=%s, domain=%s, instance_id=%s>)rrr�r�r�r�r�r��s�zElasticIP.__repr__)Nrr�r�r�r�rts
rc@s"eZdZdZddd�Zdd�ZdS)�VPCInternetGatewayzl
    Class which stores information about VPC Internet Gateways.

    Note: This class is VPC specific.
    NcCs&||_||_||_||_|pi|_dSr�)rGrHr�r�r)r�rGrHr�r�r�rr�r�r�r��s
zVPCInternetGateway.__init__cCs
d|jS)Nz<VPCInternetGateway: id=%s>rr�r�r�r�r��szVPCInternetGateway.__repr__)Nrr�r�r�r�r�s
rc@s"eZdZdZddd�Zdd�ZdS)r8zg
    Class which stores information about VPC Route Tables.

    Note: This class is VPC specific.
    NcCs,||_||_||_||_||_|p$i|_dS)aO
        :param      id: The ID of the route table.
        :type       id: ``str``

        :param      name: The name of the route table.
        :type       name: ``str``

        :param      routes: A list of routes in the route table.
        :type       routes: ``list`` of :class:`EC2Route`

        :param      subnet_associations: A list of associations between the
                                         route table and one or more subnets.
        :type       subnet_associations: ``list`` of
                                         :class:`EC2SubnetAssociation`

        :param      propagating_gateway_ids: The list of IDs of any virtual
                                             private gateways propagating the
                                             routes.
        :type       propagating_gateway_ids: ``list``
        N)rGrH�routes�subnet_associations�propagating_gateway_idsr)r�rGrHrrrrr�r�r�r��szEC2RouteTable.__init__cCs
d|jS)Nz<EC2RouteTable: id=%s>rr�r�r�r�r��szEC2RouteTable.__repr__)Nrr�r�r�r�r8�s�
r8c@s eZdZdZdd�Zdd�ZdS)r9z^
    Class which stores information about a Route.

    Note: This class is VPC specific.
    c		Cs4||_||_||_||_||_||_||_||_dS)a�
        :param      cidr: The CIDR block used for the destination match.
        :type       cidr: ``str``

        :param      gateway_id: The ID of a gateway attached to the VPC.
        :type       gateway_id: ``str``

        :param      instance_id: The ID of a NAT instance in the VPC.
        :type       instance_id: ``str``

        :param      owner_id: The AWS account ID of the owner of the instance.
        :type       owner_id: ``str``

        :param      interface_id: The ID of the network interface.
        :type       interface_id: ``str``

        :param      state: The state of the route (active | blackhole).
        :type       state: ``str``

        :param      origin: Describes how the route was created.
        :type       origin: ``str``

        :param      vpc_peering_connection_id: The ID of the VPC
                                               peering connection.
        :type       vpc_peering_connection_id: ``str``
        N)�cidr�
gateway_idr�r�r�r��origin�vpc_peering_connection_id)	r�r r!r�r�r�r�r"r#r�r�r�r��szEC2Route.__init__cCs
d|jS)Nz<EC2Route: cidr=%s>)r r�r�r�r�r��szEC2Route.__repr__Nrr�r�r�r�r9�s&r9c@s"eZdZdZddd�Zdd�ZdS)	r:z�
    Class which stores information about Route Table associated with
    a given Subnet in a VPC

    Note: This class is VPC specific.
    FcCs||_||_||_||_dS)a�
        :param      id: The ID of the subnet association in the VPC.
        :type       id: ``str``

        :param      route_table_id: The ID of a route table in the VPC.
        :type       route_table_id: ``str``

        :param      subnet_id: The ID of a subnet in the VPC.
        :type       subnet_id: ``str``

        :param      main: If true, means this is a main VPC route table.
        :type       main: ``bool``
        N)rG�route_table_idr��main)r�rGr$r�r%r�r�r�r�szEC2SubnetAssociation.__init__cCs
d|jS)Nz<EC2SubnetAssociation: id=%s>rr�r�r�r�r�szEC2SubnetAssociation.__repr__N)Frr�r�r�r�r:s
r:c@s"eZdZdZddd�Zdd�ZdS)�EC2VolumeModificationz�
    Describes the modification status of an EBS volume.

    If the volume has never been modified, some element values will be null.
    Nc

CsL||_||_||_||_||_||_||_||_|	|_|
|_	||_
||_dSr�r�)
r�r�r�r�r�r�r�r�r�r�r�r�r|r�r�r�r�'szEC2VolumeModification.__init__c
Cs8d|j|j|j|j|j|j|j|j|j|j	|j
|jfS)Nz�<EC2VolumeModification: end_time=%s, modification_state=%s, original_iops=%s, original_size=%s, original_volume_type=%s, progress=%s, start_time=%s, status_message=%s, target_iops=%s, target_size=%s, target_volume_type=%s, volume_id=%s>r�r�r�r�r�r�9s��zEC2VolumeModification.__repr__)NNNNNNNNNNNNrr�r�r�r�r& s�
r&cs�eZdZdZeZddgiZdZdZdZ	e
Zej
ejejejd�Zejejejejejejejd�Zejejejd�Z�dSd
d�Z�dTdd
�Z�dUdd�Zdd�Zdd�Z �dVdd�Z!�dWdd�Z"dd�Z#dd�Z$�dXdd �Z%d!d"�Z&�dYd#d$�Z'd%d&�Z(�dZd'd(�Z)d)d*�Z*�d[d+d,�Z+d-d.�Z,d/d0�Z-d1d2�Z.d3d4�Z/d5d6�Z0d7d8�Z1�d\d9d:�Z2�d]d;d<�Z3d=d>�Z4d?d@�Z5dAdB�Z6dCdD�Z7dEdF�Z8�d^dGdH�Z9�d_dKdL�Z:�d`dMdN�Z;�dadOdP�Z<�dbdQdR�Z=�dcdSdT�Z>�dddVdW�Z?dXdY�Z@�dedZd[�ZA�dfd\d]�ZB�dgd_d`�ZCdadb�ZDdcdd�ZE�dhdedf�ZF�didgdh�ZGdidj�ZHdkdl�ZIdmdn�ZJ�djdpdq�ZK�dkdrds�ZL�dldtdu�ZM�dmdvdw�ZN�dndxdy�ZOdzd{�ZP�dod}d~�ZQdd��ZRd�d��ZSd�d��ZTd�d��ZU�dpd�d��ZV�dqd�d��ZW�drd�d��ZX�dsd�d��ZY�dtd�d��ZZ�dud�d��Z[d�d��Z\d�d��Z]d�d��Z^�dvd�d��Z_d�d��Z`d�d��Za�dwd�d��Zbd�d��Zcd�d��Zdd�d��Zed�d��Zfd�d��Zgd�d��Zhd�d��Zid�d��Zjd�d��Zkd�d��Zld�d��Zmd�d��Znd�d��Zod�d��Zpd�d��Zqd�d��Zrd�d„Zsd�dĄZt�dxd�dƄZu�dyd�dȄZvd�dʄZwd�d̄Zxd�d΄Zy�dzd�dЄZz�d{d�d҄Z{d�dԄZ|d�dքZ}d�d؄Z~d�dڄZ�d|d�d܄Z�d�dބZ��d}d�d�Z�d�d�Z��d~d�d�Z��fd�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z��dd�d�Z�d�d�Z�d�d�Z�d�d��Z��d�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d��d�Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d��d	�d
�Z��d�d�Z��d
�d�Z��d�d�Z��d�d�Z��d�d�Z��d��d�d�Z��d�d�Z��d��d�d�Z��d�d�Z��d�d�Z��d�d �Z��d!�d"�Z��d#�d$�Z��d%�d&�Z��d'�d(�Z��d��d)�d*�Z��d+�d,�Z��d��d-�d.�Z��d/�d0�Z��d1�d2�Z��d3�d4�Z��d5�d6�Z��d7�d8�Z��d9�d:�Z��d;�d<�Z��d=�d>�Z��d?�d@�Z��dA�dB�Z��dC�dD�Z��dE�dF�Z��dG�dH�Z��dI�dJ�Z��dK�dL�Z��d��dM�dN�Z��dO�dP�Z��dQ�dR�Z��Z�S(�r+zs
    Base Amazon EC2 node driver.

    Used for main EC2 and other derivate driver classes to inherit from it.
    �create_nodeZssh_key�/�)�pending�running�
shutting-down�
terminated)�	availablezin-use�errorZcreatingZdeletingZdeletedZerror_deleting)r*�	completedr/Nc
Cs�ddi}|r|�|�d|��|r2|�|�|��|jj|j|d�j}g}t|dtd�D]}||�	|d�7}qX|�
|�}|D]}||j}	|j�
|	�q||S)a
        Lists all nodes.

        Ex_node_ids parameter is used to filter the list of
        nodes that should be returned. Only the nodes
        with the corresponding node IDs will be returned.

        :param      ex_node_ids: List of ``node.id``
        :type       ex_node_ids: ``list`` of ``str``

        :param      ex_filters: The filters so that the list includes
                                information for certain nodes only.
        :type       ex_filters: ``dict``

        :rtype: ``list`` of :class:`Node`
        �ActionZDescribeInstances�
InstanceId��paramszreservationSet/item��elementrw�	namespace�instancesSet/item)�update�	_pathlist�_build_filtersr��request�path�objectr
r$�	_to_nodes�ex_describe_addressesrGr�extend)
r�Zex_node_ids�
ex_filtersr4�elem�nodes�rsZnodes_elastic_ips_mappingsr��ipsr�r�r��
list_nodesls �


zBaseEC2NodeDriver.list_nodesc	Cs~t|jd}g}|D]b}t|}t�|�}z|j|d�}||d<Wnty^d|d<Yn0|�tfd|i|���q|S)NrD�Zsize_id�pricer�)	r"r
r!�copy�deepcopy�_get_size_price�KeyErrorr�r�r��locationZavailable_types�sizesr��
attributesrIr�r�r��
list_sizes�s
zBaseEC2NodeDriver.list_sizesc
Cs�ddi}|r|�d|i�|r,|�d|i�|r\t|�D]"\}}|d7}|�d||i�q8|rp|�|�|��|�|jj|j|d�j�}	|	S)a�
        Lists all images
        @inherits: :class:`NodeDriver.list_images`

        Ex_image_ids parameter is used to filter the list of
        images that should be returned. Only the images
        with the corresponding image IDs will be returned.

        Ex_owner parameter is used to filter the list of
        images that should be returned. Only the images
        with the corresponding owner will be returned.
        Valid values: amazon|aws-marketplace|self|all|aws id

        Ex_executableby parameter describes images for which
        the specified user has explicit launch permissions.
        The user can be an AWS account ID, self to return
        images for which the sender of the request has
        explicit launch permissions, or all to return
        images with public launch permissions.
        Valid values: all|self|aws id

        Ex_filters parameter is used to filter the list of
        images that should be returned. Only images matching
        the filter will be returned.

        :param      ex_image_ids: List of ``NodeImage.id``
        :type       ex_image_ids: ``list`` of ``str``

        :param      ex_owner: Owner name
        :type       ex_owner: ``str``

        :param      ex_executableby: Executable by
        :type       ex_executableby: ``str``

        :param      ex_filters: Filter by
        :type       ex_filters: ``dict``

        :rtype: ``list`` of :class:`NodeImage`
        r1ZDescribeImages�Owner.1zExecutableBy.1�z
ImageId.%sr3)r9�	enumerater;�
_to_imagesr�r<r=r>)
r�rO�ex_image_idsZex_ownerZex_executablebyrBr4�indexr��imagesr�r�r��list_images�s)�zBaseEC2NodeDriver.list_imagescCs|j|gd�}|d}|S)z�
        Gets an image based on an image_id.

        :param image_id: Image identifier
        :type image_id: ``str``

        :return: A NodeImage object
        :rtype: :class:`NodeImage`

        )rWr)rZ)r�r�rYr�r�r�r��	get_image�szBaseEC2NodeDriver.get_imagec	Cs<g}t|���}|D]"\}}|�t||j|j||��q|Sr�)rU�ex_list_availability_zonesr�r0rHrB)r��	locations�iteratorrXr�r�r�r��list_locations�s�z BaseEC2NodeDriver.list_locationscsnddi}|si}|r|j|d<|s&|r6|���|���jj�j|d�j}�fdd�|�tdt	d��D�}|S)	a�
        List volumes that are attached to a node, if specified and those that
        satisfy the filters, if specified.

        :param node: The node to which the volumes are attached.
        :type node: :class:`Node`

        :param ex_filters: The dictionary of additional filters.
        :type ex_filters: ``dict``

        :return: The list of volumes that match the criteria.
        :rtype: ``list`` of :class:`StorageVolume`
        r1ZDescribeVolumeszattachment.instance-idr3csg|]}��|��qSr�)�
_to_volume�r��elr�r�r�r�r�z2BaseEC2NodeDriver.list_volumes.<locals>.<listcomp>zvolumeSet/item�rwr7)
rGr9r;r�r<r=r>r
rr$)r�r�rBr4�responseZvolumesr�r�r��list_volumes�s�

�zBaseEC2NodeDriver.list_volumesrTFc,Cstd|jt|�t|
�|jd�}|r(d|d<|rHd|d<|durHt|�|d<|rX|	rXtd	��|p^|	}|r�t|ttf�sx|g}tt|��D]}|||d
|df<q�|
r�|s�td��|
}i}|r�t|ttf�s�|g}tt|��D]}|||d
|df<q�|�r6t|dd�}|�r6|j	|j	k�r,t
d|j��|j|d<|�rJ|�rJt
d��|�rr|�|�}|�
|j�}|d|d<|�r�||d<|�r�t�t|���d�|d<|�r�||d<|�r�|�|�|��|�r�t|t��s�t
d��|�d��r�||d<n||d<|�r||d<d}|�r|j}|�r&||d<|} | �r�d}!d||!d<d||!d <d!||!d"<|�rj|||!d#<|��D]\}}"|!|}|"||<�qrn|�|�|�r�||d#<d$|i}#|�r�|#�|�d%}$d&||$d'<d}%|#��D]6\}&}'|$d(|%}(|&||(d)<|'||(d*<|%d7}%�q�|jj|j|d+�j})|�|)d,�}*|*D]}+||+_|+j�d-|#i��q8t|*�dk�rl|*d.S|*SdS)/a�
        Create a new EC2 node.

        Reference: http://bit.ly/8ZyPSy [docs.amazonwebservices.com]

        @inherits: :class:`NodeDriver.create_node`

        :keyword    ex_keyname: The name of the key pair
        :type       ex_keyname: ``str``

        :keyword    ex_userdata: User data
        :type       ex_userdata: ``str``

        :keyword    ex_security_groups: A list of names of security groups to
                                        assign to the node.
        :type       ex_security_groups:   ``list``

        :keyword    ex_security_group_ids: A list of ids of security groups to
                                        assign to the node.[for VPC nodes only]
        :type       ex_security_group_ids:   ``list``

        :keyword    ex_metadata: Key/Value metadata to associate with a node
        :type       ex_metadata: ``dict``

        :keyword    ex_mincount: Minimum number of instances to launch
        :type       ex_mincount: ``int``

        :keyword    ex_maxcount: Maximum number of instances to launch
        :type       ex_maxcount: ``int``

        :keyword    ex_clienttoken: Unique identifier to ensure idempotency
        :type       ex_clienttoken: ``str``

        :keyword    ex_blockdevicemappings: ``list`` of ``dict`` block device
                    mappings.
        :type       ex_blockdevicemappings: ``list`` of ``dict``

        :keyword    ex_iam_profile: Name or ARN of IAM profile
        :type       ex_iam_profile: ``str``

        :keyword    ex_ebs_optimized: EBS-Optimized if True
        :type       ex_ebs_optimized: ``bool``

        :keyword    ex_subnet: The subnet to launch the instance into.
        :type       ex_subnet: :class:`.EC2Subnet`

        :keyword    ex_placement_group: The name of the placement group to
                                        launch the instance into.
        :type       ex_placement_group: ``str``

        :keyword    ex_assign_public_ip: If True, the instance will
                                         be assigned a public ip address.
                                         Note : It takes takes a short
                                         while for the instance to be
                                         assigned the public ip so the
                                         node returned will NOT have
                                         the public ip assigned yet.
        :type       ex_assign_public_ip: ``bool``

        :keyword    ex_terminate_on_shutdown: Indicates if the instance
                                              should be terminated instead
                                              of just shut down when using
                                              the operating systems command
                                              for system shutdown.
        :type       ex_terminate_on_shutdown: ``bool``

        :keyword    ex_spot: If true, ask for a Spot Instance instead of
                             requesting On-Demand.
        :type       ex_spot: ``bool``

        :keyword    ex_spot_max_price: Maximum price to pay for the spot
                                       instance. If not specified, the
                                       on-demand price will be used.
        :type       ex_spot_max_price: ``float``
        ZRunInstances)r1�ImageIdZMinCountZMaxCountZInstanceType�	terminateZ!InstanceInitiatedShutdownBehaviorZspotz InstanceMarketOptions.MarketTypeNz*InstanceMarketOptions.SpotOptions.MaxPricez:You can only supply ex_security_groups or ex_securitygroupzSecurityGroup.%drTzCYou can only supply ex_security_group_ids combinated with ex_subnetzSecurityGroupId.%dr�zInvalid availability zone: %szPlacement.AvailabilityZonez+Cannot specify auth and ex_keyname togetherr��KeyName�utf-8ZUserData�ClientTokenzex_iamprofile not stringzarn:aws:iam:zIamInstanceProfile.ArnzIamInstanceProfile.Name�EbsOptimizedzPlacement.GroupNamezNetworkInterface.1.r�ZAssociatePublicIpAddressZDeleteOnTermination�0�DeviceIndex�SubnetId�NamezTagSpecification.1.�instanceZResourceTypezTag.%d.�Key�Valuer3r8�tagsr)rGr��
ValueError�
isinstance�tupler��ranger��getattrr
�AttributeErrorrHZ_get_and_check_auth�)ex_find_or_import_keypair_by_key_material�pubkey�base64�	b64encoder�decoder9� _get_block_device_mapping_paramsr�
startswith�itemsr�r<r=r>r?r),r�rHrr�rO�authZ
ex_keynameZex_userdataZex_security_groupsZex_securitygroupZex_security_group_ids�ex_metadataZex_mincountZex_maxcountZex_clienttokenZex_blockdevicemappings�
ex_iamprofileZex_ebs_optimizedZ	ex_subnetZex_placement_groupZex_assign_public_ipZex_terminate_on_shutdownZex_spotZex_spot_max_pricer4Zsecurity_groups�sigZsecurity_group_idsZsecurity_group_id_paramsr��keyr�Zassign_public_ipZroot_keyZsecurity_group_idrsZtagspec_rootZtag_nr�kr�Ztag_rootr>rDr�r�r�r�r's�V�����

��


zBaseEC2NodeDriver.create_nodecCs<ddi}|�|�d|jg��|jj|j|d�j}|�|�S)Nr1ZRebootInstancesr2r3)r9r:rGr�r<r=r>�_get_boolean�r�r�r4�resr�r�r��reboot_nodeszBaseEC2NodeDriver.reboot_nodecCs<ddi}|�|�d|jg��|jj|j|d�j}|�|�S)Nr1ZTerminateInstancesr2r3)r9r:rGr�r<r=r>�_get_terminate_booleanr�r�r�r��destroy_nodeszBaseEC2NodeDriver.destroy_noder�c	Cs�dt|�d�}	|r&|tvr&td|��|r4|j|	d<|sD|��d}|jj|	d<|r\||	d<|dkrp|rp||	d	<|r�d
|	d<|dur�||	d
<|j|jj	|j
|	d�j|d�}
|�|
d|i�r�||
j
dd<|
S)a�
        Create a new volume.

        :param size: Size of volume in gigabytes (required)
        :type size: ``int``

        :param name: Name of the volume to be created
        :type name: ``str``

        :param location: Which data center to create a volume in. If
                               empty, undefined behavior will be selected.
                               (optional)
        :type location: :class:`.NodeLocation`

        :param snapshot:  Snapshot from which to create the new
                               volume.  (optional)
        :type snapshot:  :class:`.VolumeSnapshot`

        :param location: Datacenter in which to create a volume in.
        :type location: :class:`.ExEC2AvailabilityZone`

        :param ex_volume_type: Type of volume to create.
        :type ex_volume_type: ``str``

        :param iops: The number of I/O operations per second (IOPS)
                     that the volume supports. Only used if ex_volume_type
                     is io1.
        :type iops: ``int``

        :param ex_encrypted: Specifies whether the volume should be encrypted.
        :type ex_encrypted: ``bool``

        :param ex_kms_key_id: The full ARN of the AWS Key Management
                            Service (AWS KMS) customer master key (CMK) to use
                            when creating the encrypted volume.
                            Example:
                            arn:aws:kms:us-east-1:012345678910:key/abcd1234-a123
                            -456a-a12b-a123b4cd56ef.
                            Only used if encrypted is set to True.
        :type ex_kms_key_id: ``str``

        :return: The newly created volume.
        :rtype: :class:`StorageVolume`
        ZCreateVolume)r1�Size�!Invalid volume type specified: %s�
SnapshotIdr�AvailabilityZone�
VolumeTyper�ZIopsrTZ	EncryptedNZKmsKeyIdr3�rHrors)r��VALID_VOLUME_TYPESrtrGr_r�rHr`r�r<r=r>�ex_create_tagsr)r�rrHrOr�Zex_volume_typeZex_iopsZex_encryptedZ
ex_kms_key_idr4r�r�r�r��
create_volumes61��
�zBaseEC2NodeDriver.create_volumecCs(d|j|j|d�}|jj|j|d�dS)NZAttachVolume)r1�VolumeIdr2ZDevicer3T�rGr�r<r=)r�r�r�r�r4r�r�r��
attach_volumeis�zBaseEC2NodeDriver.attach_volumecCs.d|jd�}|rd|d<|jj|j|d�dS)NZDetachVolume�r1r�rT�Forcer3Tr�)r�r�Zex_forcer4r�r�r��
detach_volumess�zBaseEC2NodeDriver.detach_volumecCs*d|jd�}|jj|j|d�j}|�|�S)NZDeleteVolumer�r3�rGr�r<r=r>r�)r�r�r4rdr�r�r��destroy_volume}s
�z BaseEC2NodeDriver.destroy_volumecCs�d|jd�}|r|�d|i�|dur*i}|jj|j|d�j}|�||�}|jfi|r^d|ini��|�||�r|||jd<|S)a�
        Create snapshot from volume

        :param      volume: Instance of ``StorageVolume``
        :type       volume: ``StorageVolume``

        :param      name: Name of snapshot (optional)
        :type       name: ``str``

        :keyword    ex_metadata: The Key/Value metadata to associate
                                 with a snapshot (optional)
        :type       ex_metadata: ``dict``

        :rtype: :class:`VolumeSnapshot`
        ZCreateSnapshotr��DescriptionNr3rors)	rGr9r�r<r=r>�_to_snapshotr�r)r�r�rHr�r4rdr�r�r�r��create_volume_snapshot�s��
z(BaseEC2NodeDriver.create_volume_snapshotcs�fdd�|jdd�D�S)Ncs g|]}|jd�jkr|�qS)r|)rrG)r�r��r�r�r�r��s�z;BaseEC2NodeDriver.list_volume_snapshots.<locals>.<listcomp>r�)�owner)�list_snapshots)r�r�r�r�r��list_volume_snapshots�sz'BaseEC2NodeDriver.list_volume_snapshotscCsPddi}|r|�d|ji�|r.|�d|i�|jj|j|d�j}|�|�}|S)a:
        Describes all snapshots.

        :param snapshot: If provided, only returns snapshot information for the
                         provided snapshot.

        :param owner: The owner of the snapshot: self|amazon|ID
        :type owner: ``str``

        :rtype: ``list`` of :class:`VolumeSnapshot`
        r1ZDescribeSnapshotszSnapshotId.1rSr3)r9rGr�r<r=r>�
_to_snapshots)r�r�r�r4rdZ	snapshotsr�r�r�r��s
���
z BaseEC2NodeDriver.list_snapshotscCs*d|jd�}|jj|j|d�j}|�|�S)NZDeleteSnapshot)r1r�r3r�)r�r�r4rdr�r�r��destroy_volume_snapshot�s
�z)BaseEC2NodeDriver.destroy_volume_snapshotcCs:ddi}|jj|j|d�}t|jdtd�}|j|d�}|S)Nr1�DescribeKeyPairsr3�keySet/itemr5��elems�r�r<r=r
r>r$�
_to_key_pairs)r�r4rdr��	key_pairsr�r�r��list_key_pairs�s��z BaseEC2NodeDriver.list_key_pairscCs@d|d�}|jj|j|d�}t|jdtd�}|j|d�d}|S)Nr��r1rhr3r�r5r�rr�)r�rHr4rdr��key_pairr�r�r��get_key_pair�s��zBaseEC2NodeDriver.get_key_paircCs2d|d�}|jj|j|d�}|j}|j|d�}|S)NZ
CreateKeyPairr�r3�rC)r�r<r=r>�_to_key_pair)r�rHr4rdrCr�r�r�r��create_key_pair�s�z!BaseEC2NodeDriver.create_key_paircCsFtt�t|���}d||d�}|jj|j|d�}|j}|j|d�}|S)NZ
ImportKeyPair)r1rhZPublicKeyMaterialr3r�)	rr|r}rr�r<r=r>r�)r�rH�key_materialZ	base64keyr4rdrCr�r�r�r��import_key_pair_from_string�s�z-BaseEC2NodeDriver.import_key_pair_from_stringcCs*d|jd�}|jj|j|d�j}|�|�S)NZ
DeleteKeyPairr�r3)rHr�r<r=r>r�)r�r�r4r�r�r�r��delete_key_pair	s
�z!BaseEC2NodeDriver.delete_key_paircCsLd||jd�}|dur||d<|dur.||d<|�|jj|j|d�j�}|S)a�
        Copy an Amazon Machine Image from the specified source region
        to the current region.

        @inherits: :class:`NodeDriver.copy_image`

        :param      source_region: The region where the image resides
        :type       source_region: ``str``

        :param      image: Instance of class NodeImage
        :type       image: :class:`NodeImage`

        :param      name: The name of the new image
        :type       name: ``str``

        :param      description: The description of the new image
        :type       description: ``str``

        :return:    Instance of class ``NodeImage``
        :rtype:     :class:`NodeImage`
        Z	CopyImage)r1ZSourceRegionZ
SourceImageIdNror�r3)rG�	_to_imager�r<r=r>)r�r��
source_regionrHr�r4r�r�r��
copy_image
	s��zBaseEC2NodeDriver.copy_imagecCsXd|j||d�}|dur"||d<|dur:|�|�|��|�|jj|j|d�j�}|S)a�
        Create an Amazon Machine Image based off of an EBS-backed instance.

        @inherits: :class:`NodeDriver.create_image`

        :param      node: Instance of ``Node``
        :type       node: :class: `Node`

        :param      name: The name for the new image
        :type       name: ``str``

        :param      block_device_mapping: A dictionary of the disk layout
                                          An example of this dict is included
                                          below.
        :type       block_device_mapping: ``list`` of ``dict``

        :param      reboot: Whether or not to shutdown the instance before
                               creation. Amazon calls this NoReboot and
                               sets it to false by default to ensure a
                               clean image.
        :type       reboot: ``bool``

        :param      description: An optional description for the new image
        :type       description: ``str``

        An example block device mapping dictionary is included:

        mapping = [{'VirtualName': None,
                    'Ebs': {'VolumeSize': 10,
                            'VolumeType': 'standard',
                            'DeleteOnTermination': 'true'},
                            'DeviceName': '/dev/sda1'}]

        :return:    Instance of class ``NodeImage``
        :rtype:     :class:`NodeImage`
        ZCreateImage)r1r2roZNoRebootNr�r3)rGr9rr�r�r<r=r>)r�r�rHr�Zreboot�block_device_mappingr4r�r�r�r��create_image2	s&���zBaseEC2NodeDriver.create_imagecCs*d|jd�}|jj|j|d�j}|�|�S)z�
        Deletes an image at Amazon given a NodeImage object

        @inherits: :class:`NodeDriver.delete_image`

        :param image: Instance of ``NodeImage``
        :type image: :class: `NodeImage`

        :rtype:     ``bool``
        ZDeregisterImage)r1rfr3r�)r�r�r4rdr�r�r��delete_imagei	s
�zBaseEC2NodeDriver.delete_imagecCs<ddi}|�|�d|jg��|jj|j|d�j}|�|�S)z�
        Starts the node by passing in the node object, does not work with
        instance store backed instances.

        :param      node: The node to be used
        :type       node: :class:`Node`

        :rtype: ``bool``
        r1ZStartInstancesr2r3�r9r:rGr�r<r=r>�_get_state_booleanr�r�r�r��
start_nodez	s
zBaseEC2NodeDriver.start_nodecCs<ddi}|�|�d|jg��|jj|j|d�j}|�|�S)z�
        Stops the node by passing in the node object, does not work with
        instance store backed instances

        :param      node: The node to be used
        :type       node: :class:`Node`

        :rtype: ``bool``
        r1Z
StopInstancesr2r3r�r�r�r�r��	stop_node�	s
zBaseEC2NodeDriver.stop_nodecCs*dd|d�}|jj|j|d�j}|�|�S)z�
        Creates a new placement group.

        :param name: The name for the new placement group
        :type name: ``str``

        :rtype: ``bool``
        ZCreatePlacementGroupr)r1ZStrategy�	GroupNamer3�r�r<r=r>r��r�rHr4rdr�r�r��ex_create_placement_group�	s	�z+BaseEC2NodeDriver.ex_create_placement_groupcCs(d|d�}|jj|j|d�j}|�|�S)z�
        Deletes a placement group.

        :param name: The placement group name
        :type name: ``str``

        :rtype: ``bool``
        ZDeletePlacementGroup�r1r�r3r�r�r�r�r��ex_delete_placement_group�	s
	�z+BaseEC2NodeDriver.ex_delete_placement_groupcCs�ddi}|dur||d<|dur(||d<|dur@|�|�|��|durP||d<|dur`||d<|jj|j|d�j}t|d	td
�}	|j|	ddd
�}
|
S)a�
        Imports a disk into an EBS snapshot. More information can be found
        at https://goo.gl/sbXkYA.

        :param  client_data: Describes the client specific data (optional)
        :type   client_data: ``dict``

        :param  client_token: The token to enable idempotency for VM
                import requests.(optional)
        :type   client_token: ``str``

        :param  description: The description string for the
                             import snapshot task.(optional)
        :type   description: ``str``

        :param  disk_container:The disk container object for the
                              import snapshot request.
        :type   disk_container:``dict``

        :param  dry_run: Checks whether you have the permission for
                        the action, without actually making the request,
                        and provides an error response.(optional)
        :type   dry_run: ``bool``

        :param  role_name: The name of the role to use when not using the
                          default role, 'vmimport'.(optional)
        :type   role_name: ``str``

        :rtype: :class: ``VolumeSnapshot``
        r1ZImportSnapshotNrjr��DryRunZRoleNamer3�importTaskIdr5��)�import_task_id�timeout�interval)	r9�_get_disk_container_paramsr�r<r=r>rr$�$_wait_for_import_snapshot_completion)r��client_datar�r��disk_container�dry_runZ	role_namer4ZimportSnapshotr��volumeSnapshotr�r�r��ex_import_snapshot�	s,"
���z$BaseEC2NodeDriver.ex_import_snapshotr�r�cCsdt��}d}|durTt��||kr0td|��|�|�}|j}|durt�|�qt||d�}|S)a�
        It waits for import snapshot to be completed

        :param import_task_id: Import task Id for the
                               current Import Snapshot Task
        :type import_task_id: ``str``

        :param timeout: Timeout value for snapshot generation
        :type timeout: ``float``

        :param interval: Time interval for repetative describe
                         import snapshot tasks requests
        :type interval: ``float``

        :rtype: :class:``VolumeSnapshot``
        Nz+Timeout while waiting for import task Id %s)r�)�timer��!ex_describe_import_snapshot_tasksr��sleepr)r�r�r�r�r�r�r�r�r�r�r�r��	s�
z6BaseEC2NodeDriver._wait_for_import_snapshot_completioncCs>ddi}|dur||d<||d<|�|jj|j|d�j�}|S)aB
        Describes your import snapshot tasks. More information can be found
        at https://goo.gl/CI0MdS.

        :param import_task_id: Import task Id for the current
                               Import Snapshot Task
        :type import_task_id: ``str``

        :param  dry_run: Checks whether you have the permission for
                        the action, without actually making the request,
                        and provides an error response.(optional)
        :type   dry_run: ``bool``

        :rtype: :class:``DescribeImportSnapshotTasks Object``

        r1ZDescribeImportSnapshotTasksNr�zImportTaskId.1r3)�_to_import_snapshot_taskr�r<r=r>)r�r�r�r4r�r�r�r�r�
s�z3BaseEC2NodeDriver.ex_describe_import_snapshot_taskscCsP|pg}ddi}t|�D]\}}||d|d<q|jj|j|d�j}|�|�S)z�
        A list of placement groups.

        :param names: Placement Group names
        :type names: ``list`` of ``str``

        :rtype: ``list`` of :class:`.EC2PlacementGroup`
        r1ZDescribePlacementGroups�GroupName.%srTr3)rUr�r<r=r>�_to_placement_groups)r��namesr4rXrHrdr�r�r��ex_list_placement_groups:
s	z*BaseEC2NodeDriver.ex_list_placement_groupsc
Cs�d|d�}
|dur||
d<|dur*||
d<|dur:||
d<|durJ||
d<|durb|
�|�|��|durr||
d<|dur�||
d	<|	dur�|	|
d
<|
dur�|
|
d<|dur�|
�|�|��|dur�||
d<|�|jj|j|
d
�j�}|S)a�
        Registers an Amazon Machine Image based off of an EBS-backed instance.
        Can also be used to create images from snapshots. More information
        can be found at http://goo.gl/hqZq0a.

        :param      name:  The name for the AMI being registered
        :type       name: ``str``

        :param      description: The description of the AMI (optional)
        :type       description: ``str``

        :param      architecture: The architecture of the AMI (i386/x86_64)
                                  (optional)
        :type       architecture: ``str``

        :param      image_location: The location of the AMI within Amazon S3
                                    Required if registering an instance
                                    store-backed AMI
        :type       image_location: ``str``

        :param      root_device_name: The device name for the root device
                                      Required if registering an EBS-backed AMI
        :type       root_device_name: ``str``

        :param      block_device_mapping: A dictionary of the disk layout
                                          (optional)
        :type       block_device_mapping: ``dict``

        :param      kernel_id: Kernel id for AMI (optional)
        :type       kernel_id: ``str``

        :param      ramdisk_id: RAM disk for AMI (optional)
        :type       ramdisk_id: ``str``

        :param      virtualization_type: The type of virtualization for the
                                         AMI you are registering, paravirt
                                         or hvm (optional)
        :type       virtualization_type: ``str``

        :param      ena_support: Enable enhanced networking with Elastic
                                 Network Adapter for the AMI
        :type       ena_support: ``bool``

        :param      billing_products: The billing product codes
        :type       billing_products: ''list''

        :param      sriov_net_support: Set to "simple" to enable enhanced
                                       networking with the Intel 82599 Virtual
                                       Function interface
        :type       sriov_net_support: ``str``

        :rtype:     :class:`NodeImage`
        Z
RegisterImage)r1roNr�ZArchitectureZ
ImageLocationZRootDeviceNameZKernelIdZ	RamDiskIdZVirtualizationTypeZ
EnaSupportZSriovNetSupportr3)r9r�_get_billing_product_paramsr�r�r<r=r>)r�rHr�r�r�r�r�r�r�r�r��billing_productsr�r4r�r�r�r��ex_register_imageL
sB<����z#BaseEC2NodeDriver.ex_register_imagecCsLddi}|r|�|�d|��|r2|�|�|��|�|jj|j|d�j�S)a�
        Returns a list of :class:`EC2Network` objects for the
        current region.

        :param      network_ids: Returns only networks matching the provided
                                 network IDs. If not specified, a list of all
                                 the networks in the corresponding region
                                 is returned.
        :type       network_ids: ``list``

        :param      filters: The filters so that the list returned includes
                             information for certain networks only.
        :type       filters: ``dict``

        :rtype:     ``list`` of :class:`EC2Network`
        r1ZDescribeVpcs�VpcIdr3)r9r:r;�_to_networksr�r<r=r>)r�Znetwork_ids�filtersr4r�r�r��ex_list_networks�
s�z"BaseEC2NodeDriver.ex_list_networks�defaultcCshd||d�}|jj|j|d�j}|�tdtd��d}|�||�}|rd|�|d|i�rd||j	dd<|S)	a@
        Create a network/VPC

        :param      cidr_block: The CIDR block assigned to the network
        :type       cidr_block: ``str``

        :param      name: An optional name for the network
        :type       name: ``str``

        :param      instance_tenancy: The allowed tenancy of instances launched
                                      into the VPC.
                                      Valid values: default/dedicated
        :type       instance_tenancy: ``str``

        :return:    Dictionary of network properties
        :rtype:     ``dict``
        Z	CreateVpc)r1�	CidrBlockZInstanceTenancyr3�vpcrcrrors)
r�r<r=r>r
rr$�_to_networkr�r)r�r�rHr�r4rdr6r�r�r�r��ex_create_network�
s���z#BaseEC2NodeDriver.ex_create_networkcCs*d|jd�}|jj|j|d�j}|�|�S)z�
        Deletes a network/VPC.

        :param      vpc: VPC to delete.
        :type       vpc: :class:`.EC2Network`

        :rtype:     ``bool``
        Z	DeleteVpc�r1r�r3r�)r�r�r4r�r�r�r��ex_delete_network�
s	z#BaseEC2NodeDriver.ex_delete_networkcCsLddi}|r|�|�d|��|r2|�|�|��|�|jj|j|d�j�S)a�
        Returns a list of :class:`EC2NetworkSubnet` objects for the
        current region.

        :param      subnet_ids: Returns only subnets matching the provided
                                subnet IDs. If not specified, a list of all
                                the subnets in the corresponding region
                                is returned.
        :type       subnet_ids: ``list``

        :param      filters: The filters so that the list returned includes
                             information for certain subnets only.
        :type       filters: ``dict``

        :rtype:     ``list`` of :class:`EC2NetworkSubnet`
        r1ZDescribeSubnetsrnr3)r9r:r;�_to_subnetsr�r<r=r>)r�Z
subnet_idsr�r4r�r�r��ex_list_subnetss�z!BaseEC2NodeDriver.ex_list_subnetsc	Csjd|||d�}|jj|j|d�j}|�tdtd��d}|�||�}|rf|�|d|i�rf||j	dd<|S)	a�
        Creates a network subnet within a VPC.

        :param      vpc_id: The ID of the VPC that the subnet should be
                            associated with
        :type       vpc_id: ``str``

        :param      cidr_block: The CIDR block assigned to the subnet
        :type       cidr_block: ``str``

        :param      availability_zone: The availability zone where the subnet
                                       should reside
        :type       availability_zone: ``str``

        :param      name: An optional name for the network
        :type       name: ``str``

        :rtype:     :class: `EC2NetworkSubnet`
        ZCreateSubnet)r1r�r�r�r3r�rcrrors)
r�r<r=r>r
rr$�
_to_subnetr�r)	r�r�r�r�rHr4rdr6r�r�r�r��ex_create_subnets���z"BaseEC2NodeDriver.ex_create_subnet�auto_public_ipcCsZd|jd�}|dkr||d<n|dkr0||d<ntd|��|jj|j|d�j}|�|�S)	a
        Modifies a subnet attribute.
        You can only modify one attribute at a time.

        :param      subnet: The subnet to delete
        :type       subnet: :class:`.EC2NetworkSubnet`

        :param      attribute: The attribute to set on the subnet; one of:
                               ``'auto_public_ip'``: Automatically allocate a
                               public IP address when a server is created
                               ``'auto_ipv6'``: Automatically assign an IPv6
                               address when a server is created
        :type       attribute: ``str``

        :param      value: The value to set the subnet attribute to
                           (defaults to ``False``)
        :type       value: ``bool``

        :rtype:     ``bool``
        ZModifySubnetAttribute�r1rnr�zMapPublicIpOnLaunch.ValueZ	auto_ipv6z!AssignIpv6AddressOnCreation.ValuezUnsupported attribute: %sr3)rGrtr�r<r=r>r�)r�r��	attribute�valuer4r�r�r�r��ex_modify_subnet_attributeCs

z,BaseEC2NodeDriver.ex_modify_subnet_attributecCs*d|jd�}|jj|j|d�j}|�|�S)z�
        Deletes a VPC subnet.

        :param      subnet: The subnet to delete
        :type       subnet: :class:`.EC2NetworkSubnet`

        :rtype:     ``bool``
        ZDeleteSubnetr�r3r�)r�r�r4r�r�r�r��ex_delete_subnetfs	z"BaseEC2NodeDriver.ex_delete_subnetcCsPddi}|jj|j|d�j}g}t|dtd�D]}t|dtd�}|�|�q.|S)z�
        Lists existing Security Groups.

        @note: This is a non-standard extension API, and only works for EC2.

        :rtype: ``list`` of ``str``
        r1�DescribeSecurityGroupsr3�securityGroupInfo/itemr5�	groupName)r�r<r=r>r
r$rr�)r�r4rdr��grouprHr�r�r��ex_list_security_groupsus�
�z)BaseEC2NodeDriver.ex_list_security_groupsc	Cs~ddi}|r|�|�d|��|rLt|�D] \}}|d7}d|}|||<q*|r`|�|�|��|jj|j|d�}|�|j�S)a�
        Returns a list of :class:`EC2SecurityGroup` objects for the
        current region.

        :param      group_ids: Returns only groups matching the provided
                               group IDs.
        :type       group_ids: ``list``

        :param      group_names: Returns only groups matching the provided
                                 group names.
        :type       group_ids: ``list``

        :param      filters: The filters so that the list returned includes
                             information for specific security groups only.
        :type       filters: ``dict``

        :rtype:     ``list`` of :class:`EC2SecurityGroup`
        r1r��GroupIdrTr�r3)	r9r:rUr;r�r<r=�_to_security_groupsr>)	r�Z	group_idsZgroup_namesr�r4Zname_idx�
group_nameZname_keyrdr�r�r��ex_get_security_groups�s
z(BaseEC2NodeDriver.ex_get_security_groupscCsFd||d�}|dur||d<|jj|j|d�j}t|dtd�}d|iS)	a!
        Creates a new Security Group in EC2-Classic or a targeted VPC.

        :param      name:        The name of the security group to create.
                                 This must be unique.
        :type       name:        ``str``

        :param      description: Human readable description of a Security
                                 Group.
        :type       description: ``str``

        :param      vpc_id:      Optional identifier for VPC networks
        :type       vpc_id:      ``str``

        :rtype: ``dict``
        ZCreateSecurityGroup)r1r�ZGroupDescriptionNr�r3�groupIdr5�group_id)r�r<r=r>r	r$)r�rHr�r�r4rdrr�r�r��ex_create_security_group�s���z*BaseEC2NodeDriver.ex_create_security_groupcCs(d|d�}|jj|j|d�j}|�|�S)z�
        Deletes a new Security Group using the group ID.

        :param      group_id: The ID of the security group
        :type       group_id: ``str``

        :rtype: ``bool``
        �DeleteSecurityGroup)r1r�r3r�)r�rr4r�r�r�r��ex_delete_security_group_by_id�s	
z0BaseEC2NodeDriver.ex_delete_security_group_by_idcCs(d|d�}|jj|j|d�j}|�|�S)z�
        Deletes a new Security Group using the group name.

        :param      group_name: The name of the security group
        :type       group_name: ``str``

        :rtype: ``bool``
        rr�r3r�)r�r�r4r�r�r�r�� ex_delete_security_group_by_name�s	
z2BaseEC2NodeDriver.ex_delete_security_group_by_namecCs
|�|�S)z�
        A wrapper method which calls ex_delete_security_group_by_name.

        :param      name: The name of the security group
        :type       name: ``str``

        :rtype: ``bool``
        )r�r�rHr�r�r��ex_delete_security_group�s	z*BaseEC2NodeDriver.ex_delete_security_group�tcpc	
Cs�d||t|�t|�|d�}z$|jj|j|��d�j}|�|�WStyz}z$|jd�	d�dkrf|�WYd}~n
d}~00dS)a�
        Edit a Security Group to allow specific traffic.

        @note: This is a non-standard extension API, and only works for EC2.

        :param      name: The name of the security group to edit
        :type       name: ``str``

        :param      from_port: The beginning of the port range to open
        :type       from_port: ``str``

        :param      to_port: The end of the port range to open
        :type       to_port: ``str``

        :param      cidr_ip: The ip to allow traffic for.
        :type       cidr_ip: ``str``

        :param      protocol: tcp/udp/icmp
        :type       protocol: ``str``

        :rtype: ``bool``
        �AuthorizeSecurityGroupIngress�r1r��
IpProtocol�FromPort�ToPortZCidrIpr3r�InvalidPermission.Duplicater�N)
r�r�r<r=rJr>r�r��args�find)	r�rH�	from_port�to_port�cidr_ip�protocolr4r��er�r�r��ex_authorize_security_group�s�
�z-BaseEC2NodeDriver.ex_authorize_security_groupc
	Cs<|�|||||||�}d|d<|jj|j|d�j}	|�|	�S)a�
        Edit a Security Group to allow specific ingress traffic using
        CIDR blocks or either a group ID, group name or user ID (account).

        :param      id: The id of the security group to edit
        :type       id: ``str``

        :param      from_port: The beginning of the port range to open
        :type       from_port: ``int``

        :param      to_port: The end of the port range to open
        :type       to_port: ``int``

        :param      cidr_ips: The list of IP ranges to allow traffic for.
        :type       cidr_ips: ``list``

        :param      group_pairs: Source user/group pairs to allow traffic for.
                    More info can be found at http://goo.gl/stBHJF

                    EC2 Classic Example: To allow access from any system
                    associated with the default group on account 1234567890

                    [{'group_name': 'default', 'user_id': '1234567890'}]

                    VPC example: To allow access from any system associated
                    with security group sg-47ad482e on your own account

                    [{'group_id': ' sg-47ad482e'}]
        :type       group_pairs: ``list`` of ``dict``

        :param      protocol: tcp/udp/icmp
        :type       protocol: ``str``

        :param      description: description to be added to the rules inserted
        :type       description: ``str``

        :rtype: ``bool``
        r	r1r3��!_get_common_security_group_paramsr�r<r=r>r�)
r�rGrr�cidr_ips�group_pairsrr�r4r�r�r�r��#ex_authorize_security_group_ingresss*�z5BaseEC2NodeDriver.ex_authorize_security_group_ingressc	Cs:|�||||||�}d|d<|jj|j|d�j}|�|�S)ar
        Edit a Security Group to allow specific egress traffic using
        CIDR blocks or either a group ID, group name or user ID (account).
        This call is not supported for EC2 classic and only works for VPC
        groups.

        :param      id: The id of the security group to edit
        :type       id: ``str``

        :param      from_port: The beginning of the port range to open
        :type       from_port: ``int``

        :param      to_port: The end of the port range to open
        :type       to_port: ``int``

        :param      cidr_ips: The list of ip ranges to allow traffic for.
        :type       cidr_ips: ``list``

        :param      group_pairs: Source user/group pairs to allow traffic for.
                    More info can be found at http://goo.gl/stBHJF

                    EC2 Classic Example: To allow access from any system
                    associated with the default group on account 1234567890

                    [{'group_name': 'default', 'user_id': '1234567890'}]

                    VPC Example: Allow access from any system associated with
                    security group sg-47ad482e on your own account

                    [{'group_id': ' sg-47ad482e'}]
        :type       group_pairs: ``list`` of ``dict``

        :param      protocol: tcp/udp/icmp
        :type       protocol: ``str``

        :rtype: ``bool``
        ZAuthorizeSecurityGroupEgressr1r3r�	r�rGrrrrrr4r�r�r�r��"ex_authorize_security_group_egressVs)�z4BaseEC2NodeDriver.ex_authorize_security_group_egressc	Cs:|�||||||�}d|d<|jj|j|d�j}|�|�S)a
        Edits a Security Group to revoke specific ingress traffic using
        CIDR blocks or either a group ID, group name or user ID (account).

        :param      id: The ID of the security group to edit
        :type       id: ``str``

        :param      from_port: The beginning of the port range to open
        :type       from_port: ``int``

        :param      to_port: The end of the port range to open
        :type       to_port: ``int``

        :param      cidr_ips: The list of ip ranges to allow traffic for.
        :type       cidr_ips: ``list``

        :param      group_pairs: Source user/group pairs to allow traffic for.
                    More info can be found at http://goo.gl/stBHJF

                    EC2 Classic Example: To allow access from any system
                    associated with the default group on account 1234567890

                    [{'group_name': 'default', 'user_id': '1234567890'}]

                    VPC Example: Allow access from any system associated with
                    security group sg-47ad482e on your own account

                    [{'group_id': ' sg-47ad482e'}]
        :type       group_pairs: ``list`` of ``dict``

        :param      protocol: tcp/udp/icmp
        :type       protocol: ``str``

        :rtype: ``bool``
        ZRevokeSecurityGroupIngressr1r3rrr�r�r�� ex_revoke_security_group_ingress�s'�z2BaseEC2NodeDriver.ex_revoke_security_group_ingressc	Cs:|�||||||�}d|d<|jj|j|d�j}|�|�S)as
        Edit a Security Group to revoke specific egress traffic using
        CIDR blocks or either a group ID, group name or user ID (account).
        This call is not supported for EC2 classic and only works for
        VPC groups.

        :param      id: The id of the security group to edit
        :type       id: ``str``

        :param      from_port: The beginning of the port range to open
        :type       from_port: ``int``

        :param      to_port: The end of the port range to open
        :type       to_port: ``int``

        :param      cidr_ips: The list of ip ranges to allow traffic for.
        :type       cidr_ips: ``list``

        :param      group_pairs: Source user/group pairs to allow traffic for.
                    More info can be found at http://goo.gl/stBHJF

                    EC2 Classic Example: To allow access from any system
                    associated with the default group on account 1234567890

                    [{'group_name': 'default', 'user_id': '1234567890'}]

                    VPC Example: Allow access from any system associated with
                    security group sg-47ad482e on your own account

                    [{'group_id': ' sg-47ad482e'}]
        :type       group_pairs: ``list`` of ``dict``

        :param      protocol: tcp/udp/icmp
        :type       protocol: ``str``

        :rtype: ``bool``
        ZRevokeSecurityGroupEgressr1r3rrr�r�r��ex_revoke_security_group_egress�s)�z1BaseEC2NodeDriver.ex_revoke_security_group_egressc
CsXg}d|ddddd�}z"|�|jj|j|��d�j�Wn<tyt}z$|jd�d	�d
kr`|�WYd}~n
d}~00d|d
<z"|�|jj|j|��d�j�Wn<ty�}z$|jd�d	�d
kr�|�WYd}~n
d}~00|�	dddd��z"|�|jj|j|��d�j�Wn@t�yR}z&|jd�d	�d
k�r>|�WYd}~n
d}~00|S)a
        Edit a Security Group to allow all traffic.

        @note: This is a non-standard extension API, and only works for EC2.

        :param      name: The name of the security group to edit
        :type       name: ``str``

        :rtype: ``list`` of ``str``
        r	rrlZ65535z	0.0.0.0/0r
r3rrr�NZudprZicmpz-1)rrr
)
r�r�r<r=rJr>r�rrr9)r�rH�resultsr4rr�r�r��&ex_authorize_security_group_permissive�s@����z8BaseEC2NodeDriver.ex_authorize_security_group_permissiveTcCs�ddi}d|ji}|rd|d<|�|�|��|jj|j|��d�j}g}t|dt	d�D]F}t
|d	t	d�}t
|d
t	d�}t
|dt	d�}	t|||	d�}
|�|
�qX|S)
a�
        Returns a list of :class:`ExEC2AvailabilityZone` objects for the
        current region.

        Note: This is an extension method and is only available for EC2
        driver.

        :keyword  only_available: If true, returns only availability zones
                                  with state 'available'
        :type     only_available: ``str``

        :rtype: ``list`` of :class:`ExEC2AvailabilityZone`
        r1ZDescribeAvailabilityZoneszregion-namer.r�r3zavailabilityZoneInfo/itemr5ZzoneNameZ	zoneStateZ
regionNamer)
r
r9r;r�r<r=rJr>r
r$rr;r�)r�Zonly_availabler4r��resultZavailability_zonesr6rHr	r
r�r�r�r�r\&
s:

��
����z,BaseEC2NodeDriver.ex_list_availability_zonescCs@ddi}d|ji}|�|�|��|jj|j|d�j}|�|�S)a]
        Returns a dictionary of tags for a resource (e.g. Node or
        StorageVolume).

        :param  resource: The resource to be used
        :type   resource: any resource class, such as :class:`Node,`
                :class:`StorageVolume,` or :class:NodeImage`

        :return: A dictionary of Node tags
        :rtype: ``dict``
        r1ZDescribeTagszresource-idr3)rGr9r;r�r<r=r>�_get_resource_tags)r��resourcer4r�r"r�r�r��ex_describe_tagsS
s�z"BaseEC2NodeDriver.ex_describe_tagscCsd|sdSd|jd�}t|�D]$\}}||d|<|||d|<q|jj|j|��d�j}|�|�S)a�
        Creates tags for a resource (Node or StorageVolume).

        :param resource: The resource to be tagged
        :type resource: :class:`Node` or :class:`StorageVolume` or
                        :class:`VolumeSnapshot`

        :param tags: A dictionary or other mapping of strings to strings,
                     associating tag names with tag values.
        :type tags: ``dict``

        :rtype: ``bool``
        NZ
CreateTags�r1zResourceId.0�
Tag.%d.Key�Tag.%d.Valuer3�rGrUr�r<r=rJr>r��r�r$rsr4�ir�r�r�r�r�r�k
s�
�z BaseEC2NodeDriver.ex_create_tagscCsp|sdSd|jd�}t|�D]0\}}||d|<||dur|||d|<q|jj|j|��d�j}|�|�S)aq
        Deletes tags from a resource.

        :param resource: The resource to be tagged
        :type resource: :class:`Node` or :class:`StorageVolume`

        :param tags: A dictionary or other mapping of strings to strings,
                     specifying the tag names and tag values to be deleted.
        :type tags: ``dict``

        :rtype: ``bool``
        NZ
DeleteTagsr&r'r(r3r)r*r�r�r��ex_delete_tags�
s
�
�z BaseEC2NodeDriver.ex_delete_tagscCs
|jdS)a.
        Returns the metadata associated with the node.

        :param      node: Node instance
        :type       node: :class:`Node`

        :return: A dictionary or other mapping of strings to strings,
                 associating tag names with tag values.
        :rtype tags: ``dict``
        rs�r�r�r�r�r�r��ex_get_metadata_for_node�
sz*BaseEC2NodeDriver.ex_get_metadata_for_nodecCs:ddi}|dkr||d<|jj|j|d�j}|j|dd�S)a2
        Allocate a new Elastic IP address for EC2 classic or VPC

        :param      domain: The domain to allocate the new address in
                            (standard/vpc)
        :type       domain: ``str``

        :return:    Instance of ElasticIP
        :rtype:     :class:`ElasticIP`
        r1ZAllocateAddressr��Domainr3F)�only_associated)r�r<r=r>�_to_address)r�rr4rdr�r�r��ex_allocate_address�
s
z%BaseEC2NodeDriver.ex_allocate_addresscCs`ddi}|dur |dkr td��|dur4|j|d<n|jd|d<|jj|j|d	�j}|�|�S)
a�
        Releases an Elastic IP address using the IP (EC2-Classic) or
        using the allocation ID (VPC).

        :param      elastic_ip: Elastic IP instance
        :type       elastic_ip: :class:`ElasticIP`

        :param      domain: The domain where the IP resides (vpc only)
        :type       domain: ``str``

        :return:    True on success, False otherwise.
        :rtype:     ``bool``
        r1ZReleaseAddressNr��Domain can only be set to vpc�PublicIpr��AllocationIdr3�ryrrr�r<r=r>r�)r�r�rr4rdr�r�r��ex_release_address�
sz$BaseEC2NodeDriver.ex_release_addresscCs(ddi}|jj|j|d�j}|�||�S)a�
        Returns all the Elastic IP addresses for this account
        optionally, returns only addresses associated with nodes.

        :param    only_associated: If true, return only the addresses
                                   that are associated with an instance.
        :type     only_associated: ``bool``

        :return:  List of Elastic IP addresses.
        :rtype:   ``list`` of :class:`ElasticIP`
        r1�DescribeAddressesr3)r�r<r=r>�
_to_addresses)r�r1r4rdr�r�r��ex_describe_all_addresses�
sz+BaseEC2NodeDriver.ex_describe_all_addressescCsxd|jd�}|dur$|dkr$td��|dur>|�d|ji�n|�d|jdi�|jj|j|d	�j}t	|d
t
d�}|S)aN
        Associate an Elastic IP address with a particular node.

        :param      node: Node instance
        :type       node: :class:`Node`

        :param      elastic_ip: Elastic IP instance
        :type       elastic_ip: :class:`ElasticIP`

        :param      domain: The domain where the IP resides (vpc only)
        :type       domain: ``str``

        :return:    A string representation of the association ID which is
                    required for VPC disassociation. EC2/standard
                    addresses return None
        :rtype:     ``None`` or ``str``
        ZAssociateAddress�r1r2Nr�r4r5r6r�r3r�r5)rGryr9rrr�r<r=r>rr$)r�r�r�rr4rdr�r�r�r��ex_associate_address_with_node�
s�z0BaseEC2NodeDriver.ex_associate_address_with_nodecCs|j|||d�S)zv
        Note: This method has been deprecated in favor of
        the ex_associate_address_with_node method.
        )r�r�r)r=)r�r�r�rr�r�r��ex_associate_addressess�z(BaseEC2NodeDriver.ex_associate_addressescCs`ddi}|dur |dkr td��|dur4|j|d<n|jd|d<|jj|j|d	�j}|�|�S)
a�
        Disassociates an Elastic IP address using the IP (EC2-Classic)
        or the association ID (VPC).

        :param      elastic_ip: ElasticIP instance
        :type       elastic_ip: :class:`ElasticIP`

        :param      domain: The domain where the IP resides (vpc only)
        :type       domain: ``str``

        :return:    True on success, False otherwise.
        :rtype:     ``bool``
        r1ZDisassociateAddressNr�r4r5r��
AssociationIdr3r7)r�r�rr4r�r�r�r��ex_disassociate_addresssz)BaseEC2NodeDriver.ex_disassociate_addressc
Cs�|siSddi}t|�dkr,|�||d�|jj|j|d�j}dd�|D�}i}d}|D]@}|�|g�|�||�D]"}|j}	||	krv||	�	|j
�qvqZ|S)	a�
        Returns Elastic IP addresses for all the nodes in the provided list.

        :param      nodes: A list of :class:`Node` instances
        :type       nodes: ``list`` of :class:`Node`

        :return:    Dictionary where a key is a node ID and the value is a
                    list with the Elastic IP addresses associated with
                    this node.
        :rtype:     ``dict``
        r1r9rTrr3cSsg|]
}|j�qSr�r)r�r�r�r�r�r�Qr�z;BaseEC2NodeDriver.ex_describe_addresses.<locals>.<listcomp>T)r��_add_instance_filterr�r<r=r>�
setdefaultr:r�r�r)
r�rDr4r"Znode_instance_ids�nodes_elastic_ip_mappingsr1Znode_id�addrr�r�r�r�r@;s(��z'BaseEC2NodeDriver.ex_describe_addressescCs|�|g�}||jS)a
        Returns a list of Elastic IP Addresses associated with this node.

        :param      node: Node instance
        :type       node: :class:`Node`

        :return: List Elastic IP Addresses attached to this node.
        :rtype: ``list`` of ``str``
        )r@rG)r�r�Znode_elastic_ipsr�r�r��ex_describe_addresses_for_nodees
z0BaseEC2NodeDriver.ex_describe_addresses_for_nodecCs"ddi}|�|jj|j|d�j�S)z�
        Returns all network interfaces.

        :return:    List of EC2NetworkInterface instances
        :rtype:     ``list`` of :class `EC2NetworkInterface`
        r1ZDescribeNetworkInterfacesr3)�_to_interfacesr�r<r=r>)r�r4r�r�r��ex_list_network_interfacests�z,BaseEC2NodeDriver.ex_list_network_interfacesc	Cs�d|jd�}|r||d<|r$||d<|jj|j|d�j}|�tdtd��d}|�||�}|r||�	|d	|i�r|||j
d
d	<|S)a
        Create a network interface within a VPC subnet.

        :param      subnet: EC2NetworkSubnet instance
        :type       subnet: :class:`EC2NetworkSubnet`

        :param      name:  Optional name of the interface
        :type       name:  ``str``

        :param      description:  Optional description of the network interface
        :type       description:  ``str``

        :param      private_ip_address: Optional address to assign as the
                                        primary private IP address of the
                                        interface. If one is not provided then
                                        Amazon will automatically auto-assign
                                        an available IP. EC2 allows assignment
                                        of multiple IPs, but this will be
                                        the primary.
        :type       private_ip_address: ``str``

        :return:    EC2NetworkInterface instance
        :rtype:     :class `EC2NetworkInterface`
        ZCreateNetworkInterfacer�r�ZPrivateIpAddressr3ZnetworkInterfacercrrors)rGr�r<r=r>r
rr$�
_to_interfacer�r)	r�r�rHr��private_ip_addressr4rdr6Z	interfacer�r�r��ex_create_network_interface�s"���z-BaseEC2NodeDriver.ex_create_network_interfacecCs*d|jd�}|jj|j|d�j}|�|�S)z�
        Deletes a network interface.

        :param      network_interface: EC2NetworkInterface instance
        :type       network_interface: :class:`EC2NetworkInterface`

        :rtype:     ``bool``
        ZDeleteNetworkInterface)r1�NetworkInterfaceIdr3r�)r�r�r4r�r�r�r��ex_delete_network_interface�s
	�z-BaseEC2NodeDriver.ex_delete_network_interfacecCs8d|j|j|d�}|jj|j|d�j}t|dtd�}|S)a
        Attach a network interface to an instance.

        :param      network_interface: EC2NetworkInterface instance
        :type       network_interface: :class:`EC2NetworkInterface`

        :param      node: Node instance
        :type       node: :class:`Node`

        :param      device_index: The interface device index
        :type       device_index: ``int``

        :return:    String representation of the attachment id.
                    This is required to detach the interface.
        :rtype:     ``str``
        ZAttachNetworkInterface)r1rKr2rmr3ZattachmentIdr5)rGr�r<r=r>r	r$)r�r�r�r�r4rdr�r�r�r��#ex_attach_network_interface_to_node�s��z5BaseEC2NodeDriver.ex_attach_network_interface_to_nodecCs4d|d�}|rd|d<|jj|j|d�j}|�|�S)a�
        Detach a network interface from an instance.

        :param      attachment_id: The attachment ID associated with the
                                   interface
        :type       attachment_id: ``str``

        :param      force: Forces the detachment.
        :type       force: ``bool``

        :return:    ``True`` on successful detachment, ``False`` otherwise.
        :rtype:     ``bool``
        ZDetachNetworkInterface)r1ZAttachmentIdTr�r3r�)r�r��forcer4r�r�r�r��ex_detach_network_interface�s�z-BaseEC2NodeDriver.ex_detach_network_interfacecCsL|pi}|�d|ji�ddi}|�|�|jj|j|��d�j}|�|�S)ax
        Modify node attributes.
        A list of valid attributes can be found at http://goo.gl/gxcj8

        :param      node: Node instance
        :type       node: :class:`Node`

        :param      attributes: Dictionary with node attributes
        :type       attributes: ``dict``

        :return: True on success, False otherwise.
        :rtype: ``bool``
        r2r1ZModifyInstanceAttributer3�r9rGr�r<r=rJr>r�)r�r�rQr4r�r�r�r��ex_modify_instance_attribute�s

�z.BaseEC2NodeDriver.ex_modify_instance_attributecCsL|pi}|�d|ji�ddi}|�|�|jj|j|��d�j}|�|�S)aV
        Modify Snapshot attributes.

        :param      snapshot: VolumeSnapshot instance
        :type       snanpshot: :class:`VolumeSnapshot`

        :param      attributes: Dictionary with snapshot attributes
        :type       attributes: ``dict``

        :return: True on success, False otherwise.
        :rtype: ``bool``
        r�r1ZModifySnapshotAttributer3rP)r�r�rQr4r�r�r�r��ex_modify_snapshot_attributes


�z.BaseEC2NodeDriver.ex_modify_snapshot_attributecCsL|pi}|�d|ji�ddi}|�|�|jj|j|��d�j}|�|�S)aB
        Modifies image attributes.

        :param      image: NodeImage instance
        :type       image: :class:`NodeImage`

        :param      attributes: A dictionary with node attributes
        :type       attributes: ``dict``

        :return: True on success, False otherwise.
        :rtype: ``bool``
        rfr1ZModifyImageAttributer3rP)r�r�rQr4r�r�r�r��ex_modify_image_attribute's


�z+BaseEC2NodeDriver.ex_modify_image_attributecCs>d|jvr&|jd}||jkr&td��d|ji}|j||d�S)ae
        Change the node size.
        Note: Node must be turned of before changing the size.

        :param      node: Node instance
        :type       node: :class:`Node`

        :param      new_size: NodeSize instance
        :type       new_size: :class:`NodeSize`

        :return: True on success, False otherwise.
        :rtype: ``bool``
        Zinstancetypez/New instance size is the same asthe current one�InstanceType.Value)r�rQ)rrGrtrQ)r�r��new_sizeZcurrent_instance_typerQr�r�r��ex_change_node_size?s



�z%BaseEC2NodeDriver.ex_change_node_sizecCs|j|d�S�N)r�)r�r.r�r�r��
ex_start_nodeXszBaseEC2NodeDriver.ex_start_nodecCs|j|d�SrW)r�r.r�r�r��ex_stop_node^szBaseEC2NodeDriver.ex_stop_nodecCspd|jd�}|jj|j|d�j}t|dtd�}t|dtd�}t|�}|r^t�	t
|���d�}nd}|j||d	�S)
a�
        Gets console output for the node.

        :param      node: Node which should be used
        :type       node: :class:`Node`

        :return:    A dictionary with the following keys:
                    - instance_id (``str``)
                    - timestamp (``datetime.datetime``) - last output timestamp
                    - output (``str``) - console output
        :rtype:     ``dict``
        ZGetConsoleOutputr<r3�	timestampr5�outputriN)r�rZr[)rGr�r<r=r>r	r$r
r|�	b64decoderr~)r�r�r4rdrZ�encoded_stringr[r�r�r��ex_get_console_outputds(����z'BaseEC2NodeDriver.ex_get_console_outputcCs(ddi}|jj|j|d�j}|�|d�S)aO
        Lists all reserved instances/nodes which can be purchased from Amazon
        for one or three year terms. Reservations are made at a region level
        and reduce the hourly charge for instances.

        More information can be found at http://goo.gl/ulXCC7.

        :rtype: ``list`` of :class:`.EC2ReservedNode`
        r1ZDescribeReservedInstancesr3zreservedInstancesSet/item)r�r<r=r>�_to_reserved_nodes�r�r4rdr�r�r��ex_list_reserved_nodes�s
z(BaseEC2NodeDriver.ex_list_reserved_nodescCs�gd�}i}d|d<t|�D]\}}||d|<q|jj|j|d�}|j}|�tdtd��}dii}|D]0}	t|	d	td
�}
t|	dtd
�}t	|�|d|
<qh|S)zM
        Retrieve account resource limits.

        :rtype: ``dict``
        )z
max-instanceszmax-elastic-ipszvpc-max-elastic-ipsZDescribeAccountAttributesr1zAttributeName.%sr3zaccountAttributeSet/itemrcr$Z
attributeNamer5z%attributeValueSet/item/attributeValue)
rUr�r<r=r>r
rr$r�int)r�rQr4rXr�rd�datar�r"rCrHr�r�r�r��
ex_get_limits�s*���zBaseEC2NodeDriver.ex_get_limitscCs<t�d�|��}g}|D]}|j|jd�}|�|�q|S)ze
        Lists all the keypair names and fingerprints.

        :rtype: ``list`` of ``dict``
        zAThis method has been deprecated in favor of list_key_pairs method�r��keyFingerprint)�warnings�warnr�rH�fingerprintr�)r�r�r"r��itemr�r�r��ex_list_keypairs�s
�z"BaseEC2NodeDriver.ex_list_keypairscCsdd�|��D�}|S)z�
        Returns names for all the available key pairs.

        @note: This is a non-standard extension API, and only works for EC2.

        :rtype: ``list`` of ``str``
        cSsg|]
}|j�qSr�r��r�r�r�r�r�r��r�z>BaseEC2NodeDriver.ex_describe_all_keypairs.<locals>.<listcomp>)r�)r�r�r�r�r��ex_describe_all_keypairs�sz*BaseEC2NodeDriver.ex_describe_all_keypairscCs|j|d�S)z2
        Here for backward compatibility.
        r�)�ex_describe_keypairrr�r�r��ex_describe_keypairs�sz&BaseEC2NodeDriver.ex_describe_keypairscCsHd|d�}|jj|j|d�j}t|dtd�}t|dtd���}||d�S)z�
        Describes a keypair by name.

        @note: This is a non-standard extension API, and only works for EC2.

        :param      name: The name of the keypair to describe.
        :type       name: ``str``

        :rtype: ``dict``
        r�)r1z	KeyName.1r3zkeySet/item/keyNamer5zkeySet/item/keyFingerprintre)r�r<r=r>r	r$�strip)r�rHr4rdr�rir�r�r�rn�s
���
�z%BaseEC2NodeDriver.ex_describe_keypaircCs(t�d�|j|d�}|j|jd�}|S)aK
        Creates a new keypair

        @note: This is a non-standard extension API, and only works for EC2.

        :param      name: The name of the keypair to Create. This must be
            unique, otherwise an InvalidKeyPair.Duplicate exception is raised.
        :type       name: ``str``

        :rtype: ``dict``
        zBThis method has been deprecated in favor of create_key_pair methodr�)�keyMaterialrf)rgrhr��private_keyri)r�rHr�r"r�r�r��ex_create_keypairs
�z#BaseEC2NodeDriver.ex_create_keypaircCs$t�d�t|dd|d�}|�|�S)z�
        Deletes a key pair by name.

        @note: This is a non-standard extension API, and only works with EC2.

        :param      keypair: The name of the keypair to delete.
        :type       keypair: ``str``

        :rtype: ``bool``
        zBThis method has been deprecated in favor of delete_key_pair methodN)rH�
public_keyrir�)rgrhrr�)r�Zkeypairr�r�r��ex_delete_keypairs

�z#BaseEC2NodeDriver.ex_delete_keypaircCs*t�d�|j||d�}|j|jd�}|S)a�
        Imports a new public key where the public key is passed in as a string.

        @note: This is a non-standard extension API, and only works for EC2.

        :param      name: The name of the public key to import. This must be
         unique, otherwise an InvalidKeyPair.Duplicate exception is raised.
        :type       name: ``str``

        :param     key_material: The contents of a public key file.
        :type      key_material: ``str``

        :rtype: ``dict``
        zNThis method has been deprecated in favor of import_key_pair_from_string method)rHr�re)rgrhr�rHri)r�rHr�r�r"r�r�r��ex_import_keypair_from_string/s
��z/BaseEC2NodeDriver.ex_import_keypair_from_stringcCs*t�d�|j||d�}|j|jd�}|S)a>
        Imports a new public key where the public key is passed via a filename.

        @note: This is a non-standard extension API, and only works for EC2.

        :param      name: The name of the public key to import. This must be
                          unique, otherwise an InvalidKeyPair. Duplicate
                          exception is raised.
        :type       name: ``str``

        :param     keyfile: The filename with the path of the public key
                            to import.
        :type      keyfile: ``str``

        :rtype: ``dict``
        zLThis method has been deprecated in favor of import_key_pair_from_file method)rHZ
key_file_pathre)rgrhZimport_key_pair_from_filerHri)r�rH�keyfiler�r"r�r�r��ex_import_keypairJs
��z#BaseEC2NodeDriver.ex_import_keypaircsnt|��t|dd�}d|�f}|��}�fdd�|D�}t|�dkr^|d}|j|jd�}n|�||�}|S)	a

        Given a public key, look it up in the EC2 KeyPair database. If it
        exists, return any information we have about it. Otherwise, create it.

        Keys that are created are named based on their comment and fingerprint.

        :rtype: ``dict``
        �unnamed)r�z%s-%scsg|]}|j�kr|�qSr�)rirl�Zkey_fingerprintr�r�r�us
�zOBaseEC2NodeDriver.ex_find_or_import_keypair_by_key_material.<locals>.<listcomp>rTrre)rrr�r�rHrirv)r�r{Zkey_commentr�r�r�r"r�rzr�rzgs	�z;BaseEC2NodeDriver.ex_find_or_import_keypair_by_key_materialcCsRddi}|r|�|�d|��|r2|�|�|��|jj|j|d�j}|�|d�S)a
        Describes available Internet gateways and whether or not they are
        attached to a VPC. These are required for VPC nodes to communicate
        over the Internet.

        :param      gateway_ids: Returns only Internet gateways matching the
                                 provided Internet gateway IDs. If not
                                 specified, a list of all the Internet
                                 gateways in the corresponding region is
                                 returned.
        :type       gateway_ids: ``list``

        :param      filters: The filters so the list returned inclues
                             information for certain gateways only.
        :type       filters: ``dict``

        :rtype: ``list`` of :class:`.VPCInternetGateway`
        r1ZDescribeInternetGateways�InternetGatewayIdr3zinternetGatewaySet/item)r9r:r;r�r<r=r>�_to_internet_gateways)r�Zgateway_idsr�r4rdr�r�r��ex_list_internet_gateways�sz+BaseEC2NodeDriver.ex_list_internet_gatewayscCsdddi}|jj|j|d�j}|�tdtd��}|�|d|�}|r`|�|d|i�r`||j	dd<|S)	zM
        Delete a VPC Internet gateway

        :rtype:     ``bool``
        r1ZCreateInternetGatewayr3ZinternetGatewayrcrrors)
r�r<r=r>r
rr$�_to_internet_gatewayr�r)r�rHr4�respr6�gatewayr�r�r��ex_create_internet_gateway�s�z,BaseEC2NodeDriver.ex_create_internet_gatewaycCs*d|jd�}|jj|j|d�j}|�|�S)z�
        Deletes a VPC Internet gateway.

        :param      gateway: The gateway to delete
        :type       gateway: :class:`.VPCInternetGateway`

        :rtype:     ``bool``
        ZDeleteInternetGateway)r1r{r3r�)r�r�r4r�r�r�r��ex_delete_internet_gateway�s
	�z,BaseEC2NodeDriver.ex_delete_internet_gatewaycCs.d|j|jd�}|jj|j|d�j}|�|�S)a.
        Attach an Internet gateway to a VPC

        :param      gateway: The gateway to attach
        :type       gateway: :class:`.VPCInternetGateway`

        :param      network: The VPC network to attach to
        :type       network: :class:`.EC2Network`

        :rtype:     ``bool``
        ZAttachInternetGateway�r1r{r�r3r��r�r�r�r4r�r�r�r��ex_attach_internet_gateway�s�z,BaseEC2NodeDriver.ex_attach_internet_gatewaycCs.d|j|jd�}|jj|j|d�j}|�|�S)a5
        Detaches an Internet gateway from a VPC.

        :param      gateway: The gateway to detach
        :type       gateway: :class:`.VPCInternetGateway`

        :param      network: The VPC network to detach from
        :type       network: :class:`.EC2Network`

        :rtype:     ``bool``
        ZDetachInternetGatewayr�r3r�r�r�r�r��ex_detach_internet_gateway�s�z,BaseEC2NodeDriver.ex_detach_internet_gatewaycCsPddi}|r|�|�d|��|r2|�|�|��|jj|j|d�}|�|j�S)a�
        Describes one or more of a VPC's route tables.
        These are used to determine where network traffic is directed.

        :param      route_table_ids: Returns only route tables matching the
                                provided route table IDs. If not specified,
                                a list of all the route tables in the
                                corresponding region is returned.
        :type       route_table_ids: ``list``

        :param      filters: The filters so that the list returned includes
                             information for certain route tables only.
        :type       filters: ``dict``

        :rtype: ``list`` of :class:`.EC2RouteTable`
        r1ZDescribeRouteTables�RouteTableIdr3)r9r:r;r�r<r=�_to_route_tablesr>)r�Zroute_table_idsr�r4rdr�r�r��ex_list_route_tables�sz&BaseEC2NodeDriver.ex_list_route_tablescCsjd|jd�}|jj|j|d�j}|�tdtd��d}|j||d�}|rf|�	|d|i�rf||j
d	d<|S)
z�
        Creates a route table within a VPC.

        :param      vpc_id: The VPC that the subnet should be created in.
        :type       vpc_id: :class:`.EC2Network`

        :rtype:     :class: `.EC2RouteTable`
        ZCreateRouteTabler�r3Z
routeTablercrr�rors)rGr�r<r=r>r
rr$�_to_route_tabler�r)r�r�rHr4rdr6r�r�r�r��ex_create_route_tables	���z'BaseEC2NodeDriver.ex_create_route_tablecCs*d|jd�}|jj|j|d�j}|�|�S)z�
        Deletes a VPC route table.

        :param      route_table: The route table to delete.
        :type       route_table: :class:`.EC2RouteTable`

        :rtype:     ``bool``
        ZDeleteRouteTable)r1r�r3r�)r�r�r4r�r�r�r��ex_delete_route_table"s

�z'BaseEC2NodeDriver.ex_delete_route_tablecCs6d|j|jd�}|jj|j|d�j}t|dtd�}|S)a�
        Associates a route table with a subnet within a VPC.

        Note: A route table can be associated with multiple subnets.

        :param      route_table: The route table to associate.
        :type       route_table: :class:`.EC2RouteTable`

        :param      subnet: The subnet to associate with.
        :type       subnet: :class:`.EC2Subnet`

        :return:    Route table association ID.
        :rtype:     ``str``
        ZAssociateRouteTable)r1r�rnr3r�r5)rGr�r<r=r>rr$)r�r�r�r4r"r�r�r�r��ex_associate_route_table3s��z*BaseEC2NodeDriver.ex_associate_route_tablecCs>t|t�r|j}n|}d|d�}|jj|j|d�j}|�|�S)a[
        Dissociates a subnet from a route table.

        :param      subnet_association: The subnet association object or
                                        subnet association ID.
        :type       subnet_association: :class:`.EC2SubnetAssociation` or
                                        ``str``

        :rtype:     ``bool``
        ZDisassociateRouteTable)r1r?r3)rur:rGr�r<r=r>r�)r��subnet_association�subnet_association_idr4r�r�r�r��ex_dissociate_route_tableNs
�z+BaseEC2NodeDriver.ex_dissociate_route_tablecCsJt|t�r|j}n|}d||jd�}|jj|j|d�j}t|dtd�}|S)a
        Changes the route table associated with a given subnet in a VPC.

        Note: This method can be used to change which table is the main route
              table in the VPC (Specify the main route table's association ID
              and the route table to be the new main route table).

        :param      subnet_association: The subnet association object or
                                        subnet association ID.
        :type       subnet_association: :class:`.EC2SubnetAssociation` or
                                        ``str``

        :param      route_table: The new route table to associate.
        :type       route_table: :class:`.EC2RouteTable`

        :return:    A new route table association ID.
        :rtype:     ``str``
        ZReplaceRouteTableAssociation)r1r?r�r3ZnewAssociationIdr5)	rur:rGr�r<r=r>rr$)r�r�r�r�r4r"Znew_association_idr�r�r��"ex_replace_route_table_associationfs
��z4BaseEC2NodeDriver.ex_replace_route_table_associationc	Csdd|j|d�}|r|j|d<|r*|j|d<|r8|j|d<|rF|j|d<|jj|j|d�j}|�|�S)a`
        Creates a route entry in the route table.

        :param      route_table: The route table to create the route in.
        :type       route_table: :class:`.EC2RouteTable`

        :param      cidr: The CIDR block used for the destination match.
        :type       cidr: ``str``

        :param      internet_gateway: The Internet gateway to route
                                      traffic through.
        :type       internet_gateway: :class:`.VPCInternetGateway`

        :param      node: The NAT instance to route traffic through.
        :type       node: :class:`Node`

        :param      network_interface: The network interface of the node
                                       to route traffic through.
        :type       network_interface: :class:`.EC2NetworkInterface`

        :param      vpc_peering_connection: The VPC peering connection.
        :type       vpc_peering_connection: :class:`.VPCPeeringConnection`

        :rtype:     ``bool``

        Note: You must specify one of the following: internet_gateway,
              node, network_interface, vpc_peering_connection.
        ZCreateRoute�r1r�ZDestinationCidrBlock�	GatewayIdr2rK�VpcPeeringConnectionIdr3r��	r�r�r Zinternet_gatewayr�r�Zvpc_peering_connectionr4r�r�r�r��ex_create_route�s �



z!BaseEC2NodeDriver.ex_create_routecCs,d|j|d�}|jj|j|d�j}|�|�S)aL
        Deletes a route entry from the route table.

        :param      route_table: The route table to delete the route from.
        :type       route_table: :class:`.EC2RouteTable`

        :param      cidr: The CIDR block used for the destination match.
        :type       cidr: ``str``

        :rtype:     ``bool``
        ZDeleteRouter�r3r�)r�r�r r4r�r�r�r��ex_delete_route�s
�z!BaseEC2NodeDriver.ex_delete_routec	Csdd|j|d�}|r|j|d<|r*|j|d<|r8|j|d<|rF|j|d<|jj|j|d�j}|�|�S)a�
        Replaces an existing route entry within a route table in a VPC.

        :param      route_table: The route table to replace the route in.
        :type       route_table: :class:`.EC2RouteTable`

        :param      cidr: The CIDR block used for the destination match.
        :type       cidr: ``str``

        :param      internet_gateway: The new internet gateway to route
                                       traffic through.
        :type       internet_gateway: :class:`.VPCInternetGateway`

        :param      node: The new NAT instance to route traffic through.
        :type       node: :class:`Node`

        :param      network_interface: The new network interface of the node
                                       to route traffic through.
        :type       network_interface: :class:`.EC2NetworkInterface`

        :param      vpc_peering_connection: The new VPC peering connection.
        :type       vpc_peering_connection: :class:`.VPCPeeringConnection`

        :rtype:     ``bool``

        Note: You must specify one of the following: internet_gateway,
              node, network_interface, vpc_peering_connection.
        ZReplaceRouter�r�r2rKr�r3r�r�r�r�r��ex_replace_route�s �



z"BaseEC2NodeDriver.ex_replace_routecCsp|pi}|�d�}|r*|tvr*td|��|�d|jd��|jj|j|��d�j	}|�
|�tdt
d��d�S)	a�
        Modify volume parameters.
        A list of valid parameters can be found at https://goo.gl/N0rPEQ

        :param      volume: Volume instance
        :type       volume: :class:`Volume`

        :param      parameters: Dictionary with updated volume parameters
        :type       parameters: ``dict``

        :return: Volume modification status object
        :rtype: :class:`VolumeModification
        r�r�ZModifyVolumer�r3ZvolumeModificationrcr)r�r�rtr9rGr�r<r=rJr>�_to_volume_modificationr
rr$)r�r��
parametersr~rdr�r�r��ex_modify_volumes

�
��z"BaseEC2NodeDriver.ex_modify_volumecCsbddi}|r|�d|i�|r0|�|�d|��|rD|�|�|��|jj|j|d�j}|�|�S)an
        Describes one or more of your volume modifications.

        :param      dry_run: dry_run
        :type       dry_run: ``bool``

        :param      volume_ids: The volume_ids so that the response includes
                             information for only said volumes
        :type       volume_ids: ``dict``

        :param      filters: The filters so that the response includes
                             information for only certain volumes
        :type       filters: ``dict``

        :return:  List of volume modification status objects
        :rtype:   ``list`` of :class:`VolumeModification
        r1ZDescribeVolumesModificationsr�r�r3)r9r:r;r�r<r=r>�_to_volume_modifications)r�r�Z
volume_idsr�r4rdr�r�r��!ex_describe_volumes_modifications#sz3BaseEC2NodeDriver.ex_describe_volumes_modificationscsDtt|���}t|d�r6|jdur6|j|d<d|d<n
|j|d<|S)N�token�4rC)r�r+�_ex_connection_class_kwargs�hasattrr�rC�r��kwargsr�r�r�r�Es


z-BaseEC2NodeDriver._ex_connection_class_kwargscs �fdd�|�t|td��D�S)Ncsg|]}��|��qSr�)�_to_noderar�r�r�r�Rs�z/BaseEC2NodeDriver._to_nodes.<locals>.<listcomp>rc�r
rr$�r�r>rwr�r�r�r?Qs

��zBaseEC2NodeDriver._to_nodesc
Cs(z|jt|dtd�}Wnty0tj}Yn0tt|dtd��}t|dtd�}t|dtd�}|rj|gng}t|dtd�}|r�|gng}g}	t|dtd�D]}
|	�	|
�q�|�
|�}|�d|�}|�|t
d	�}
|�|�|
d
<|�|�|
d<|�|�|
d<|	|
d
<||
d<t||||||jj||
d�S)Nr�r5r�r�Z	ipAddress�privateIpAddressz productCodesSet/item/productCoderor�r�r�Znetwork_interfaces�
product_codesrs)rGrHr�rr
r�Z
created_atr)�NODE_STATE_MAPr	r$rMr�UNKNOWNr
rr
r�r#r��_get_extra_dict�RESOURCE_EXTRA_ATTRIBUTES_MAP�_to_instance_device_mappings�_get_security_groupsrFrr�r�)r�r6r��createdr��	public_iprr�r
r��prsrHrr�r�r�r�VsX������

���zBaseEC2NodeDriver._to_nodecs �fdd�|�tdtd��D�S)Ncsg|]}��|��qSr�)r�rar�r�r�r��r�z0BaseEC2NodeDriver._to_images.<locals>.<listcomp>zimagesSet/itemrcr��r�r>r�r�r�rV�s
�zBaseEC2NodeDriver._to_imagesc	Cs�t|dtd�}t|dtd�}|�|�}g}t|dtd�D]}|�|j�q8|�|�}|�|td�}||d<||d<||d<t	||||d	�S)
Nr�r5rHz#billingProducts/item/billingProductr�rsr�r�)rGrHr�r)
rr$�_to_device_mappingsr
r�r�r#r�r�r)	r�r6rGrHr�r�r�rsrr�r�r�r��s"
�

�zBaseEC2NodeDriver._to_imagec	Cs�t|dtd�}t|dtd�}t|dtd�}|j�|tj�}|�|�}|rL|n
|�d|�}|�|td�}||d<t	||t
|�|||d�S)	a�
        Parse the XML element and return a StorageVolume object.

        :param      name: An optional name for the volume. If not provided
                          then either tag with a key "Name" or volume ID
                          will be used (which ever is available first in that
                          order).
        :type       name: ``str``

        :rtype:     :class:`StorageVolume`
        r�r5rr{ror�rs)rGrHrr�r�r)rr$�VOLUME_STATE_MAPr�rr�r#r�r�rrb)	r�r6rHZvolIdrZ	raw_stater�rsrr�r�r�r`�s.���
��zBaseEC2NodeDriver._to_volumecs �fdd�|�tdtd��D�S)Ncsg|]}��|��qSr�)r�rar�r�r�r��r�z>BaseEC2NodeDriver._to_volume_modifications.<locals>.<listcomp>zvolumeModificationSet/itemrcr�r�r�r�r�r��s
�z*BaseEC2NodeDriver._to_volume_modificationscCs|�|t�}tfi|��S)z~
        Parse the XML element and return a StorageVolume object.

        :rtype:     :class:`EC2VolumeModification`
        )r��!VOLUME_MODIFICATION_ATTRIBUTE_MAPr&)r�r6r4r�r�r�r��s�z)BaseEC2NodeDriver._to_volume_modificationcs �fdd�|�tdtd��D�S)Ncsg|]}��|��qSr�)r�rar�r�r�r��r�z3BaseEC2NodeDriver._to_snapshots.<locals>.<listcomp>zsnapshotSet/itemrcr��r�rdr�r�r�r��s
�zBaseEC2NodeDriver._to_snapshotsc		Cs�t|dtd�}t|dtd�}tt|dtd��}|�|�}|r@|n
|�d|�}|�|td�}||d<||d<|j�|d	tj	�}t
|t|�|||||d
�S)Nr�r5Z
volumeSizer�ror�rsrHr�)rr�rr�r�rH)rr$r
r#r�r�r��SNAPSHOT_STATE_MAPr r�rrb)	r�r6rHZsnapIdrr�rsrr�r�r�r�r��s8���
���zBaseEC2NodeDriver._to_snapshotcCs:t|dtd�}|dkrd}nd}t||td�}t||d�S)Nz4importSnapshotTaskSet/item/snapshotTaskDetail/statusr5r0z8importSnapshotTaskSet/item/snapshotTaskDetail/snapshotId)r�)rr$r3)r�r6r{r�rwr�r�r�r�s��z*BaseEC2NodeDriver._to_import_snapshot_taskcs�fdd�|D�}|S)Ncsg|]}�j|d��qS)r�)r�)r�rCr�r�r�r�r�z3BaseEC2NodeDriver._to_key_pairs.<locals>.<listcomp>r�)r�r�r�r�r�r�r�szBaseEC2NodeDriver._to_key_pairscCsDt|dtd�}t|dtd���}t|dtd�}t|d|||d�}|S)Nr�r5rfrq)rHrtrirrr�)rr$rpr)r�rCrHrirrr�r�r�r�r�s�
��zBaseEC2NodeDriver._to_key_paircs �fdd�|�tdtd��D�S)Ncsg|]}��|��qSr�)�_to_security_grouprar�r�r�r�(r�z9BaseEC2NodeDriver._to_security_groups.<locals>.<listcomp>r�rcr�r�r�r�r�r�'s
�z%BaseEC2NodeDriver._to_security_groupscCsht|dtd�}t|dtd�}|�|�}|�|td�}||d<|�|d�}|�|d�}t|||||d�S)	Nrr5r�r�rszipPermissions/itemzipPermissionsEgress/itemr-)rr$r#r�r��_to_security_group_rulesr2)r�r6Zsg_idrHrsrrrr�r�r�r�,s,��
����z$BaseEC2NodeDriver._to_security_groupcs �fdd�|�t|td��D�S)Ncsg|]}��|��qSr�)�_to_security_group_rulerar�r�r�r�Or�z>BaseEC2NodeDriver._to_security_group_rules.<locals>.<listcomp>rcr��r�r6rwr�r�r�r�Ns
�z*BaseEC2NodeDriver._to_security_group_rulescCs�i}t|dtd�|d<t|dtd�|d<t|dtd�|d<|�tdtd	��}g|d
<|D]<}t|dtd�t|dtd�t|d
td�d�}|d
�|�qX|�tdtd	��}dd�|D�|d<|S)zy
        Parse the XML element and return a SecurityGroup object.

        :rtype:     :class:`EC2SecurityGroup`
        Z
ipProtocolr5rZfromPortrZtoPortrzgroups/itemrcrZuserIdrr�)�user_idrr�z
ipRanges/itemcSsg|]}t|dtd��qS)ZcidrIpr5)rr$)r�r6r�r�r�r��s��z=BaseEC2NodeDriver._to_security_group_rule.<locals>.<listcomp>r)rr$r
rr�)r�r6�rule�elementsrjr�r�r�r�SsX�
�
�
�������
z)BaseEC2NodeDriver._to_security_group_rulecs �fdd�|�tdtd��D�S)Ncsg|]}��|��qSr�)r�rar�r�r�r��r�z2BaseEC2NodeDriver._to_networks.<locals>.<listcomp>zvpcSet/itemrcr�r�r�r�r�r��s
�zBaseEC2NodeDriver._to_networkscCsbt|dtd�}|�|�}|r |n
|�d|�}t|dtd�}|�|td�}||d<t||||d�S)Nr�r5ror�r�rsr-)rr$r#r�r�r�r5)r�r6rHr�rsr�rr�r�r�r��s�
��zBaseEC2NodeDriver._to_networkcCs>g}|�tdtd��D]"}|�||�}|dur|�|�q|S)a�
        Builds a list of dictionaries containing elastic IP properties.

        :param    only_associated: If true, return only those addresses
                                   that are associated with an instance.
                                   If false, return all addresses.
        :type     only_associated: ``bool``

        :rtype:   ``list`` of :class:`ElasticIP`
        zaddressesSet/itemrcN)r
rr$r2r�)r�rdr1�	addressesrbrDr�r�r�r:�s�zBaseEC2NodeDriver._to_addressescCsVt|dtd�}t|dtd�}t|dtd�}|�|td�}|rF|sFdSt||||d�S)Nr�r5ZpublicIprr�r-)rr$r�r�r)r�r6r1r�r�rrr�r�r�r2�s"����zBaseEC2NodeDriver._to_addresscs �fdd�|�tdtd��D�S)Ncsg|]}��|��qSr�)�_to_placement_grouprar�r�r�r��s�z:BaseEC2NodeDriver._to_placement_groups.<locals>.<listcomp>zplacementGroupSet/itemrcr�r�r�r�r�r��s
���z&BaseEC2NodeDriver._to_placement_groupscCs6t|dtd�}t|dtd�}t|dtd�}t|||�S)Nr�r5r�r)rr$r4)r�r6rHr�rr�r�r�r��s���z%BaseEC2NodeDriver._to_placement_groupcs �fdd�|�tdtd��D�S)Ncsg|]}��|��qSr�)r�rar�r�r�r��r�z1BaseEC2NodeDriver._to_subnets.<locals>.<listcomp>zsubnetSet/itemrcr�r�r�r�r�r��s
�zBaseEC2NodeDriver._to_subnetscCsbt|dtd�}|�|�}|r |n
|�d|�}t|dtd�}|�|td�}||d<t||||d�S)Nr�r5ror�r�rsr-)rr$r#r�r�r�r6)r�r6rHr�rsr�rr�r�r�r��s�
��zBaseEC2NodeDriver._to_subnetcs �fdd�|�tdtd��D�S)Ncsg|]}��|��qSr�)rHrar�r�r�r�	r�z4BaseEC2NodeDriver._to_interfaces.<locals>.<listcomp>znetworkInterfaceSet/itemrcr�r�r�r�r�rFs
�z BaseEC2NodeDriver._to_interfacesc
Cs�t|dtd�}t|dtd�}|�|�}|r.|n
|�d|�}|�|�}g}t|dtd�D]4}|�t|dtd�t|dtd�t|dtd�d	��qVtd
}	|�||	�}
td}	|�||	�}||d<|
|d
<||d<||d<t	||||d�S)a�
        Parse the XML element and return an EC2NetworkInterface object.

        :param      name: An optional name for the interface. If not provided
                          then either tag with a key "Name" or the interface ID
                          will be used (whichever is available first in that
                          order).
        :type       name: ``str``

        :rtype:     :class: `EC2NetworkInterface`
        r�r5r{rozprivateIpAddressesSet/itemr�r��primary)r�r�r�r�r�rs�
attachmentr
r�r-)
rr$r#r�r�r
r�r�r�r7)r�r6rHr�r�rsr�Zpriv_ipsrjZattributes_mapr�rr�r�r�rH
sN
��

�
����
�zBaseEC2NodeDriver._to_interfacecs �fdd�|�t|td��D�S)Ncsg|]}��|��qSr�)�_to_reserved_noderar�r�r�r�Ls�z8BaseEC2NodeDriver._to_reserved_nodes.<locals>.<listcomp>rcr�r�r�r�r�r_Ks

��z$BaseEC2NodeDriver._to_reserved_nodescsl|�|td��z�fdd�|��D�d}WntyDd}Yn0tt|dtd�t|dtd�||�d	�S)
z�
        Build an EC2ReservedNode object using the reserved instance properties.
        Information on these properties can be found at http://goo.gl/ulXCC7.
        r�csg|]}|j�dkr|�qS)r�r)r�rr-r�r�r�[s�z7BaseEC2NodeDriver._to_reserved_node.<locals>.<listcomp>rNZreservedInstancesIdr5r�)rGr�r�rr)r�r�rR�
IndexErrorr1rr$r	)r�r6rr�r-r�r�Ps*��
���z#BaseEC2NodeDriver._to_reserved_nodecs �fdd�|�tdtd��D�S)Ncsg|]}��|��qSr�)�_to_device_mappingrar�r�r�r�kr�z9BaseEC2NodeDriver._to_device_mappings.<locals>.<listcomp>�blockDeviceMapping/itemrcr�r�r�r�r�r�js
�z%BaseEC2NodeDriver._to_device_mappingscCsLi}t|dtd�|d<t|dtd�|d<|ddurH|�|td�|d<|S)	a&
        Parse the XML element and return a dictionary of device properties.
        Additional information can be found at http://goo.gl/GjWYBf.

        @note: EBS volumes do not have a virtual name. Only ephemeral
               disks use this property.
        :rtype:     ``dict``
        �
deviceNamer5�device_nameZvirtualNameZvirtual_nameNr��ebs�r	r$r�r��r�r6�mappingr�r�r�r�os	�
�
�z$BaseEC2NodeDriver._to_device_mappingcs �fdd�|�tdtd��D�S)Ncsg|]}��|��qSr�)�_to_instance_device_mappingrar�r�r�r��r�zBBaseEC2NodeDriver._to_instance_device_mappings.<locals>.<listcomp>r�rcr�r�r�r�r�r��s
�z.BaseEC2NodeDriver._to_instance_device_mappingscCs.i}t|dtd�|d<|�|td�|d<|S)z�
        Parse the XML element and return a dictionary of device properties.
        Additional information can be found at https://goo.gl/OGK88a.

        :rtype:     ``dict``
        r�r5r�r�r�r�r�r�r�r�r��s�
�z-BaseEC2NodeDriver._to_instance_device_mappingcs �fdd�|�t|td��D�S)Ncsg|]}��|��qSr�)r~rar�r�r�r��s�z;BaseEC2NodeDriver._to_internet_gateways.<locals>.<listcomp>rcr�r�r�r�r�r|�s

��z'BaseEC2NodeDriver._to_internet_gatewayscCslt|dtd�}t|dtd�}t|dtd�}|s2d}|�|�}|rD|n
|�d|�}t|||||jjd|id�S)	NZinternetGatewayIdr5zattachmentSet/item/vpcIdzattachmentSet/item/stater.rors)rGrHr�r�r�r)rr$r#r�rr�r�)r�r6rHrGr�r�rsr�r�r�r~�s(���
�z&BaseEC2NodeDriver._to_internet_gatewaycs �fdd�|�tdtd��D�S)Ncsg|]}��|��qSr�)r�rar�r�r�r��r�z6BaseEC2NodeDriver._to_route_tables.<locals>.<listcomp>zrouteTableSet/itemrcr�r�r�r�r�r��s
�z"BaseEC2NodeDriver._to_route_tablesc
Cs�t|dtd�}|�|�}|�|td�}||d<|�|d�}|�|d�}g}|�tdtd��D]}	|�	t|	d	td��q^|r�|n
|�
d
t�}t||||||d�S)N�routeTableIdr5r�rsz
routeSet/itemzassociationSet/itemzpropagatingVgwSet/itemrc�	gatewayIdror-)
rr$r#r�r��
_to_routes�_to_subnet_associationsr
rr�r�rGr8)
r�r6rHr$rsrrrrrbr�r�r�r��s2�
����

�z!BaseEC2NodeDriver._to_route_tablecs �fdd�|�t|td��D�S)Ncsg|]}��|��qSr�)�	_to_routerar�r�r�r��r�z0BaseEC2NodeDriver._to_routes.<locals>.<listcomp>rcr�r�r�r�r�r��s
�zBaseEC2NodeDriver._to_routesc
	Cs�t|dtd�}t|dtd�}t|dtd�}t|dtd�}t|dtd�}t|dtd�}t|dtd�}t|d	td�}	t||||||||	�S)
zi
        Parse the XML element and return a route object

        :rtype:     :class: `EC2Route`
        ZdestinationCidrBlockr5r�r�ZinstanceOwnerIdr�r�r"ZvpcPeeringConnectionId)rr$r9)
r�r6Zdestination_cidrr!r�r�r�r�r"r#r�r�r�r��sF��������
�zBaseEC2NodeDriver._to_routecs �fdd�|�t|td��D�S)Ncsg|]}��|��qSr�)�_to_subnet_associationrar�r�r�r�r�z=BaseEC2NodeDriver._to_subnet_associations.<locals>.<listcomp>rcr�r�r�r�r�r�s
�z)BaseEC2NodeDriver._to_subnet_associationscCsRt|dtd�}t|dtd�}t|dtd�}t|dtd�}|r@dnd}t||||�S)z�
        Parse the XML element and return a route table association object

        :rtype:     :class: `EC2SubnetAssociation`
        ZrouteTableAssociationIdr5r�r�r%TF)rr$r:)r�r6r�r$r�r%r�r�r�r� s(�����z(BaseEC2NodeDriver._to_subnet_associationcCs.i}d}|D]}|d7}||d||f<q|S)zT
        Converts a key and an array of values into AWS query param format.
        rrTz%s.%sr�)r�r�Zarrr4r+r�r�r�r�r:<szBaseEC2NodeDriver._pathlistcCsdtdf}|�|�dkS)Nz{%s}%s�returnr�)r$r)r�r6�tagr�r�r�r�IszBaseEC2NodeDriver._get_booleancs(|�dtdf��t�fdd�dD��S)Nz	.//{%s}%srHcsg|]}|�k�qSr�r�)r�Zterm_status�r{r�r�r�Os�z<BaseEC2NodeDriver._get_terminate_boolean.<locals>.<listcomp>)r,r-)rr$�any)r�r6r�r�r�r�Ms�z(BaseEC2NodeDriver._get_terminate_booleancCsd|ji}|�|�|��|S)zH
        Add instance filter to the provided params dictionary.
        zinstance-id)rGr9r;)r�r4r�r�r�r�r�rASs
z&BaseEC2NodeDriver._add_instance_filtercCst|dtd�dj}|dvS)z2
        Checks for the instances's state
        z#instancesSet/item/currentState/namer5r)Zstoppingr*�starting)r
r$r�)r�r6r�r�r�r�r�\s��z$BaseEC2NodeDriver._get_state_booleancCsRi}|��D]@\}}|d}t||dtd�}|durD||�||<qd||<q|S)am
        Extract attributes from the element based on rules provided in the
        mapping dictionary.

        :param      element: Element to parse the values from.
        :type       element: xml.etree.ElementTree.Element.

        :param      mapping: Dictionary with the extra layout
        :type       node: :class:`Node`

        :rtype: ``dict``
        rxrwr5N)r�r	r$)r�r6r�rr��valuesrxr�r�r�r�r�fs
�
z!BaseEC2NodeDriver._get_extra_dictcCsDi}t|dtd�}|D](}t|dtd�}t|dtd�}|||<q|S)z�
        Parse tags from the provided element and return a dictionary with
        key/value pairs.

        :rtype: ``dict``
        ztagSet/itemr5r�r�)r
r$r)r�r6rsZtag_setr�r�r�r�r�r�r#�s ���
z$BaseEC2NodeDriver._get_resource_tagsc		Cs�t|ttf�std��i}t|�D]�\}}|d7}t|t�sHtd|��|��D]P\}}t|t�sxt|�|d||f<qP|��D]\}}t|�|d|||f<q�qPq"|S)aK
        Return a list of dictionaries with query parameters for
        a valid block device mapping.

        :param      mapping: List of dictionaries with the drive layout
        :type       mapping: ``list`` or ``dict``

        :return:    Dictionary representation of the drive mapping
        :rtype:     ``dict``
        z&block_device_mapping not list or tuplerTz-mapping %s in block_device_mapping not a dictzBlockDeviceMapping.%d.%szBlockDeviceMapping.%d.%s.%s�rur�rvryrU�dictr�r�)	r�r�r4�idxr�r�r�r�r�r�r�r�r�s,�
��
��
z2BaseEC2NodeDriver._get_block_device_mapping_paramscCsHt|ttf�std��i}t|�D] \}}|d7}t|�|d|<q"|S)a3
        Return a list of dictionaries with valid param for billing product.

        :param      billing_product: List of billing code values(str)
        :type       billing product: ``list``

        :return:    Dictionary representation of the billing product codes
        :rtype:     ``dict``
        z"billing_products not list or tuplerTzBillingProduct.%d)rur�rvryrUr�)r�r�r4r�r�r�r�r�r��s�z-BaseEC2NodeDriver._get_billing_product_paramsc	Cs�t|ttf�std��i}t|�D]z\}}|d7}t|t�sHtd|��|��D]J\}}t|t�stt|�|d|<qP|��D]\}}t|�|d||f<q|qPq"|S)a~
        Return a list of dictionaries with query parameters for
        a valid disk container.

        :param      disk_container: List of dictionaries with
                                    disk_container details
        :type       disk_container: ``list`` or ``dict``

        :return:    Dictionary representation of the disk_container
        :rtype:     ``dict``
        z disk_container not list or tuplerTz'content %s in disk_container not a dictzDiskContainer.%szDiskContainer.%s.%sr�)	r�r�r4r��contentr�r�r�r�r�r�r�r��s$

�
��
z,BaseEC2NodeDriver._get_disk_container_paramscCspt|ttf�std��i}t|�D]H\}}|d7}t|t�sHtd|��|��D]\}}t|�|d|<qPq"|S)aZ
        Return a dictionary with query parameters for
        a valid client data.

        :param      client_data: List of dictionaries with the disk
                                 upload details
        :type       client_data: ``dict``

        :return:    Dictionary representation of the client data
        :rtype:     ``dict``
        zclient_data not list or tuplerTz#content %s in client_datanot a dictz
ClientData.%sr�)r�r�r4r�r�r�r�r�r�r��_get_client_data_params�s

��z)BaseEC2NodeDriver._get_client_data_paramscCs�||||d�}|dur^i}	t|�D]0\}
}|
d7}
||	d|
<|dur"||	d|
<q"|�|	�|dur�i}t|�D]d\}
}
|
d7}
d|
��vr�|
d|d|
<d|
��vr�|
d|d	|
<d
|
��vrr|
d
|d|
<qr|�|�|S)z�
        Return a dictionary with common query parameters which are used when
        operating on security groups.

        :rtype: ``dict``
        )r�zIpPermissions.1.IpProtocolzIpPermissions.1.FromPortzIpPermissions.1.ToPortNrTz"IpPermissions.1.IpRanges.%s.CidrIpz'IpPermissions.1.IpRanges.%s.Descriptionrz!IpPermissions.1.Groups.%s.GroupIdr�z#IpPermissions.1.Groups.%s.GroupNamer�z IpPermissions.1.Groups.%s.UserId)rUr9�keys)r�rrrrrrr�r4Z	ip_rangesrXrZuser_groupsZ
group_pairr�r�r�rsP	�����
������
z3BaseEC2NodeDriver._get_common_security_group_paramsc	Cs@g}t|dtd�D](}|�t|dtd�t|dtd�d��q|S)z�
        Parse security groups from the provided element and return a
        list of security groups with the id ane name key/value pairs.

        :rtype: ``list`` of ``dict``
        z
groupSet/itemr5rr�)rr�)r
r$r�r)r�r6r�rjr�r�r�r�Ds �
���
	z&BaseEC2NodeDriver._get_security_groupscCs�i}t|���D]r\}}|d7}|\}}d|}|||<t|t�rrt|�D]$\}}	|d7}d||f}
|	||
<qJqd|}
|||
<q|S)a
        Return a dictionary with filter query parameters which are used when
        listing networks, security groups, etc.

        :param      filters: Dict of filter names and filter values
        :type       filters: ``dict``

        :rtype:     ``dict``
        rTzFilter.%s.NamezFilter.%s.Value.%szFilter.%s.Value.1)rUr�rur�)r�r�Zfilter_entriesZ
filter_idxZfilter_dataZfilter_nameZ
filter_valuesZ
filter_keyZ	value_idxr�Z	value_keyr�r�r�r;[s 
�
z BaseEC2NodeDriver._build_filters)NN)N)NNNNN)NN)NNNNNNNNrTrTNNNNNNFFFN)NNr�NFN)F)NN)NN)NN)NFN)NNNNNN)r�r�)N)N)NNNNNNNNNNN)NN)Nr�)NN)N)r�F)NNN)N)r)NNrN)Nr)NNr)NNr)T)r�)N)F)N)N)N)NNN)F)NN)N)NN)N)NNNN)NNNN)FNN)N)N)N)N)N)N)N)N)�r�r�r�rr�
connectionCls�featuresr=r
rBrrCr�PENDING�RUNNINGr��
TERMINATEDr�rZ	AVAILABLEZINUSE�ERRORZCREATINGZDELETINGZDELETEDr�r r�rGrRrZr[r_rer'r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrr!r\r%r�r,r/r3r8r;r=r>r@r@rErGrJrLrMrOrQrRrSrVrXrYr^rardrkrmrornrsrurvrxrzr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r?r�rVr�r`r�r�r�r�r�r�r�r�r�r�r�r�r�r:r2r�r�r�r�rFrHr_r�r�r�r�r�r|r~r�r�r�r�r�r�r:r�r�rAr�r�r#rr�r�r�rr�r;r�r�r�r�r�r+Fs�
�	��*�
>�
k�
W

%

	%�
7�
E�
$�
g�
"�
%�
#�
&�
(�
9�
7�
5�
60-
"
*
�
0(#&�
4�
4�
".)%

"<>$*
	
!# �0r+cs^eZdZdZeZejZdZ	dZ
dZej
ejejejejd�Zd
�fd	d
�	Zedd��Z�ZS)r*z!
    Amazon EC2 node driver.
    z
Amazon EC2zhttp://aws.amazon.com/ec2/r(�r*r+r,r-�stoppedNTrucs�t|d�r|j}|��}	||	vr,td|��t|}
||_||_|
d|_|
d|_|
�	dt
�|_|pl|
d}tt
|�jf|||||d�|��dS)N�_region�Invalid region: %srqrBrCrp�r��secret�securer�port)r�r��list_regionsrtr"r
r�rqrBr�rrCr�r*r�)r�r�r�r�rr��regionr�r�Z
valid_regions�detailsr�r�r�r��s(


���zEC2NodeDriver.__init__cCstSr�)�VALID_EC2_REGIONS)�clsr�r�r�r��szEC2NodeDriver.list_regions)NTNNruN)r�r�r�rrr�rZEC2�typerH�websiter=rr�r�r�r��STOPPEDr�r��classmethodr�r�r�r�r�r�r*{s"��r*c@seZdZdZdd�ZdS)r<zZ
    Request used the same client token as a previous,
    but non-identical request.
    cCs
t|j�Sr�)�reprr�r�r�r�r��__str__�szIdempotentParamError.__str__N)r�r�r�rr�r�r�r�r�r<�sr<c@seZdZdZdZdS)�
EucConnectionz)
    Connection class for Eucalyptus
    N�r�r�r�rrr�r�r�r�r��sr�csneZdZdZdZdZdZdZeZ	dZ
dddddef�fd	d
�	Zdd�Z
d
d�Zdd�Zdd�Zdd�Z�ZS)r-z%
    Driver class for Eucalyptus
    Z
Eucalyptuszhttp://www.eucalyptus.com/Zec2_us_eastrur>NTcs8tt|��|||||�|dur$d}||_d||_dS)aI
        @inherits: :class:`EC2NodeDriver.__init__`

        :param    path: The host where the API can be reached.
        :type     path: ``str``

        :param    api_version: The API version to extend support for
                               Eucalyptus proprietary API calls
        :type     api_version: ``str``
        Nz/services/Eucalyptusr=)r�r-r�r=r))r�r�r�r�rr=r��api_versionr�r�r�r��s
zEucNodeDriver.__init__cCstd��dS)Nz.list_locations not implemented for this driver)�NotImplementedErrorr�r�r�r�r_�s�zEucNodeDriver.list_locationscs"�fdd�|�td�jd��D�S)Ncsg|]}��|��qSr�)�_to_sizerar�r�r�r��r�z+EucNodeDriver._to_sizes.<locals>.<listcomp>zinstanceTypeDetails/itemrc)r
rr)r�r�r�r��	_to_sizes�s
��zEucNodeDriver._to_sizescCsht|d|jd�}t|d|jd�}t|d|jd�}t|d|jd�}t||t|�t|�ddtdt|�id�S)NrHr5�cpurJ�memory)rGrHrIrJrKrIr�r)rr)rrbr-)r�rbrHr�rJrr�r�r�r��s4������zEucNodeDriver._to_sizecCs&ddi}|jj|j|d�j}|�|�S)z]
        Lists available nodes sizes.

        :rtype: ``list`` of :class:`NodeSize`
        r1�DescribeInstanceTypesr3)r�r<r=r>r�r`r�r�r�rR�szEucNodeDriver.list_sizescCsdS)zh
        Eucalyptus driver doesn't support filtering on instance id so this is a
        no-op.
        Nr�)r�r4r�r�r�r�rA	sz"EucNodeDriver._add_instance_filter)r�r�r�rrHr�rqr
r�r�rCr(r�r_r�r�rRrAr�r�r�r�r�r-�s�r-c@seZdZdZdZdS)�NimbusConnectionz%
    Connection class for Nimbus
    Nr�r�r�r�r�rsrc@sFeZdZdZejZdZdZdZ	dZ
dZdZe
ZdZdd	�Zd
d�ZdS)
r,z!
    Driver class for Nimbus
    ZNimbuszhttp://www.nimbusproject.org/ZPrivaterEzNimbus Private Cloudr>cCsi}|D]}g||j<q|S)z�
        Nimbus doesn't support elastic IPs, so this is a pass-through.

        @inherits: :class:`EC2NodeDriver.ex_describe_addresses`
        r)r�rDrCr�r�r�r�r@(sz&NimbusNodeDriver.ex_describe_addressescCsdS)z�
        Nimbus doesn't support creating tags, so this is a pass-through.

        @inherits: :class:`EC2NodeDriver.ex_create_tags`
        Nr�)r�r$rsr�r�r�r�4szNimbusNodeDriver.ex_create_tagsN)r�r�r�rrZNIMBUSr�rHr�rBrqr
Z
friendly_namerr�rCr@r�r�r�r�r�r,sr,c@seZdZdZeZdZdS)�OutscaleConnectionz'
    Connection class for Outscale
    N)r�r�r�r�DEFAULT_OUTSCALE_API_VERSIONrrr�r�r�r�r=srcseZdZdZeZdZdZdZdZ	e
je
je
j
e
je
jd�Zd5�fd
d�	Z�fdd
�Zd6�fdd�	Zd7�fdd�	Zd8�fdd�	Zd9dd�Zdd�Zd:dd�Zdd�Zdd�Zd;dd �Zd<d!d"�Zd=d#d$�Zd%d&�Zd>d'd(�Zd)d*�Z d?d+d,�Z!d-d.�Z"d@d/d0�Z#d1d2�Z$dAd3d4�Z%�Z&S)B�OutscaleNodeDriverzc
    Base Outscale FCU node driver.

    Outscale per provider driver classes inherit from it.
    ZOutscalezhttp://www.outscale.comr(r>r�NTruc
s�t|d�rt|dd�}|dur&td��||��vr>td|��||_||_|j|}	|	d|_|	d|_|	d|j_	d|_
tt|�j
f|||||d�|��dS)	Nr�zInvalid region_details argumentr�rqrBrpz3This method is not supported in the Outscale driverr�)r�rxrtr�r
�region_detailsrqrBr�r�_not_implemented_msgr�rr�)
r�r�r�r�rr�r�rr�r�r�r�r�r�[s(



���zOutscaleNodeDriver.__init__cs&d|vrtd��tt|�jfi|��S)a+
        Creates a new Outscale node. The ex_iamprofile keyword
        is not supported.

        @inherits: :class:`BaseEC2NodeDriver.create_node`

        :keyword    ex_keyname: The name of the key pair
        :type       ex_keyname: ``str``

        :keyword    ex_userdata: The user data
        :type       ex_userdata: ``str``

        :keyword    ex_security_groups: A list of names of security groups to
                                        assign to the node.
        :type       ex_security_groups:   ``list``

        :keyword    ex_metadata: The Key/Value metadata to associate
                                 with a node.
        :type       ex_metadata: ``dict``

        :keyword    ex_mincount: The minimum number of nodes to launch
        :type       ex_mincount: ``int``

        :keyword    ex_maxcount: The maximum number of nodes to launch
        :type       ex_maxcount: ``int``

        :keyword    ex_clienttoken: A unique identifier to ensure idempotency
        :type       ex_clienttoken: ``str``

        :keyword    ex_blockdevicemappings: ``list`` of ``dict`` block device
                    mappings.
        :type       ex_blockdevicemappings: ``list`` of ``dict``

        :keyword    ex_ebs_optimized: EBS-Optimized if True
        :type       ex_ebs_optimized: ``bool``
        r�zex_iamprofile not implemented)r�r�rr'r�r�r�r�r'us%zOutscaleNodeDriver.create_nodecstt|�j||d�S)au
        Creates a network/VPC. Outscale does not support instance_tenancy.

        :param      cidr_block: The CIDR block assigned to the network
        :type       cidr_block: ``str``

        :param      name: An optional name for the network
        :type       name: ``str``

        :return:    Dictionary of network properties
        :rtype:     ``dict``
        r�)r�rr�)r�r�rHr�r�r�r��s
�z$OutscaleNodeDriver.ex_create_networkc		sz|pi}|dur||d<|dur(||d<|dur8||d<|durH||d<|durX||d<|durh||d<tt|��||�S)a�
        Modifies node attributes.
        Ouscale supports the following attributes:
        'DisableApiTermination.Value', 'EbsOptimized', 'GroupId.n',
        'SourceDestCheck.Value', 'UserData.Value',
        'InstanceType.Value'

        :param      node: Node instance
        :type       node: :class:`Node`

        :param      attributes: A dictionary with node attributes
        :type       attributes: ``dict``

        :return: True on success, False otherwise.
        :rtype: ``bool``
        NzDisableApiTermination.Valuerkz	GroupId.nzSourceDestCheck.ValuezUserData.ValuerT)r�rrQ)	r�r�Zdisable_api_terminationr�rr��	user_datar�rQr�r�r�rQ�s 
�z/OutscaleNodeDriver.ex_modify_instance_attributecstt|�j|||||d�S)a�
        Registers a Machine Image based off of an EBS-backed instance.
        Can also be used to create images from snapshots.

        Outscale does not support image_location, kernel_id and ramdisk_id.

        :param      name:  The name for the AMI being registered
        :type       name: ``str``

        :param      description: The description of the AMI (optional)
        :type       description: ``str``

        :param      architecture: The architecture of the AMI (i386/x86_64)
                                  (optional)
        :type       architecture: ``str``

        :param      root_device_name: The device name for the root device
                                      Required if registering an EBS-backed AMI
        :type       root_device_name: ``str``

        :param      block_device_mapping: A dictionary of the disk layout
                                          (optional)
        :type       block_device_mapping: ``dict``

        :rtype:     :class:`NodeImage`
        )r�r�r�r�)r�rr�)r�rHr�r�r�r�r�r�r�r��s

�z$OutscaleNodeDriver.ex_register_imagecCst|j��dS)zt
        Outscale does not support copying images.

        @inherits: :class:`EC2NodeDriver.ex_copy_image`
        N�r�r)r�r�r�rHr�r�r�r��
ex_copy_image�sz OutscaleNodeDriver.ex_copy_imagecCst|j��dS)zt
        Outscale does not support getting limits.

        @inherits: :class:`EC2NodeDriver.ex_get_limits`
        Nr	r�r�r�r�rd�sz OutscaleNodeDriver.ex_get_limitscCst|j��dS)z�
        Outscale does not support creating a network interface within a VPC.

        @inherits: :class:`EC2NodeDriver.ex_create_network_interface`
        Nr	)r�r�rHr�rIr�r�r�rJsz.OutscaleNodeDriver.ex_create_network_interfacecCst|j��dS)z�
        Outscale does not support deleting a network interface within a VPC.

        @inherits: :class:`EC2NodeDriver.ex_delete_network_interface`
        Nr	)r�r�r�r�r�rLsz.OutscaleNodeDriver.ex_delete_network_interfacecCst|j��dS)z�
        Outscale does not support attaching a network interface.

        @inherits: :class:`EC2NodeDriver.ex_attach_network_interface_to_node`
        Nr	)r�r�r�r�r�r�r�rMsz6OutscaleNodeDriver.ex_attach_network_interface_to_nodeFcCst|j��dS)z�
        Outscale does not support detaching a network interface

        @inherits: :class:`EC2NodeDriver.ex_detach_network_interface`
        Nr	)r�r�rNr�r�r�rO sz.OutscaleNodeDriver.ex_detach_network_interfacecCsf|j|jd}g}|D]H}t|}t�|�}|j|d�}|�d|i�|�tfd|i|���q|S)z�
        Lists available nodes sizes.

        This overrides the EC2 default method in order to use Outscale
        information or data.

        :rtype: ``list`` of :class:`NodeSize`
        rDrHrIr�)	rr
r%rJrKrLr9r�rrNr�r�r�rR(s
�
zOutscaleNodeDriver.list_sizescCsTddi}|�d|i�|dur,|�d|i�|jj|j|dd�j}t|dtd	�d
kS)aW
        Modifies the keypair associated with a specified instance.
        Once the modification is done, you must restart the instance.

        :param      instance_id: The ID of the instance
        :type       instance_id: ``string``

        :param      key_name: The name of the keypair
        :type       key_name: ``string``
        r1ZModifyInstanceKeypairr�Nr��GET�r4�methodr�r5r�)r9r�r<r=r>r�OUTSCALE_NAMESPACE)r�r�r�r4rdr�r�r��ex_modify_instance_keypair=s���z-OutscaleNodeDriver.ex_modify_instance_keypaircCs�i}t|dtd�D]�}t|dtd�}g}t|dtd�D]�}t|dtd�}t|dtd�}t|dtd�}	t|dtd�}
t|d	td�}t|d
td�}t|dtd�}
|�|||	|
|||
d��q6|||<q|S)
z
        To Quota
        zreferenceQuotaSet/itemr5�	referencez
quotaSet/itemr�rH�displayNamer�r��
maxQuotaValue�usedQuotaValue)r�rHrr�r�rr�r
rrr�)r�rC�quotaZreference_quota_itemrZ	quota_setZ
quota_itemr�rHrr�r�rrr�r�r��	_to_quotaVsh�
��
��������

zOutscaleNodeDriver._to_quotac	Csz|rtd��|rtd��ddi}|r2|�d|i�|rD|�d|i�|jj|j|dd�j}|�|�}t|d	td
�}||fS)a�
        Describes one or more of your quotas.

        :param      dry_run: dry_run
        :type       dry_run: ``bool``

        :param      filters: The filters so that the response returned includes
                             information for certain quotas only.
        :type       filters: ``dict``

        :param      max_results: The maximum number of items that can be
                                 returned in a single page (by default, 100)
        :type       max_results: ``int``

        :param      marker: Set quota marker
        :type       marker: ``string``

        :return:    (is_truncated, quota) tuple
        :rtype:     ``(bool, dict)``
        z!quota filters are not implementedzquota marker is not implementedr1ZDescribeQuotasr�Z
MaxResultsrrZisTruncatedr5)	r�r9r�r<r=r>rrr)	r�r�r�Zmax_results�markerr4rdrZis_truncatedr�r�r��ex_describe_quotas�s*���
�z%OutscaleNodeDriver.ex_describe_quotascCs&t|dtd�}t|dtd�}||d�S)N�
productTypeIdr5r��rr�)rr)r�rCrr�r�r�r��_to_product_type�s���z#OutscaleNodeDriver._to_product_typecCsPddi}|�d|i�|dur,|�d|i�|jj|j|dd�j}|�|�}|S)aG
        Gets the product type of a specified OMI or snapshot.

        :param      image_id: The ID of the OMI
        :type       image_id: ``string``

        :param      snapshot_id: The ID of the snapshot
        :type       snapshot_id: ``string``

        :return:    A product type
        :rtype:     ``dict``
        r1ZGetProductTyperfNr�rr)r9r�r<r=r>r)r�r�r}r4rd�product_typer�r�r��ex_get_product_type�s�
z&OutscaleNodeDriver.ex_get_product_typecCsHg}t|dtd�D]0}t|dtd�}t|dtd�}|�||d��q|S)NzproductTypeSet/itemr5rr�rr)r�rC�
product_typesZproduct_types_itemrr�r�r�r��_to_product_types�s"�
���
z$OutscaleNodeDriver._to_product_typescCs@ddi}|r|�|�|��|jj|j|dd�j}|�|�}|S)a&
        Describes product types.

        :param      filters: The filters so that the list returned includes
                             information for certain quotas only.
        :type       filters: ``dict``

        :return:    A product types list
        :rtype:     ``list``
        r1ZDescribeProductTypesrr)r9r;r�r<r=r>r)r�r�r4rdrr�r�r��ex_describe_product_types�s�
z,OutscaleNodeDriver.ex_describe_product_typesc	Cs�g}t|dtd�D]�}t|dtd�}t|dtd�}t|dtd�}t|dtd�}t|dtd�}t|dtd�}	t|d	td�}
||||||	|
d
�}|�|�q|S)NzinstanceTypeSet/itemr5rH�vcpur�storageSize�storageCount�maxIpAddresses�ebsOptimizedAvailable)rHr!rr"r#r$r%r)r�rCrDZinstance_types_itemrHr!rr"r#r$r%�dr�r�r��_to_instance_typessV�
��������z%OutscaleNodeDriver._to_instance_typescCs@ddi}|r|�|�|��|jj|j|dd�j}|�|�}|S)a
        Describes instance types.

        :param      filters: The filters so that the list returned includes
                    information for instance types only
        :type       filters: ``dict``

        :return:    A instance types list
        :rtype:     ``list``
        r1rrr)r9r;r�r<r=r>r')r�r�r4rdrDr�r�r��ex_describe_instance_types+s�
z-OutscaleNodeDriver.ex_describe_instance_types)NTNNruN)N)NNNNNNN)NNNN)NN)NNN)F)N)N)FNNN)N)N)N)'r�r�r�rrr�rHr�r=rCrr�r�r�r�r�r�r�r'r�rQr�r
rdrJrLrMrOrRrrrrrrr r'r(r�r�r�r�r�rFs\��)�&�!
�

	


0�
1


&rcs,eZdZdZdZejZd�fdd�	Z�Z	S)	r.z"
    Outscale SAS node driver
    zOutscale SASNTruc	
s*tt|�jf||||||td�|��dS�N)r�r�r�rr�r�r)r�r.r�r&�	r�r�r�r�rr�r�rr�r�r�r�r�Ks
��zOutscaleSASNodeDriver.__init__)NTNNruN)
r�r�r�rrHrZOUTSCALE_SASr�r�r�r�r�r�r�r.Ds�r.cs,eZdZdZdZejZd�fdd�	Z�Z	S)	r/z"
    Outscale INC node driver
    zOutscale INCNTruc	
s*tt|�jf||||||td�|��dSr))r�r/r�r'r*r�r�r�r�Zs
��zOutscaleINCNodeDriver.__init__)NTNNruN)
r�r�r�rrHrZOUTSCALE_INCr�r�r�r�r�r�r�r/Ss�r/)ar�typingrr�r|rJrgr�Zlibcloud.utils.py3rrrrZlibcloud.utils.xmlrrr	r
Zlibcloud.utils.publickeyrrZlibcloud.utils.iso8601r
Zlibcloud.common.awsrrrZlibcloud.common.typesrrrZlibcloud.compute.providersrZlibcloud.compute.baserrrrrrrrZlibcloud.compute.typesrrrr Zlibcloud.compute.constantsr!r"�__all__r#r$r(r)rrr%r&r'r�rb�floatr�r�r�r�r�r0r�rr>r;r1r2r3r4r5r6r7rrr8r9r:r&r+r*r<r�r-rr,rrr.r/r�r�r�r��<module>s�#�
�����������������������������	�	�	����v�����������������������������������������������D��������������$�������� �����������������������������t�������������4���������������������
�������3������p�������������3
. )1 &U/
U$	

Youez - 2016 - github.com/yon3zu
LinuXploit