MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / delete_host

Method delete_host

db_manager.py:858–890  ·  view source on GitHub ↗

Delete a host record by MAC address. Args: mac: MAC address to delete Returns: bool: True if successful

(self, mac: str)

Source from the content-addressed store, hash-verified

856 cursor.execute(
857 f"UPDATE hosts SET {column} = ?, updated_at = CURRENT_TIMESTAMP WHERE lower(mac) = lower(?)",
858 (status, mac)
859 )
860 updated = cursor.rowcount > 0
861 if not updated:
862 logger.debug(f"No host updated for MAC {mac} when setting {column}")
863 return updated
864 except Exception as exc:
865 logger.error(f"Failed to update action status for {mac}: {exc}")
866 return False
867
868 def delete_host(self, mac: str) -> bool:
869 """
870 Delete a host record by MAC address.
871
872 Args:
873 mac: MAC address to delete
874
875 Returns:
876 bool: True if successful
877 """
878 if not mac:
879 logger.warning("Cannot delete host without MAC address")
880 return False
881
882 # Normalize MAC address
883 mac = mac.lower().strip()
884
885 try:
886 with self.get_connection() as conn:
887 cursor = conn.cursor()
888 cursor.execute("DELETE FROM hosts WHERE mac = ?", (mac,))
889 conn.commit()
890
891 if cursor.rowcount > 0:
892 logger.info(f"Deleted host: {mac}")
893 return True

Callers 1

upsert_hostMethod · 0.95

Calls 8

get_connectionMethod · 0.95
warningMethod · 0.80
cursorMethod · 0.80
commitMethod · 0.80
infoMethod · 0.80
debugMethod · 0.80
errorMethod · 0.80
executeMethod · 0.45

Tested by

no test coverage detected