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();
}
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();
}
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());
}
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());
}
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);
}
Aggregations