asterust_junos/interfaces/aggregated_ether_options/
lacp.rs1use crate::{arg_of, has_leaf};
9use asterust::config::ConfigLine;
10
11#[derive(Clone, Debug, PartialEq, Eq)]
13#[non_exhaustive]
14pub struct Lacp {
15 pub mode: Option<String>,
17 pub periodic: Option<String>,
19 pub system_priority: Option<String>,
20 pub system_id: Option<String>,
21 pub admin_key: Option<String>,
22 pub force_up: bool,
23 pub fast_failover: bool,
24 pub accept_data: bool,
25}
26
27pub(super) fn parse_lacp(lacp: &ConfigLine) -> Lacp {
28 Lacp {
29 mode: ["active", "passive"]
30 .iter()
31 .find(|mode| has_leaf(lacp, mode))
32 .map(|mode| mode.to_string()),
33 periodic: arg_of(lacp, "periodic").map(str::to_string),
34 system_priority: arg_of(lacp, "system-priority").map(str::to_string),
35 system_id: arg_of(lacp, "system-id").map(str::to_string),
36 admin_key: arg_of(lacp, "admin-key").map(str::to_string),
37 force_up: has_leaf(lacp, "force-up"),
38 fast_failover: has_leaf(lacp, "fast-failover"),
39 accept_data: has_leaf(lacp, "accept-data"),
40 }
41}