Skip to main content

asterust_junos/interfaces/aggregated_ether_options/
lacp.rs

1//! `interfaces { <name> { aggregated-ether-options { lacp { ... } } } }`.
2
3use crate::{arg_of, has_leaf};
4use asterust::config::ConfigLine;
5
6/// The `lacp` settings of an aggregated Ethernet bundle.
7#[derive(Clone, Debug, PartialEq, Eq)]
8#[non_exhaustive]
9pub struct Lacp {
10    /// `active` or `passive`; LACP is passive when neither is written.
11    pub mode: Option<String>,
12    /// `fast` or `slow`.
13    pub periodic: Option<String>,
14    pub system_priority: Option<String>,
15    pub system_id: Option<String>,
16    pub admin_key: Option<String>,
17    pub force_up: bool,
18    pub fast_failover: bool,
19    pub accept_data: bool,
20}
21
22pub(super) fn parse_lacp(lacp: &ConfigLine) -> Lacp {
23    Lacp {
24        mode: ["active", "passive"]
25            .iter()
26            .find(|mode| has_leaf(lacp, mode))
27            .map(|mode| mode.to_string()),
28        periodic: arg_of(lacp, "periodic").map(str::to_string),
29        system_priority: arg_of(lacp, "system-priority").map(str::to_string),
30        system_id: arg_of(lacp, "system-id").map(str::to_string),
31        admin_key: arg_of(lacp, "admin-key").map(str::to_string),
32        force_up: has_leaf(lacp, "force-up"),
33        fast_failover: has_leaf(lacp, "fast-failover"),
34        accept_data: has_leaf(lacp, "accept-data"),
35    }
36}