Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
flame-clmc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flame
flame-clmc
Commits
d1a70994
Commit
d1a70994
authored
Sep 21, 2018
by
Nikolay Stanchev
Browse files
Options
Downloads
Patches
Plain Diff
Slight code refactoring
parent
4df8037b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/service/clmcservice/alertsapi/alerts_specification_schema.py
+18
-18
18 additions, 18 deletions
...vice/clmcservice/alertsapi/alerts_specification_schema.py
src/service/clmcservice/alertsapi/views.py
+4
-1
4 additions, 1 deletion
src/service/clmcservice/alertsapi/views.py
with
22 additions
and
19 deletions
src/service/clmcservice/alertsapi/alerts_specification_schema.py
+
18
−
18
View file @
d1a70994
...
@@ -23,22 +23,22 @@
...
@@ -23,22 +23,22 @@
"""
"""
# Python standard libs
# Python standard libs
from
re
import
compile
,
IGNORECASE
import
re
# PIP installed libs
# PIP installed libs
from
schema
import
Schema
,
And
,
Or
,
Optional
,
SchemaError
from
schema
import
Schema
,
And
,
Or
,
Optional
,
SchemaError
"""
This module defines the schema objects for the TOSCA Alert Specification:
#
This module defines the schema objects for the TOSCA Alert Specification:
#
* flame_clmc_alerts_definitions.yaml must be the only import
#
* flame_clmc_alerts_definitions.yaml must be the only import
* metadata section must be present (with key-value pairs for sfc and sfci)
#
* metadata section must be present (with key-value pairs for sfc and sfci)
* policies section must be present (under the topology_template node)
#
* policies section must be present (under the topology_template node)
* each policy must be associated with a triggers node (containing at least 1 trigger)
#
* each policy must be associated with a triggers node (containing at least 1 trigger)
* each policy is of type eu.ict-flame.policies.StateChange or eu.ict-flame.policies.Alert
#
* each policy is of type eu.ict-flame.policies.StateChange or eu.ict-flame.policies.Alert
* each trigger must specify event_type, metric, condition, and at least one handler in action/implementation
#
* each trigger must specify event_type, metric, condition, and at least one handler in action/implementation
* the condition section must specify threshold, granularity, aggregation_method, comparison_operator
#
* the condition section must specify threshold, granularity, aggregation_method, comparison_operator
"""
# Influx QL functions defined in the documentation https://docs.influxdata.com/influxdb/v1.6/query_language/functions/
# Influx QL functions defined in the documentation https://docs.influxdata.com/influxdb/v1.6/query_language/functions/
INFLUX_QL_FUNCTIONS
=
(
INFLUX_QL_FUNCTIONS
=
(
...
@@ -52,14 +52,14 @@ TICK_SCRIPT_TEMPLATES = ("threshold", "relative", "deadman")
...
@@ -52,14 +52,14 @@ TICK_SCRIPT_TEMPLATES = ("threshold", "relative", "deadman")
COMPARISON_OPERATORS
=
{
"
lt
"
:
"
<
"
,
"
gt
"
:
"
>
"
,
"
lte
"
:
"
<=
"
,
"
gte
"
:
"
>=
"
,
"
eq
"
:
"
=
"
,
"
neq
"
:
"
<>
"
}
COMPARISON_OPERATORS
=
{
"
lt
"
:
"
<
"
,
"
gt
"
:
"
>
"
,
"
lte
"
:
"
<=
"
,
"
gte
"
:
"
>=
"
,
"
eq
"
:
"
=
"
,
"
neq
"
:
"
<>
"
}
# Regular expression for validating http handlers
# Regular expression for validating http handlers
URL_REGEX
=
compile
(
URL_REGEX
=
re
.
compile
(
r
'
^https?://
'
# http:// or https://
r
'
^https?://
'
# http:// or https://
r
'
(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|
'
# domain, e.g. example.domain.com
r
'
(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|
'
# domain, e.g. example.domain.com
r
'
localhost|
'
# or localhost...
r
'
localhost|
'
# or localhost...
r
'
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})
'
# or IP address (IPv4 format)
r
'
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})
'
# or IP address (IPv4 format)
r
'
(?::\d{2,5})?
'
# optional port number
r
'
(?::\d{2,5})?
'
# optional port number
r
'
(?:[/?#][^\s]*)?$
'
,
# URL path or query parameters
r
'
(?:[/?#][^\s]*)?$
'
,
# URL path or query parameters
IGNORECASE
)
re
.
IGNORECASE
)
# Global tags allowed to be used for filtering in the trigger condition
# Global tags allowed to be used for filtering in the trigger condition
CLMC_INFORMATION_MODEL_GLOBAL_TAGS
=
{
"
flame_sfc
"
,
"
flame_sfci
"
,
"
flame_sfp
"
,
"
flame_sf
"
,
"
flame_sfe
"
,
"
flame_server
"
,
"
flame_location
"
}
CLMC_INFORMATION_MODEL_GLOBAL_TAGS
=
{
"
flame_sfc
"
,
"
flame_sfci
"
,
"
flame_sfp
"
,
"
flame_sf
"
,
"
flame_sfe
"
,
"
flame_server
"
,
"
flame_location
"
}
...
@@ -120,10 +120,10 @@ def validate_clmc_alerts_specification(tosca_yaml_tpl, include_error=False):
...
@@ -120,10 +120,10 @@ def validate_clmc_alerts_specification(tosca_yaml_tpl, include_error=False):
try
:
try
:
ALERTS_SPECIFICATION_SCHEMA
.
validate
(
tosca_yaml_tpl
)
ALERTS_SPECIFICATION_SCHEMA
.
validate
(
tosca_yaml_tpl
)
valid
,
err
=
True
,
None
valid
,
err
=
True
,
None
except
SchemaError
as
e
:
except
SchemaError
as
schema_error
:
valid
,
err
=
False
,
e
valid
,
err
=
False
,
schema_error
if
include_error
:
if
include_error
:
return
valid
,
err
return
valid
,
err
else
:
return
valid
return
valid
This diff is collapsed.
Click to expand it.
src/service/clmcservice/alertsapi/views.py
+
4
−
1
View file @
d1a70994
...
@@ -59,6 +59,9 @@ class AlertsConfigurationAPI(object):
...
@@ -59,6 +59,9 @@ class AlertsConfigurationAPI(object):
@view_config
(
route_name
=
'
alerts_configuration
'
,
request_method
=
'
GET
'
)
@view_config
(
route_name
=
'
alerts_configuration
'
,
request_method
=
'
GET
'
)
def
get_alerts_hash
(
self
):
def
get_alerts_hash
(
self
):
"""
Retrieves hash value for alerts task, topic and handlers based on sfc, sfci, policy and trigger IDs
"""
for
param
in
(
"
sfc
"
,
"
sfci
"
,
"
policy
"
,
"
trigger
"
):
for
param
in
(
"
sfc
"
,
"
sfci
"
,
"
policy
"
,
"
trigger
"
):
if
param
not
in
self
.
request
.
params
:
if
param
not
in
self
.
request
.
params
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment