Config & tools¶
Reading the configuration, raw CLI access, and on-device reachability tools.
get_config¶
Returns the running configuration — by default as a JSON document, straight from the running datastore:
device.get_config(retrieve="running") # JSON string
device.get_config(retrieve="running", sanitized=True) # aaa/tls subtrees removed
Prefer flat CLI commands? Pass format="cli" per call, or set the running_format optional argument to make it the default — the output is then equivalent to info flat:
set / interface ethernet-1/1 admin-state enable
set / interface ethernet-1/1 subinterface 0 ipv4 admin-state enable
set / interface ethernet-1/1 subinterface 0 ipv4 address 10.0.0.1/30
...
Two notes:
sanitized=True(stripsaaaandtlssecrets) is only available with the JSON format.retrieve="candidate"andretrieve="startup"return""— the candidate exists only client-side, and the startup config is not exposed via JSON-RPC.
cli¶
Runs arbitrary CLI commands through the JSON-RPC cli method and returns the output per command:
=== "text"
```python
>>> device.cli(["show version"])
{"show version": "--------------------------------------\nHostname : srl1\nChassis Type : 7220 IXR-D2L\n..."}
```
=== "json"
```python
>>> device.cli(["show version"], encoding="json")
{"show version": {"basic system info": {"Hostname": "srl1", "Chassis Type": "7220 IXR-D2L", ...}}}
```
With encoding="json" you get SR Linux's structured output instead of rendered text — usually much nicer to post-process than parsing CLI screens. Each command is sent as its own request, so the per-command mapping in the result is always exact.
ping¶
device.ping(destination, source="", ttl=255, timeout=2,
size=100, count=5, vrf="", source_interface="")
Pings from the device. vrf selects the network-instance the ping runs in — for management-network targets that's typically vrf="mgmt".
Example output
{
"success": {
"probes_sent": 5,
"packet_loss": 0,
"rtt_min": 2.923,
"rtt_avg": 3.326,
"rtt_max": 3.477,
"rtt_stddev": 0.203,
"results": [
{"ip_address": "8.8.8.8", "rtt": 3.48},
{"ip_address": "8.8.8.8", "rtt": 3.43},
{"ip_address": "8.8.8.8", "rtt": 2.92},
{"ip_address": "8.8.8.8", "rtt": 3.41},
{"ip_address": "8.8.8.8", "rtt": 3.39}
]
}
}
traceroute¶
Traceroute from the device, per network-instance via vrf. SR Linux's traceroute does not support the source and timeout options; they are accepted for API compatibility but ignored.
Example output
Changing configuration¶
Everything about writing config — the candidate workflow, accepted formats, commit, rollback, and confirmed commits — lives in the user guide: