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//! - [aggregate-wait-time](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/interfaces-edit-aggregate-wait-time.html)
7//! - [sync-reset](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/interfaces-aggregated-ether-options-lacp-sync-reset.html)
8//! - [link-protection](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/link-protection-edit-interfaces.html)
9//! - [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)
10
11use super::balancing::{parse_link_protection, LinkProtection};
12use crate::{arg_of, child_block, has_leaf};
13use asterust::config::ConfigLine;
14
15/// The `lacp` settings of an aggregated Ethernet bundle.
16#[derive(Clone, Debug, PartialEq, Eq)]
17#[non_exhaustive]
18pub struct Lacp {
19    /// `active` or `passive`; LACP is passive when neither is written.
20    pub mode: Option<String>,
21    /// `fast` or `slow`.
22    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    /// Seconds.
30    pub aggregate_wait_time: Option<String>,
31    /// `enable` or `disable`.
32    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}