Bug 906929 - blockdevicemapping.py does not populate a request parameter as per the syntax in AWS EC2 API reference
Summary: blockdevicemapping.py does not populate a request parameter as per the syntax...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora EPEL
Classification: Fedora
Component: python-boto
Version: el6
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
Assignee: Garrett Holmstrom
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-02-01 22:44 UTC by Swathi Gangisetty
Modified: 2013-08-22 00:46 UTC (History)
4 users (show)

Fixed In Version: euca2ools-2.1.3-2.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-08-21 19:00:24 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Patch file for the code fix (646 bytes, application/octet-stream)
2013-02-01 22:44 UTC, Swathi Gangisetty
no flags Details

Description Swathi Gangisetty 2013-02-01 22:44:01 UTC
Created attachment 691782 [details]
Patch file for the code fix

Description of problem:
AWS EC2 API reference for RunInstances and RegisterImage:

http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-RunInstances.html
http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-RegisterImage.html

As per the EC2 API reference syntax for the request parameter to suppress a device mapping is BlockDeviceMapping.n.NoDevice. 

Line number 128 in boto script blockdevicemapping.py constructs this request parameter incorrectly. It is of the form BlockDeviceMapping.Ebs.n.NoDevice where the "Ebs." substring is the additional element. EC2 fails to recognize the request parameter constructed by boto and therefore fails the RegisterImage/RunInstances request

Version-Release number of selected component (if applicable):
boto-2.8.0

How reproducible:
always

Steps to Reproduce:
Used ipython to reproduce the issue. Every step is followed by the corresponding ipython operation

1. Create an AWS EC2 account. Using boto scripts establish a connection to EC2. Bump up the debug level.
In [46]: from boto import ec2
In [47]: ec2=ec2.EC2Connection(aws_access_key_id='myaccesskey', aws_secret_access_key='mysecretkey',host='https://ec2.us-east-1.amazonaws.com')

2. Create an instance of "BlockDeviceType" with no_device=True.
In [48]: bdt = BlockDeviceType(no_device=True)

3. Initialize an instance of "BlockDeviceMapping" using the "BlockDeviceType" object created above.
In [49]: bdm = BlockDeviceMapping()
In [50]: bdm['/dev/sda1']=bdt

4. Register a boot from ebs image using the above objects. 
In [51]: ec2.register_image(name='bfebs1',root_device_name='/dev/sda1',block_device_map=bdm)

Dump from the above request, notice the syntax of NoDevice request parameter

send: 'POST / HTTP/1.1\r\nHost: ec2.us-east-1.amazonaws.com\r\nAccept-Encoding: identity\r\nContent-Length: 396\r\nContent-Type: application/x-www-form-urlencoded; charset=UTF-8\r\nUser-Agent: Boto/2.8.0 (linux2)\r\n\r\n'
send: 'AWSAccessKeyId=myaccesskey=RegisterImage&BlockDeviceMapping.1.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.1.Ebs.DeleteOnTermination=false&BlockDeviceMapping.1.Ebs.NoDevice=true&Name=bfebs1&RootDeviceName=%2Fdev%2Fsda1&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2013-02-01T22%3A00%3A54Z&Version=2012-06-01&Signature=somerandomcharacters'

  
Actual results:
EC2 rejects this request as it does not recognize the request parameter "NoDevice". The error response from EC2 is:

EC2ResponseError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>UnknownParameter</Code><Message>The parameter NoDevice is not recognized</Message></Error></Errors><RequestID>71fc7bb5-0ad1-40d0-ab8e-bba853e4ed81</RequestID></Response>


Expected results:

Same operation using ec2 command line tools, notice the syntax of NoDevice request parameter

# ec2-register -n swathibfebs1 --root-device-name /dev/sda1 --block-device-mapping /dev/sda1=none --verbose
Setting User-Agent to [ec2-api-tools 1.6.6.3]
2013-02-01 14:26:00,577 [main] DEBUG org.apache.http.wire  - >> "POST / HTTP/1.1[\r][\n]"
2013-02-01 14:26:00,578 [main] DEBUG org.apache.http.wire  - >> "Host: ec2.us-east-1.amazonaws.com[\r][\n]"
2013-02-01 14:26:00,578 [main] DEBUG org.apache.http.wire  - >> "User-Agent: ec2-api-tools 1.6.6.3[\r][\n]"
2013-02-01 14:26:00,579 [main] DEBUG org.apache.http.wire  - >> "Content-Type: application/x-www-form-urlencoded; charset=utf-8[\r][\n]"
2013-02-01 14:26:00,579 [main] DEBUG org.apache.http.wire  - >> "Content-Length: 351[\r][\n]"
2013-02-01 14:26:00,579 [main] DEBUG org.apache.http.wire  - >> "Connection: Keep-Alive[\r][\n]"
2013-02-01 14:26:00,579 [main] DEBUG org.apache.http.wire  - >> "[\r][\n]"
2013-02-01 14:26:00,579 [main] DEBUG org.apache.http.wire  - >> "Name=swathibfebs1&RootDeviceName=%2Fdev%2Fsda1&Action=RegisterImage&SignatureMethod=HmacSHA256&BlockDeviceMapping.1.DeviceName=%2Fdev%2Fsda1&AWSAccessKeyId=myaccesskey&SignatureVersion=2&BlockDeviceMapping.1.NoDevice=&Version=2012-12-01&Signature=somerandomcharacters&Timestamp=2013-02-01T22%3A25%3A59.899Z"


Additional info:

Submitted a pull request with the code fix.

Comment 1 Fedora Update System 2013-07-02 22:45:26 UTC
python-boto-2.9.6-2.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/python-boto-2.9.6-2.el6

Comment 2 Fedora Update System 2013-07-03 20:53:58 UTC
Package python-boto-2.9.6-2.el6:
* should fix your issue,
* was pushed to the Fedora EPEL 6 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=epel-testing python-boto-2.9.6-2.el6'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-EPEL-2013-10719/python-boto-2.9.6-2.el6
then log in and leave karma (feedback).

Comment 3 Fedora Update System 2013-07-03 23:58:58 UTC
euca2ools-2.1.3-2.fc19,python-boto-2.9.6-2.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/euca2ools-2.1.3-2.fc19,python-boto-2.9.6-2.fc19

Comment 4 Fedora Update System 2013-07-04 20:04:03 UTC
Package python-boto-2.9.6-2.el6, euca2ools-2.1.3-2.el6:
* should fix your issue,
* was pushed to the Fedora EPEL 6 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=epel-testing python-boto-2.9.6-2.el6 euca2ools-2.1.3-2.el6'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-EPEL-2013-10719/euca2ools-2.1.3-2.el6,python-boto-2.9.6-2.el6
then log in and leave karma (feedback).

Comment 5 Fedora Update System 2013-08-21 19:00:24 UTC
euca2ools-2.1.3-2.el6, python-boto-2.9.9-2.el6 has been pushed to the Fedora EPEL 6 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 6 Fedora Update System 2013-08-22 00:46:09 UTC
euca2ools-2.1.3-2.fc19, python-boto-2.9.6-2.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.