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

Method get_all_hosts

db_manager.py:930–952  ·  view source on GitHub ↗

Get all hosts, optionally filtered by status. Args: status: Filter by status ('alive', 'degraded', None for all) Returns: List of host dictionaries

(self, status: str = None)

Source from the content-addressed store, hash-verified

928 # If multiple entries exist for same IP, prefer real MAC over pseudo-MAC
929 if len(rows) > 1:
930 logger.warning(f"Found {len(rows)} entries for IP {ip} - preferring real MAC")
931 for row in rows:
932 if not self._is_pseudo_mac(row['mac']):
933 return dict(row)
934
935 return dict(rows[0])
936 except Exception as e:
937 logger.error(f"Failed to get host by IP {ip}: {e}")
938 return None
939
940 def get_all_hosts(self, status: str = None) -> List[Dict]:
941 """
942 Get all hosts, optionally filtered by status.
943
944 Args:
945 status: Filter by status ('alive', 'degraded', None for all)
946
947 Returns:
948 List of host dictionaries
949 """
950 try:
951 with self.get_connection() as conn:
952 cursor = conn.cursor()
953
954 if status:
955 cursor.execute("SELECT * FROM hosts WHERE status = ? ORDER BY ip", (status,))

Callers 15

export_to_csvMethod · 0.95
_collect_hostsMethod · 0.80
read_dataMethod · 0.80
sync_all_countsFunction · 0.80
get_stable_network_dataFunction · 0.80
get_networkFunction · 0.80
get_network_topologyFunction · 0.80
get_host_detailFunction · 0.80
export_reportFunction · 0.80
legacy_netkb_jsonFunction · 0.80

Calls 5

get_connectionMethod · 0.95
cursorMethod · 0.80
errorMethod · 0.80
executeMethod · 0.45
fetchallMethod · 0.45

Tested by

no test coverage detected