Skip to content
Snippets Groups Projects
Commit 5ae3dc98 authored by Jonathan Klimt's avatar Jonathan Klimt :cowboy:
Browse files

Added check for duplicate IPMI addresses

parent 13e1e4eb
No related branches found
No related tags found
No related merge requests found
......@@ -67,8 +67,12 @@ class ServerManager:
try:
with open('servers.json', 'r') as f:
self.groups = json.load(f) # The file contains an array of groups directly
ipmi_ips = set()
for group in self.groups:
for server in group['servers']:
if server['ipmi_ip'] in ipmi_ips:
raise ValueError(f"Duplicate IPMI IP address found in servers.json: {server['ipmi_ip']}")
ipmi_ips.add(server['ipmi_ip'])
self.servers[f"{group['name']}/{server['name']}"] = {
'config': server,
'connection': None,
......@@ -78,6 +82,7 @@ class ServerManager:
logger.error(f"Failed to load server configuration: {str(e)}")
self.servers = {}
self.groups = []
raise # Re-raise the exception to prevent the application from starting with invalid configuration
def initialize_connections(self) -> None:
for server_name, server_data in self.servers.items():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment