asterust_junos/interfaces/aggregated_ether_options/
lacp.rs1use super::balancing::{parse_link_protection, LinkProtection};
12use crate::{arg_of, child_block, has_leaf};
13use asterust::config::ConfigLine;
14
15#[derive(Clone, Debug, PartialEq, Eq)]
17#[non_exhaustive]
18pub struct Lacp {
19 pub mode: Option<String>,
21 pub periodic: Option<String>,
23 pub system_priority: Option<String>,
24 pub system_id: Option<String>,
25 pub admin_key: Option<String>,
26 pub force_up: bool,
27 pub fast_failover: bool,
28 pub accept_data: bool,
29 pub aggregate_wait_time: Option<String>,
31 pub sync_reset: Option<String>,
33 pub link_protection: Option<LinkProtection>,
34}
35
36pub(in crate::interfaces) fn parse_lacp(lacp: &ConfigLine) -> Lacp {
37 Lacp {
38 mode: ["active", "passive"]
39 .iter()
40 .find(|mode| has_leaf(lacp, mode))
41 .map(|mode| mode.to_string()),
42 periodic: arg_of(lacp, "periodic").map(str::to_string),
43 system_priority: arg_of(lacp, "system-priority").map(str::to_string),
44 system_id: arg_of(lacp, "system-id").map(str::to_string),
45 admin_key: arg_of(lacp, "admin-key").map(str::to_string),
46 force_up: has_leaf(lacp, "force-up"),
47 fast_failover: has_leaf(lacp, "fast-failover"),
48 accept_data: has_leaf(lacp, "accept-data"),
49 aggregate_wait_time: arg_of(lacp, "aggregate-wait-time").map(str::to_string),
50 sync_reset: arg_of(lacp, "sync-reset").map(str::to_string),
51 link_protection: child_block(lacp, "link-protection").map(parse_link_protection),
52 }
53}