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
99c55e1b
Commit
99c55e1b
authored
11 months ago
by
Javier Diaz
Browse files
Options
Downloads
Patches
Plain Diff
Debugging
parent
c103dda5
No related branches found
No related tags found
2 merge requests
!294
Release TeraFlowSDN 4.0
,
!259
Resolve "(CTTC) Replace DLT Gateway functionality with an opensource and Hyper Ledger v2.4+ compliant version"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/interdomain/service/topology_abstractor/DltRecorder.py
+20
-14
20 additions, 14 deletions
src/interdomain/service/topology_abstractor/DltRecorder.py
with
20 additions
and
14 deletions
src/interdomain/service/topology_abstractor/DltRecorder.py
+
20
−
14
View file @
99c55e1b
...
...
@@ -4,7 +4,7 @@ from typing import Dict, Optional
from
common.Constants
import
DEFAULT_CONTEXT_NAME
,
DEFAULT_TOPOLOGY_NAME
,
INTERDOMAIN_TOPOLOGY_NAME
,
ServiceNameEnum
from
common.Settings
import
ENVVAR_SUFIX_SERVICE_HOST
,
ENVVAR_SUFIX_SERVICE_PORT_GRPC
,
find_environment_variables
,
get_env_var_name
from
common.proto.context_pb2
import
ContextEvent
,
ContextId
,
Device
,
DeviceEvent
,
DeviceId
,
EndPointId
,
Link
,
LinkId
,
LinkEvent
,
TopologyId
,
TopologyEvent
from
common.proto.context_pb2
import
ContextEvent
,
ContextId
,
Device
,
DeviceEvent
,
DeviceId
,
EndPointId
,
Link
,
LinkEvent
,
TopologyId
,
TopologyEvent
from
common.tools.context_queries.Context
import
create_context
from
common.tools.context_queries.Device
import
get_uuids_of_devices_in_topology
from
common.tools.context_queries.Topology
import
create_missing_topologies
...
...
@@ -30,7 +30,7 @@ class DLTRecorder(threading.Thread):
self
.
terminate
=
threading
.
Event
()
self
.
context_client
=
ContextClient
()
self
.
context_event_collector
=
EventsCollector
(
self
.
context_client
)
self
.
topology_cache
=
{}
self
.
topology_cache
:
Dict
[
str
,
TopologyId
]
=
{}
def
stop
(
self
):
self
.
terminate
.
set
()
...
...
@@ -56,15 +56,19 @@ class DLTRecorder(threading.Thread):
create_missing_topologies
(
self
.
context_client
,
ADMIN_CONTEXT_ID
,
topology_uuids
)
def
get_dlt_connector_client
(
self
)
->
Optional
[
DltConnectorClient
]:
env_vars
=
find_environment_variables
([
get_env_var_name
(
ServiceNameEnum
.
DLT
,
ENVVAR_SUFIX_SERVICE_HOST
),
get_env_var_name
(
ServiceNameEnum
.
DLT
,
ENVVAR_SUFIX_SERVICE_PORT_GRPC
),
])
if
len
(
env_vars
)
==
2
:
dlt_connector_client
=
DltConnectorClient
()
dlt_connector_client
.
connect
()
return
dlt_connector_client
return
None
# Always enable DLT for testing
dlt_connector_client
=
DltConnectorClient
()
dlt_connector_client
.
connect
()
return
dlt_connector_client
# env_vars = find_environment_variables([
# get_env_var_name(ServiceNameEnum.DLT, ENVVAR_SUFIX_SERVICE_HOST),
# get_env_var_name(ServiceNameEnum.DLT, ENVVAR_SUFIX_SERVICE_PORT_GRPC),
# ])
# if len(env_vars) == 2:
# dlt_connector_client = DltConnectorClient()
# dlt_connector_client.connect()
# return dlt_connector_client
# return None
def
update_record
(
self
,
event
:
EventTypes
)
->
None
:
dlt_connector_client
=
self
.
get_dlt_connector_client
()
...
...
@@ -106,7 +110,7 @@ class DLTRecorder(threading.Thread):
topology_details
=
self
.
context_client
.
GetTopologyDetails
(
topology_id
)
topology_name
=
topology_details
.
name
self
.
topology_cache
[
topology_uuid
]
=
topology_d
etails
self
.
topology_cache
[
topology_uuid
]
=
topology_
i
d
if
((
context_uuid
==
DEFAULT_CONTEXT_NAME
)
or
(
context_name
==
DEFAULT_CONTEXT_NAME
))
and
\
(
topology_uuid
not
in
topology_uuids
)
and
(
topology_name
not
in
topology_uuids
):
...
...
@@ -122,14 +126,16 @@ class DLTRecorder(threading.Thread):
LOGGER
.
warning
(
MSG
.
format
(
*
args
))
def
find_topology_for_device
(
self
,
device_id
:
DeviceId
)
->
Optional
[
TopologyId
]:
for
topology_id
,
details
in
self
.
topology_cache
.
items
():
for
topology_uuid
,
topology_id
in
self
.
topology_cache
.
items
():
details
=
self
.
context_client
.
GetTopologyDetails
(
topology_id
)
for
device
in
details
.
devices
:
if
device
.
device_id
==
device_id
:
return
topology_id
return
None
def
find_topology_for_link
(
self
,
link_id
:
LinkId
)
->
Optional
[
TopologyId
]:
for
topology_id
,
details
in
self
.
topology_cache
.
items
():
for
topology_uuid
,
topology_id
in
self
.
topology_cache
.
items
():
details
=
self
.
context_client
.
GetTopologyDetails
(
topology_id
)
for
link
in
details
.
links
:
if
link
.
link_id
==
link_id
:
return
topology_id
...
...
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