def _delete_all_attached(session: Session, machine: Machine):
"""
Delete all resources attached to a machine
As we don't need performance we can avoid heuristics by dropping and re-creating theses needed resources
The discovery data is the reference of the reality
:param session:
:param machine:
:return:
"""
session.query(MachineDisk) \
.filter(MachineDisk.machine_id == machine.id) \
.delete()
all_mi = session.query(MachineInterface) \
.filter(MachineInterface.machine_id == machine.id)
for i in all_mi:
session.query(ChassisPort) \
.filter(ChassisPort.machine_interface == i.id) \
.delete()
session.delete(i)
session.flush()
machine_discovery_repo.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录