Skip to content

Commit

Permalink
Arista: encapsulation dot1q vlan (#5714)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhalperi committed Apr 22, 2020
1 parent 6a24a78 commit a1e76e1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,17 @@ if_eos_mlag
MLAG id = DEC NEWLINE
;

if_encapsulation_eos
:
ENCAPSULATION
if_encapsulation_dot1q_eos
;

if_encapsulation_dot1q_eos
:
DOT1Q VLAN id = DEC NEWLINE
;

if_evpn_eos
:
EVPN ETHERNET_SEGMENT NEWLINE
Expand Down Expand Up @@ -1666,11 +1677,6 @@ if_txq_null
) null_rest_of_line
;

if_vlan
:
VLAN vlan = vlan_id NEWLINE
;

if_vrf
:
VRF
Expand Down Expand Up @@ -1911,6 +1917,7 @@ if_inner
| if_default_gw
| if_description
| if_eos_mlag
| if_encapsulation_eos
| if_evpn_eos
| if_igmp
| if_ip
Expand Down Expand Up @@ -1948,7 +1955,6 @@ if_inner
| if_traffic_loopback_eos
| if_tunnel
| if_tx_queue
| if_vlan
| if_vrf
| if_vrrp
// do not rearrange items below
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@
import org.batfish.grammar.arista.AristaParser.If_bfd_templateContext;
import org.batfish.grammar.arista.AristaParser.If_crypto_mapContext;
import org.batfish.grammar.arista.AristaParser.If_descriptionContext;
import org.batfish.grammar.arista.AristaParser.If_encapsulation_dot1q_eosContext;
import org.batfish.grammar.arista.AristaParser.If_eos_mlagContext;
import org.batfish.grammar.arista.AristaParser.If_ip_helper_addressContext;
import org.batfish.grammar.arista.AristaParser.If_ip_inband_access_groupContext;
Expand Down Expand Up @@ -645,7 +646,6 @@
import org.batfish.grammar.arista.AristaParser.If_switchport_trunk_encapsulationContext;
import org.batfish.grammar.arista.AristaParser.If_switchport_trunk_group_eosContext;
import org.batfish.grammar.arista.AristaParser.If_switchport_trunk_nativeContext;
import org.batfish.grammar.arista.AristaParser.If_vlanContext;
import org.batfish.grammar.arista.AristaParser.If_vrf_nameContext;
import org.batfish.grammar.arista.AristaParser.If_vrrpContext;
import org.batfish.grammar.arista.AristaParser.Ifcg_num_eosContext;
Expand Down Expand Up @@ -5093,6 +5093,12 @@ public void exitIf_crypto_map(If_crypto_mapContext ctx) {
_currentInterfaces.forEach(i -> i.setCryptoMap(ctx.name.getText()));
}

@Override
public void exitIf_encapsulation_dot1q_eos(If_encapsulation_dot1q_eosContext ctx) {
int vlanId = toInteger(ctx.id);
_currentInterfaces.forEach(i -> i.setEncapsulationVlan(vlanId));
}

private @Nullable String computeAggregatedInterfaceName(int num) {
return String.format("Port-Channel%d", num);
}
Expand Down Expand Up @@ -5491,12 +5497,6 @@ public void exitIf_switchport_trunk_native(If_switchport_trunk_nativeContext ctx
}
}

@Override
public void exitIf_vlan(If_vlanContext ctx) {
int vlan = toInteger(ctx.vlan);
_currentInterfaces.forEach(iface -> iface.setEncapsulationVlan(vlan));
}

@Override
public void exitIf_vrf_name(If_vrf_nameContext ctx) {
String name = ctx.name.getText();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import static org.batfish.datamodel.matchers.InterfaceMatchers.hasAllAddresses;
import static org.batfish.datamodel.matchers.InterfaceMatchers.hasAllowedVlans;
import static org.batfish.datamodel.matchers.InterfaceMatchers.hasDescription;
import static org.batfish.datamodel.matchers.InterfaceMatchers.hasEncapsulationVlan;
import static org.batfish.datamodel.matchers.InterfaceMatchers.hasMlagId;
import static org.batfish.datamodel.matchers.InterfaceMatchers.hasMtu;
import static org.batfish.datamodel.matchers.InterfaceMatchers.hasSpeed;
Expand Down Expand Up @@ -1422,7 +1423,10 @@ public void testRedistributeOspfConversion() {
@Test
public void testInterfaceConversion() {
Configuration c = parseConfig("arista_interface");
assertThat(c, hasInterface("Ethernet1", hasVrf(hasName(equalTo("VRF_1")))));
assertThat(
c,
hasInterface(
"Ethernet1", allOf(hasVrf(hasName(equalTo("VRF_1"))), hasEncapsulationVlan(7))));
assertThat(c, hasInterface("Ethernet2", hasVrf(hasName(equalTo("VRF_2")))));
assertThat(c, hasInterface("UnconnectedEthernet5"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ hostname arista_interface
interface Ethernet1
!! New vrf syntax, EOS 4.23 and later
vrf VRF_1
encapsulation dot1q vlan 7
ip address 1.1.1.1/31
ip ospf priority 150
no queue-monitor length
Expand Down

0 comments on commit a1e76e1

Please sign in to comment.