Accept single unicode instance id as a query param #741

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
@todddeluca

By convention, boto.ec2.connection.EC2Connection methods
get_all_instances() and get_all_instance_status() accepts a string
instance id or a list of instance ids. Unfortunately the id from a
boto.ec2.instance.Instance cannot be used, because a unicode instance
id causes the method call to fail. Now an Instance id works.

Todd DeLuca
Accept single unicode instance id as a query param
By convention, boto.ec2.connection.EC2Connection methods
get_all_instances() and get_all_instance_status() accepts a string
instance id or a list of instance ids.  Unfortunately the id from a
boto.ec2.instance.Instance can not be used, because a unicode instance
id causes the method call to fail. Now an Instance id works.
@todddeluca

This comment has been minimized.

Show comment Hide comment
@todddeluca

todddeluca May 9, 2012

This snippet demonstrates the bad behavior for one of my instances:

import boto
conn = boto.connect_ec2()
instanceid = "i-2921ff4f"
print repr(instanceid)
instance = conn.get_all_instances(instanceid)[0].instances[0]
print repr(instance.id)
conn.get_all_instances(instance.id)[0]

Here is the output:

'i-2921ff4f'
u'i-2921ff4f'
Traceback (most recent call last):
  File "foo.py", line 7, in <module>
    conn.get_all_instances(instance.id)[0]
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/ec2/connection.py", line 467, in get_all_instances
    [('item', Reservation)], verb='POST')
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/connection.py", line 896, in get_list
    raise self.ResponseError(response.status, response.reason, body)
boto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>InvalidInstanceID.Malformed</Code><Message>Invalid id: "-" (expecting "i-...")</Message></Error></Errors><RequestID>af498bfa-3054-49bb-9ff3-80094a5766f4</RequestID></Response>

This snippet demonstrates the bad behavior for one of my instances:

import boto
conn = boto.connect_ec2()
instanceid = "i-2921ff4f"
print repr(instanceid)
instance = conn.get_all_instances(instanceid)[0].instances[0]
print repr(instance.id)
conn.get_all_instances(instance.id)[0]

Here is the output:

'i-2921ff4f'
u'i-2921ff4f'
Traceback (most recent call last):
  File "foo.py", line 7, in <module>
    conn.get_all_instances(instance.id)[0]
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/ec2/connection.py", line 467, in get_all_instances
    [('item', Reservation)], verb='POST')
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/connection.py", line 896, in get_list
    raise self.ResponseError(response.status, response.reason, body)
boto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>InvalidInstanceID.Malformed</Code><Message>Invalid id: "-" (expecting "i-...")</Message></Error></Errors><RequestID>af498bfa-3054-49bb-9ff3-80094a5766f4</RequestID></Response>
@pasc

This comment has been minimized.

Show comment Hide comment
@pasc

pasc Feb 27, 2013

Contributor

This ticket can be closed (it was implemented differently in #1066 )

Contributor

pasc commented Feb 27, 2013

This ticket can be closed (it was implemented differently in #1066 )

@todddeluca todddeluca closed this Mar 26, 2014

dyzsasd pushed a commit to dailymotion/boto that referenced this pull request May 9, 2017

Merge pull request #741 from boto/port-s3transfer
Merging port-s3transfer branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment