Fetch endpoint from service catalog

Fetch endpoint from service catalog for building signal url
if not specified in config.

Change-Id: If8a2d3f37d87c26228e709c20f61969b397f2da0
This commit is contained in:
Rabi Mishra 2015-05-21 21:12:40 +05:30
parent bf669cbf13
commit e33075dd85
13 changed files with 28 additions and 74 deletions

View File

@ -45,7 +45,6 @@ service_opts = [
default="",
help=_('URL of the Heat metadata server.')),
cfg.StrOpt('heat_waitcondition_server_url',
default="",
help=_('URL of the Heat waitcondition server.')),
cfg.StrOpt('heat_watch_server_url',
default="",

View File

@ -68,8 +68,14 @@ class SignalResponder(stack_user.StackUser):
'no stored access/secret key'))
return
waitcond_url = cfg.CONF.heat_waitcondition_server_url
signal_url = waitcond_url.replace('/waitcondition', signal_type)
config_url = cfg.CONF.heat_waitcondition_server_url
if config_url:
signal_url = config_url.replace('/waitcondition', signal_type)
else:
heat_client_plugin = self.stack.clients.client_plugin('heat')
endpoint = heat_client_plugin.get_heat_url()
signal_url = ''.join([endpoint, signal_type])
host_url = urlparse.urlparse(signal_url)
path = self.identifier().arn_url_path()

View File

@ -13,7 +13,6 @@
import json
import mock
from oslo_config import cfg
import six
from heat.common import exception
@ -33,8 +32,6 @@ class TestAutoScalingGroupValidation(common.HeatTestCase):
super(TestAutoScalingGroupValidation, self).setUp()
resource._register_class('ResourceWithPropsAndAttrs',
generic_resource.ResourceWithPropsAndAttrs)
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
self.parsed = template_format.parse(inline_templates.as_heat_template)
def test_invalid_min_size(self):
@ -93,8 +90,6 @@ class TestInitialGroupSize(common.HeatTestCase):
def setUp(self):
super(TestInitialGroupSize, self).setUp()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
def test_initial_size(self):
t = template_format.parse(inline_templates.as_heat_template)
@ -112,8 +107,6 @@ class TestInitialGroupSize(common.HeatTestCase):
class TestGroupAdjust(common.HeatTestCase):
def setUp(self):
super(TestGroupAdjust, self).setUp()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
resource._register_class('ResourceWithPropsAndAttrs',
generic_resource.ResourceWithPropsAndAttrs)
@ -285,8 +278,6 @@ class TestGroupCrud(common.HeatTestCase):
super(TestGroupCrud, self).setUp()
resource._register_class('ResourceWithPropsAndAttrs',
generic_resource.ResourceWithPropsAndAttrs)
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
self.stub_ImageConstraint_validate()
self.stub_FlavorConstraint_validate()
self.stub_SnapshotConstraint_validate()
@ -364,8 +355,6 @@ class TestGroupCrud(common.HeatTestCase):
class HeatScalingGroupAttrTest(common.HeatTestCase):
def setUp(self):
super(HeatScalingGroupAttrTest, self).setUp()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
resource._register_class('ResourceWithPropsAndAttrs',
generic_resource.ResourceWithPropsAndAttrs)
@ -467,8 +456,6 @@ class RollingUpdatePolicyTest(common.HeatTestCase):
self.stub_keystoneclient(username='test_stack.CfnLBUser')
resource._register_class('ResourceWithPropsAndAttrs',
generic_resource.ResourceWithPropsAndAttrs)
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://127.0.0.1:8000/v1/waitcondition')
def test_parse_without_update_policy(self):
tmpl = template_format.parse(inline_templates.as_heat_template)
@ -531,8 +518,6 @@ class RollingUpdatePolicyDiffTest(common.HeatTestCase):
self.stub_keystoneclient(username='test_stack.CfnLBUser')
resource._register_class('ResourceWithPropsAndAttrs',
generic_resource.ResourceWithPropsAndAttrs)
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://127.0.0.1:8000/v1/waitcondition')
def validate_update_policy_diff(self, current, updated):
# load current stack
@ -602,8 +587,6 @@ class IncorrectUpdatePolicyTest(common.HeatTestCase):
self.stub_keystoneclient(username='test_stack.CfnLBUser')
resource._register_class('ResourceWithPropsAndAttrs',
generic_resource.ResourceWithPropsAndAttrs)
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://127.0.0.1:8000/v1/waitcondition')
def test_with_update_policy_aws(self):
t = template_format.parse(inline_templates.as_heat_template)

View File

