Skip to content
Snippets Groups Projects
Commit 870329f2 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Context component:

- Corrected method UnsetSlice to remove constraints
parent 08e7992a
No related branches found
No related tags found
2 merge requests!142Release TeraFlowSDN 2.1,!62Add relese/2.0.1 fixes
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment