From 8a7ea792b00fa470270d85b3d08f210b5e98b78f Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Tue, 24 Jul 2012 14:09:29 +1000 Subject: [PATCH] loadbalancer: implement Interval and Timeout Change-Id: I74abc742371cb23ddfe38f83812662a9d42f3d43 Signed-off-by: Angus Salkeld --- heat/engine/loadbalancer.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/heat/engine/loadbalancer.py b/heat/engine/loadbalancer.py index 12e8115c..fcc44050 100644 --- a/heat/engine/loadbalancer.py +++ b/heat/engine/loadbalancer.py @@ -254,11 +254,13 @@ class LoadBalancer(stack.Stack): health_chk = self.properties['HealthCheck'] if health_chk: check = 'check inter %ss fall %s rise %s' % ( - health_chk.get('Interval', '2'), - health_chk.get('UnHealthyTheshold', '3'), - health_chk.get('HealthyTheshold', '3')) + health_chk['Interval'], + health_chk['UnHealthyTheshold'], + health_chk['HealthyTheshold']) + timeout_check = 'timeout check %ds' % (health_chk['Timeout']) else: check = '' + timeout_check = '' backend = ''' default_backend servers @@ -268,7 +270,8 @@ class LoadBalancer(stack.Stack): option http-server-close option forwardfor option httpchk -''' + %s +''' % timeout_check servers = [] n = 1 @@ -293,6 +296,20 @@ class LoadBalancer(stack.Stack): self.create_with_template(templ) + def validate(self): + ''' + Validate any of the provided params + ''' + res = super(LoadBalancer, self).validate() + if res: + return res + + health_chk = self.properties['HealthCheck'] + if health_chk: + if float(health_chk['Interval']) >= float(health_chk['Timeout']): + return {'Error': + 'Interval must be larger than Timeout'} + def reload(self, inst_list): ''' re-generate the Metadata -- 2.45.2