Merge "Make ASG resource work when no lb is specified"
This commit is contained in:
commit
f3232ae7d8
@ -121,6 +121,7 @@ class Group(resource.Resource):
|
||||
_('List of load balancers to hook the '
|
||||
'server up to. If not specified, no '
|
||||
'load balancing will be configured.'),
|
||||
default=[],
|
||||
schema=properties.Schema(
|
||||
properties.Schema.MAP,
|
||||
schema={
|
||||
@ -292,15 +293,14 @@ class Group(resource.Resource):
|
||||
server_args = lcargs[self.LAUNCH_CONFIG_ARGS_SERVER]
|
||||
lb_args = lcargs.get(self.LAUNCH_CONFIG_ARGS_LOAD_BALANCERS)
|
||||
lbs = copy.deepcopy(lb_args)
|
||||
if lbs:
|
||||
for lb in lbs:
|
||||
# if the port is not specified, the lbid must be that of a
|
||||
# RackConnectV3 lb pool.
|
||||
if not lb[self.LAUNCH_CONFIG_ARGS_LOAD_BALANCER_PORT]:
|
||||
del lb[self.LAUNCH_CONFIG_ARGS_LOAD_BALANCER_PORT]
|
||||
continue
|
||||
lbid = int(lb[self.LAUNCH_CONFIG_ARGS_LOAD_BALANCER_ID])
|
||||
lb[self.LAUNCH_CONFIG_ARGS_LOAD_BALANCER_ID] = lbid
|
||||
for lb in lbs:
|
||||
# if the port is not specified, the lbid must be that of a
|
||||
# RackConnectV3 lb pool.
|
||||
if not lb[self.LAUNCH_CONFIG_ARGS_LOAD_BALANCER_PORT]:
|
||||
del lb[self.LAUNCH_CONFIG_ARGS_LOAD_BALANCER_PORT]
|
||||
continue
|
||||
lbid = int(lb[self.LAUNCH_CONFIG_ARGS_LOAD_BALANCER_ID])
|
||||
lb[self.LAUNCH_CONFIG_ARGS_LOAD_BALANCER_ID] = lbid
|
||||
personality = server_args.get(
|
||||
self.LAUNCH_CONFIG_ARGS_SERVER_PERSONALITY)
|
||||
if personality:
|
||||
|
@ -313,7 +313,7 @@ Resources:
|
||||
'flavor': 'flavor-ref',
|
||||
'image': 'image-ref',
|
||||
'launch_config_type': 'launch_server',
|
||||
'load_balancers': None,
|
||||
'load_balancers': [],
|
||||
'key_name': "my-key",
|
||||
'max_entities': 25,
|
||||
'group_metadata': {'group': 'metadata'},
|
||||
@ -757,3 +757,31 @@ class AutoScaleGroupValidationTests(common.HeatTestCase):
|
||||
mock.Mock(id='pool_exists'),
|
||||
]
|
||||
self.assertIsNone(asg.validate())
|
||||
|
||||
def test_validate_no_lb_specified(self, mock_client, mock_plugin):
|
||||
asg_properties = {
|
||||
"groupConfiguration": {
|
||||
"name": "My Group",
|
||||
"cooldown": 60,
|
||||
"minEntities": 1,
|
||||
"maxEntities": 25,
|
||||
"metadata": {
|
||||
"group": "metadata",
|
||||
},
|
||||
},
|
||||
"launchConfiguration": {
|
||||
"type": "launch_server",
|
||||
"args": {
|
||||
"server": {
|
||||
"name": "sdfsdf",
|
||||
"flavorRef": "ffdgdf",
|
||||
"imageRef": "image-ref",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
rsrcdef = rsrc_defn.ResourceDefinition(
|
||||
"test", auto_scale.Group, properties=asg_properties)
|
||||
asg = auto_scale.Group("test", rsrcdef, self.mockstack)
|
||||
|
||||
self.assertIsNone(asg.validate())
|
||||
|
Loading…
Reference in New Issue
Block a user