mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-10-27 10:42:28 +02:00
docs: Add best practices section for device config — template usage, error checking, config backup
This commit is contained in:
parent
647c5c0e65
commit
aabf54b6d1
@ -242,6 +242,30 @@ device_command_run(project_id,
|
|||||||
])
|
])
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Best Practices
|
||||||
|
|
||||||
|
**Prefer template over direct commands for batch.** When ≥2 nodes share the same config structure with different values, use `template`+`vars` instead of writing `config_commands` per node. This reduces token usage and transcription errors.
|
||||||
|
|
||||||
|
**Batch merging.** Multiple entries with the same `device_name` are merged into a single Nornir session. The output contains all commands' results in one block. Match results by `device_name`, not list index.
|
||||||
|
|
||||||
|
**Don't rely on `status: success` alone.** It only means commands entered config mode. IOS errors (`% Invalid input`, `% overlaps`, `% Incomplete command`) appear inside `output` text — always scan for `%` lines.
|
||||||
|
|
||||||
|
**Pilot before full rollout.** Test template + vars on 1–2 devices first to verify rendering and syntax, then expand to all nodes.
|
||||||
|
|
||||||
|
**Config backup via file operations.** IOU and Dynamips nodes save startup config as a plain text file (`startup-config.cfg`) in the node directory after `write memory`. These can be backed up and restored via `node_file_get`/`node_file_write`.
|
||||||
|
|
||||||
|
```python
|
||||||
|
# Save config on device
|
||||||
|
device_command_run(project_id, device_configs=[
|
||||||
|
{"device_name": "R1", "commands": ["write memory"]},
|
||||||
|
])
|
||||||
|
# Backup
|
||||||
|
config = node_file_get(project_id, node_id, "startup-config.cfg")
|
||||||
|
# Restore if config breaks
|
||||||
|
node_file_write(project_id, node_id, "startup-config.cfg", config)
|
||||||
|
node_reload(project_id, node_id)
|
||||||
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
### Claude Code (CLI)
|
### Claude Code (CLI)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user