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
547ceec4
Commit
547ceec4
authored
2 years ago
by
Lluis Gifre Renom
Browse files
Options
Downloads
Patches
Plain Diff
Context component:
- add device to default context/topology by default
parent
ba0565e7
No related branches found
No related tags found
2 merge requests
!54
Release 2.0.0
,
!45
Bug fixes and improvements related to device configuration and monitoring
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/context/service/database/Device.py
+11
-1
11 additions, 1 deletion
src/context/service/database/Device.py
with
11 additions
and
1 deletion
src/context/service/database/Device.py
+
11
−
1
View file @
547ceec4
...
@@ -19,9 +19,10 @@ from sqlalchemy.orm import Session, sessionmaker
...
@@ -19,9 +19,10 @@ from sqlalchemy.orm import Session, sessionmaker
from
sqlalchemy_cockroachdb
import
run_transaction
from
sqlalchemy_cockroachdb
import
run_transaction
from
typing
import
Dict
,
List
,
Optional
,
Set
,
Tuple
from
typing
import
Dict
,
List
,
Optional
,
Set
,
Tuple
from
common.method_wrappers.ServiceExceptions
import
InvalidArgumentException
,
NotFoundException
from
common.method_wrappers.ServiceExceptions
import
InvalidArgumentException
,
NotFoundException
from
common.proto.context_pb2
import
Device
,
DeviceId
from
common.proto.context_pb2
import
Device
,
DeviceId
,
TopologyId
from
common.tools.grpc.Tools
import
grpc_message_to_json_string
from
common.tools.grpc.Tools
import
grpc_message_to_json_string
from
common.tools.object_factory.Device
import
json_device_id
from
common.tools.object_factory.Device
import
json_device_id
from
context.service.database.uuids.Topology
import
topology_get_uuid
from
.models.DeviceModel
import
DeviceModel
from
.models.DeviceModel
import
DeviceModel
from
.models.EndPointModel
import
EndPointModel
from
.models.EndPointModel
import
EndPointModel
from
.models.TopologyModel
import
TopologyDeviceModel
from
.models.TopologyModel
import
TopologyDeviceModel
...
@@ -73,6 +74,15 @@ def device_set(db_engine : Engine, request : Device) -> Tuple[Dict, bool]:
...
@@ -73,6 +74,15 @@ def device_set(db_engine : Engine, request : Device) -> Tuple[Dict, bool]:
topology_uuids
:
Set
[
str
]
=
set
()
topology_uuids
:
Set
[
str
]
=
set
()
related_topologies
:
List
[
Dict
]
=
list
()
related_topologies
:
List
[
Dict
]
=
list
()
# By default, always add device to default Context/Topology
_
,
topology_uuid
=
topology_get_uuid
(
TopologyId
(),
allow_random
=
False
,
allow_default
=
True
)
related_topologies
.
append
({
'
topology_uuid
'
:
topology_uuid
,
'
device_uuid
'
:
device_uuid
,
})
topology_uuids
.
add
(
topology_uuid
)
endpoints_data
:
List
[
Dict
]
=
list
()
endpoints_data
:
List
[
Dict
]
=
list
()
for
i
,
endpoint
in
enumerate
(
request
.
device_endpoints
):
for
i
,
endpoint
in
enumerate
(
request
.
device_endpoints
):
endpoint_device_uuid
=
endpoint
.
endpoint_id
.
device_id
.
device_uuid
.
uuid
endpoint_device_uuid
=
endpoint
.
endpoint_id
.
device_id
.
device_uuid
.
uuid
...
...
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