Comment 2 for bug 530824

Revision history for this message
Neil Soman (neilsoman) wrote :

The issue here is that boto does not do input validation in some cases and in case the keypair is empty, it should not send a malformed request to the service. Something like,

--- boto-1.8d-orig/boto/ec2/connection.py 2009-06-24 18:28:54.000000000 -0700
+++ boto-1.8d/boto/ec2/connection.py 2010-03-02 13:50:51.000000000 -0800
@@ -597,7 +597,7 @@
             self.build_list_params(params, keynames, 'KeyName')
         return self.get_list('DescribeKeyPairs', params, [('item', KeyPair)])

- def get_key_pair(self, keyname):
+ def get_key_pair(self, keyname=None):
         """
         Convenience method to retrieve a specific keypair (KeyPair).

@@ -607,10 +607,11 @@
         @rtype: L{KeyPair<boto.ec2.keypair.KeyPair>}
         @return: The KeyPair specified or None if it is not found
         """
- try:
- return self.get_all_key_pairs(keynames=[keyname])[0]
- except IndexError: # None of those key pairs available
- return None
+ if keyname:
+ try:
+ return self.get_all_key_pairs(keynames=[keyname])[0]
+ except IndexError: # None of those key pairs available
+ return None

     def create_key_pair(self, key_name):
         """

However, Eucalyptus should not throw an "500 Internal Error" regardless, so this issue needs to be fixed on both ends.