boto/boto — pull request #1897 by hiroki-soum (2013-12-09 07:04:57+00:00)
Title: Fixing user data url

I'm working on instance initiation by CloudInit in CloudStack and have a problem when I use boto 2.9.0 later together. The problem is that I can't get "user-data" by boto.

This commit is for fixing access url to fetch user-data. I of course know a similar issue(https://github.com/boto/boto/pull/1856) and a pull request are already made.

However, this patch fixes it in a different way. I only changed get_instance_userdata and it makes no harm to fetching meta-data from meta-data service url. My suggestion is described in detail below.

CloudInit in CloudStack uses boto for retrieving meta-data and user-data, becuase CloudStack provides those data like Amazon EC2. So, CloudInit simply calls boto.utils.get_instance_metadata and boto.utils.get_instance_userdata to get them.

Access url composition routine in boto.utils.get_instance_userdata was changed at 2.9.0 and it is a reason of failing to get user-data. Difference is below.

(1) before 2.8.0 http:///latest/user-data
(2) after 2.9.0 http:///latest/user-data/

user-data service in CloudStack provides only user-data at (1) and an access to (2) leads to 404 Not Found error.

A document of Amazon EC2 also describes that the service url is (1).

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html

I think url composition like (2) is not correct though the access to (2) actually works fine in Amazon EC2 because the url may be redirected or rewritten to (1).

So, this patch fixes backward compatibility and gives boto portability to CloudStack in fetching user-data.