import string

template = string.Template("""#contrail-collector-marker-start
listen contrail-collector-stats :5938
   mode http
   stats enable
   stats uri /
   stats auth $__contrail_hap_user__:$__contrail_hap_passwd__

frontend  contrail-analytics-api *:8081
    default_backend    contrail-analytics-api

backend contrail-analytics-api
    option nolinger
    balance     roundrobin
    option tcp-check
    tcp-check connect port 6379
    default-server error-limit 1 on-error mark-down
$__contrail_analytics_api_backend_servers__

#contrail-collector-marker-end
""")

import string

template = string.Template("""#contrail-collector-marker-start
listen contrail-collector-stats :5938
   mode http
   stats enable
   stats uri /
   stats auth $__contrail_hap_user__:$__contrail_hap_passwd__

frontend  contrail-analytics-api *:8081
    default_backend    contrail-analytics-api

backend contrail-analytics-api
    option nolinger
    timeout server 3m
    balance     roundrobin
$__contrail_analytics_api_backend_servers__

#contrail-collector-marker-end
""")

Remove tcp-check connect option for redis on haproxy
Remove tcp-check connect option for redis on haproxy

tcp-check connect option for redis on haproxy.cfg causes the client
connections in the redis-server to grow continuously and reaches the max
limit resulting in connection failure/response error for requests from
collector and other analytics services to redis.

Change-Id: If088ba40e7f0bc420a753ec11bca9dd081ffb160
Partial-Bug: #1648601

  import string
  
  template = string.Template("""#contrail-collector-marker-start
  listen contrail-collector-stats :5938
     mode http
     stats enable
     stats uri /
     stats auth $__contrail_hap_user__:$__contrail_hap_passwd__
  
  frontend  contrail-analytics-api *:8081
      default_backend    contrail-analytics-api
  
  backend contrail-analytics-api
      option nolinger
+     timeout server 3m
      balance     roundrobin
-     option tcp-check
-     tcp-check connect port 6379
-     default-server error-limit 1 on-error mark-down
  $__contrail_analytics_api_backend_servers__
  
  #contrail-collector-marker-end
  """)
  
Remove tcp-check connect option for redis on haproxy
## Code Before:
import string

template = string.Template("""#contrail-collector-marker-start
listen contrail-collector-stats :5938
   mode http
   stats enable
   stats uri /
   stats auth $__contrail_hap_user__:$__contrail_hap_passwd__

frontend  contrail-analytics-api *:8081
    default_backend    contrail-analytics-api

backend contrail-analytics-api
    option nolinger
    balance     roundrobin
    option tcp-check
    tcp-check connect port 6379
    default-server error-limit 1 on-error mark-down
$__contrail_analytics_api_backend_servers__

#contrail-collector-marker-end
""")

## Instruction:
Remove tcp-check connect option for redis on haproxy
## Code After:
import string

template = string.Template("""#contrail-collector-marker-start
listen contrail-collector-stats :5938
   mode http
   stats enable
   stats uri /
   stats auth $__contrail_hap_user__:$__contrail_hap_passwd__

frontend  contrail-analytics-api *:8081
    default_backend    contrail-analytics-api

backend contrail-analytics-api
    option nolinger
    timeout server 3m
    balance     roundrobin
$__contrail_analytics_api_backend_servers__

#contrail-collector-marker-end
""")
