# asterust-junos
Typed views of common Juniper JunOS config statements, extracted from a config tree parsed by
[asterust](https://github.com/asterust/asterust) (`config::juniper`, brace-format `show configuration`).
| `interfaces` | `interfaces` |
| `protocols::ospf` | `protocols ospf` |
| `protocols::ospf3` | `protocols ospf3` |
| `protocols::bgp` | `protocols bgp` |
| `protocols::evpn` | `protocols evpn` |
| `protocols::igmp` and `protocols::mld` | `protocols igmp` and `protocols mld` |
| `protocols::isis` | `protocols isis` |
| `protocols::l2vpn` | `routing-instances <name> protocols l2vpn` |
| `protocols::ldp` | `protocols ldp` |
| `protocols::lldp` | `protocols lldp` |
| `protocols::lldp_med` | `protocols lldp-med` |
| `protocols::mpls` | `protocols mpls` |
| `protocols::pcep` | `protocols pcep` |
| `protocols::pim` | `protocols pim` |
| `protocols::rsvp` | `protocols rsvp` |
| `protocols::source_packet_routing` | `protocols source-packet-routing` |
| `routing_instances` | `routing-instances` |
| `routing_options` | `routing-options` |
| `policy_options` | `policy-options` |
| `class_of_service` | `class-of-service` |
| `firewall` | `firewall` |
| `system` | `system` |
The statements each module reads are listed in [docs/modules.md](https://github.com/asterust/asterust/blob/main/crates/asterust-junos/docs/modules.md).
The source tree mirrors the configuration hierarchy so a statement is easy to find: a folder per top-level block
(`system/`, `protocols/`, `policy_options/`), a file per statement inside it (`system/radius_server.rs`,
`system/root_authentication.rs`), and a folder instead of a file when that statement has many children of its own
(`system/services/ssh.rs`, `system/login/class.rs`, `system/syslog/host.rs`). The types of each level are re-exported
from its parent, e.g. `system::RadiusServer`.
```rust
use asterust_junos::JunosDevice;
let device = JunosDevice::parse(show_configuration_text);
for iface in &device.interfaces {
println!("{}: {:?}", iface.name, iface.units);
}
if let Some(bgp) = &device.protocols.bgp {
println!("{} BGP groups", bgp.groups.len());
}
```
Unlike the Cisco crates, `JunosDevice` reads every view once and exposes it as a field that mirrors the configuration
hierarchy: `device.protocols.bgp`, `device.protocols.ospf`, `device.system`, `device.routing_options`, `device.class_of_service`. A protocol or
block that is not configured is `None`, and the views read from named top-level blocks rather than one struct per block.
`JunosDevice` also implements `asterust::device::Device`.
Secrets: passwords, keys and shared secrets are not read by default, only a `has_*` flag says whether one is
configured. With the `secrets` feature (`asterust-junos = { version = "...", features = ["secrets"] }`) the matching
`Option<Secret>` fields are filled with the value as written (usually the encrypted `$9$...` form). `Secret` prints as
`Secret(<redacted>)` in `Debug`; read it with `Secret::expose`. Covered: BGP, OSPF, IS-IS, LDP, RSVP, VRRP, auto-configure, and in `system` the RADIUS and TACACS+ servers, NTP, login users, root and diag/PIC console authentication, archival, autoinstallation, license, outbound-ssh, static subscribers and subscriber-management. `master-password` has nothing to read, since the password is not part of the configuration.
Limitations: statements deactivated with `inactive:` are skipped; `| display set` output is not supported;
protocols nested inside routing instances (other than `bgp` SRv6 and `l2vpn`), `apply-groups` expansion and BGP group-to-neighbor setting
inheritance are not resolved.
## Sources
Test fixtures marked `DOC_*` or `reads_the_guide_*` are adapted from the Juniper documentation pages listed in
[docs/sources.md](https://github.com/asterust/asterust/blob/main/crates/asterust-junos/docs/sources.md), which also lists the fixtures that are not from documentation and so
are unverified.