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
1731c04e
Commit
1731c04e
authored
2 years ago
by
Lluis Gifre Renom
Browse files
Options
Downloads
Patches
Plain Diff
Context component:
- Added logic to keep order of link endpoints
parent
efed73e3
No related branches found
No related tags found
2 merge requests
!142
Release TeraFlowSDN 2.1
,
!71
OFC'23 + IETF L2VPN Device Driver + Device Controllers + Multiple small improvements
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/context/service/database/Link.py
+2
-1
2 additions, 1 deletion
src/context/service/database/Link.py
src/context/service/database/models/LinkModel.py
+8
-2
8 additions, 2 deletions
src/context/service/database/models/LinkModel.py
with
10 additions
and
3 deletions
src/context/service/database/Link.py
+
2
−
1
View file @
1731c04e
...
@@ -64,13 +64,14 @@ def link_set(db_engine : Engine, request : Link) -> Tuple[Dict, bool]:
...
@@ -64,13 +64,14 @@ def link_set(db_engine : Engine, request : Link) -> Tuple[Dict, bool]:
topology_uuids
:
Set
[
str
]
=
set
()
topology_uuids
:
Set
[
str
]
=
set
()
related_topologies
:
List
[
Dict
]
=
list
()
related_topologies
:
List
[
Dict
]
=
list
()
link_endpoints_data
:
List
[
Dict
]
=
list
()
link_endpoints_data
:
List
[
Dict
]
=
list
()
for
endpoint_id
in
request
.
link_endpoint_ids
:
for
i
,
endpoint_id
in
enumerate
(
request
.
link_endpoint_ids
)
:
endpoint_topology_uuid
,
_
,
endpoint_uuid
=
endpoint_get_uuid
(
endpoint_topology_uuid
,
_
,
endpoint_uuid
=
endpoint_get_uuid
(
endpoint_id
,
allow_random
=
False
)
endpoint_id
,
allow_random
=
False
)
link_endpoints_data
.
append
({
link_endpoints_data
.
append
({
'
link_uuid
'
:
link_uuid
,
'
link_uuid
'
:
link_uuid
,
'
endpoint_uuid
'
:
endpoint_uuid
,
'
endpoint_uuid
'
:
endpoint_uuid
,
'
position
'
:
i
,
})
})
if
endpoint_topology_uuid
not
in
topology_uuids
:
if
endpoint_topology_uuid
not
in
topology_uuids
:
...
...
This diff is collapsed.
Click to expand it.
src/context/service/database/models/LinkModel.py
+
8
−
2
View file @
1731c04e
...
@@ -12,7 +12,8 @@
...
@@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
from
sqlalchemy
import
Column
,
DateTime
,
ForeignKey
,
String
import
operator
from
sqlalchemy
import
CheckConstraint
,
Column
,
DateTime
,
ForeignKey
,
Integer
,
String
from
sqlalchemy.dialects.postgresql
import
UUID
from
sqlalchemy.dialects.postgresql
import
UUID
from
sqlalchemy.orm
import
relationship
from
sqlalchemy.orm
import
relationship
from
typing
import
Dict
from
typing
import
Dict
...
@@ -38,7 +39,7 @@ class LinkModel(_Base):
...
@@ -38,7 +39,7 @@ class LinkModel(_Base):
'
name
'
:
self
.
link_name
,
'
name
'
:
self
.
link_name
,
'
link_endpoint_ids
'
:
[
'
link_endpoint_ids
'
:
[
link_endpoint
.
endpoint
.
dump_id
()
link_endpoint
.
endpoint
.
dump_id
()
for
link_endpoint
in
self
.
link_endpoints
for
link_endpoint
in
sorted
(
self
.
link_endpoints
,
key
=
operator
.
attrgetter
(
'
position
'
))
],
],
}
}
...
@@ -47,6 +48,11 @@ class LinkEndPointModel(_Base):
...
@@ -47,6 +48,11 @@ class LinkEndPointModel(_Base):
link_uuid
=
Column
(
ForeignKey
(
'
link.link_uuid
'
,
ondelete
=
'
CASCADE
'
),
primary_key
=
True
)
link_uuid
=
Column
(
ForeignKey
(
'
link.link_uuid
'
,
ondelete
=
'
CASCADE
'
),
primary_key
=
True
)
endpoint_uuid
=
Column
(
ForeignKey
(
'
endpoint.endpoint_uuid
'
,
ondelete
=
'
RESTRICT
'
),
primary_key
=
True
,
index
=
True
)
endpoint_uuid
=
Column
(
ForeignKey
(
'
endpoint.endpoint_uuid
'
,
ondelete
=
'
RESTRICT
'
),
primary_key
=
True
,
index
=
True
)
position
=
Column
(
Integer
,
nullable
=
False
)
link
=
relationship
(
'
LinkModel
'
,
back_populates
=
'
link_endpoints
'
,
lazy
=
'
joined
'
)
link
=
relationship
(
'
LinkModel
'
,
back_populates
=
'
link_endpoints
'
,
lazy
=
'
joined
'
)
endpoint
=
relationship
(
'
EndPointModel
'
,
lazy
=
'
joined
'
)
# back_populates='link_endpoints'
endpoint
=
relationship
(
'
EndPointModel
'
,
lazy
=
'
joined
'
)
# back_populates='link_endpoints'
__table_args__
=
(
CheckConstraint
(
position
>=
0
,
name
=
'
check_position_value
'
),
)
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