asterust_junos/interfaces/aggregated_ether_options/
lacp.rs1use crate::{arg_of, has_leaf};
4use asterust::config::ConfigLine;
5
6#[derive(Clone, Debug, PartialEq, Eq)]
8#[non_exhaustive]
9pub struct Lacp {
10 pub mode: Option<String>,
12 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}