use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.
the class VplsOptArgCompleter method vplsIfaces.
/**
* Returns the list of interfaces associated to a VPLS.
*
* @return the list of interfaces associated to a VPLS
*/
private List<String> vplsIfaces() {
String vplsName = commandLine.getArguments()[2];
VplsData vplsData = vpls.getVpls(vplsName);
return vplsData.interfaces().stream().map(Interface::name).collect(Collectors.toList());
}
use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.
the class VplsIntentUtility method buildUniIntents.
/**
* Builds unicast Intents for a VPLS.
*
* @param vplsData the VPLS
* @param hosts the hosts of the VPLS
* @param appId application ID for Intents
* @return unicast Intents for the VPLS
*/
public static Set<Intent> buildUniIntents(VplsData vplsData, Set<Host> hosts, ApplicationId appId) {
Set<Interface> interfaces = vplsData.interfaces();
if (interfaces.size() < 2) {
return ImmutableSet.of();
}
Set<Intent> uniIntents = Sets.newHashSet();
ResourceGroup resourceGroup = ResourceGroup.of(vplsData.name());
hosts.forEach(host -> {
FilteredConnectPoint hostFcp = buildFilteredConnectedPoint(host);
Set<FilteredConnectPoint> srcFcps = interfaces.stream().map(VplsIntentUtility::buildFilteredConnectedPoint).filter(fcp -> !fcp.equals(hostFcp)).collect(Collectors.toSet());
Key key = buildKey(PREFIX_UNICAST, hostFcp.connectPoint(), vplsData.name(), host.mac(), appId);
Intent uniIntent = buildUniIntent(key, appId, srcFcps, hostFcp, host, vplsData.encapsulationType(), resourceGroup);
uniIntents.add(uniIntent);
});
return uniIntents;
}
use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.
the class VplsCodec method decode.
@Override
public VplsData decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
List<String> names = new ArrayList<>();
json.findValues(NAME).forEach(jsonNode -> {
names.add(jsonNode.asText());
});
Collection<Interface> interfaceList = new ArrayList<>();
JsonNode interfacesJeson = json.findValue(INTERFACES);
JsonCodec<Interface> interfaceCodec = context.codec(Interface.class);
if (interfacesJeson != null) {
IntStream.range(0, interfacesJeson.size()).forEach(i -> interfaceList.add(interfaceCodec.decode(get(interfacesJeson, i), context)));
}
interfaceList.forEach(interf -> {
names.remove(interf.name());
});
String vplsName = names.get(0);
EncapsulationType encap = json.findValue(ENCAPSULATION_TYPE) == null ? null : EncapsulationType.enumFromString(json.findValue(ENCAPSULATION_TYPE).asText());
VplsData vplsData = VplsData.of(vplsName, encap);
vplsData.addInterfaces(interfaceList);
return vplsData;
}
use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.
the class VplsWebResource method getVpls.
/**
* Gets Vpls. Returns a Vpls by vplsName.
* @param vplsName vpls name
* @return 200 OK with a vpls, return 404 if no entry has been found
* @onos.rsModel Vpls
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{vplsName}")
public Response getVpls(@PathParam("vplsName") String vplsName) {
ArrayNode vplsNode = root.putArray(VPLS);
Vpls service = get(Vpls.class);
final VplsData vplsData = nullIsNotFound(service.getVpls(vplsName), VPLS_NOT_FOUND + vplsName);
vplsNode.add(codec(VplsData.class).encode(vplsData, this));
return ok(root).build();
}
use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.
the class VplsWebResource method deleteInterface.
/**
* Removes a specified interface.
*
* @param vplsName Vpls name
* @param interfaceName interface name
* @return 204 NO CONTENT
*/
@DELETE
@Path("interface/{vplsName}/{interfaceName}")
public Response deleteInterface(@PathParam("vplsName") String vplsName, @PathParam("interfaceName") String interfaceName) {
Vpls service = get(Vpls.class);
InterfaceAdminService interfaceService = get(InterfaceAdminService.class);
final VplsData vplsData = nullIsNotFound(service.getVpls(vplsName), VPLS_NOT_FOUND + vplsName);
vplsData.interfaces().forEach(anInterface -> {
if (anInterface.name().equals(interfaceName)) {
interfaceService.remove(anInterface.connectPoint(), anInterface.name());
service.removeInterface(vplsData, anInterface);
}
});
return Response.noContent().build();
}
Aggregations