Skip to content

Commit

Permalink
Fix iscsi.host.batch_update (#13799)
Browse files Browse the repository at this point in the history
Broken with iSCSI auditing was introduced.
  • Loading branch information
bmeagherix authored May 24, 2024
1 parent f29608f commit 467e3f4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/middlewared/middlewared/plugins/iscsi_/host_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down Expand Up @@ -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'])
Expand Down Expand Up @@ -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:
Expand All @@ -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()
Expand Down

0 comments on commit 467e3f4

Please sign in to comment.