]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
loadbalancer: implement Interval and Timeout
authorAngus Salkeld <asalkeld@redhat.com>
Tue, 24 Jul 2012 04:09:29 +0000 (14:09 +1000)
committerAngus Salkeld <asalkeld@redhat.com>
Tue, 24 Jul 2012 06:47:45 +0000 (16:47 +1000)
Change-Id: I74abc742371cb23ddfe38f83812662a9d42f3d43
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
heat/engine/loadbalancer.py

index 12e8115c88131a4ae8dc1c5ad3c5a0c2922a7273..fcc440501608661aeedddf8c82a62603e18d4dab 100644 (file)
@@ -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