@ -14,7 +14,6 @@
import datetime
import mock
from oslo_config import cfg
from oslo_utils import timeutils
import six
@ -37,8 +36,6 @@ class TestAutoScalingPolicy(common.HeatTestCase):
super(TestAutoScalingPolicy, self).setUp()
resource._register_class('ResourceWithPropsAndAttrs',
generic_resource.ResourceWithPropsAndAttrs)
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
def create_scaling_policy(self, t, stack, resource_name):
rsrc = stack[resource_name]
@ -130,8 +127,6 @@ class TestAutoScalingPolicy(common.HeatTestCase):
class TestCooldownMixin(common.HeatTestCase):
def setUp(self):
super(TestCooldownMixin, self).setUp()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
def create_scaling_policy(self, t, stack, resource_name):
rsrc = stack[resource_name]
@ -207,8 +202,6 @@ class TestCooldownMixin(common.HeatTestCase):
class ScalingPolicyAttrTest(common.HeatTestCase):
def setUp(self):
super(ScalingPolicyAttrTest, self).setUp()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
t = template_format.parse(as_template)
self.stack = utils.parse_stack(t, params=as_params)
self.stack_name = self.stack.name
@ -219,8 +212,12 @@ class ScalingPolicyAttrTest(common.HeatTestCase):
self.policy.state)
def test_alarm_attribute(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:8000/v1')
self.m.ReplayAll()
alarm_url = self.policy.FnGetAtt('alarm_url')
base = alarm_url.split('?')[0].split('%3A')
self.assertEqual('http://server.test:8000/v1/signal/arn', base[0])
self.assertEqual('openstack', base[1])
@ -239,3 +236,4 @@ class ScalingPolicyAttrTest(common.HeatTestCase):
self.assertEqual('AWSAccessKeyId', args[2].split('=')[0])
self.assertEqual('SignatureVersion', args[3].split('=')[0])
self.assertEqual('Signature', args[4].split('=')[0])
self.m.VerifyAll()

View File

@ -12,7 +12,6 @@
# under the License.
import mock
from oslo_config import cfg
import six
from heat.common import exception
@ -28,8 +27,6 @@ from heat.tests import utils
class LaunchConfigurationTest(common.HeatTestCase):
def setUp(self):
super(LaunchConfigurationTest, self).setUp()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
def validate_launch_config(self, t, stack, resource_name):
# create the launch configuration resource

View File

@ -14,7 +14,6 @@
import json
import mock
from oslo_config import cfg
import six
from heat.common import exception
@ -36,8 +35,6 @@ as_template = inline_templates.as_template
class TestAutoScalingGroupValidation(common.HeatTestCase):
def setUp(self):
super(TestAutoScalingGroupValidation, self).setUp()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
def validate_scaling_group(self, t, stack, resource_name):
# create the launch configuration resource
@ -276,8 +273,6 @@ class TestInitialGroupSize(common.HeatTestCase):
def setUp(self):
super(TestInitialGroupSize, self).setUp()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
def test_initial_size(self):
t = template_format.parse(as_template)
@ -295,8 +290,6 @@ class TestInitialGroupSize(common.HeatTestCase):
class TestGroupAdjust(common.HeatTestCase):
def setUp(self):
super(TestGroupAdjust, self).setUp()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
t = template_format.parse(as_template)
self.stack = utils.parse_stack(t, params=inline_templates.as_params)
@ -464,9 +457,6 @@ class TestGroupAdjust(common.HeatTestCase):
class TestGroupCrud(common.HeatTestCase):
def setUp(self):
super(TestGroupCrud, self).setUp()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
t = template_format.parse(as_template)
self.stack = utils.parse_stack(t, params=inline_templates.as_params)
self.group = self.stack['WebServerGroup']
@ -587,8 +577,6 @@ class RollingUpdatePolicyTest(common.HeatTestCase):
self.stub_ImageConstraint_validate()
self.stub_FlavorConstraint_validate()
self.stub_SnapshotConstraint_validate()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://127.0.0.1:8000/v1/waitcondition')
def test_parse_without_update_policy(self):
tmpl = template_format.parse(inline_templates.as_template)
@ -654,8 +642,6 @@ class RollingUpdatePolicyDiffTest(common.HeatTestCase):
super(RollingUpdatePolicyDiffTest, self).setUp()
self.fc = fakes_nova.FakeClient()
self.stub_keystoneclient(username='test_stack.CfnLBUser')
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://127.0.0.1:8000/v1/waitcondition')
def validate_update_policy_diff(self, current, updated):
# load current stack

View File

@ -14,7 +14,6 @@
import datetime
import mock
from oslo_config import cfg
from oslo_utils import timeutils
import six
@ -34,8 +33,6 @@ as_params = inline_templates.as_params
class TestAutoScalingPolicy(common.HeatTestCase):
def setUp(self):
super(TestAutoScalingPolicy, self).setUp()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
def create_scaling_policy(self, t, stack, resource_name):
rsrc = stack[resource_name]
@ -130,8 +127,6 @@ class TestAutoScalingPolicy(common.HeatTestCase):
class TestCooldownMixin(common.HeatTestCase):
def setUp(self):
super(TestCooldownMixin, self).setUp()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
def create_scaling_policy(self, t, stack, resource_name):
rsrc = stack[resource_name]

View File

@ -74,8 +74,6 @@ class LoadBalancerTest(common.HeatTestCase):
def setUp(self):
super(LoadBalancerTest, self).setUp()
self.fc = fakes_nova.FakeClient()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
def test_loadbalancer(self):
t = template_format.parse(lb_template)

View File

@ -16,7 +16,6 @@ import datetime
import json
import uuid
from oslo_config import cfg
from oslo_utils import timeutils
import six
@ -79,8 +78,6 @@ class WaitConditionTest(common.HeatTestCase):
def setUp(self):
super(WaitConditionTest, self).setUp()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
def create_stack(self, stack_id=None,
template=test_template_waitcondition, params=None,
@ -351,8 +348,6 @@ class WaitConditionTest(common.HeatTestCase):
class WaitConditionHandleTest(common.HeatTestCase):
def setUp(self):
super(WaitConditionHandleTest, self).setUp()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
def create_stack(self, stack_name=None, stack_id=None):
temp = template_format.parse(test_template_waitcondition)
@ -378,10 +373,8 @@ class WaitConditionHandleTest(common.HeatTestCase):
stack.id, '', 'WaitHandle')
self.m.StubOutWithMock(aws_wch.WaitConditionHandle, 'identifier')
aws_wch.WaitConditionHandle.identifier().MultipleTimes().AndReturn(id)
self.m.ReplayAll()
stack.create()
return stack
def test_handle(self):
@ -391,6 +384,11 @@ class WaitConditionHandleTest(common.HeatTestCase):
self.stack = self.create_stack(stack_id=stack_id,
stack_name=stack_name)
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')
self.m.ReplayAll()
rsrc = self.stack['WaitHandle']
# clear the url
rsrc.data_set('ec2_signed_url', None, False)
@ -521,8 +519,6 @@ class WaitConditionHandleTest(common.HeatTestCase):
class WaitConditionUpdateTest(common.HeatTestCase):
def setUp(self):
super(WaitConditionUpdateTest, self).setUp()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
def create_stack(self, temp=None):
if temp is None:

View File

@ -17,7 +17,6 @@ import json
from ceilometerclient import exc as ceilometerclient_exc
import mock
import mox
from oslo_config import cfg
import six
from heat.common import exception
@ -118,10 +117,6 @@ class CeilometerAlarmTest(common.HeatTestCase):
resource._register_class('SignalResourceType',
generic_resource.SignalResource)
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
self.fa = mock.Mock()
def create_stack(self, template=None):

View File

@ -13,7 +13,6 @@
import mox
from oslo_config import cfg
from heat.common import identifier
from heat.common import template_format
@ -213,8 +212,6 @@ class WaitCondMetadataUpdateTest(common.HeatTestCase):
super(WaitCondMetadataUpdateTest, self).setUp()
self.man = service.EngineService('a-host', 'a-topic')
self.man.create_periodic_tasks()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
def create_stack(self, stack_name='test_stack'):
temp = template_format.parse(test_template_waitcondition)

View File

@ -15,7 +15,6 @@ import datetime
import six
from keystoneclient import exceptions as kc_exceptions
from oslo_config import cfg
from heat.common import exception
from heat.common import template_format
@ -54,9 +53,6 @@ class SignalTest(common.HeatTestCase):
resource._register_class('GenericResourceType',
generic_resource.GenericResource)
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
self.stack_id = 'STACKABCD1234'
def tearDown(self):
@ -146,6 +142,11 @@ class SignalTest(common.HeatTestCase):
def test_FnGetAtt_Alarm_Url(self):
self.stack = self.create_stack()
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')
self.m.ReplayAll()
self.stack.create()
@ -186,7 +187,11 @@ class SignalTest(common.HeatTestCase):
def test_FnGetAtt_delete(self):
self.stack = self.create_stack()
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')
self.m.ReplayAll()
self.stack.create()

View File

@ -77,7 +77,6 @@ basic_configuration() {
BRIDGE_IP=127.0.0.1
iniset $target DEFAULT heat_metadata_server_url "http://${BRIDGE_IP}:8000/"
iniset $target DEFAULT heat_waitcondition_server_url "http://${BRIDGE_IP}:8000/v1/waitcondition/"
iniset $target DEFAULT heat_watch_server_url "http://${BRIDGE_IP}:8003/"
if detect_rabbit