Merge "Allow for keeping prefix in heat_url"

This commit is contained in:
Jenkins 2017-06-07 23:36:58 +00:00 committed by Gerrit Code Review
commit 14cbf5c167
2 changed files with 15 additions and 4 deletions

View File

@ -200,13 +200,11 @@ class SignalResponder(stack_user.StackUser):
return
url = self.client_plugin('heat').get_heat_url()
host_url = urlparse.urlparse(url)
path = self.identifier().url_path()
if project_id is not None:
path = project_id + path[path.find('/'):]
url = urlparse.urlunsplit(
(host_url.scheme, host_url.netloc, 'v1/%s/signal' % path, '', ''))
url = urlparse.urljoin(url, '%s/signal' % path)
self.data_set('heat_signal_url', url)
return url

View File

@ -318,7 +318,7 @@ class ScalingPolicyAttrTest(common.HeatTestCase):
self.m.StubOutWithMock(self.stack.clients.client_plugin('heat'),
'get_heat_url')
self.stack.clients.client_plugin('heat').get_heat_url().AndReturn(
'http://server.test:8000/v1')
'http://server.test:8000/v1/')
self.m.ReplayAll()
self.assertEqual(
'http://server.test:8000/v1/test_tenant_id/stacks/'
@ -326,3 +326,16 @@ class ScalingPolicyAttrTest(common.HeatTestCase):
self.stack.name, self.stack.id),
self.policy.FnGetAtt('signal_url'))
self.m.VerifyAll()
def test_signal_attribute_with_prefix(self):
self.m.StubOutWithMock(self.stack.clients.client_plugin('heat'),
'get_heat_url')
self.stack.clients.client_plugin('heat').get_heat_url().AndReturn(
'http://server.test/heat-api/v1/1234')
self.m.ReplayAll()
self.assertEqual(
'http://server.test/heat-api/v1/test_tenant_id/stacks/'
'%s/%s/resources/my-policy/signal' % (
self.stack.name, self.stack.id),
self.policy.FnGetAtt('signal_url'))
self.m.VerifyAll()