summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorPratik Mallya <pratik.mallya@gmail.com>2016-01-19 09:43:20 -0600
committerPratik Mallya <pratik.mallya@gmail.com>2016-01-19 14:15:40 -0600
commit8107f1ebfdeceef0e7724d599574a3a5759a7edc (patch)
tree8e7e15abd6b1638d0fe4702a6db12354f5f07a91 /contrib
parentbf2065782464bbd57d4eec49221d17f8d50f1e70 (diff)
downloadheat-8107f1ebfdeceef0e7724d599574a3a5759a7edc.tar.gz
Make ASG resource work when no lb is specified
Change-Id: I0a5a2b62ad1a81f0201d6cd8202bd6e11f7c569c Closes-Bug: #1535778
Diffstat (limited to 'contrib')
-rw-r--r--contrib/rackspace/rackspace/resources/auto_scale.py18
-rw-r--r--contrib/rackspace/rackspace/tests/test_auto_scale.py30
2 files changed, 38 insertions, 10 deletions
diff --git a/contrib/rackspace/rackspace/resources/auto_scale.py b/contrib/rackspace/rackspace/resources/auto_scale.py
index 498eeec38..068500fc8 100644
--- a/contrib/rackspace/rackspace/resources/auto_scale.py
+++ b/contrib/rackspace/rackspace/resources/auto_scale.py
@@ -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:
diff --git a/contrib/rackspace/rackspace/tests/test_auto_scale.py b/contrib/rackspace/rackspace/tests/test_auto_scale.py
index 06a9dde24..2104fe5fe 100644
--- a/contrib/rackspace/rackspace/tests/test_auto_scale.py
+++ b/contrib/rackspace/rackspace/tests/test_auto_scale.py
@@ -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())