Search in sources :

Example 41 with VplsData

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());
}
Also used : VplsData(org.onosproject.vpls.api.VplsData)

Example 42 with VplsData

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;
}
Also used : Host(org.onosproject.net.Host) Interface(org.onosproject.net.intf.Interface) LoggerFactory(org.slf4j.LoggerFactory) VplsData(org.onosproject.vpls.api.VplsData) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) ConnectPoint(org.onosproject.net.ConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) ArrayList(java.util.ArrayList) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) ApplicationId(org.onosproject.core.ApplicationId) Intent(org.onosproject.net.intent.Intent) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ResourceGroup(org.onosproject.net.ResourceGroup) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Constraint(org.onosproject.net.intent.Constraint) Objects(java.util.Objects) Key(org.onosproject.net.intent.Key) List(java.util.List) EncapsulationType(org.onosproject.net.EncapsulationType) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) MacAddress(org.onlab.packet.MacAddress) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) Interface(org.onosproject.net.intf.Interface) ResourceGroup(org.onosproject.net.ResourceGroup) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 43 with VplsData

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;
}
Also used : EncapsulationType(org.onosproject.net.EncapsulationType) VplsData(org.onosproject.vpls.api.VplsData) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) Interface(org.onosproject.net.intf.Interface)

Example 44 with 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();
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) Vpls(org.onosproject.vpls.api.Vpls) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 45 with VplsData

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();
}
Also used : InterfaceAdminService(org.onosproject.net.intf.InterfaceAdminService) VplsData(org.onosproject.vpls.api.VplsData) Vpls(org.onosproject.vpls.api.Vpls) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

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