Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Allow custom configs with LBaaS
This fix takes care of haproxy parsing and validation changes on vrouter agent. Removing extra white spaces Closes-Bug: #1475393 Change-Id: I822e27792f78168a178d555db5703fa1e73d0cc9
- Loading branch information
Varun Lodaya
authored and
Varun Lodaya
committed
Sep 3, 2015
1 parent
cd74710
commit cfbd9b8
Showing
3 changed files
with
162 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
src/vnsw/opencontrail-vrouter-netns/opencontrail_vrouter_netns/haproxy_validator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
custom_attributes_dict = { | ||
'global': { | ||
'max_conn': { | ||
'type': int, | ||
'limits': [1, 65535], | ||
'cmd': 'maxconn %d' | ||
}, | ||
'max_conn_rate': { | ||
'type': int, | ||
'limits': [1, 65535], | ||
'cmd': 'maxconnrate %d' | ||
}, | ||
'max_sess_rate': { | ||
'type': int, | ||
'limits': [1, 65535], | ||
'cmd': 'maxsessrate %d' | ||
}, | ||
'max_ssl_conn': { | ||
'type': int, | ||
'limits': [1, 65535], | ||
'cmd': 'maxsslconn %d' | ||
}, | ||
'max_ssl_rate': { | ||
'type': int, | ||
'limits': [1, 65535], | ||
'cmd': 'maxsslrate %d' | ||
}, | ||
'ssl_ciphers': { | ||
'type': str, | ||
'limits': [1, 100], | ||
'cmd': 'ssl-default-bind-ciphers %s' | ||
}, | ||
'tune_http_max_header': { | ||
'type': int, | ||
'limits': [1, 128], | ||
'cmd': 'tune.http.maxhdr %d' | ||
}, | ||
'tune_ssl_max_record': { | ||
'type': int, | ||
'limits': [1, 16384], | ||
'cmd': 'tune.ssl.maxrecord %d' | ||
} | ||
}, | ||
'default': { | ||
'server_timeout': { | ||
'type': int, | ||
'limits': [1, 5000000], | ||
'cmd': 'timeout server %d' | ||
}, | ||
'client_timeout': { | ||
'type': int, | ||
'limits': [1, 5000000], | ||
'cmd': 'timeout client %d' | ||
}, | ||
'connect_timeout': { | ||
'type': int, | ||
'limits': [1, 5000000], | ||
'cmd': 'timeout connect %d' | ||
} | ||
}, | ||
'vip': { | ||
'http_server_close': { | ||
'type': bool, | ||
'limits': ['True', 'False'], | ||
'cmd': '%soption http-server-close' | ||
}, | ||
'rate_limit_sessions': { | ||
'type': int, | ||
'limits': [1, 65535], | ||
'cmd': 'rate-limit sessions %d' | ||
} | ||
}, | ||
'pool': {}, | ||
} | ||
|
||
def validate_custom_attributes(config, section): | ||
section_dict = {} | ||
if 'custom-attributes' in config and section in custom_attributes_dict: | ||
custom_attributes = config['custom-attributes'] | ||
for key, value in custom_attributes.iteritems(): | ||
if key in custom_attributes_dict[section]: | ||
#Sanitize the value | ||
try: | ||
type_attr = custom_attributes_dict[section][key]['type'] | ||
limits = custom_attributes_dict[section][key]['limits'] | ||
if type_attr == int: | ||
value = type_attr(value) | ||
if value in range(limits[0], limits[1]): | ||
section_dict.update({key:value}) | ||
elif type_attr == str: | ||
if len(value) in range(limits[0], limits[1]): | ||
section_dict.update({key:value}) | ||
elif type_attr == bool: | ||
if value in limits: | ||
if value == 'True': | ||
value = '' | ||
elif value == 'False': | ||
value = 'no ' | ||
section_dict.update({key:value}) | ||
except Exception as e: | ||
print "Skipping key: %s, value: %s due to validation failure" \ | ||
% (key, value) | ||
continue | ||
|
||
return section_dict |