예제 #1
0
 def import_jobs(self, **kwargs: Any) -> None:
     jobs = kwargs["jobs_to_import"]
     path = self.path / "projects" / "exported_jobs"
     for file in scandir(path / "services"):
         if file.name == ".gitkeep" or file.name not in jobs:
             continue
         with open(file.path, "r") as instance_file:
             instance = yaml.load(instance_file)
             model = instance.pop("type")
             factory(model, **self.objectify(model, instance))
     Session.commit()
     for workflow in listdir(path / "workflows"):
         if workflow == ".gitkeep" or workflow not in jobs:
             continue
         workflow_name = workflow.split(".")[0]
         with open_tar(path / "workflows" / workflow) as tar_file:
             tar_file.extractall(path=path / "workflows")
         for instance_type in ("jobs", "workflow", "edges"):
             path_job = path / "workflows" / workflow_name / instance_type
             for file in scandir(path_job):
                 with open(path_job / file.name, "r") as instance_file:
                     instance = yaml.load(instance_file)
                     if instance_type == "workflow":
                         delete("Workflow",
                                allow_none=True,
                                name=instance["name"])
                         Session.commit()
                     model = instance.pop("type")
                     factory(model, **self.objectify(model, instance))
             Session.commit()
         rmtree(path / "workflows" / workflow_name)
예제 #2
0
파일: automation.py 프로젝트: mww012/eNMS
 def delete_node(self, workflow_id, service_id):
     workflow, service = (
         fetch("workflow", id=workflow_id),
         fetch("service", id=service_id),
     )
     workflow.services.remove(service)
     if not service.shared:
         delete("service", id=service.id)
     now = self.get_time()
     workflow.last_modified = now
     return {"service": service.serialized, "update_time": now}
예제 #3
0
 def delete_edge(self, workflow_id: int, edge_id: int) -> str:
     delete("WorkflowEdge", id=edge_id)
     now = self.get_time()
     fetch("Workflow", id=workflow_id).last_modified = now
     return now
예제 #4
0
 def delete(self, cls: str, name: str) -> dict:
     result = delete(cls, name=name)
     Session.commit()
     return result
예제 #5
0
 def delete_instance(self, instance_type, instance_id):
     return delete(instance_type, id=instance_id)
예제 #6
0
 def delete(self):
     for service in self.services:
         if not service.shared:
             delete("service", id=service.id)
예제 #7
0
 def delete_edge(self, workflow_id, edge_id):
     delete("workflow_edge", id=edge_id)
     now = self.get_time()
     fetch("workflow", id=workflow_id).last_modified = now
     return now
예제 #8
0
 def delete_instance(self, cls, instance_id):
     return delete(cls, id=instance_id)
예제 #9
0
파일: cli.py 프로젝트: MoAlaaElden/eNMS
 def cli_delete(table: str, name: str) -> None:
     device = delete(table, name=name)
     Session.commit()
     echo(controller.str_dict(device))
예제 #10
0
파일: base.py 프로젝트: ammoam/eNMS
 def delete_instance(self, cls: str, instance_id: int) -> dict:
     return delete(cls, id=instance_id)
예제 #11
0
파일: cli.py 프로젝트: swamim/eNMS
 def cli_delete(table, name):
     device = delete(table, name=name)
     Session.commit()
     echo(app.str_dict(device))
예제 #12
0
 def delete(self, cls, name):
     result = delete(cls, name=name)
     Session.commit()
     return result