asterust_junos/interfaces/
aggregated_inline_services_options.rs1use crate::arg_of;
9use asterust::config::ConfigLine;
10
11#[derive(Clone, Debug, PartialEq, Eq)]
13#[non_exhaustive]
14pub struct AggregatedInlineServicesOptions {
15 pub primary_interface: Option<String>,
16 pub secondary_interface: Option<String>,
17}
18
19pub(super) fn parse_aggregated_inline_services_options(options: &ConfigLine) -> AggregatedInlineServicesOptions {
20 AggregatedInlineServicesOptions {
21 primary_interface: arg_of(options, "primary-interface").map(str::to_string),
22 secondary_interface: arg_of(options, "secondary-interface").map(str::to_string),
23 }
24}
25
26#[cfg(test)]
27mod tests {
28 use crate::interfaces::interfaces;
29 use asterust::config::juniper;
30
31 #[test]
33 fn extracts_aggregated_inline_services_options() {
34 let ifaces = interfaces(&juniper::parse_braces(
35 "interfaces {\n asi0 {\n aggregated-inline-services-options {\n primary-interface si-1/0/0;\n secondary-interface si-2/0/0;\n }\n }\n}\n",
36 ));
37 let options = ifaces[0].aggregated_inline_services_options.as_ref().unwrap();
38 assert_eq!(options.primary_interface.as_deref(), Some("si-1/0/0"));
39 assert_eq!(options.secondary_interface.as_deref(), Some("si-2/0/0"));
40 }
41}