Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "Migrate LBaaS Custom Attributes Code to svc_monitor"
- Loading branch information
Showing
8 changed files
with
313 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ psutil>=0.6.0 | |
bottle | ||
kombu | ||
kazoo | ||
pyyaml |
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
Empty file.
60 changes: 60 additions & 0 deletions
60
...vc_monitor/services/loadbalancer/drivers/ha_proxy/custom_attributes/custom_attributes.yml
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,60 @@ | ||
# HAProxy custom attributes | ||
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 | ||
frontend: | ||
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 | ||
tls_container: | ||
type: CustomAttrTlsContainer | ||
limits: "" | ||
cmd: "" |
74 changes: 74 additions & 0 deletions
74
...svc_monitor/services/loadbalancer/drivers/ha_proxy/custom_attributes/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,74 @@ | ||
import logging | ||
import inspect | ||
import os | ||
|
||
class CustomAttr(object): | ||
"""This type handles non-flat data-types like | ||
int, str, bool. | ||
""" | ||
def __init__(self, key, value): | ||
self._value = value | ||
self._key = key | ||
|
||
def validate(self): | ||
pass | ||
|
||
def post_validation(self): | ||
pass | ||
|
||
class CustomAttrTlsContainer(CustomAttr): | ||
def __init__(self, key, value): | ||
super(CustomAttrTlsContainer, self).__init__(key, value) | ||
|
||
def validate(self): | ||
return True | ||
|
||
def post_validation(self): | ||
return self._value | ||
|
||
def validate_custom_attributes(custom_attributes_dict, section, | ||
custom_attributes): | ||
section_dict = {} | ||
if custom_attributes and section in custom_attributes_dict: | ||
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 = int(value) | ||
if value in range(limits[0], limits[1]): | ||
section_dict.update({key:value}) | ||
else: | ||
logging.info("Skipping key: %s, value: %s due to" \ | ||
"validation failure" % (key, value)) | ||
elif type_attr == 'str': | ||
if len(value) in range(limits[0], limits[1]): | ||
section_dict.update({key:value}) | ||
else: | ||
logging.info("Skipping key: %s, value: %s due to" \ | ||
"validation failure" % (key, value)) | ||
elif type_attr == 'bool': | ||
if value in limits: | ||
if value == 'True': | ||
value = '' | ||
elif value == 'False': | ||
value = 'no ' | ||
section_dict.update({key:value}) | ||
else: | ||
logging.info("Skipping key: %s, value: %s due to" \ | ||
"validation failure" % (key, value)) | ||
elif inspect.isclass(eval(type_attr)): | ||
new_custom_attr = eval(type_attr)(key, value) | ||
if new_custom_attr.validate(): | ||
value = new_custom_attr.post_validation() | ||
section_dict.update({key:value}) | ||
else: | ||
logging.info("Skipping key: %s, value: %s due to" \ | ||
"validation failure" % (key, value)) | ||
except Exception as e: | ||
logging.error(str(e)) | ||
continue | ||
|
||
return section_dict |
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
Oops, something went wrong.