diff options
author | Scott Moser <smoser@ubuntu.com> | 2014-08-22 11:40:25 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2014-08-22 11:40:25 -0400 |
commit | d723c17b7abe5263d879d748dade763034cce476 (patch) | |
tree | 82a1c08cd27af2df550ff4760095f766ba4b9db6 /tests/unittests/test_ec2_util.py | |
parent | bbe4b997819f43089aea12141ea393c1a46fe84d (diff) | |
download | vyos-cloud-init-d723c17b7abe5263d879d748dade763034cce476.tar.gz vyos-cloud-init-d723c17b7abe5263d879d748dade763034cce476.zip |
ec2_utils.py: get_instance_metadata explicitly add trailing /
This change works around a bug in CloudStack's EC2 api implementation.
That is filed upstream at [1].
The fix is safe for openstack and EC2 use cases as well.
EC2 and OpenStacks' EC2 metadata service both return a list with
access to either of:
<url_base>/latest/meta-data
<url_base>/latest/meta-data/
Additionally, the responses explicitly contain a trailing '/' for
items that have a child. The ec2_utils code then just re-uses the trailng
/ there. Thus, only the top level request for 'meta-data/' needs
the explicit fix.
This also changes test cases. Those test cases failed without fixing
them. If ever this regressed, those would fail again.
--
[1] https://issues.apache.org/jira/browse/CLOUDSTACK-7405
LP: #1356855
Diffstat (limited to 'tests/unittests/test_ec2_util.py')
-rw-r--r-- | tests/unittests/test_ec2_util.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/unittests/test_ec2_util.py b/tests/unittests/test_ec2_util.py index 700254a3..84aa002e 100644 --- a/tests/unittests/test_ec2_util.py +++ b/tests/unittests/test_ec2_util.py @@ -44,7 +44,7 @@ class TestEc2Util(helpers.HttprettyTestCase): @hp.activate def test_metadata_fetch_no_keys(self): - base_url = 'http://169.254.169.254/%s/meta-data' % (self.VERSION) + base_url = 'http://169.254.169.254/%s/meta-data/' % (self.VERSION) hp.register_uri(hp.GET, base_url, status=200, body="\n".join(['hostname', 'instance-id', @@ -62,7 +62,7 @@ class TestEc2Util(helpers.HttprettyTestCase): @hp.activate def test_metadata_fetch_key(self): - base_url = 'http://169.254.169.254/%s/meta-data' % (self.VERSION) + base_url = 'http://169.254.169.254/%s/meta-data/' % (self.VERSION) hp.register_uri(hp.GET, base_url, status=200, body="\n".join(['hostname', 'instance-id', @@ -83,7 +83,7 @@ class TestEc2Util(helpers.HttprettyTestCase): @hp.activate def test_metadata_fetch_with_2_keys(self): - base_url = 'http://169.254.169.254/%s/meta-data' % (self.VERSION) + base_url = 'http://169.254.169.254/%s/meta-data/' % (self.VERSION) hp.register_uri(hp.GET, base_url, status=200, body="\n".join(['hostname', 'instance-id', @@ -108,7 +108,7 @@ class TestEc2Util(helpers.HttprettyTestCase): @hp.activate def test_metadata_fetch_bdm(self): - base_url = 'http://169.254.169.254/%s/meta-data' % (self.VERSION) + base_url = 'http://169.254.169.254/%s/meta-data/' % (self.VERSION) hp.register_uri(hp.GET, base_url, status=200, body="\n".join(['hostname', 'instance-id', |