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
870329f2
Commit
870329f2
authored
2 years ago
by
Lluis Gifre Renom
Browse files
Options
Downloads
Patches
Plain Diff
Context component:
- Corrected method UnsetSlice to remove constraints
parent
08e7992a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!142
Release TeraFlowSDN 2.1
,
!62
Add relese/2.0.1 fixes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/context/service/database/Constraint.py
+12
-14
12 additions, 14 deletions
src/context/service/database/Constraint.py
with
12 additions
and
14 deletions
src/context/service/database/Constraint.py
+
12
−
14
View file @
870329f2
...
...
@@ -86,26 +86,24 @@ def upsert_constraints(
)
->
bool
:
uuids_to_upsert
:
Dict
[
str
,
int
]
=
dict
()
rules_to_upsert
:
List
[
Dict
]
=
list
()
if
not
is_delete
:
for
constraint
in
constraints
:
constraint_uuid
=
constraint
[
'
constraint_uuid
'
]
position
=
uuids_to_upsert
.
get
(
constraint_uuid
)
if
position
is
None
:
# if not added, add it
rules_to_upsert
.
append
(
constraint
)
uuids_to_upsert
[
constraint_uuid
]
=
len
(
rules_to_upsert
)
-
1
else
:
# if already added, update occurrence
rules_to_upsert
[
position
]
=
constraint
for
constraint
in
constraints
:
constraint_uuid
=
constraint
[
'
constraint_uuid
'
]
position
=
uuids_to_upsert
.
get
(
constraint_uuid
)
if
position
is
None
:
# if not added, add it
rules_to_upsert
.
append
(
constraint
)
uuids_to_upsert
[
constraint_uuid
]
=
len
(
rules_to_upsert
)
-
1
else
:
# if already added, update occurrence
rules_to_upsert
[
position
]
=
constraint
# Delete all constraints not in uuids_to_upsert
delete_affected
=
False
if
is_delete
or
len
(
uuids_to_upsert
)
>
0
:
if
len
(
uuids_to_upsert
)
>
0
:
stmt
=
delete
(
ConstraintModel
)
if
service_uuid
is
not
None
:
stmt
=
stmt
.
where
(
ConstraintModel
.
service_uuid
==
service_uuid
)
if
slice_uuid
is
not
None
:
stmt
=
stmt
.
where
(
ConstraintModel
.
slice_uuid
==
slice_uuid
)
if
not
is_delete
:
stmt
=
stmt
.
where
(
ConstraintModel
.
constraint_uuid
.
not_in
(
set
(
uuids_to_upsert
.
keys
())))
stmt
=
stmt
.
where
(
ConstraintModel
.
constraint_uuid
.
not_in
(
set
(
uuids_to_upsert
.
keys
())))
#str_stmt = stmt.compile(dialect=postgresql.dialect(), compile_kwargs={"literal_binds": True})
#LOGGER.warning('delete stmt={:s}'.format(str(str_stmt)))
constraint_deletes
=
session
.
execute
(
stmt
)
...
...
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