From 467e3f484288f534c2207f095b0418639165e4f0 Mon Sep 17 00:00:00 2001 From: bmeagherix <118192357+bmeagherix@users.noreply.github.com> Date: Fri, 24 May 2024 13:48:33 -0700 Subject: [PATCH] Fix iscsi.host.batch_update (#13799) Broken with iSCSI auditing was introduced. --- .../middlewared/plugins/iscsi_/host_crud.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/middlewared/middlewared/plugins/iscsi_/host_crud.py b/src/middlewared/middlewared/plugins/iscsi_/host_crud.py index a43f47bea34ec..e762c5fe82e80 100644 --- a/src/middlewared/middlewared/plugins/iscsi_/host_crud.py +++ b/src/middlewared/middlewared/plugins/iscsi_/host_crud.py @@ -111,6 +111,12 @@ async def do_update(self, audit_callback, id_, data): return await self.update_unlocked(audit_callback, id_, data) @private + @accepts( + Int("id"), + Ref("iscsi_host_update"), + audit='Update iSCSI host', + audit_callback=True, + ) async def update_unlocked(self, audit_callback, id_, data): old = await self.get_instance(id_) audit_callback(old['ip']) @@ -146,6 +152,10 @@ async def do_delete(self, audit_callback, id_): return await self.delete_unlocked(audit_callback, id_) @private + @accepts(Int("id"), + audit='Delete iSCSI host', + audit_callback=True, + ) async def delete_unlocked(self, audit_callback, id_): host = await self.get_instance(id_) audit_callback(host['ip']) @@ -191,9 +201,10 @@ async def read_cache(self): ), ], ), + audit_callback=True, ) @private - async def batch_update(self, hosts): + async def batch_update(self, audit_callback, hosts): async with LOCK: try: for host in hosts: @@ -206,7 +217,7 @@ async def batch_update(self, hosts): db_host = self.hosts[host["ip"]] if host["iqn"] not in db_host["iqns"]: - await self.update_unlocked(db_host["id"], {"iqns": db_host["iqns"] + [host["iqn"]]}) + await self.update_unlocked(audit_callback, db_host["id"], {"iqns": db_host["iqns"] + [host["iqn"]]}) except Exception: await self.read_cache()