Fix heat hint file reading to work properly
Heat does not give us the exact API version to request, so we must infer version 1 (/v1/) since that is what we speak. The other test cases are all updated to use /v1/ too, so that the fakes can remain the same. Change-Id: Ifb74546db16836aaa67fdd647aad2c5cf8aa84b4
This commit is contained in:
parent
3722ca41e2
commit
2d4451a80f
@ -57,7 +57,7 @@ class Collector(object):
|
||||
if (CONF.cfn.heat_metadata_hint
|
||||
and os.path.exists(CONF.cfn.heat_metadata_hint)):
|
||||
with open(CONF.cfn.heat_metadata_hint) as hint:
|
||||
CONF.cfn.metadata_url = hint.read().strip()
|
||||
CONF.cfn.metadata_url = '%s/v1/' % hint.read().strip()
|
||||
else:
|
||||
logger.warn('No metadata_url configured.')
|
||||
raise exc.CfnMetadataNotConfigured
|
||||
|
@ -63,7 +63,7 @@ class FakeRequests(object):
|
||||
self._test.addDetail('url', test_content.text_content(url))
|
||||
url = urlparse.urlparse(url)
|
||||
self._test.assertEquals(self._expected_netloc, url.netloc)
|
||||
self._test.assertEquals('/', url.path)
|
||||
self._test.assertEquals('/v1/', url.path)
|
||||
self._test.assertEquals('application/json',
|
||||
headers['Content-Type'])
|
||||
self._test.assertIn('SignatureVersion', params)
|
||||
@ -97,7 +97,7 @@ class TestCfn(testtools.TestCase):
|
||||
self.log = self.useFixture(fixtures.FakeLogger())
|
||||
self.useFixture(fixtures.NestedTempfile())
|
||||
self.hint_file = tempfile.NamedTemporaryFile()
|
||||
self.hint_file.write('http://127.0.0.1:8000/')
|
||||
self.hint_file.write('http://127.0.0.1:8000')
|
||||
self.hint_file.flush()
|
||||
self.addCleanup(self.hint_file.close)
|
||||
collect.setup_conf()
|
||||
@ -155,7 +155,7 @@ class TestCfn(testtools.TestCase):
|
||||
self.assertEquals(u'banana', content[u'b'])
|
||||
|
||||
def test_collect_cfn_metadata_url_overrides_hint(self):
|
||||
cfg.CONF.cfn.metadata_url = 'http://127.0.1.1:8000/'
|
||||
cfg.CONF.cfn.metadata_url = 'http://127.0.1.1:8000/v1/'
|
||||
cfn_collect = cfn.Collector(
|
||||
requests_impl=FakeRequests(self,
|
||||
expected_netloc='127.0.1.1:8000'))
|
||||
|
@ -71,7 +71,7 @@ class TestCollect(testtools.TestCase):
|
||||
'--config-file',
|
||||
'/dev/null',
|
||||
'--cfn-metadata-url',
|
||||
'http://127.0.0.1:8000/',
|
||||
'http://127.0.0.1:8000/v1/',
|
||||
'--cfn-stack-name',
|
||||
'foo',
|
||||
'--cfn-path',
|
||||
@ -116,7 +116,7 @@ class TestCollect(testtools.TestCase):
|
||||
'--config-file',
|
||||
'/dev/null',
|
||||
'--cfn-metadata-url',
|
||||
'http://127.0.0.1:8000/',
|
||||
'http://127.0.0.1:8000/v1/',
|
||||
'--cfn-stack-name',
|
||||
'foo',
|
||||
'--cfn-path',
|
||||
@ -179,7 +179,7 @@ class TestCollectAll(testtools.TestCase):
|
||||
self.addCleanup(restore_copy)
|
||||
|
||||
cfg.CONF.cachedir = self.cache_dir.path
|
||||
cfg.CONF.cfn.metadata_url = 'http://127.0.0.1:8000/'
|
||||
cfg.CONF.cfn.metadata_url = 'http://127.0.0.1:8000/v1/'
|
||||
cfg.CONF.cfn.stack_name = 'foo'
|
||||
cfg.CONF.cfn.path = ['foo.Metadata']
|
||||
cfg.CONF.cfn.access_key_id = '0123456789ABCDEF'
|
||||
|
Loading…
x
Reference in New Issue
Block a user