Search in sources :

Example 16 with VplsData

use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.

the class VplsManagerTest method testRemoveHost.

/**
 * Removes hosts from a VPLS.
 */
@Test
public void testRemoveHost() {
    VplsData vplsData = VplsData.of(VPLS1, NONE);
    vplsData.addInterface(V100H1);
    vplsData.state(ADDED);
    vplsStore.addVpls(vplsData);
    HostEvent hostEvent = new HostEvent(HostEvent.Type.HOST_REMOVED, V100HOST1);
    hostService.postHostEvent(hostEvent);
    vplsData = vplsStore.getVpls(VPLS1);
    assertNotNull(vplsData);
    assertEquals(vplsData.state(), UPDATING);
}
Also used : HostEvent(org.onosproject.net.host.HostEvent) VplsData(org.onosproject.vpls.api.VplsData) Test(org.junit.Test)

Example 17 with VplsData

use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.

the class VplsManagerTest method testAddInterface.

/**
 * Adds network interfaces one by one to a VPLS.
 */
@Test
public void testAddInterface() {
    VplsData vplsData = vplsManager.createVpls(VPLS1, NONE);
    vplsManager.addInterface(vplsData, V100H1);
    vplsManager.addInterface(vplsData, V100H2);
    vplsData = vplsStore.getVpls(VPLS1);
    assertNotNull(vplsData);
    assertEquals(vplsData.state(), UPDATING);
    assertEquals(2, vplsData.interfaces().size());
    assertTrue(vplsData.interfaces().contains(V100H1));
    assertTrue(vplsData.interfaces().contains(V100H2));
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) Test(org.junit.Test)

Example 18 with VplsData

use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.

the class VplsManagerTest method testSetEncapsulationType.

/**
 * Sets encapsulation type for a VPLS.
 */
@Test
public void testSetEncapsulationType() {
    VplsData vplsData = vplsManager.createVpls(VPLS1, NONE);
    vplsManager.setEncapsulationType(vplsData, EncapsulationType.VLAN);
    vplsData = vplsStore.getVpls(VPLS1);
    assertNotNull(vplsData);
    assertEquals(vplsData.state(), UPDATING);
    assertEquals(vplsData.encapsulationType(), EncapsulationType.VLAN);
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) Test(org.junit.Test)

Example 19 with VplsData

use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.

the class VplsNeighbourHandler method findVpls.

/**
 * Finds the VPLS with given neighbour message context.
 *
 * @param context the neighbour message context
 * @return the VPLS for specific neighbour message context
 */
private VplsData findVpls(NeighbourMessageContext context) {
    Collection<VplsData> vplses = vplsStore.getAllVpls();
    for (VplsData vplsData : vplses) {
        Set<Interface> interfaces = vplsData.interfaces();
        ConnectPoint port = context.inPort();
        VlanId vlanId = context.vlan();
        boolean match = interfaces.stream().anyMatch(iface -> iface.connectPoint().equals(port) && iface.vlan().equals(vlanId));
        if (match) {
            return vplsData;
        }
    }
    return null;
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) ConnectPoint(org.onosproject.net.ConnectPoint) Interface(org.onosproject.net.intf.Interface) VlanId(org.onlab.packet.VlanId)

Example 20 with VplsData

use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.

the class VplsOperationManagerTest method testSubmitAddOperationFail.

/**
 * Submits an ADD operation to the operation manager; check the VPLS state
 * from store if Intent install failed.
 */
@Test
public void testSubmitAddOperationFail() {
    vplsOperationManager.intentService = new AlwaysFailureIntentService();
    VplsData vplsData = VplsData.of(VPLS1);
    vplsData.addInterfaces(ImmutableSet.of(V100H1, V100H2));
    VplsOperation vplsOperation = VplsOperation.of(vplsData, VplsOperation.Operation.ADD);
    vplsOperationManager.submit(vplsOperation);
    assertAfter(OPERATION_DELAY, OPERATION_DURATION, () -> {
        Collection<VplsData> vplss = vplsOperationManager.vplsStore.getAllVpls();
        assertEquals(1, vplss.size());
        VplsData result = vplss.iterator().next();
        assertEquals(vplsData, result);
        assertEquals(VplsData.VplsState.FAILED, result.state());
    });
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) VplsOperation(org.onosproject.vpls.api.VplsOperation) Test(org.junit.Test)

Aggregations

VplsData (org.onosproject.vpls.api.VplsData)73 Test (org.junit.Test)44 VplsOperation (org.onosproject.vpls.api.VplsOperation)18 VplsTest (org.onosproject.vpls.VplsTest)11 ArrayDeque (java.util.ArrayDeque)10 Interface (org.onosproject.net.intf.Interface)10 Vpls (org.onosproject.vpls.api.Vpls)7 NetworkConfigEvent (org.onosproject.net.config.NetworkConfigEvent)6 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 Host (org.onosproject.net.Host)4 HostEvent (org.onosproject.net.host.HostEvent)4 Intent (org.onosproject.net.intent.Intent)4 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Objects (java.util.Objects)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 MacAddress (org.onlab.packet.MacAddress)3