Skip to content
Snippets Groups Projects
Commit c1700266 authored by Nikolay Stanchev's avatar Nikolay Stanchev
Browse files

Updates alert spec. schema to allow all kind of tags rather than limiting to global tags only

parent 4bd1486f
No related branches found
No related tags found
No related merge requests found
......@@ -64,8 +64,10 @@ URL_REGEX = re.compile(
r'(?:[/?#][^\s]*)?$', # URL path or query parameters
re.IGNORECASE)
# Global tags allowed to be used for filtering in the trigger condition
CLMC_INFORMATION_MODEL_GLOBAL_TAGS = {"flame_sfp", "flame_sf", "flame_server", "flame_location"}
# Global tags allowed to be used for filtering in the trigger condition - removed the restriction, so that all tags could be used for filtering (not just global)
# CLMC_INFORMATION_MODEL_GLOBAL_TAGS = {"flame_sfp", "flame_sf", "flame_server", "flame_location"}
# NOTICE that "flame_sfc", "flame_sfci" are not allowed, even though they are part of the CLMC Information Model
# This is because those two tags are automatically added to the InfluxDB queries - the required values are retrieved from the alert spec. metadata
# "flame_sfe" cannot be used as well, because the value of this tag is only known at runtime.
......@@ -95,7 +97,7 @@ ALERTS_SPECIFICATION_SCHEMA = Schema({
"granularity": And(int, lambda p: p > 0),
Optional("aggregation_method"): And(str, lambda s: s in INFLUX_QL_FUNCTIONS),
Optional("resource_type"): {
And(str, lambda s: s in CLMC_INFORMATION_MODEL_GLOBAL_TAGS): str
str: str
},
Optional("comparison_operator"): And(str, lambda s: s in COMPARISON_OPERATORS)
},
......
......@@ -535,8 +535,9 @@ class AlertsConfigurationAPI(object):
raise HTTPBadRequest("Request alert specification file could not be parsed as a valid TOSCA document.")
# validate against CLMC spec.
valid_alert_spec = validate_clmc_alerts_specification(tosca_tpl.tpl)
valid_alert_spec, error = validate_clmc_alerts_specification(tosca_tpl.tpl, include_error=True)
if not valid_alert_spec:
log.error("Error encountered while validating alerts specification against CLMC alerts specification schema - {0}".format(error))
raise HTTPBadRequest("Request alert specification file could not be validated as a CLMC TOSCA alerts specification document.")
return tosca_tpl
......
......@@ -7,6 +7,7 @@ imports:
metadata:
servicefunctionchain: companyA-VR
sfc: companyA-VR # correct metadata field is servicefunctionchain
# sfci: companyA-VR-premium
topology_template:
......@@ -24,7 +25,6 @@ topology_template:
granularity: 120
aggregation_method: mean
resource_type:
flame_sfc: companyA-VR # not allowed - sfc tag is automatically added in the filters
flame_location: watershed
comparison_operator: gt
action:
......
......@@ -7,7 +7,7 @@ imports:
metadata:
servicefunctionchain: companyA-VR
# sfci: companyA-VR-premium
sfci: companyA-VR-premium # not allowed - sfc instance tag is automatically added in the filters
topology_template:
......@@ -24,7 +24,6 @@ topology_template:
granularity: 120
aggregation_method: mean
resource_type:
flame_sfci: companyA-VR-premium # not allowed - sfci tag is automatically added in the filters
flame_location: watershed
comparison_operator: gt
action:
......
......@@ -26,7 +26,7 @@ topology_template:
granularity: 60
aggregation_method: last
resource_type:
flame_sf_package_id: storage # sf_package_id is not the correct tag name, it is sfp
status_code: 200 # integers must be quoted as strings when used as tag values, e.g. '200'
flame_sf: storage-users
flame_location: watershed
comparison_operator: lt
......
......@@ -41,6 +41,7 @@ topology_template:
threshold: -100 # requests have decreased by at least 100
granularity: 120
resource_type:
status_code: '200'
flame_sfp: storage
flame_sf: storage-users
flame_location: watershed
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment