Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TFS
controller
Commits
18a6c2e6
Commit
18a6c2e6
authored
7 months ago
by
Konstantinos Poulakakis
Browse files
Options
Downloads
Patches
Plain Diff
Complete Automation Service implementation. Add correct error messages. Add analyzer before policy.
parent
e5baccf9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!294
Release TeraFlowSDN 4.0
,
!238
Automation component skeleton
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/automation/service/AutomationServiceServicerImpl.py
+44
-50
44 additions, 50 deletions
src/automation/service/AutomationServiceServicerImpl.py
src/tests/hackfest3/tests/test_functional_create_service.py
+2
-0
2 additions, 0 deletions
src/tests/hackfest3/tests/test_functional_create_service.py
with
46 additions
and
50 deletions
src/automation/service/AutomationServiceServicerImpl.py
+
44
−
50
View file @
18a6c2e6
...
@@ -58,47 +58,57 @@ class AutomationServiceServicerImpl(AutomationServiceServicer):
...
@@ -58,47 +58,57 @@ class AutomationServiceServicerImpl(AutomationServiceServicer):
policy_client
=
PolicyClient
()
policy_client
=
PolicyClient
()
telemetry_frontend_client
=
TelemetryFrontendClient
()
telemetry_frontend_client
=
TelemetryFrontendClient
()
analytics_frontend_client
=
AnalyticsFrontendClient
()
analytics_frontend_client
=
AnalyticsFrontendClient
()
analytic_frontend_service
=
AnalyticsFrontendServiceServicerImpl
()
LOGGER
.
info
(
'
Trying to get the service
'
)
LOGGER
.
info
(
'
request.serviceId.service_uuid.uuid({:s})
'
.
format
(
str
(
request
.
serviceId
.
service_uuid
.
uuid
)))
LOGGER
.
info
(
'
request.serviceId.service_uuid({:s})
'
.
format
(
str
(
request
.
serviceId
.
service_uuid
)))
LOGGER
.
info
(
'
request.serviceId({:s})
'
.
format
(
str
(
request
.
serviceId
)))
LOGGER
.
info
(
'
Request({:s})
'
.
format
(
str
(
request
)))
try
:
try
:
# TODO: Remove static variables(get them from ZSMCreateRequest)
# TODO: Refactor policy component (remove unnecessary variables)
####### GET Context #######################
####### GET Context #######################
LOGGER
.
info
(
'
Get the service from Context:
'
)
service
:
Service
=
context_client
.
GetService
(
request
.
serviceId
)
service
:
Service
=
context_client
.
GetService
(
request
.
serviceId
)
LOGGER
.
info
(
'
s
ervice({:s})
'
.
format
(
str
(
service
)))
LOGGER
.
info
(
'
S
ervice
({:s})
:
'
.
format
(
str
(
service
)))
###########################################
###########################################
####### SET Kpi Descriptor LAT ################
####### SET Kpi Descriptor LAT ################
LOGGER
.
info
(
'
Set Kpi Descriptor LAT:
'
)
if
(
len
(
service
.
service_constraints
)
==
0
):
raise
InvalidArgumentException
(
"
service_constraints
"
,
"
empty
"
,
[]);
#
if(len(service.service_constraints)
== 0
):
if
(
len
(
service
.
service_constraints
)
>
1
):
#
raise InvalidArgumentException("
argument_name" , "argument_value
", []);
raise
InvalidArgumentException
(
"
service_constraints
"
,
"
>1
"
,
[]);
# KPI Descriptor
if
(
service
.
service_constraints
[
0
].
sla_latency
is
None
):
raise
InvalidArgumentException
(
"
sla_latency
"
,
"
empty
"
,
[]);
## Static Implementation Applied only in case of SLA Latency Constraint ##
# KPI Descriptor
kpi_descriptor_lat
=
KpiDescriptor
()
kpi_descriptor_lat
=
KpiDescriptor
()
kpi_descriptor_lat
.
kpi_sample_type
=
701
#'KPISAMPLETYPE_SERVICE_LATENCY_MS' #static service.service_constraints[].sla_latency.e2e_latency_ms
kpi_descriptor_lat
.
kpi_sample_type
=
701
#'KPISAMPLETYPE_SERVICE_LATENCY_MS' #static service.service_constraints[].sla_latency.e2e_latency_ms
kpi_descriptor_lat
.
service_id
.
service_uuid
.
uuid
=
request
.
serviceId
.
service_uuid
.
uuid
kpi_descriptor_lat
.
service_id
.
service_uuid
.
uuid
=
request
.
serviceId
.
service_uuid
.
uuid
kpi_descriptor_lat
.
kpi_id
.
kpi_id
.
uuid
=
str
(
uuid4
())
kpi_descriptor_lat
.
kpi_id
.
kpi_id
.
uuid
=
str
(
uuid4
())
kpi_id_lat
:
KpiId
=
kpi_manager_client
.
SetKpiDescriptor
(
kpi_descriptor_lat
)
kpi_id_lat
:
KpiId
=
kpi_manager_client
.
SetKpiDescriptor
(
kpi_descriptor_lat
)
LOGGER
.
info
(
'
kpi_id_lat({:s})
'
.
format
(
str
(
kpi_id_lat
)))
LOGGER
.
info
(
'
The
kpi_id_lat({:s})
'
.
format
(
str
(
kpi_id_lat
)))
###########################################
###########################################
####### SET Kpi Descriptor TX ################
####### SET Kpi Descriptor TX ################
LOGGER
.
info
(
'
Set Kpi Descriptor TX:
'
)
kpi_descriptor_tx
=
KpiDescriptor
()
kpi_descriptor_tx
=
KpiDescriptor
()
kpi_descriptor_tx
.
kpi_sample_type
=
101
# static KPISAMPLETYPE_PACKETS_TRANSMITTED
kpi_descriptor_tx
.
kpi_sample_type
=
101
# static KPISAMPLETYPE_PACKETS_TRANSMITTED
kpi_descriptor_tx
.
service_id
.
service_uuid
.
uuid
=
request
.
serviceId
.
service_uuid
.
uuid
kpi_descriptor_tx
.
service_id
.
service_uuid
.
uuid
=
request
.
serviceId
.
service_uuid
.
uuid
kpi_descriptor_tx
.
kpi_id
.
kpi_id
.
uuid
=
str
(
uuid4
())
kpi_descriptor_tx
.
kpi_id
.
kpi_id
.
uuid
=
str
(
uuid4
())
kpi_id_tx
:
KpiId
=
kpi_manager_client
.
SetKpiDescriptor
(
kpi_descriptor_tx
)
kpi_id_tx
:
KpiId
=
kpi_manager_client
.
SetKpiDescriptor
(
kpi_descriptor_tx
)
LOGGER
.
info
(
'
kpi_id_tx({:s})
'
.
format
(
str
(
kpi_id_tx
)))
LOGGER
.
info
(
'
The
kpi_id_tx({:s})
'
.
format
(
str
(
kpi_id_tx
)))
###########################################
###########################################
####### SET Kpi Descriptor RX ################
####### SET Kpi Descriptor RX ################
LOGGER
.
info
(
'
Set Kpi Descriptor RX:
'
)
kpi_descriptor_rx
=
KpiDescriptor
()
kpi_descriptor_rx
=
KpiDescriptor
()
kpi_descriptor_rx
.
kpi_sample_type
=
102
# static KPISAMPLETYPE_PACKETS_RECEIVED
kpi_descriptor_rx
.
kpi_sample_type
=
102
# static KPISAMPLETYPE_PACKETS_RECEIVED
kpi_descriptor_rx
.
service_id
.
service_uuid
.
uuid
=
request
.
serviceId
.
service_uuid
.
uuid
kpi_descriptor_rx
.
service_id
.
service_uuid
.
uuid
=
request
.
serviceId
.
service_uuid
.
uuid
...
@@ -114,7 +124,7 @@ class AutomationServiceServicerImpl(AutomationServiceServicer):
...
@@ -114,7 +124,7 @@ class AutomationServiceServicerImpl(AutomationServiceServicer):
collect_tx
=
Collector
()
collect_tx
=
Collector
()
collect_tx
.
collector_id
.
collector_id
.
uuid
=
str
(
uuid4
())
collect_tx
.
collector_id
.
collector_id
.
uuid
=
str
(
uuid4
())
collect_tx
.
kpi_id
.
kpi_id
.
uuid
=
kpi_id_tx
.
kpi_id
.
uuid
collect_tx
.
kpi_id
.
kpi_id
.
uuid
=
kpi_id_tx
.
kpi_id
.
uuid
collect_tx
.
duration_s
=
2000
# static
collect_tx
.
duration_s
=
2000
0
# static
collect_tx
.
interval_s
=
1
# static
collect_tx
.
interval_s
=
1
# static
LOGGER
.
info
(
'
Start Collector TX
'
.
format
(
str
(
collect_tx
)))
LOGGER
.
info
(
'
Start Collector TX
'
.
format
(
str
(
collect_tx
)))
...
@@ -126,7 +136,7 @@ class AutomationServiceServicerImpl(AutomationServiceServicer):
...
@@ -126,7 +136,7 @@ class AutomationServiceServicerImpl(AutomationServiceServicer):
collect_rx
=
Collector
()
collect_rx
=
Collector
()
collect_rx
.
collector_id
.
collector_id
.
uuid
=
str
(
uuid4
())
collect_rx
.
collector_id
.
collector_id
.
uuid
=
str
(
uuid4
())
collect_rx
.
kpi_id
.
kpi_id
.
uuid
=
kpi_id_rx
.
kpi_id
.
uuid
collect_rx
.
kpi_id
.
kpi_id
.
uuid
=
kpi_id_rx
.
kpi_id
.
uuid
collect_rx
.
duration_s
=
2000
# static
collect_rx
.
duration_s
=
2000
0
# static
collect_rx
.
interval_s
=
1
# static
collect_rx
.
interval_s
=
1
# static
LOGGER
.
info
(
'
Start Collector RX
'
.
format
(
str
(
collect_rx
)))
LOGGER
.
info
(
'
Start Collector RX
'
.
format
(
str
(
collect_rx
)))
...
@@ -134,6 +144,24 @@ class AutomationServiceServicerImpl(AutomationServiceServicer):
...
@@ -134,6 +144,24 @@ class AutomationServiceServicerImpl(AutomationServiceServicer):
LOGGER
.
info
(
'
collect_id_tx({:s})
'
.
format
(
str
(
collect_id_rx
)))
LOGGER
.
info
(
'
collect_id_tx({:s})
'
.
format
(
str
(
collect_id_rx
)))
###############################################
###############################################
####### START Analyzer LAT ################
analyzer
=
Analyzer
()
analyzer
.
analyzer_id
.
analyzer_id
.
uuid
=
str
(
uuid4
())
analyzer
.
algorithm_name
=
'
Test_Aggregate_and_Threshold
'
# static
analyzer
.
operation_mode
=
2
analyzer
.
input_kpi_ids
.
append
(
kpi_id_rx
)
analyzer
.
input_kpi_ids
.
append
(
kpi_id_tx
)
analyzer
.
output_kpi_ids
.
append
(
kpi_id_lat
)
_threshold_dict
=
{
'
min_latency_E2E
'
:
(
0
,
service
.
service_constraints
[
0
].
sla_latency
.
e2e_latency_ms
)}
analyzer
.
parameters
[
'
thresholds
'
]
=
json
.
dumps
(
_threshold_dict
)
analyzer
.
parameters
[
'
window_size
'
]
=
"
60s
"
analyzer
.
parameters
[
'
window_slider
'
]
=
"
30s
"
analyzer_id_lat
:
AnalyzerId
=
analytics_frontend_client
.
StartAnalyzer
(
analyzer
)
LOGGER
.
info
(
'
analyzer_id_lat({:s})
'
.
format
(
str
(
analyzer_id_lat
)))
###########################################################
####### SET Policy LAT ################
####### SET Policy LAT ################
policy_lat
=
PolicyRuleService
()
policy_lat
=
PolicyRuleService
()
policy_lat
.
serviceId
.
service_uuid
.
uuid
=
request
.
serviceId
.
service_uuid
.
uuid
policy_lat
.
serviceId
.
service_uuid
.
uuid
=
request
.
serviceId
.
service_uuid
.
uuid
...
@@ -160,45 +188,13 @@ class AutomationServiceServicerImpl(AutomationServiceServicer):
...
@@ -160,45 +188,13 @@ class AutomationServiceServicerImpl(AutomationServiceServicer):
policyRuleCondition
=
PolicyRuleCondition
()
policyRuleCondition
=
PolicyRuleCondition
()
policyRuleCondition
.
kpiId
.
kpi_id
.
uuid
=
kpi_id_lat
.
kpi_id
.
uuid
policyRuleCondition
.
kpiId
.
kpi_id
.
uuid
=
kpi_id_lat
.
kpi_id
.
uuid
policyRuleCondition
.
numericalOperator
=
5
policyRuleCondition
.
numericalOperator
=
5
policyRuleCondition
.
kpiValue
.
floatVal
=
300
#constraint.sla_latency.e2e_latency_ms
policyRuleCondition
.
kpiValue
.
floatVal
=
300
policy_lat
.
policyRuleBasic
.
conditionList
.
append
(
policyRuleCondition
)
policy_lat
.
policyRuleBasic
.
conditionList
.
append
(
policyRuleCondition
)
policy_rule_state
:
PolicyRuleState
=
policy_client
.
PolicyAddService
(
policy_lat
)
policy_rule_state
:
PolicyRuleState
=
policy_client
.
PolicyAddService
(
policy_lat
)
LOGGER
.
info
(
'
policy_rule_state({:s})
'
.
format
(
str
(
policy_rule_state
)))
LOGGER
.
info
(
'
policy_rule_state({:s})
'
.
format
(
str
(
policy_rule_state
)))
####### START Analyzer LAT ################
analyzer
=
Analyzer
()
analyzer
.
analyzer_id
.
analyzer_id
.
uuid
=
str
(
uuid4
())
analyzer
.
algorithm_name
=
'
Test_Aggergate_and_Threshold
'
# static
analyzer
.
operation_mode
=
2
analyzer
.
input_kpi_ids
.
append
(
kpi_id_rx
)
analyzer
.
input_kpi_ids
.
append
(
kpi_id_tx
)
analyzer
.
output_kpi_ids
.
append
(
kpi_id_lat
)
_threshold_dict
=
{
'
min_latency_E2E
'
:
(
2
,
105
)}
analyzer
.
parameters
[
'
thresholds
'
]
=
json
.
dumps
(
_threshold_dict
)
analyzer
.
parameters
[
'
window_size
'
]
=
"
60s
"
analyzer
.
parameters
[
'
window_slider
'
]
=
"
30s
"
analyzer_id_lat
:
AnalyzerId
=
analytics_frontend_client
.
StartAnalyzer
(
analyzer
)
LOGGER
.
info
(
'
analyzer_id_lat({:s})
'
.
format
(
str
(
analyzer_id_lat
)))
kpi_value_api_client
=
KpiValueApiClient
()
stream
:
KpiAlarms
=
kpi_value_api_client
.
GetKpiAlarms
(
kpi_id_lat
.
kpi_id
.
uuid
)
for
response
in
stream
:
if
response
is
None
:
LOGGER
.
debug
(
'
NO message
'
)
else
:
LOGGER
.
debug
(
str
(
response
))
###########################################
# for response in analytic_frontend_service.StartResponseListener( analyzer_id_lat.analyzer_id.uuid):
# LOGGER.info("response.value {:s}",response)
except
grpc
.
RpcError
as
e
:
except
grpc
.
RpcError
as
e
:
if
e
.
code
()
!=
grpc
.
StatusCode
.
NOT_FOUND
:
raise
# pylint: disable=no-member
if
e
.
code
()
!=
grpc
.
StatusCode
.
NOT_FOUND
:
raise
# pylint: disable=no-member
LOGGER
.
exception
(
'
Unable to get Service({:s})
'
.
format
(
str
(
request
)))
LOGGER
.
exception
(
'
Unable to get Service({:s})
'
.
format
(
str
(
request
)))
...
@@ -208,8 +204,6 @@ class AutomationServiceServicerImpl(AutomationServiceServicer):
...
@@ -208,8 +204,6 @@ class AutomationServiceServicerImpl(AutomationServiceServicer):
telemetry_frontend_client
.
close
()
telemetry_frontend_client
.
close
()
return
None
return
None
LOGGER
.
info
(
'
Here is the service
'
)
context_client
.
close
()
context_client
.
close
()
kpi_manager_client
.
close
()
kpi_manager_client
.
close
()
policy_client
.
close
()
policy_client
.
close
()
...
...
This diff is collapsed.
Click to expand it.
src/tests/hackfest3/tests/test_functional_create_service.py
+
2
−
0
View file @
18a6c2e6
...
@@ -28,6 +28,7 @@ from service.client.ServiceClient import ServiceClient
...
@@ -28,6 +28,7 @@ from service.client.ServiceClient import ServiceClient
from
.Objects
import
CONTEXT_ID
,
CONTEXTS
,
DEVICES
,
LINKS
,
TOPOLOGIES
,
SERVICES
from
.Objects
import
CONTEXT_ID
,
CONTEXTS
,
DEVICES
,
LINKS
,
TOPOLOGIES
,
SERVICES
from
common.proto.context_pb2
import
ConfigActionEnum
,
Device
,
DeviceId
,
\
from
common.proto.context_pb2
import
ConfigActionEnum
,
Device
,
DeviceId
,
\
DeviceOperationalStatusEnum
DeviceOperationalStatusEnum
from
common.tools.object_factory.Constraint
import
json_constraint_sla_latency
LOGGER
=
logging
.
getLogger
(
__name__
)
LOGGER
=
logging
.
getLogger
(
__name__
)
LOGGER
.
setLevel
(
logging
.
DEBUG
)
LOGGER
.
setLevel
(
logging
.
DEBUG
)
...
@@ -62,4 +63,5 @@ def test_rules_entry(
...
@@ -62,4 +63,5 @@ def test_rules_entry(
service_p4
=
copy
.
deepcopy
(
service
)
service_p4
=
copy
.
deepcopy
(
service
)
service_client
.
CreateService
(
Service
(
**
service_p4
))
service_client
.
CreateService
(
Service
(
**
service_p4
))
service_p4
[
'
service_endpoint_ids
'
].
extend
(
endpoints
)
service_p4
[
'
service_endpoint_ids
'
].
extend
(
endpoints
)
service_p4
[
'
service_constraints
'
].
extend
([
json_constraint_sla_latency
(
3
)])
service_client
.
UpdateService
(
Service
(
**
service_p4
))
service_client
.
UpdateService
(
Service
(
**
service_p4
))
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