Skip to content

Commit

Permalink
add new recursive path update from top_level_workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
afourmy committed Feb 14, 2023
1 parent 86a7919 commit 8897da9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions eNMS/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,8 +984,8 @@ def migration_import(self, folder="migrations", **kwargs):
status = "Partial import (see logs)."
db.session.commit()
if kwargs.get("service_import", False):
for service in service_instances:
service.post_update()
main_workflow = [service for service in service_instances if not service.workflows][0]
main_workflow.recursive_update()
if not kwargs.get("skip_model_update"):
for model in ("user", "service", "network"):
for instance in db.fetch_all(model):
Expand Down
1 change: 1 addition & 0 deletions eNMS/models/automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def post_update(self):
self.path = f"{self.workflows[0].path}>{self.id}"
else:
self.path = str(self.id)
print(self.name, self.path)
self.set_name()
return self.to_dict(include=["services", "workflows"])

Expand Down
9 changes: 9 additions & 0 deletions eNMS/models/services/workflow/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ def __init__(self, **kwargs):
if not migration_import and self.name not in end.positions:
end.positions[self.name] = (500, 0)

def recursive_update(self):
def rec(service):
service.post_update()
if service.type == "workflow":
for subservice in service.services:
rec(subservice)

rec(self)

def delete(self):
for service in self.services:
if not service.shared:
Expand Down

0 comments on commit 8897da9

Please sign in to comment.