Adding Encapsulation in VPLS and correcting bugs.
Change-Id: Idc0c1834ae2bbd0fdaf564fd65360cc0f018d18d
diff --git a/apps/vpls/src/test/java/org/onosproject/vpls/VplsConfigurationServiceAdapter.java b/apps/vpls/src/test/java/org/onosproject/vpls/VplsConfigurationServiceAdapter.java
new file mode 100644
index 0000000..a534bd2
--- /dev/null
+++ b/apps/vpls/src/test/java/org/onosproject/vpls/VplsConfigurationServiceAdapter.java
@@ -0,0 +1,79 @@
+package org.onosproject.vpls;
+
+import com.google.common.collect.SetMultimap;
+import org.onlab.packet.VlanId;
+import org.onosproject.incubator.net.intf.Interface;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.EncapsulationType;
+import org.onosproject.vpls.config.VplsConfigurationService;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Test adapter for VPLS configuration service.
+ */
+public class VplsConfigurationServiceAdapter implements VplsConfigurationService {
+ @Override
+ public void addVpls(String vplsName, Set<String> ifaces, String encap) {}
+
+ @Override
+ public void removeVpls(String vplsName) {}
+
+ @Override
+ public void addIface(String vplsName, String iface) {}
+
+ @Override
+ public void setEncap(String vplsName, String encap) {}
+
+ @Override
+ public EncapsulationType encap(String vplsName) {
+ return null;
+ }
+
+ @Override
+ public void removeIface(String iface) {}
+
+ @Override
+ public void cleanVplsConfig() {}
+
+ @Override
+ public Set<String> vplsAffectedByApi() {
+ return null;
+ }
+
+ @Override
+ public Set<Interface> allIfaces() {
+ return null;
+ }
+
+ @Override
+ public Set<Interface> ifaces(String vplsName) {
+ return null;
+ }
+
+ @Override
+ public Set<String> vplsNames() {
+ return null;
+ }
+
+ @Override
+ public Set<String> vplsNamesOld() {
+ return null;
+ }
+
+ @Override
+ public SetMultimap<String, Interface> ifacesByVplsName() {
+ return null;
+ }
+
+ @Override
+ public SetMultimap<String, Interface> ifacesByVplsName(VlanId vlan, ConnectPoint connectPoint) {
+ return null;
+ }
+
+ @Override
+ public Map<String, EncapsulationType> encapByVplsName() {
+ return null;
+ }
+}
diff --git a/apps/vpls/src/test/java/org/onosproject/vpls/VplsNeighbourHandlerTest.java b/apps/vpls/src/test/java/org/onosproject/vpls/VplsNeighbourHandlerTest.java
index 90e3415..66edd13 100644
--- a/apps/vpls/src/test/java/org/onosproject/vpls/VplsNeighbourHandlerTest.java
+++ b/apps/vpls/src/test/java/org/onosproject/vpls/VplsNeighbourHandlerTest.java
@@ -19,6 +19,7 @@
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSetMultimap;
+import com.google.common.collect.Maps;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets;
import org.junit.After;
@@ -41,6 +42,7 @@
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultHost;
import org.onosproject.net.DeviceId;
+import org.onosproject.net.EncapsulationType;
import org.onosproject.net.Host;
import org.onosproject.net.HostId;
import org.onosproject.net.HostLocation;
@@ -48,9 +50,9 @@
import org.onosproject.net.host.HostService;
import org.onosproject.net.host.HostServiceAdapter;
import org.onosproject.net.provider.ProviderId;
-import org.onosproject.vpls.config.VplsConfigurationService;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@@ -61,81 +63,88 @@
* Tests the the {@link VplsNeighbourHandler} class.
*/
public class VplsNeighbourHandlerTest {
- private final ConnectPoint of1p1 =
- new ConnectPoint(DeviceId.deviceId("of:1"),
- PortNumber.portNumber(1));
- private final ConnectPoint of4p1 =
- new ConnectPoint(DeviceId.deviceId("of:4"),
- PortNumber.portNumber(1));
- private final ConnectPoint of3p1 =
- new ConnectPoint(DeviceId.deviceId("of:3"),
- PortNumber.portNumber(1));
- private final ConnectPoint of4p2 =
- new ConnectPoint(DeviceId.deviceId("of:4"),
- PortNumber.portNumber(2));
- private final ConnectPoint of2p1 =
- new ConnectPoint(DeviceId.deviceId("of:2"),
- PortNumber.portNumber(1));
- private final VlanId vlan100 = VlanId.vlanId("100");
- private final VlanId vlan200 = VlanId.vlanId("200");
- private final VlanId vlan300 = VlanId.vlanId("300");
+ private static final String IFACES_NOT_EXPECTED =
+ "The interfaces reached by the packet are not equal to the " +
+ "interfaces expected";
- private final Interface v100h1 =
- new Interface("v100h1", of1p1, null, null, vlan100);
- private final Interface v100h2 =
- new Interface("v100h2", of4p1, null, null, vlan100);
- private final Interface v200h1 =
- new Interface("v200h1", of4p2, null, null, vlan200);
- private final Interface v300h1 =
- new Interface("v300h1", of3p1, null, null, vlan300);
- private final Interface v200h2 =
- new Interface("v200h2", of2p1, null, null, vlan200);
+ private static final DeviceId DID1 = getDeviceId(1);
+ private static final DeviceId DID2 = getDeviceId(2);
+ private static final DeviceId DID3 = getDeviceId(3);
+ private static final DeviceId DID4 = getDeviceId(4);
- private final MacAddress mac1 = MacAddress.valueOf("00:00:00:00:00:01");
- private final MacAddress mac2 = MacAddress.valueOf("00:00:00:00:00:02");
- private final MacAddress mac3 = MacAddress.valueOf("00:00:00:00:00:03");
- private final MacAddress mac4 = MacAddress.valueOf("00:00:00:00:00:04");
- private final MacAddress mac5 = MacAddress.valueOf("00:00:00:00:00:05");
+ private static final PortNumber P1 = PortNumber.portNumber(1);
+ private static final PortNumber P2 = PortNumber.portNumber(2);
- private final ProviderId pid = new ProviderId("of", "foo");
+ private static final ConnectPoint OF1P1 = new ConnectPoint(DID1, P1);
+ private static final ConnectPoint OF2P1 = new ConnectPoint(DID2, P1);
+ private static final ConnectPoint OF3P1 = new ConnectPoint(DID3, P1);
+ private static final ConnectPoint OF4P1 = new ConnectPoint(DID4, P1);
+ private static final ConnectPoint OF4P2 = new ConnectPoint(DID4, P2);
- private final Host v100host1 = makeHost(mac1, vlan100, of1p1);
- private final Host v100host2 = makeHost(mac2, vlan100, of4p1);
- private final Host v200host1 = makeHost(mac3, vlan200, of4p2);
- private final Host v300host1 = makeHost(mac4, vlan300, of3p1);
- private final Host v200host2 = makeHost(mac5, vlan200, of2p1);
+ private static final String VPLS1 = "vpls1";
+ private static final String VPLS2 = "vpls2";
- private final Set<Host> availableHosts = ImmutableSet.of(v100host1,
- v100host2,
- v200host1,
- v300host1,
- v200host2);
+ private static final VlanId VLAN100 = VlanId.vlanId("100");
+ private static final VlanId VLAN200 = VlanId.vlanId("200");
+ private static final VlanId VLAN300 = VlanId.vlanId("300");
- private final Set<Interface> avaliableInterfaces =
- ImmutableSet.of(v100h1, v100h2, v200h1, v200h2, v300h1);
+ private static final Interface V100H1 =
+ new Interface("v100h1", OF1P1, null, null, VLAN100);
+ private static final Interface V100H2 =
+ new Interface("v100h2", OF4P1, null, null, VLAN100);
+ private static final Interface V200H1 =
+ new Interface("v200h1", OF4P2, null, null, VLAN200);
+ private static final Interface V200H2 =
+ new Interface("v200h2", OF2P1, null, null, VLAN200);
+ private static final Interface V300H1 =
+ new Interface("v300h1", OF3P1, null, null, VLAN300);
+
+ private static final MacAddress MAC1 = MacAddress.valueOf("00:00:00:00:00:01");
+ private static final MacAddress MAC2 = MacAddress.valueOf("00:00:00:00:00:02");
+ private static final MacAddress MAC3 = MacAddress.valueOf("00:00:00:00:00:03");
+ private static final MacAddress MAC4 = MacAddress.valueOf("00:00:00:00:00:04");
+ private static final MacAddress MAC5 = MacAddress.valueOf("00:00:00:00:00:05");
+
+ private static final ProviderId PID = new ProviderId("of", "foo");
+
+ private final Host v100Host1 = makeHost(MAC1, VLAN100, OF1P1);
+ private final Host v100Host2 = makeHost(MAC2, VLAN100, OF4P1);
+ private final Host v200Host1 = makeHost(MAC3, VLAN200, OF4P2);
+ private final Host v200Host2 = makeHost(MAC5, VLAN200, OF2P1);
+ private final Host v300Host1 = makeHost(MAC4, VLAN300, OF3P1);
+
+ private final Set<Host> availableHosts = ImmutableSet.of(v100Host1,
+ v100Host2,
+ v200Host1,
+ v300Host1,
+ v200Host2);
+
+ private final Set<Interface> availableInterfaces =
+ ImmutableSet.of(V100H1, V100H2, V200H1, V200H2, V300H1);
private VplsNeighbourHandler vplsNeighbourHandler;
private HostService hostService;
/**
- * Sets up 2 VPLS which contain 2 networks and 5 hosts.
- * net1 contains 3 hosts: v100h1, v200h1 and v300h1
- * net2 contains 2 hosts: v100h2, v200h2
+ * Sets up 2 VPLS.
+ * VPLS 1 contains 3 hosts: v100h1, v200h1 and v300h1
+ * VPLS 2 contains 2 hosts: v100h2, v200h2
*/
@Before
public void setUp() {
vplsNeighbourHandler = new VplsNeighbourHandler();
- SetMultimap<String, Interface> vplsNetworks =
+ SetMultimap<String, Interface> ifacesByVpls =
HashMultimap.create();
- vplsNetworks.put("net1", v100h1);
- vplsNetworks.put("net1", v200h1);
- vplsNetworks.put("net1", v300h1);
- vplsNetworks.put("net2", v100h2);
- vplsNetworks.put("net2", v200h2);
+ ifacesByVpls.put(VPLS1, V100H1);
+ ifacesByVpls.put(VPLS1, V200H1);
+ ifacesByVpls.put(VPLS1, V300H1);
+ ifacesByVpls.put(VPLS2, V100H2);
+ ifacesByVpls.put(VPLS2, V200H2);
+ HashMap<String, EncapsulationType> encap = Maps.newHashMap();
vplsNeighbourHandler.vplsConfigService =
- new TestVplsConfigService(vplsNetworks);
+ new TestVplsConfigService(ifacesByVpls, encap);
vplsNeighbourHandler.interfaceService =
new TestInterfaceService();
vplsNeighbourHandler.neighbourService =
@@ -150,133 +159,133 @@
}
/**
- * Sends request messages to all hosts in VPLS net1.
- * Request messages should be received from other hosts in net1.
+ * Sends request messages to all hosts in VPLS 1.
+ * Request messages should be received from other hosts in VPLS 1.
*/
@Test
- public void testNet1RequestMessage() {
- // Request from v100h1 (net1)
- // Should be received by v200h1 and v300h1
+ public void vpls1RequestMessage() {
+ // Request messages from v100h1 (VPLS 1) should be received by v200h1 and v300h1
TestMessageContext requestMessage =
- makeBroadcastRequestContext(v100host1);
- Set<Interface> expectInterfaces = ImmutableSet.of(v200h1, v300h1);
+ makeBroadcastRequestContext(v100Host1);
+ Set<Interface> expectInterfaces = ImmutableSet.of(V200H1, V300H1);
vplsNeighbourHandler.handleRequest(requestMessage);
- assertEquals(expectInterfaces, requestMessage.forwardResults);
+ assertEquals(IFACES_NOT_EXPECTED, expectInterfaces, requestMessage.forwardResults);
- // Request from v200h1 (net1)
- // Should be received by v100h1 and v300h1
- requestMessage = makeBroadcastRequestContext(v200host1);
- expectInterfaces = ImmutableSet.of(v100h1, v300h1);
+ // Request messages from v200h1 (VPLS 1) should be received by v100h1 and v300h1
+ requestMessage = makeBroadcastRequestContext(v200Host1);
+ expectInterfaces = ImmutableSet.of(V100H1, V300H1);
vplsNeighbourHandler.handleRequest(requestMessage);
- assertEquals(expectInterfaces, requestMessage.forwardResults);
+ assertEquals(IFACES_NOT_EXPECTED, expectInterfaces, requestMessage.forwardResults);
- // Request from v300h1 (net1)
- // Should be received by v100h1 and v200h1
- requestMessage = makeBroadcastRequestContext(v300host1);
- expectInterfaces = ImmutableSet.of(v100h1, v200h1);
+ // Request from v300h1 (VPLS 1) should be received by v100h1 and v200h1
+ requestMessage = makeBroadcastRequestContext(v300Host1);
+ expectInterfaces = ImmutableSet.of(V100H1, V200H1);
vplsNeighbourHandler.handleRequest(requestMessage);
- assertEquals(expectInterfaces, requestMessage.forwardResults);
+ assertEquals(IFACES_NOT_EXPECTED, expectInterfaces, requestMessage.forwardResults);
}
/**
- * Sends request messages to all hosts in VPLS net2.
- * Request messages should be received from other hosts in net2.
+ * Sends request messages to all hosts in VPLS 2.
+ * Request messages should be received from other hosts in VPLS 2.
*/
@Test
- public void testNet2RequestMessage() {
- // Request from v100h2
- // Should be received by v200h2
+ public void vpls2RequestMessage() {
+ // Request messages from v100h2 (VPLS 2) should be received by v200h2
TestMessageContext requestMessage =
- makeBroadcastRequestContext(v100host2);
- Set<Interface> expectInterfaces = ImmutableSet.of(v200h2);
+ makeBroadcastRequestContext(v100Host2);
+ Set<Interface> expectInterfaces = ImmutableSet.of(V200H2);
vplsNeighbourHandler.handleRequest(requestMessage);
- assertEquals(expectInterfaces, requestMessage.forwardResults);
+ assertEquals(IFACES_NOT_EXPECTED, expectInterfaces, requestMessage.forwardResults);
- // Request from v200h2
- // Should be received by v100h2
- requestMessage = makeBroadcastRequestContext(v200host2);
- expectInterfaces = ImmutableSet.of(v100h2);
+ // Request messages from v200h2 (VPLS 2) should be received by v100h2
+ requestMessage = makeBroadcastRequestContext(v200Host2);
+ expectInterfaces = ImmutableSet.of(V100H2);
vplsNeighbourHandler.handleRequest(requestMessage);
- assertEquals(expectInterfaces, requestMessage.forwardResults);
+ assertEquals(IFACES_NOT_EXPECTED, expectInterfaces, requestMessage.forwardResults);
}
/**
- * Sends reply messages to hosts in VPLS net1.
+ * Sends reply messages to hosts in VPLS 1.
* Reply messages should be received by the host with MAC address equal to
* the dstMac of the message context.
*/
@Test
- public void testNet1ReplyMessage() {
- // Response from v100h1 (net1) to v200h1 (net1)
- // Should be received by v200h1
+ public void vpls1ReplyMessage() {
+ // Reply messages from v100h1 (VPLS 1) should be received by v200h1
TestMessageContext replyMessage =
- makeReplyContext(v100host1, v200host1);
- Set<Interface> expectInterfaces = ImmutableSet.of(v200h1);
+ makeReplyContext(v100Host1, v200Host1);
+ Set<Interface> expectInterfaces = ImmutableSet.of(V200H1);
vplsNeighbourHandler.handleReply(replyMessage, hostService);
- assertEquals(expectInterfaces, replyMessage.forwardResults);
+ assertEquals(IFACES_NOT_EXPECTED, expectInterfaces, replyMessage.forwardResults);
- // Response from v200h1 (net1) to v300h1 (net1)
- // Should be received by v300h1
- replyMessage = makeReplyContext(v200host1, v300host1);
- expectInterfaces = ImmutableSet.of(v300h1);
+ // Reply messages from v200h1 (VPLS 1) should be received by v300h1
+ replyMessage = makeReplyContext(v200Host1, v300Host1);
+ expectInterfaces = ImmutableSet.of(V300H1);
vplsNeighbourHandler.handleReply(replyMessage, hostService);
- assertEquals(expectInterfaces, replyMessage.forwardResults);
+ assertEquals(IFACES_NOT_EXPECTED, expectInterfaces, replyMessage.forwardResults);
- // Response from v300h1 (net1) to v100h1 (net1)
- // Should be received by v100h1
- replyMessage = makeReplyContext(v300host1, v100host1);
- expectInterfaces = ImmutableSet.of(v100h1);
+ // Reply messages from v300h1 (VPLS 1) should be received by v100h1
+ replyMessage = makeReplyContext(v300Host1, v100Host1);
+ expectInterfaces = ImmutableSet.of(V100H1);
vplsNeighbourHandler.handleReply(replyMessage, hostService);
- assertEquals(expectInterfaces, replyMessage.forwardResults);
+ assertEquals(IFACES_NOT_EXPECTED, expectInterfaces, replyMessage.forwardResults);
}
/**
- * Sends reply messages to hosts in VPLS net2.
+ * Sends reply messages to hosts in VPLS 2.
* Reply messages should be received by the host with MAC address equal to
* the dstMac of the message context.
*/
@Test
- public void testNet2ReplyMessage() {
- // Response from v100h2 (net2) to v200h2 (net2)
- // Should be received by v200h2
+ public void vpls2ReplyMessage() {
+ // Reply messages from v100h2 (VPLS 2) should be received by v200h2
TestMessageContext replyMessage =
- makeReplyContext(v100host2, v200host2);
- Set<Interface> expectInterfaces = ImmutableSet.of(v200h2);
+ makeReplyContext(v100Host2, v200Host2);
+ Set<Interface> expectInterfaces = ImmutableSet.of(V200H2);
vplsNeighbourHandler.handleReply(replyMessage, hostService);
- assertEquals(expectInterfaces, replyMessage.forwardResults);
+ assertEquals(IFACES_NOT_EXPECTED, expectInterfaces, replyMessage.forwardResults);
- // Response from v200h2 (net2) to v100h2 (net2)
- // Should be received by v100h2
- replyMessage = makeReplyContext(v200host2, v100host2);
- expectInterfaces = ImmutableSet.of(v100h2);
+ // Reply messages from v200h2 (VPLS 2) should be received by v100h2
+ replyMessage = makeReplyContext(v200Host2, v100Host2);
+ expectInterfaces = ImmutableSet.of(V100H2);
vplsNeighbourHandler.handleReply(replyMessage, hostService);
- assertEquals(expectInterfaces, replyMessage.forwardResults);
+ assertEquals(IFACES_NOT_EXPECTED, expectInterfaces, replyMessage.forwardResults);
}
/**
* Sends wrong reply messages to hosts.
* The source and the destination MAC addresses are not set on any host of the VPLS.
- * The reply messages won't be received by any hosts.
+ * The reply messages will not be received by any hosts.
*/
@Test
- public void testWrongReplyMessage() {
- // Response from v100h1 (net1) to v100h2 (net2)
- // forward results should be empty
- TestMessageContext replyMessage = makeReplyContext(v100host1, v100host2);
+ public void wrongReplyMessage() {
+ // Reply message from v100h1 (VPLS 1) to v100h2 (VPLS 2).
+ // Forward results should be empty
+ TestMessageContext replyMessage = makeReplyContext(v100Host1, v100Host2);
Set<Interface> expectInterfaces = ImmutableSet.of();
vplsNeighbourHandler.handleReply(replyMessage, hostService);
- assertEquals(expectInterfaces, replyMessage.forwardResults);
+ assertEquals(IFACES_NOT_EXPECTED, expectInterfaces, replyMessage.forwardResults);
- // Response from v200h2 (net2) to v300h1 (net1)
- // forward results should be empty
- replyMessage = makeReplyContext(v200host2, v300host1);
+ // Reply message from v200h2 (VPLS 2) to v300h1 (VPLS 1).
+ // Forward results should be empty
+ replyMessage = makeReplyContext(v200Host2, v300Host1);
expectInterfaces = ImmutableSet.of();
vplsNeighbourHandler.handleReply(replyMessage, hostService);
- assertEquals(expectInterfaces, replyMessage.forwardResults);
+ assertEquals(IFACES_NOT_EXPECTED, expectInterfaces, replyMessage.forwardResults);
+ }
+
+ /**
+ * Returns the device Id of the ith device.
+ *
+ * @param i the device to get the Id of
+ * @return the device Id
+ */
+ private static DeviceId getDeviceId(int i) {
+ return DeviceId.deviceId("" + i);
}
private Host makeHost(MacAddress mac, VlanId vlan, ConnectPoint cp) {
- return new DefaultHost(pid,
+ return new DefaultHost(PID,
HostId.hostId(mac, vlan),
mac,
vlan,
@@ -336,6 +345,7 @@
this.forwardResults = Sets.newHashSet();
}
+
@Override
public ConnectPoint inPort() {
return inPort;
@@ -407,21 +417,22 @@
}
}
- private class TestVplsConfigService implements VplsConfigurationService {
+ private class TestVplsConfigService extends VplsConfigurationServiceAdapter {
- private final SetMultimap<String, Interface> vplsNetworks;
+ private final SetMultimap<String, Interface> ifacesByVplsName;
- public TestVplsConfigService(SetMultimap<String, Interface> networks) {
- this.vplsNetworks = networks;
+ public TestVplsConfigService(SetMultimap<String, Interface> ifacesByVplsName,
+ HashMap<String, EncapsulationType> encapByVplsName) {
+ this.ifacesByVplsName = ifacesByVplsName;
}
@Override
- public void addVpls(String name, Set<String> ifaceNames) {
- if (!vplsNetworks.containsKey(name)) {
+ public void addVpls(String vplsName, Set<String> ifaceNames, String encap) {
+ if (!ifacesByVplsName.containsKey(vplsName)) {
ifaceNames.forEach(ifaceName -> {
- avaliableInterfaces.forEach(intf -> {
- if (intf.name().equals(ifaceName)) {
- vplsNetworks.put(name, intf);
+ availableInterfaces.forEach(iface -> {
+ if (iface.name().equals(ifaceName)) {
+ ifacesByVplsName.put(vplsName, iface);
}
});
});
@@ -429,87 +440,77 @@
}
@Override
- public void removeVpls(String name) {
- if (vplsNetworks.containsKey(name)) {
- vplsNetworks.removeAll(name);
+ public void removeVpls(String vplsName) {
+ if (ifacesByVplsName.containsKey(vplsName)) {
+ ifacesByVplsName.removeAll(vplsName);
}
}
@Override
- public void addInterfaceToVpls(String name, String ifaceName) {
- avaliableInterfaces.forEach(intf -> {
+ public void addIface(String vplsName, String ifaceName) {
+ availableInterfaces.forEach(intf -> {
if (intf.name().equals(ifaceName)) {
- vplsNetworks.put(name, intf);
+ ifacesByVplsName.put(vplsName, intf);
}
});
}
@Override
- public void removeInterfaceFromVpls(String ifaceName) {
+ public void removeIface(String ifaceName) {
SetMultimap<String, Interface> toBeRemoved = HashMultimap.create();
- vplsNetworks.entries().forEach(e -> {
+ ifacesByVplsName.entries().forEach(e -> {
if (e.getValue().name().equals(ifaceName)) {
toBeRemoved.put(e.getKey(), e.getValue());
}
});
toBeRemoved.entries()
- .forEach(e -> vplsNetworks.remove(e.getKey(),
- e.getValue()));
+ .forEach(e -> ifacesByVplsName.remove(e.getKey(),
+ e.getValue()));
}
@Override
- public void cleanVpls() {
- vplsNetworks.clear();
+ public void cleanVplsConfig() {
+ ifacesByVplsName.clear();
}
@Override
- public Set<String> getVplsAffectedByApi() {
- return null;
+ public Set<Interface> allIfaces() {
+ return ImmutableSet.copyOf(ifacesByVplsName.values());
}
@Override
- public Set<Interface> getAllInterfaces() {
- return ImmutableSet.copyOf(vplsNetworks.values());
- }
-
- @Override
- public Set<Interface> getVplsInterfaces(String name) {
- return vplsNetworks.get(name)
+ public Set<Interface> ifaces(String name) {
+ return ifacesByVplsName.get(name)
.stream()
.collect(Collectors.toSet());
}
@Override
- public Set<String> getAllVpls() {
- return vplsNetworks.keySet();
+ public Set<String> vplsNames() {
+ return ifacesByVplsName.keySet();
}
@Override
- public Set<String> getOldVpls() {
- return null;
+ public SetMultimap<String, Interface> ifacesByVplsName() {
+ return ImmutableSetMultimap.copyOf(ifacesByVplsName);
}
@Override
- public SetMultimap<String, Interface> getVplsNetworks() {
- return ImmutableSetMultimap.copyOf(vplsNetworks);
- }
-
- @Override
- public SetMultimap<String, Interface> getVplsNetwork(VlanId vlan,
- ConnectPoint connectPoint) {
- String vplsNetworkName =
- vplsNetworks.entries().stream()
+ public SetMultimap<String, Interface> ifacesByVplsName(VlanId vlan,
+ ConnectPoint connectPoint) {
+ String vplsName =
+ ifacesByVplsName.entries().stream()
.filter(e -> e.getValue().connectPoint().equals(connectPoint))
.filter(e -> e.getValue().vlan().equals(vlan))
.map(e -> e.getKey())
.findFirst()
.orElse(null);
SetMultimap<String, Interface> result = HashMultimap.create();
- if (vplsNetworkName != null &&
- vplsNetworks.containsKey(vplsNetworkName)) {
- vplsNetworks.get(vplsNetworkName)
- .forEach(intf -> result.put(vplsNetworkName, intf));
+ if (vplsName != null &&
+ ifacesByVplsName.containsKey(vplsName)) {
+ ifacesByVplsName.get(vplsName)
+ .forEach(intf -> result.put(vplsName, intf));
return result;
}
return null;
@@ -654,13 +655,13 @@
@Override
public Set<Interface> getInterfaces() {
- return avaliableInterfaces;
+ return availableInterfaces;
}
@Override
public Interface getInterfaceByName(ConnectPoint connectPoint,
String name) {
- return avaliableInterfaces.stream()
+ return availableInterfaces.stream()
.filter(intf -> intf.name().equals(name))
.findFirst()
.orElse(null);
@@ -669,28 +670,28 @@
@Override
public Set<Interface> getInterfacesByPort(ConnectPoint port) {
- return avaliableInterfaces.stream()
+ return availableInterfaces.stream()
.filter(intf -> intf.connectPoint().equals(port))
.collect(Collectors.toSet());
}
@Override
public Set<Interface> getInterfacesByIp(IpAddress ip) {
- return avaliableInterfaces.stream()
+ return availableInterfaces.stream()
.filter(intf -> intf.ipAddressesList().contains(ip))
.collect(Collectors.toSet());
}
@Override
public Set<Interface> getInterfacesByVlan(VlanId vlan) {
- return avaliableInterfaces.stream()
+ return availableInterfaces.stream()
.filter(intf -> intf.vlan().equals(vlan))
.collect(Collectors.toSet());
}
@Override
public Interface getMatchingInterface(IpAddress ip) {
- return avaliableInterfaces.stream()
+ return availableInterfaces.stream()
.filter(intf -> intf.ipAddressesList().contains(ip))
.findFirst()
.orElse(null);
diff --git a/apps/vpls/src/test/java/org/onosproject/vpls/VplsTest.java b/apps/vpls/src/test/java/org/onosproject/vpls/VplsTest.java
index 178e1a8..a7585da 100644
--- a/apps/vpls/src/test/java/org/onosproject/vpls/VplsTest.java
+++ b/apps/vpls/src/test/java/org/onosproject/vpls/VplsTest.java
@@ -16,6 +16,7 @@
package org.onosproject.vpls;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -23,6 +24,7 @@
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.SetMultimap;
@@ -47,6 +49,7 @@
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultHost;
import org.onosproject.net.DeviceId;
+import org.onosproject.net.EncapsulationType;
import org.onosproject.net.Host;
import org.onosproject.net.HostId;
import org.onosproject.net.HostLocation;
@@ -61,6 +64,7 @@
import org.onosproject.net.host.HostListener;
import org.onosproject.net.host.HostService;
import org.onosproject.net.host.HostServiceAdapter;
+import org.onosproject.net.intent.ConnectivityIntent;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.IntentServiceAdapter;
@@ -68,6 +72,7 @@
import org.onosproject.net.intent.Key;
import org.onosproject.net.intent.MultiPointToSinglePointIntent;
import org.onosproject.net.intent.SinglePointToMultiPointIntent;
+import org.onosproject.net.intent.constraint.EncapsulationConstraint;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.routing.IntentSynchronizationAdminService;
import org.onosproject.routing.IntentSynchronizationService;
@@ -82,6 +87,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.onosproject.net.EncapsulationType.*;
import static org.onosproject.vpls.IntentInstaller.PREFIX_BROADCAST;
import static org.onosproject.vpls.IntentInstaller.PREFIX_UNICAST;
@@ -93,9 +99,8 @@
private static final ApplicationId APPID = TestApplicationId.create(APP_NAME);
private static final String DASH = "-";
private static final int PRIORITY_OFFSET = 1000;
- private static final String NET1 = "net1";
- private static final String NET2 = "net2";
- private static final String COMPARE = "Comparing %s to %s";
+ private static final String VPLS1 = "vpls1";
+ private static final String VPLS2 = "vpls2";
private static final PortNumber P1 = PortNumber.portNumber(1);
@@ -147,47 +152,47 @@
private static IdGenerator idGenerator;
- private final Interface v100h1 =
+ private static final Interface V100H1 =
new Interface("v100h1", CP1, null, null, VLAN100);
- private final Interface v100h2 =
+ private static final Interface V100H2 =
new Interface("v100h2", CP2, null, null, VLAN100);
- private final Interface v200h1 =
+ private static final Interface V200H1 =
new Interface("v200h1", CP3, null, null, VLAN200);
- private final Interface v200h2 =
+ private static final Interface V200H2 =
new Interface("v200h2", CP4, null, null, VLAN200);
- private final Interface v300h1 =
+ private static final Interface V300H1 =
new Interface("v300h1", CP5, null, null, VLAN300);
- private final Interface v300h2 =
+ private static final Interface V300H2 =
new Interface("v300h2", CP6, null, null, VLAN300);
- private final Host v100host1 =
+ private static final Host V100HOST1 =
new DefaultHost(PID, HID1, MAC1, VLAN100,
getLocation(1), Collections.singleton(IP1));
- private final Host v100host2 =
+ private static final Host V100HOST2 =
new DefaultHost(PID, HID2, MAC2, VLAN100,
getLocation(2), Sets.newHashSet());
- private final Host v200host1 =
+ private static final Host V200HOST1 =
new DefaultHost(PID, HID3, MAC3, VLAN200,
getLocation(3), Collections.singleton(IP2));
- private final Host v200host2 =
+ private static final Host V200HOST2 =
new DefaultHost(PID, HID4, MAC4, VLAN200,
getLocation(4), Sets.newHashSet());
- private final Host v300host1 =
+ private static final Host V300HOST1 =
new DefaultHost(PID, HID5, MAC5, VLAN300,
getLocation(5), Sets.newHashSet());
- private final Host v300host2 =
+ private static final Host V300HOST2 =
new DefaultHost(PID, HID6, MAC6, VLAN300,
getLocation(6), Sets.newHashSet());
- private final Host v300host3 =
+ private static final Host V300HOST3 =
new DefaultHost(PID, HID7, MAC7, VLAN300,
getLocation(7), Sets.newHashSet());
- private final Set<Interface> avaliableInterfaces =
- ImmutableSet.of(v100h1, v100h2, v200h1, v200h2, v300h1, v300h2);
+ private static final Set<Interface> AVALIABLE_INTERFACES =
+ ImmutableSet.of(V100H1, V100H2, V200H1, V200H2, V300H1, V300H2);
- private final Set<Host> avaliableHosts =
- ImmutableSet.of(v100host1, v100host2, v200host1,
- v200host2, v300host1, v300host2, v300host3);
+ private static final Set<Host> AVALIABLE_HOSTS =
+ ImmutableSet.of(V100HOST1, V100HOST2, V200HOST1,
+ V200HOST2, V300HOST1, V300HOST2, V300HOST3);
private ApplicationService applicationService;
private CoreService coreService;
@@ -225,18 +230,22 @@
interfaceService = createMock(InterfaceService.class);
interfaceService.addListener(anyObject(InterfaceListener.class));
expectLastCall().anyTimes();
- addIntfConfig();
+ addIfaceConfig();
- SetMultimap<String, Interface> vplsNetworks =
+ SetMultimap<String, Interface> interfacesByVpls =
HashMultimap.create();
- vplsNetworks.put(NET1, v100h1);
- vplsNetworks.put(NET1, v200h1);
- vplsNetworks.put(NET1, v300h1);
- vplsNetworks.put(NET2, v100h2);
- vplsNetworks.put(NET2, v200h2);
- vplsNetworks.put(NET2, v300h2);
+ interfacesByVpls.put(VPLS1, V100H1);
+ interfacesByVpls.put(VPLS1, V200H1);
+ interfacesByVpls.put(VPLS1, V300H1);
+ interfacesByVpls.put(VPLS2, V100H2);
+ interfacesByVpls.put(VPLS2, V200H2);
+ interfacesByVpls.put(VPLS2, V300H2);
- vplsConfigService = new TestVplsConfigService(vplsNetworks);
+ Map<String, EncapsulationType> encapByVpls = new HashMap<>();
+ encapByVpls.put(VPLS1, VLAN);
+ encapByVpls.put(VPLS2, NONE);
+
+ vplsConfigService = new TestVplsConfigService(interfacesByVpls, encapByVpls);
vpls = new Vpls();
vpls.applicationService = applicationService;
@@ -261,13 +270,13 @@
* an interface on port 1 with vlan 200. On device 5 and 6 is configured
* an interface on port 1 with vlan 300.
*/
- private void addIntfConfig() {
- Set<Interface> interfaces = ImmutableSet.copyOf(avaliableInterfaces);
- Set<Interface> vlanOneSet = ImmutableSet.of(v100h1, v100h2);
- Set<Interface> vlanTwoSet = ImmutableSet.of(v200h1, v200h2);
- Set<Interface> vlanThreeSet = ImmutableSet.of(v300h1, v300h2);
+ private void addIfaceConfig() {
+ Set<Interface> interfaces = ImmutableSet.copyOf(AVALIABLE_INTERFACES);
+ Set<Interface> vlanOneSet = ImmutableSet.of(V100H1, V100H2);
+ Set<Interface> vlanTwoSet = ImmutableSet.of(V200H1, V200H2);
+ Set<Interface> vlanThreeSet = ImmutableSet.of(V300H1, V300H2);
- avaliableInterfaces.forEach(intf -> {
+ AVALIABLE_INTERFACES.forEach(intf -> {
expect(interfaceService.getInterfacesByPort(intf.connectPoint()))
.andReturn(Sets.newHashSet(intf)).anyTimes();
});
@@ -284,41 +293,41 @@
/**
* Six ports are configured with VLANs but no hosts are registered by the
- * HostService. The first three ports have an interface configured on NET1,
- * the other three on NET2. The number of intents expected is six: three for
- * NET1, three for NET2. Six mp2sp intents. Checks if the number of intents
+ * HostService. The first three ports have an interface configured on VPLS 1,
+ * the other three on VPLS 2. The number of intents expected is six: three for
+ * VPLS 1, three for VPLS 2. Six MP2SP intents. Checks if the number of intents
* submitted to the intent framework is equal to the number of intents
* expected and if all intents are equivalent.
*/
@Test
- public void testActivateNoHosts() {
+ public void activateNoHosts() {
vpls.activate();
List<Intent> expectedIntents = Lists.newArrayList();
Set<FilteredConnectPoint> fcPoints;
- fcPoints = buildFCPoints(ImmutableSet.of(v100h1, v200h1, v300h1));
- expectedIntents.addAll(generateVplsBrc(fcPoints, NET1));
+ fcPoints = buildFCPoints(ImmutableSet.of(V100H1, V200H1, V300H1));
+ expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS1, VLAN));
- fcPoints = buildFCPoints(ImmutableSet.of(v100h2, v200h2, v300h2));
- expectedIntents.addAll(generateVplsBrc(fcPoints, NET2));
+ fcPoints = buildFCPoints(ImmutableSet.of(V100H2, V200H2, V300H2));
+ expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS2, NONE));
checkIntents(expectedIntents);
}
/**
* Six ports are configured with VLANs and six hosts are registered by the
- * HostService. The first three ports have an interface configured on NET1,
- * the other three on NET2. The number of intents expected is twelve: six
- * for VLAN1, six for NET2. six sp2mp intents, six mp2sp intents. For NET1
+ * HostService. The first three ports have an interface configured on VPLS 1,
+ * the other three on VPLS 2. The number of intents expected is twelve: six
+ * for VLAN 1, six for VPLS 2. six sp2mp intents, six mp2sp intents. For VPLS 1
* IPs are added to demonstrate this doesn't influence the number of intents
* created. Checks if the number of intents submitted to the intent
* framework is equal to the number of intents expected and if all intents
* are equivalent.
*/
@Test
- public void testSixInterfacesConfiguredHostsPresent() {
- hostsAvailable.addAll(avaliableHosts);
+ public void sixInterfacesConfiguredHostsPresent() {
+ hostsAvailable.addAll(AVALIABLE_HOSTS);
vpls.activate();
@@ -326,15 +335,15 @@
Set<FilteredConnectPoint> fcPoints;
Set<Host> hosts;
- fcPoints = buildFCPoints(ImmutableSet.of(v100h1, v200h1, v300h1));
- hosts = ImmutableSet.of(v100host1, v200host1, v300host1);
- expectedIntents.addAll(generateVplsBrc(fcPoints, NET1));
- expectedIntents.addAll(generateVplsUni(fcPoints, hosts, NET1));
+ fcPoints = buildFCPoints(ImmutableSet.of(V100H1, V200H1, V300H1));
+ hosts = ImmutableSet.of(V100HOST1, V200HOST1, V300HOST1);
+ expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS1, VLAN));
+ expectedIntents.addAll(generateVplsUni(fcPoints, hosts, VPLS1, VLAN));
- fcPoints = buildFCPoints(ImmutableSet.of(v100h2, v200h2, v300h2));
- hosts = ImmutableSet.of(v100host2, v200host2, v300host2);
- expectedIntents.addAll(generateVplsBrc(fcPoints, NET2));
- expectedIntents.addAll(generateVplsUni(fcPoints, hosts, NET2));
+ fcPoints = buildFCPoints(ImmutableSet.of(V100H2, V200H2, V300H2));
+ hosts = ImmutableSet.of(V100HOST2, V200HOST2, V300HOST2);
+ expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS2, NONE));
+ expectedIntents.addAll(generateVplsUni(fcPoints, hosts, VPLS2, NONE));
checkIntents(expectedIntents);
}
@@ -342,12 +351,12 @@
/**
* Six ports are configured with VLANs and initially no hosts are registered
* by the HostService. The first three ports have an interface configured on
- * NET1, the other three have an interface configured on NET2. When the
+ * VPLS 1, the other three have an interface configured on VPLS 2. When the
* module starts up, three hosts attached to device one, two and three -
* port 1, are registered by the HostService and events are sent to the
* application. sp2mp intents are created for all interfaces configured and
* mp2sp intents are created only for the hosts attached.
- * The number of intents expected is nine: six for NET1, three for NET2.
+ * The number of intents expected is nine: six for VPLS 1, three for VPLS 2.
* Six sp2mp intents, three mp2sp intents. IPs are added on the first two
* hosts only to demonstrate this doesn't influence the number of intents
* created.
@@ -358,25 +367,25 @@
* to the number of intents expected and if all intents are equivalent.
*/
@Test
- public void testSixInterfacesThreeHostEventsSameVpls() {
+ public void sixInterfacesThreeHostEventsSameVpls() {
vpls.activate();
List<Intent> expectedIntents = Lists.newArrayList();
Set<FilteredConnectPoint> fcPoints;
Set<Host> hosts;
- hostsAvailable.addAll(Sets.newHashSet(v100host1, v200host1, v300host1, v300host3));
+ hostsAvailable.addAll(Sets.newHashSet(V100HOST1, V200HOST1, V300HOST1, V300HOST3));
hostsAvailable.forEach(host ->
hostListener.event(new HostEvent(HostEvent.Type.HOST_ADDED, host)));
- fcPoints = buildFCPoints(ImmutableSet.of(v100h1, v200h1, v300h1));
- hosts = ImmutableSet.of(v100host1, v200host1, v300host1);
- expectedIntents.addAll(generateVplsBrc(fcPoints, NET1));
- expectedIntents.addAll(generateVplsUni(fcPoints, hosts, NET1));
+ fcPoints = buildFCPoints(ImmutableSet.of(V100H1, V200H1, V300H1));
+ hosts = ImmutableSet.of(V100HOST1, V200HOST1, V300HOST1);
+ expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS1, VLAN));
+ expectedIntents.addAll(generateVplsUni(fcPoints, hosts, VPLS1, VLAN));
- fcPoints = buildFCPoints(ImmutableSet.of(v100h2, v200h2, v300h2));
- expectedIntents.addAll(generateVplsBrc(fcPoints, NET2));
+ fcPoints = buildFCPoints(ImmutableSet.of(V100H2, V200H2, V300H2));
+ expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS2, NONE));
checkIntents(expectedIntents);
}
@@ -386,10 +395,11 @@
*
* @param fcPoints the filtered connect point
* @param name the name of the VPLS
+ * @param encap the encapsulation type
* @return the list of expected sp2mp intents for the given VPLS
*/
private List<SinglePointToMultiPointIntent>
- generateVplsBrc(Set<FilteredConnectPoint> fcPoints, String name) {
+ generateVplsBrc(Set<FilteredConnectPoint> fcPoints, String name, EncapsulationType encap) {
List<SinglePointToMultiPointIntent> intents = Lists.newArrayList();
fcPoints.forEach(point -> {
@@ -401,7 +411,7 @@
Key brckey = buildKey(PREFIX_BROADCAST,
point.connectPoint(), name, MacAddress.BROADCAST);
- intents.add(buildBrcIntent(brckey, point, otherPoints));
+ intents.add(buildBrcIntent(brckey, point, otherPoints, encap));
});
return intents;
@@ -413,10 +423,12 @@
* @param fcPoints the filtered connect point
* @param hosts the hosts
* @param name the name of the VPLS
+ * @param encap the encapsulation type
* @return the list of expected mp2sp intents for the given VPLS
*/
private List<MultiPointToSinglePointIntent>
- generateVplsUni(Set<FilteredConnectPoint> fcPoints, Set<Host> hosts, String name) {
+ generateVplsUni(Set<FilteredConnectPoint> fcPoints, Set<Host> hosts,
+ String name, EncapsulationType encap) {
List<MultiPointToSinglePointIntent> intents = Lists.newArrayList();
hosts.forEach(host -> {
@@ -430,7 +442,7 @@
Key uniKey = buildKey(PREFIX_UNICAST,
host.location(), name, host.mac());
- intents.add(buildUniIntent(uniKey, otherPoints, hostPoint, host));
+ intents.add(buildUniIntent(uniKey, otherPoints, hostPoint, host, encap));
});
return intents;
@@ -443,19 +455,24 @@
* @param intents the list of intents expected
*/
private void checkIntents(List<Intent> intents) {
- assertEquals(intents.size(), intentService.getIntentCount());
+ assertEquals("The number of intents submitted differs from the number" +
+ "of intents expected",
+ intents.size(), intentService.getIntentCount());
for (Intent intentOne : intents) {
boolean found = false;
for (Intent intentTwo : intentService.getIntents()) {
if (intentOne.key().equals(intentTwo.key())) {
found = true;
- assertTrue(format(COMPARE, intentOne, intentTwo),
+ assertTrue(format("The intent submitted is different from" +
+ "the intent expected",
+ intentOne, intentTwo),
IntentUtils.intentsAreEqual(intentOne, intentTwo));
break;
}
}
- assertTrue(found);
+ assertTrue("The intent submitted is not equal to any of the expected" +
+ "intents", found);
}
}
@@ -468,23 +485,26 @@
* @return the generated single-point to multi-point intent
*/
private SinglePointToMultiPointIntent buildBrcIntent(Key key,
- FilteredConnectPoint src,
- Set<FilteredConnectPoint> dsts) {
- SinglePointToMultiPointIntent intent;
+ FilteredConnectPoint src,
+ Set<FilteredConnectPoint> dsts,
+ EncapsulationType encap) {
+ SinglePointToMultiPointIntent.Builder intentBuilder;
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthDst(MacAddress.BROADCAST)
.build();
- intent = SinglePointToMultiPointIntent.builder()
+ intentBuilder = SinglePointToMultiPointIntent.builder()
.appId(APPID)
.key(key)
.selector(selector)
.filteredIngressPoint(src)
.filteredEgressPoints(dsts)
- .priority(PRIORITY_OFFSET)
- .build();
- return intent;
+ .priority(PRIORITY_OFFSET);
+
+ encap(intentBuilder, encap);
+
+ return intentBuilder.build();
}
/**
@@ -497,22 +517,27 @@
* @return the generated multi-point to single-point intent
*/
private MultiPointToSinglePointIntent buildUniIntent(Key key,
- Set<FilteredConnectPoint> srcs,
- FilteredConnectPoint dst,
- Host host) {
+ Set<FilteredConnectPoint> srcs,
+ FilteredConnectPoint dst,
+ Host host,
+ EncapsulationType encap) {
+ MultiPointToSinglePointIntent.Builder intentBuilder;
+
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthDst(host.mac())
.build();
- return MultiPointToSinglePointIntent.builder()
+ intentBuilder = MultiPointToSinglePointIntent.builder()
.appId(APPID)
.key(key)
.selector(selector)
.filteredIngressPoints(srcs)
.filteredEgressPoint(dst)
- .priority(PRIORITY_OFFSET)
- .build();
+ .priority(PRIORITY_OFFSET);
+ encap(intentBuilder, encap);
+
+ return intentBuilder.build();
}
/**
@@ -546,7 +571,7 @@
* @return the set of filtered connect points
*/
private Set<FilteredConnectPoint> buildFCPoints(Set<Interface> interfaces) {
- // Build all filtered connected point in the network
+ // Build all filtered connected point for the VPLS
return interfaces
.stream()
.map(intf -> {
@@ -567,19 +592,19 @@
* Builds an intent Key either for a single-point to multi-point or
* multi-point to single-point intent, based on a prefix that defines
* the intent type, the connection point representing the source or the
- * destination and the VLAN Id representing the network.
+ * destination and the VLAN Id representing the VPLS.
*
* @param prefix the key prefix
* @param cPoint the ingress/egress connect point
- * @param networkName the VPLS name
+ * @param vplsName the VPLS name
* @param hostMac the ingress/egress MAC address
* @return the key to identify the intent
*/
private Key buildKey(String prefix,
ConnectPoint cPoint,
- String networkName,
+ String vplsName,
MacAddress hostMac) {
- String keyString = networkName +
+ String keyString = vplsName +
DASH +
prefix +
DASH +
@@ -593,6 +618,21 @@
}
/**
+ * Adds an encapsulation constraint to the builder given, if encap is not
+ * equal to NONE.
+ *
+ * @param builder the intent builder
+ * @param encap the encapsulation type
+ */
+ private static void encap(ConnectivityIntent.Builder builder,
+ EncapsulationType encap) {
+ if (!encap.equals(NONE)) {
+ builder.constraints(ImmutableList.of(
+ new EncapsulationConstraint(encap)));
+ }
+ }
+
+ /**
* Returns the device Id of the ith device.
*
* @param i the device to get the Id of
@@ -728,63 +768,82 @@
/**
* Represents a fake VplsConfigService class which is needed for testing.
*/
- private class TestVplsConfigService implements VplsConfigurationService {
+ private class TestVplsConfigService extends VplsConfigurationServiceAdapter {
- private final SetMultimap<String, Interface> vplsNetworks;
+ private final SetMultimap<String, Interface> ifacesByVplsName;
+ private final Map<String, EncapsulationType> encapsByVplsName;
+
private Set<String> vplsAffectByApi = new HashSet<>();
- TestVplsConfigService(SetMultimap<String, Interface> vplsNetworks) {
- this.vplsNetworks = vplsNetworks;
+ TestVplsConfigService(SetMultimap<String, Interface> ifacesByVplsName,
+ Map<String, EncapsulationType> encapsByVplsName) {
+ this.ifacesByVplsName = ifacesByVplsName;
+ this.encapsByVplsName = encapsByVplsName;
}
@Override
- public void addVpls(String name, Set<String> ifaces) {
- if (!vplsNetworks.containsKey(name)) {
- ifaces.forEach(iface -> {
- avaliableInterfaces.forEach(intf -> {
- if (intf.name().equals(iface)) {
- vplsNetworks.put(name, intf);
+ public void addVpls(String vplsName, Set<String> ifaceNames, String encap) {
+ if (!ifacesByVplsName.containsKey(vplsName)) {
+ ifaceNames.forEach(ifaceName -> {
+ AVALIABLE_INTERFACES.forEach(iface -> {
+ if (iface.name().equals(ifaceName)) {
+ ifacesByVplsName.put(vplsName, iface);
}
});
});
+ encapsByVplsName.put(vplsName, valueOf(encap));
}
}
@Override
- public void removeVpls(String name) {
- if (vplsNetworks.containsKey(name)) {
- vplsNetworks.removeAll(name);
+ public void removeVpls(String vplsName) {
+ if (ifacesByVplsName.containsKey(vplsName)) {
+ ifacesByVplsName.removeAll(vplsName);
}
}
@Override
- public void addInterfaceToVpls(String name, String iface) {
- if (!vplsNetworks.containsKey(name)) {
- avaliableInterfaces.forEach(intf -> {
+ public void addIface(String vplsName, String iface) {
+ if (!ifacesByVplsName.containsKey(vplsName)) {
+ AVALIABLE_INTERFACES.forEach(intf -> {
if (intf.name().equals(iface)) {
- vplsNetworks.put(name, intf);
+ ifacesByVplsName.put(vplsName, intf);
}
});
}
}
@Override
- public void removeInterfaceFromVpls(String iface) {
- SetMultimap<String, Interface> search = HashMultimap.create(vplsNetworks);
+ public void setEncap(String vplsName, String encap) {
+ encapsByVplsName.put(vplsName, EncapsulationType.enumFromString(encap));
+ }
+
+ @Override
+ public void removeIface(String iface) {
+ SetMultimap<String, Interface> search = HashMultimap.create(ifacesByVplsName);
search.entries().forEach(e -> {
if (e.getValue().name().equals(iface)) {
- vplsNetworks.remove(e.getKey(), iface);
+ ifacesByVplsName.remove(e.getKey(), iface);
}
});
}
@Override
- public void cleanVpls() {
- vplsNetworks.clear();
+ public void cleanVplsConfig() {
+ ifacesByVplsName.clear();
}
@Override
- public Set<String> getVplsAffectedByApi() {
+ public EncapsulationType encap(String vplsName) {
+ EncapsulationType encap = null;
+ if (encapsByVplsName.containsKey(vplsName)) {
+ encap = encapsByVplsName.get(vplsName);
+ }
+ return encap;
+ }
+
+ @Override
+ public Set<String> vplsAffectedByApi() {
Set<String> vplsNames = ImmutableSet.copyOf(vplsAffectByApi);
vplsAffectByApi.clear();
@@ -793,52 +852,50 @@
}
@Override
- public Set<Interface> getAllInterfaces() {
- return vplsNetworks.values()
+ public Set<Interface> allIfaces() {
+ return ifacesByVplsName.values()
.stream()
.collect(Collectors.toSet());
}
@Override
- public Set<Interface> getVplsInterfaces(String name) {
- return vplsNetworks.get(name)
+ public Set<Interface> ifaces(String name) {
+ return ifacesByVplsName.get(name)
.stream()
.collect(Collectors.toSet());
}
@Override
- public Set<String> getAllVpls() {
- return vplsNetworks.keySet();
+ public Set<String> vplsNames() {
+ return ifacesByVplsName.keySet();
}
@Override
- public Set<String> getOldVpls() {
- return vplsNetworks.keySet();
+ public Set<String> vplsNamesOld() {
+ return ifacesByVplsName.keySet();
+ }
+
+ public SetMultimap<String, Interface> ifacesByVplsName() {
+ return ImmutableSetMultimap.copyOf(ifacesByVplsName);
}
@Override
- public SetMultimap<String, Interface> getVplsNetworks() {
- return ImmutableSetMultimap.copyOf(vplsNetworks);
- }
-
- @Override
- public SetMultimap<String, Interface> getVplsNetwork(VlanId vlan,
+ public SetMultimap<String, Interface> ifacesByVplsName(VlanId vlan,
ConnectPoint connectPoint) {
- String vplsNetworkName =
- vplsNetworks.entries().stream()
+ String vplsName =
+ ifacesByVplsName.entries().stream()
.filter(e -> e.getValue().connectPoint().equals(connectPoint))
.filter(e -> e.getValue().vlan().equals(vlan))
.map(e -> e.getKey())
.findFirst()
.orElse(null);
SetMultimap<String, Interface> result = HashMultimap.create();
- if (vplsNetworkName != null && vplsNetworks.containsKey(vplsNetworkName)) {
- vplsNetworks.get(vplsNetworkName)
- .forEach(intf -> result.put(vplsNetworkName, intf));
+ if (vplsName != null && ifacesByVplsName.containsKey(vplsName)) {
+ ifacesByVplsName.get(vplsName)
+ .forEach(intf -> result.put(vplsName, intf));
return result;
}
return null;
}
-
}
}
diff --git a/apps/vpls/src/test/java/org/onosproject/vpls/config/VplsAppConfigTest.java b/apps/vpls/src/test/java/org/onosproject/vpls/config/VplsAppConfigTest.java
new file mode 100644
index 0000000..d7098e7
--- /dev/null
+++ b/apps/vpls/src/test/java/org/onosproject/vpls/config/VplsAppConfigTest.java
@@ -0,0 +1,271 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.vpls.config;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.TestApplicationId;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.EncapsulationType;
+import org.onosproject.net.config.Config;
+import org.onosproject.net.config.ConfigApplyDelegate;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests for the {@link VplsAppConfig} class.
+ */
+public class VplsAppConfigTest {
+ private static final String APP_NAME = "org.onosproject.vpls";
+ private static final ApplicationId APP_ID = new TestApplicationId(APP_NAME);
+ private static final String VPLS = "vplsList";
+ private static final String NAME = "name";
+ private static final String INTERFACE = "interfaces";
+ private static final String ENCAPSULATION = "encapsulation";
+ private static final String VPLS1 = "vpls1";
+ private static final String VPLS2 = "vpls2";
+ private static final String NEWVPLS = "newvpls";
+
+ private static final String IF1 = "sw5-4-100";
+ private static final String IF2 = "sw5-4-200";
+ private static final String IF3 = "sw5-5-100";
+ private static final String IF4 = "sw6-5-100";
+ private static final String IF5 = "sw6-5-400";
+ private static final String IF_NON_EXIST = "sw7-5-100";
+
+ private static final String JSON_TREE = "{\"" + VPLS + "\" : [{\"" + NAME +
+ "\" : \"" + VPLS1 + "\"," + "\"" + INTERFACE + "\" : [" + "\"" +
+ IF1 + "\",\"" + IF2 + "\",\"" + IF3 + "\"]" + ",\"" +
+ ENCAPSULATION + "\" : \"none\"}]}";
+
+ private static final String EMPTY_JSON_TREE = "{}";
+
+ private final ObjectMapper mapper = new ObjectMapper();
+ private final ConfigApplyDelegate delegate = new MockCfgDelegate();
+ private final VplsConfig initialVpls = createInitialVpls();
+
+ private Set<VplsConfig> vplss = new HashSet<>();
+ private VplsAppConfig vplsAppConfig = new VplsAppConfig();
+ private VplsAppConfig emptyVplsAppConfig = new VplsAppConfig();
+
+ @Before
+ public void setUp() throws Exception {
+ JsonNode tree = new ObjectMapper().readTree(JSON_TREE);
+ vplsAppConfig.init(APP_ID, APP_NAME, tree, mapper, delegate);
+ JsonNode emptyTree = new ObjectMapper().readTree(EMPTY_JSON_TREE);
+ emptyVplsAppConfig.init(APP_ID, APP_NAME, emptyTree, mapper, delegate);
+ vplss.add(initialVpls);
+ }
+
+ /**
+ * Tests if a VPLS configuration can be retrieved from JSON.
+ */
+ @Test
+ public void vplss() {
+ assertEquals("Cannot load VPLS configuration or unexpected configuration" +
+ "loaded", vplss, vplsAppConfig.vplss());
+ }
+
+ /**
+ * Tests an empty VPLS application configuration is retrieved from JSON.
+ */
+ @Test
+ public void emptyVplss() {
+ assertTrue("Configuration retrieved from JSON was not empty",
+ emptyVplsAppConfig.vplss().isEmpty());
+ }
+
+ /**
+ * Tests if a VPLS can be found by name. Tries also to find a VPLS that
+ * does not exist in the configuration.
+ */
+ @Test
+ public void getVplsWithName() {
+ assertNotNull("Configuration for VPLS not found",
+ vplsAppConfig.getVplsWithName(VPLS1));
+ assertNull("Unexpected configuration for VPLS found",
+ vplsAppConfig.getVplsWithName(VPLS2));
+ }
+
+ /**
+ * Tests the addition of a new VPLS.
+ */
+ @Test
+ public void addVpls() {
+ int initialSize = vplsAppConfig.vplss().size();
+ VplsConfig newVpls = createNewVpls();
+ vplsAppConfig.addVpls(newVpls);
+ assertEquals("The new VPLS has not been added correctly to the list of" +
+ "existing VPLSs",
+ initialSize + 1,
+ vplsAppConfig.vplss().size());
+ vplss.add(newVpls);
+ }
+
+ /**
+ * Tests the addition of new VPLS to an empty configuration.
+ */
+ @Test
+ public void addVplsToEmpty() {
+ VplsConfig newVpls = createNewVpls();
+ emptyVplsAppConfig.addVpls(newVpls);
+
+ assertFalse("The new VPLS has not been added correctly",
+ emptyVplsAppConfig.vplss().isEmpty());
+ }
+
+ /**
+ * Tests the removal of an existing VPLS from the configuration.
+ */
+ @Test
+ public void removeExistingVpls() {
+ int initialSize = vplsAppConfig.vplss().size();
+ vplsAppConfig.removeVpls(VPLS1);
+
+ assertEquals("The VPLS has not been removed correctly",
+ initialSize - 1, vplsAppConfig.vplss().size());
+ }
+
+ /**
+ * Tests the removal of a non-existing VPLS from the configuration.
+ */
+ @Test
+ public void removeInexistingVpls() {
+ int initialSize = vplsAppConfig.vplss().size();
+ vplsAppConfig.removeVpls(VPLS2);
+
+ assertEquals("Non-configured VPLS has been unexpectedly removed",
+ initialSize, vplsAppConfig.vplss().size());
+ }
+
+ /**
+ * Tests the addition of a new interface.
+ */
+ @Test
+ public void addInterfaceToVpls() {
+ int initialSize = vplsAppConfig.getVplsWithName(VPLS1).ifaces().size();
+ vplsAppConfig.addIface(VPLS1, IF4);
+
+ assertEquals("The interface has not been added to the VPLS",
+ initialSize + 1,
+ vplsAppConfig.getVplsWithName(VPLS1).ifaces().size());
+ }
+
+ /**
+ * Tests the addition of a new interface when it already exists.
+ */
+ @Test
+ public void addExistingInterfaceToVpls() {
+ int initialSize = vplsAppConfig.getVplsWithName(VPLS1).ifaces().size();
+ vplsAppConfig.addIface(VPLS1, IF1);
+
+ assertEquals("The interface has been unexpectedly added twice to the" +
+ "same VPLS",
+ initialSize,
+ vplsAppConfig.getVplsWithName(VPLS1).ifaces().size());
+ }
+
+ /**
+ * Tests the retrieval of a VPLS, given an interface name.
+ */
+ @Test
+ public void getVplsFromInterface() {
+ assertNotNull("VPLS not found", vplsAppConfig.vplsFromIface(IF1));
+ assertNull("VPLS unexpectedly found",
+ vplsAppConfig.vplsFromIface(IF_NON_EXIST));
+ }
+
+ /**
+ * Tests the removal of an interface.
+ */
+ @Test
+ public void removeExistingInterfaceFromVpls() {
+ int initialSize = vplsAppConfig.getVplsWithName(VPLS1).ifaces().size();
+ vplsAppConfig.removeIface(initialVpls, IF1);
+
+ assertEquals("Interface has not been removed correctly from the VPLS",
+ initialSize - 1,
+ vplsAppConfig.getVplsWithName(VPLS1).ifaces().size());
+ }
+
+ /**
+ * Tests the removal of an interface from a VPLS when it does not exist.
+ */
+ @Test
+ public void removeNonExistingInterfaceFromVpls() {
+ int initialSize = vplsAppConfig.getVplsWithName(VPLS1).ifaces().size();
+ vplsAppConfig.removeIface(initialVpls, IF_NON_EXIST);
+
+ assertEquals("Interface unexpectedly removed from the VPLS",
+ initialSize, vplsAppConfig.getVplsWithName(VPLS1).ifaces().size());
+ }
+
+ /**
+ * Tests if the two interfaces are attached to the VPLS, while one of them
+ * is also attached and another.
+ */
+ @Test
+ public void isAttached() {
+ VplsConfig vpls = createNewVpls();
+
+ assertTrue("Interface not correctly attached to the VPLS",
+ vpls.isAttached(IF4));
+ assertFalse("Unexpected interface attached to the VPLS",
+ vpls.isAttached(IF_NON_EXIST));
+ }
+
+ /**
+ * Tests if encapsulation is set correctly.
+ */
+ @Test
+ public void encap() {
+ vplsAppConfig.setEncap(VPLS1, EncapsulationType.VLAN);
+ assertEquals("Wrong encapsulation type found",
+ EncapsulationType.VLAN,
+ vplsAppConfig.getVplsWithName(VPLS1).encap());
+ }
+
+ private class MockCfgDelegate implements ConfigApplyDelegate {
+
+ @Override
+ public void onApply(@SuppressWarnings("rawtypes") Config config) {
+ config.apply();
+ }
+
+ }
+
+ private VplsConfig createInitialVpls() {
+ Set<String> ifaces = new HashSet<>(Arrays.asList(IF1, IF2, IF3));
+
+ return new VplsConfig(VPLS1, ifaces, EncapsulationType.NONE);
+ }
+
+ private VplsConfig createNewVpls() {
+ Set<String> ifaces = new HashSet<>(Arrays.asList(IF4, IF5));
+
+ return new VplsConfig(NEWVPLS, ifaces, EncapsulationType.NONE);
+ }
+}
diff --git a/apps/vpls/src/test/java/org/onosproject/vpls/config/VplsConfigTest.java b/apps/vpls/src/test/java/org/onosproject/vpls/config/VplsConfigTest.java
deleted file mode 100644
index 6ef0284..0000000
--- a/apps/vpls/src/test/java/org/onosproject/vpls/config/VplsConfigTest.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vpls.config;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.TestApplicationId;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.config.Config;
-import org.onosproject.net.config.ConfigApplyDelegate;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Tests for the {@link VplsConfig} class.
- */
-public class VplsConfigTest {
- private static final String APP_NAME = "org.onosproject.vpls";
- private static final ApplicationId APP_ID = new TestApplicationId(APP_NAME);
- private static final String VPLS = "vplsNetworks";
- private static final String NAME = "name";
- private static final String INTERFACE = "interfaces";
- private static final String NET1 = "net1";
- private static final String NET2 = "net2";
- private static final String NEWNET = "newnet";
-
- private static final String IF1 = "sw5-4-100";
- private static final String IF2 = "sw5-4-200";
- private static final String IF3 = "sw5-5-100";
- private static final String IF4 = "sw6-5-100";
- private static final String IF5 = "sw6-5-400";
- private static final String IF_NON_EXIST = "sw7-5-100";
-
- private static final String JSON_TREE = "{\"" + VPLS +
- "\" : [{\"" + NAME + "\" : \"net1\"," +
- "\"" + INTERFACE + "\" : [" +
- "\"sw5-4-100\",\"sw5-4-200\",\"sw5-5-100\"]}]}";
- private static final String EMPTY_JSON_TREE = "{}";
-
- private final ObjectMapper mapper = new ObjectMapper();
- private final ConfigApplyDelegate delegate = new MockCfgDelegate();
- private final VplsNetworkConfig initialNetwork = createInitialNetwork();
-
- private Set<VplsNetworkConfig> networks = new HashSet<>();
- private VplsConfig vplsConfig = new VplsConfig();
- private VplsConfig emptyVplsConfig = new VplsConfig();
-
- @Before
- public void setUp() throws Exception {
- JsonNode tree = new ObjectMapper().readTree(JSON_TREE);
- vplsConfig.init(APP_ID, APP_NAME, tree, mapper, delegate);
- JsonNode emptyTree = new ObjectMapper().readTree(EMPTY_JSON_TREE);
- emptyVplsConfig.init(APP_ID, APP_NAME, emptyTree, mapper, delegate);
- networks.add(initialNetwork);
- }
-
- /**
- * Tests if a VPLS configuration can be retrieved from JSON.
- */
- @Test
- public void testVplsNetworks() {
- assertEquals(networks, vplsConfig.vplsNetworks());
- }
-
- /**
- * Tests an empty VPLS application configuration is retrieved from JSON.
- */
- @Test
- public void testEmptyVplsNetworks() {
- assertTrue(emptyVplsConfig.vplsNetworks().isEmpty());
- }
-
- /**
- * Tests if a VPLS can be found by name.
- */
- @Test
- public void testGetVplsWithName() {
- assertNotNull(vplsConfig.getVplsWithName(NET1));
- assertNull(vplsConfig.getVplsWithName(NET2));
- }
-
- /**
- * Tests the addition of a new VPLS.
- */
- @Test
- public void testAddNetwork() {
- int initialSize = vplsConfig.vplsNetworks().size();
- VplsNetworkConfig newNetwork = createNewNetwork();
- vplsConfig.addVpls(newNetwork);
- assertEquals(initialSize + 1, vplsConfig.vplsNetworks().size());
- networks.add(newNetwork);
- assertEquals(networks, vplsConfig.vplsNetworks());
- }
-
- /**
- * Tests the addition of new VPLS to an empty configuration.
- */
- @Test
- public void testAddNetworkToEmpty() {
- VplsNetworkConfig newNetwork = createNewNetwork();
- emptyVplsConfig.addVpls(newNetwork);
-
- assertFalse(emptyVplsConfig.vplsNetworks().isEmpty());
- }
-
- /**
- * Tests the removal of an existing VPLS from the configuration.
- */
- @Test
- public void testRemoveExistingNetwork() {
- int initialSize = vplsConfig.vplsNetworks().size();
- vplsConfig.removeVpls(NET1);
-
- assertEquals(initialSize - 1, vplsConfig.vplsNetworks().size());
- }
-
- /**
- * Tests the removal of a non-existing VPLS from the configuration.
- */
- @Test
- public void testRemoveInexistingNetwork() {
- int initialSize = vplsConfig.vplsNetworks().size();
- vplsConfig.removeVpls(NET2);
-
- assertEquals(initialSize, vplsConfig.vplsNetworks().size());
- }
-
- /**
- * Tests the addition of a new interface.
- */
- @Test
- public void testAddInterfaceToNetwork() {
- int initialSize = vplsConfig.getVplsWithName(NET1).ifaces().size();
- vplsConfig.addInterfaceToVpls(NET1, IF4);
-
- assertEquals(initialSize + 1, vplsConfig.getVplsWithName(NET1).ifaces().size());
- }
-
- /**
- * Tests the addition of a new interface when it already exists.
- */
- @Test
- public void testAddExistingInterfaceToNetwork() {
- int initialSize = vplsConfig.getVplsWithName(NET1).ifaces().size();
- vplsConfig.addInterfaceToVpls(NET1, IF1);
-
- assertEquals(initialSize, vplsConfig.getVplsWithName(NET1).ifaces().size());
- }
-
- /**
- * Tests the retrieval of a VPLS, given an interface name.
- */
- @Test
- public void testgetNetworkFromInterface() {
- assertNotNull(vplsConfig.getVplsFromInterface(IF1));
- assertNull(vplsConfig.getVplsFromInterface(IF_NON_EXIST));
- }
-
- /**
- * Tests the removal of an interface.
- */
- @Test
- public void testRemoveExistingInterfaceFromNetwork() {
- int initialSize = vplsConfig.getVplsWithName(NET1).ifaces().size();
- vplsConfig.removeInterfaceFromVpls(initialNetwork, IF1);
-
- assertEquals(initialSize - 1, vplsConfig.getVplsWithName(NET1).ifaces().size());
- }
-
- /**
- * Tests the removal of an interface from a VPLS when it does not exist.
- */
- @Test
- public void testRemoveNonExistingInterfaceFromNetwork() {
- int initialSize = vplsConfig.getVplsWithName(NET1).ifaces().size();
- vplsConfig.removeInterfaceFromVpls(initialNetwork, IF_NON_EXIST);
-
- assertEquals(initialSize, vplsConfig.getVplsWithName(NET1).ifaces().size());
- }
-
- /**
- * Tests if the two interfaces are attached to the network
- * while one of the interface is attached and another one is not.
- */
- @Test
- public void testIsAttached() {
- VplsNetworkConfig network = createNewNetwork();
-
- assertTrue(network.isAttached(IF4));
- assertFalse(network.isAttached(IF_NON_EXIST));
- }
-
- private class MockCfgDelegate implements ConfigApplyDelegate {
-
- @Override
- public void onApply(@SuppressWarnings("rawtypes") Config config) {
- config.apply();
- }
-
- }
-
- private VplsNetworkConfig createInitialNetwork() {
- Set<String> ifaces = new HashSet<>(Arrays.asList(IF1, IF2, IF3));
-
- return new VplsNetworkConfig(NET1, ifaces);
- }
-
- private VplsNetworkConfig createNewNetwork() {
- Set<String> ifaces = new HashSet<>(Arrays.asList(IF4, IF5));
-
- return new VplsNetworkConfig(NEWNET, ifaces);
- }
-}