Merge "Use configurable flavor for AWS LoadBalancer"
This commit is contained in:
@@ -34,6 +34,10 @@ lb_template_default = r'''
|
||||
"Parameters" : {
|
||||
"KeyName" : {
|
||||
"Type" : "String"
|
||||
},
|
||||
"LbFlavor" : {
|
||||
"Type" : "String",
|
||||
"Default" : "m1.small"
|
||||
}
|
||||
},
|
||||
"Resources": {
|
||||
@@ -158,7 +162,7 @@ lb_template_default = r'''
|
||||
},
|
||||
"Properties": {
|
||||
"ImageId": "Fedora-Cloud-Base-20141203-21.x86_64",
|
||||
"InstanceType": "m1.small",
|
||||
"InstanceType": { "Ref": "LbFlavor" },
|
||||
"KeyName": { "Ref": "KeyName" },
|
||||
"UserData": { "Fn::Base64": { "Fn::Join": ["", [
|
||||
"#!/bin/bash -v\n",
|
||||
@@ -519,6 +523,9 @@ backend servers
|
||||
if 'KeyName' in self.stack.parameters:
|
||||
params['KeyName'] = self.stack.parameters['KeyName']
|
||||
|
||||
if 'LbFlavor' in self.stack.parameters:
|
||||
params['LbFlavor'] = self.stack.parameters['LbFlavor']
|
||||
|
||||
return params
|
||||
|
||||
def child_template(self):
|
||||
|
||||
@@ -35,6 +35,11 @@ lb_template = '''
|
||||
"Description" : "KeyName",
|
||||
"Type" : "String",
|
||||
"Default" : "test"
|
||||
},
|
||||
"LbFlavor" : {
|
||||
"Description" : "Flavor to use for LoadBalancer instance",
|
||||
"Type": "String",
|
||||
"Default": "m1.heat"
|
||||
}
|
||||
},
|
||||
"Resources": {
|
||||
@@ -148,10 +153,11 @@ class LoadBalancerTest(common.HeatTestCase):
|
||||
rsrc = self.setup_loadbalancer()
|
||||
self.assertRaises(exception.StackValidationFailed, rsrc.validate)
|
||||
|
||||
def setup_loadbalancer(self, include_keyname=True):
|
||||
def setup_loadbalancer(self, include_magic=True):
|
||||
template = template_format.parse(lb_template)
|
||||
if not include_keyname:
|
||||
if not include_magic:
|
||||
del template['Parameters']['KeyName']
|
||||
del template['Parameters']['LbFlavor']
|
||||
stack = utils.parse_stack(template)
|
||||
|
||||
resource_name = 'LoadBalancer'
|
||||
@@ -184,7 +190,7 @@ class LoadBalancerTest(common.HeatTestCase):
|
||||
|
||||
def test_child_params_without_key_name(self):
|
||||
rsrc = self.setup_loadbalancer(False)
|
||||
self.assertEqual({}, rsrc.child_params())
|
||||
self.assertNotIn('KeyName', rsrc.child_params())
|
||||
|
||||
def test_child_params_with_key_name(self):
|
||||
rsrc = self.setup_loadbalancer()
|
||||
@@ -210,6 +216,16 @@ class LoadBalancerTest(common.HeatTestCase):
|
||||
|
||||
self.assertEqual('foo', rsrc.child_template())
|
||||
|
||||
def test_child_params_with_flavor(self):
|
||||
rsrc = self.setup_loadbalancer()
|
||||
params = rsrc.child_params()
|
||||
self.assertEqual('m1.heat', params['LbFlavor'])
|
||||
|
||||
def test_child_params_without_flavor(self):
|
||||
rsrc = self.setup_loadbalancer(False)
|
||||
params = rsrc.child_params()
|
||||
self.assertNotIn('LbFlavor', params)
|
||||
|
||||
|
||||
class HaProxyConfigTest(common.HeatTestCase):
|
||||
def setUp(self):
|
||||
|
||||
Reference in New Issue
Block a user