Skip to main content

asterust_junos/interfaces/aggregated_ether_options/
lacp.rs

1//! `lacp`
2//! `interfaces { <name> { aggregated-ether-options { lacp { ... } } } }`.
3//!
4//! # See also
5//!
6//! - [lacp (Aggregated Ethernet)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/lacp-edit-interfaces-aggregated-ethernet-qfx-series.html)
7
8use crate::{arg_of, has_leaf};
9use asterust::config::ConfigLine;
10
11/// The `lacp` settings of an aggregated Ethernet bundle.
12#[derive(Clone, Debug, PartialEq, Eq)]
13#[non_exhaustive]
14pub struct Lacp {
15    /// `active` or `passive`; LACP is passive when neither is written.
16    pub mode: Option<String>,
17    /// `fast` or `slow`.
18    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}