Search in sources :

Example 46 with VplsData

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

the class VplsWebResource method getVplss.

/**
 * Gets all Vplss. Returns array of all Vplss in the system.
 *
 * @return 200 OK with a collection of Vplss
 * @onos.rsModel Vplss
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getVplss() {
    ArrayNode vplssNode = root.putArray(VPLSS);
    Vpls service = get(Vpls.class);
    Collection<VplsData> vplsDatas = service.getAllVpls();
    if (!vplsDatas.isEmpty()) {
        for (VplsData entry : vplsDatas) {
            vplssNode.add(codec(VplsData.class).encode(entry, this));
        }
    }
    return ok(root).build();
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) Vpls(org.onosproject.vpls.api.Vpls) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 47 with VplsData

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

the class VplsWebResource method deleteVpls.

/**
 * Removes the specified vpls.
 *
 * @param vplsName Vpls name
 * @return 204 NO CONTENT
 */
@DELETE
@Path("{vplsName}")
public Response deleteVpls(@PathParam("vplsName") String vplsName) {
    Vpls service = get(Vpls.class);
    final VplsData vplsData = nullIsNotFound(service.getVpls(vplsName), VPLS_NOT_FOUND + vplsName);
    service.removeVpls(vplsData);
    return Response.noContent().build();
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) Vpls(org.onosproject.vpls.api.Vpls) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 48 with VplsData

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

the class VplsStoreTest method testAddVpls.

/**
 * Adds a VPLS to the store; checks if config store is also updated.
 */
@Test
public void testAddVpls() {
    VplsData vplsData = VplsData.of(VPLS1, VLAN);
    vplsStore.addVpls(vplsData);
    Collection<VplsData> vplsDataCollection = vplsStore.getAllVpls();
    assertEquals(1, vplsDataCollection.size());
    assertTrue(vplsDataCollection.contains(vplsData));
    VplsAppConfig storedConfig = vplsStore.networkConfigService.getConfig(null, VplsAppConfig.class);
    assertNotEquals(-1L, storedConfig.updateTime());
    assertEquals(1, storedConfig.vplss().size());
    VplsConfig vplsConfig = storedConfig.vplss().iterator().next();
    assertEquals(VPLS1, vplsConfig.name());
    assertEquals(0, vplsConfig.ifaces().size());
    assertEquals(VLAN, vplsConfig.encap());
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) VplsAppConfig(org.onosproject.vpls.config.VplsAppConfig) VplsConfig(org.onosproject.vpls.config.VplsConfig) VplsTest(org.onosproject.vpls.VplsTest) Test(org.junit.Test)

Example 49 with VplsData

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

the class VplsStoreTest method testUpdateVpls.

/**
 * Updates a VPLS from store; checks if config store is also updated.
 */
@Test
public void testUpdateVpls() {
    VplsData vplsData = VplsData.of(VPLS1, VLAN);
    vplsStore.addVpls(vplsData);
    vplsData.addInterface(V100H1);
    vplsData.addInterface(V100H2);
    vplsStore.updateVpls(vplsData);
    Collection<VplsData> vplsDataCollection = vplsStore.getAllVpls();
    assertEquals(1, vplsDataCollection.size());
    VplsData newVplsData = vplsDataCollection.iterator().next();
    assertEquals(vplsData, newVplsData);
    VplsAppConfig storedConfig = vplsStore.networkConfigService.getConfig(null, VplsAppConfig.class);
    assertNotEquals(-1L, storedConfig.updateTime());
    assertEquals(1, storedConfig.vplss().size());
    VplsConfig vplsConfig = storedConfig.vplss().iterator().next();
    assertEquals(VPLS1, vplsConfig.name());
    assertEquals(2, vplsConfig.ifaces().size());
    assertTrue(vplsConfig.ifaces().contains(V100H1.name()));
    assertTrue(vplsConfig.ifaces().contains(V100H2.name()));
    assertEquals(VLAN, vplsConfig.encap());
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) VplsAppConfig(org.onosproject.vpls.config.VplsAppConfig) VplsConfig(org.onosproject.vpls.config.VplsConfig) VplsTest(org.onosproject.vpls.VplsTest) Test(org.junit.Test)

