mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-08-27 20:40:13 +03:00
fix: Merge commands for duplicate device_names in _configs_map
Dict comprehension overwrote earlier entries when the same device appeared multiple times, causing all entries' outputs to collapse into the last one. Now commands are appended for duplicate names.
This commit is contained in:
parent
fb032ade78
commit
c42b3a59bf
@ -543,12 +543,18 @@ class ExecuteMultipleDeviceConfigCommands(BaseTool):
|
||||
def _configs_map(
|
||||
self, device_config_list: list[dict[str, Any]]
|
||||
) -> dict[str, list[str]]:
|
||||
"""Create a mapping of device names to their configuration commands."""
|
||||
device_configs_map = {}
|
||||
"""Create a mapping of device names to their configuration commands.
|
||||
|
||||
Merges commands when the same device appears multiple times in the list.
|
||||
"""
|
||||
device_configs_map: dict[str, list[str]] = {}
|
||||
for device_config in device_config_list:
|
||||
device_name = device_config["device_name"]
|
||||
config_commands = device_config["config_commands"]
|
||||
device_configs_map[device_name] = config_commands
|
||||
commands = device_config.get("config_commands", [])
|
||||
if device_name in device_configs_map:
|
||||
device_configs_map[device_name].extend(commands)
|
||||
else:
|
||||
device_configs_map[device_name] = list(commands)
|
||||
|
||||
return device_configs_map
|
||||
|
||||
|
||||
@ -486,12 +486,18 @@ class ExecuteMultipleDeviceCommands(BaseTool):
|
||||
def _configs_map(
|
||||
self, device_config_list: list[dict[str, Any]]
|
||||
) -> dict[str, list[str]]:
|
||||
"""Create a mapping of device names to their diagnostic commands."""
|
||||
device_diagnostic_map = {}
|
||||
"""Create a mapping of device names to their diagnostic commands.
|
||||
|
||||
Merges commands when the same device appears multiple times in the list.
|
||||
"""
|
||||
device_diagnostic_map: dict[str, list[str]] = {}
|
||||
for device_config in device_config_list:
|
||||
device_name = device_config["device_name"]
|
||||
diagnostic_commands = device_config["commands"]
|
||||
device_diagnostic_map[device_name] = diagnostic_commands
|
||||
commands = device_config.get("commands", [])
|
||||
if device_name in device_diagnostic_map:
|
||||
device_diagnostic_map[device_name].extend(commands)
|
||||
else:
|
||||
device_diagnostic_map[device_name] = list(commands)
|
||||
|
||||
return device_diagnostic_map
|
||||
|
||||
|
||||
@ -405,16 +405,23 @@ class VPCSCommands(BaseTool):
|
||||
"""
|
||||
Create a mapping of device names to their command lists.
|
||||
|
||||
Merges commands when the same device appears multiple times.
|
||||
|
||||
Args:
|
||||
device_config_list: List of device configurations
|
||||
|
||||
Returns:
|
||||
Dictionary mapping device names to command lists
|
||||
"""
|
||||
return {
|
||||
config["device_name"]: config["commands"]
|
||||
for config in device_config_list
|
||||
}
|
||||
cmd_map: dict[str, list[str]] = {}
|
||||
for config in device_config_list:
|
||||
name = config["device_name"]
|
||||
cmds = config.get("commands", [])
|
||||
if name in cmd_map:
|
||||
cmd_map[name].extend(cmds)
|
||||
else:
|
||||
cmd_map[name] = list(cmds)
|
||||
return cmd_map
|
||||
|
||||
def _prepare_device_hosts_data(
|
||||
self,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user