'HealthCheck': {'Type': 'Map',
'Schema': healthcheck_schema},
'Instances': {'Type': 'List'},
- 'Listeners': {'Type': 'List',
- 'Schema': {'Type': 'Map',
- 'Schema': listeners_schema}},
+ 'Listeners': {'Type': 'List', 'Required': True,
+ 'Schema': {'Type': 'Map', 'Schema': listeners_schema}},
'AppCookieStickinessPolicy': {'Type': 'String',
'Implemented': False},
'LBCookieStickinessPolicy': {'Type': 'String',
'Subnets': {'Type': 'List',
'Implemented': False}
}
+ update_allowed_keys = ('Properties',)
+ update_allowed_properties = ('Instances',)
def _instance_to_ipaddress(self, inst):
'''
return self.create_with_template(templ, param)
+ def handle_update(self, json_snippet, tmpl_diff, prop_diff):
+ '''
+ re-generate the Metadata
+ save it to the db.
+ rely on the cfn-hup to reconfigure HAProxy
+ '''
+ if 'Instances' in prop_diff:
+ templ = template_format.parse(lb_template)
+ cfg = self._haproxy_config(templ, prop_diff['Instances'])
+
+ md = self.nested()['LB_instance'].metadata
+ files = md['AWS::CloudFormation::Init']['config']['files']
+ files['/etc/haproxy/haproxy.cfg']['content'] = cfg
+
+ self.nested()['LB_instance'].metadata = md
+
def handle_delete(self):
self.delete_nested()
return {'Error':
'Interval must be larger than Timeout'}
- def reload(self, inst_list):
- '''
- re-generate the Metadata
- save it to the db.
- rely on the cfn-hup to reconfigure HAProxy
- '''
- templ = template_format.parse(lb_template)
- cfg = self._haproxy_config(templ, inst_list)
-
- md = self.nested()['LB_instance'].metadata
- files = md['AWS::CloudFormation::Init']['config']['files']
- files['/etc/haproxy/haproxy.cfg']['content'] = cfg
-
- self.nested()['LB_instance'].metadata = md
-
def FnGetRefId(self):
return unicode(self.name)
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AutoScaling Test",
- "Parameters" : {},
+ "Parameters" : {
+ "KeyName": {
+ "Type": "String"
+ }
+ },
"Resources" : {
"WebServerGroup" : {
"Type" : "AWS::AutoScaling::AutoScalingGroup",
}
},
"ElasticLoadBalancer" : {
- "Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
+ "Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
+ "Properties" : {
+ "AvailabilityZones" : ["nova"],
+ "Listeners" : [ {
+ "LoadBalancerPort" : "80",
+ "InstancePort" : "80",
+ "Protocol" : "HTTP"
+ }]
+ }
},
"LaunchConfig" : {
"Type" : "AWS::AutoScaling::LaunchConfiguration",
if unset:
self.m.VerifyAll()
self.m.UnsetStubs()
- self.m.StubOutWithMock(loadbalancer.LoadBalancer, 'reload')
- loadbalancer.LoadBalancer.reload(expected_list).AndReturn(None)
+ self.m.StubOutWithMock(loadbalancer.LoadBalancer, 'handle_update')
+
+ loadbalancer.LoadBalancer.handle_update(
+ mox.IgnoreArg(), mox.IgnoreArg(), {'Instances': expected_list})\
+ .AndReturn(None)
def _stub_meta_expected(self, now, data, nmeta=1):
# Stop time at now
from heat.common import config
from heat.common import template_format
from heat.engine import clients
-from heat.engine import resource
from heat.engine import scheduler
from heat.engine.resources import instance
from heat.engine.resources import user
s)
id_list.append(inst.FnGetRefId())
- rsrc.reload(id_list)
+ rsrc.handle_update(rsrc.json_snippet, {}, {'Instances': id_list})
self.assertEqual('4.5.6.7', rsrc.FnGetAtt('DNSName'))
self.assertEqual('', rsrc.FnGetAtt('SourceSecurityGroupName'))
except exception.InvalidTemplateAttribute:
pass
- self.assertRaises(resource.UpdateReplace,
- rsrc.handle_update, {}, {}, {})
+ self.assertEqual(None, rsrc.handle_update({}, {}, {}))
self.m.VerifyAll()