Example 50 with VplsData

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

the class VplsIntentTest method tenInterfacesConfiguredHostsPresent.

/**
 * Ten ports are configured with VLANs and ten hosts are registered by the
 * HostService.
 *
 * The first three ports have an interface configured on VPLS 1,
 * the other three on VPLS 2, two on VPLS3 and two on VPLS4.
 *
 * The number of intents expected is twenty: six
 * for VPLS 1, six for VPLS 2. four for VPLS 3, four for VPLS 4.
 * That is ten sp2mp intents, ten 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 tenInterfacesConfiguredHostsPresent() {
    hostsAvailable.addAll(AVAILABLE_HOSTS);
    List<Intent> expectedIntents = Lists.newArrayList();
    Set<FilteredConnectPoint> fcPoints;
    Set<Host> hosts;
    Set<Interface> interfaces;
    VplsData vplsData;
    Set<Intent> brcIntents;
    Set<Intent> uniIntents;
    interfaces = ImmutableSet.of(V100H1, V200H1, V300H1);
    fcPoints = buildFCPoints(interfaces);
    hosts = ImmutableSet.of(V100HOST1, V200HOST1, V300HOST1);
    vplsData = createVplsData(VPLS1, VLAN, interfaces);
    brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
    uniIntents = VplsIntentUtility.buildUniIntents(vplsData, hosts, APPID);
    brcIntents.forEach(intentService::submit);
    uniIntents.forEach(intentService::submit);
    expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS1, VLAN));
    expectedIntents.addAll(generateVplsUni(fcPoints, hosts, VPLS1, VLAN));
    interfaces = ImmutableSet.of(V100H2, V200H2, V300H2);
    fcPoints = buildFCPoints(interfaces);
    hosts = ImmutableSet.of(V100HOST2, V200HOST2, V300HOST2);
    vplsData = createVplsData(VPLS2, NONE, interfaces);
    brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
    uniIntents = VplsIntentUtility.buildUniIntents(vplsData, hosts, APPID);
    brcIntents.forEach(intentService::submit);
    uniIntents.forEach(intentService::submit);
    expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS2, NONE));
    expectedIntents.addAll(generateVplsUni(fcPoints, hosts, VPLS2, NONE));
    interfaces = ImmutableSet.of(VNONEH1, VNONEH2);
    fcPoints = buildFCPoints(interfaces);
    hosts = ImmutableSet.of(VNONEHOST1, VNONEHOST2);
    vplsData = createVplsData(VPLS3, NONE, interfaces);
    brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
    uniIntents = VplsIntentUtility.buildUniIntents(vplsData, hosts, APPID);
    brcIntents.forEach(intentService::submit);
    uniIntents.forEach(intentService::submit);
    expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS3, NONE));
    expectedIntents.addAll(generateVplsUni(fcPoints, hosts, VPLS3, NONE));
    interfaces = ImmutableSet.of(V400H1, VNONEH3);
    fcPoints = buildFCPoints(interfaces);
    hosts = ImmutableSet.of(V400HOST1, VNONEHOST3);
    vplsData = createVplsData(VPLS4, NONE, interfaces);
    brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
    uniIntents = VplsIntentUtility.buildUniIntents(vplsData, hosts, APPID);
    brcIntents.forEach(intentService::submit);
    uniIntents.forEach(intentService::submit);
    expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS4, NONE));
    expectedIntents.addAll(generateVplsUni(fcPoints, hosts, VPLS4, NONE));
    checkIntents(expectedIntents);
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) Host(org.onosproject.net.Host) Interface(org.onosproject.net.intf.Interface) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) 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