Search in sources :

Example 36 with VplsData

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

the class VplsManager method addInterfaces.

@Override
public void addInterfaces(VplsData vplsData, Collection<Interface> interfaces) {
    requireNonNull(vplsData);
    requireNonNull(interfaces);
    VplsData newData = VplsData.of(vplsData);
    newData.addInterfaces(interfaces);
    updateVplsStatus(newData, VplsData.VplsState.UPDATING);
}
Also used : VplsData(org.onosproject.vpls.api.VplsData)

Example 37 with VplsData

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

the class VplsNeighbourHandler method handleRequest.

/**
 * Handles request messages.
 *
 * @param context the message context
 */
protected void handleRequest(NeighbourMessageContext context) {
    // Find target VPLS first, then broadcast to all interface of this VPLS
    VplsData vplsData = findVpls(context);
    if (vplsData != null) {
        vplsData.interfaces().stream().filter(intf -> !context.inPort().equals(intf.connectPoint())).forEach(context::forward);
    } else {
        log.warn(CAN_NOT_FIND_VPLS, context.inPort(), context.vlan());
        context.drop();
    }
}
Also used : NetworkConfigService(org.onosproject.net.config.NetworkConfigService) Host(org.onosproject.net.Host) Interface(org.onosproject.net.intf.Interface) CoreService(org.onosproject.core.CoreService) VplsStore(org.onosproject.vpls.api.VplsStore) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) VplsData(org.onosproject.vpls.api.VplsData) InterfaceService(org.onosproject.net.intf.InterfaceService) NeighbourResolutionService(org.onosproject.net.neighbour.NeighbourResolutionService) HostService(org.onosproject.net.host.HostService) ConnectPoint(org.onosproject.net.ConnectPoint) InterfaceListener(org.onosproject.net.intf.InterfaceListener) Component(org.osgi.service.component.annotations.Component) ApplicationId(org.onosproject.core.ApplicationId) Activate(org.osgi.service.component.annotations.Activate) NeighbourMessageContext(org.onosproject.net.neighbour.NeighbourMessageContext) Logger(org.slf4j.Logger) Deactivate(org.osgi.service.component.annotations.Deactivate) Collection(java.util.Collection) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) InterfaceEvent(org.onosproject.net.intf.InterfaceEvent) Collectors(java.util.stream.Collectors) NeighbourMessageHandler(org.onosproject.net.neighbour.NeighbourMessageHandler) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Objects(java.util.Objects) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) MacAddress(org.onlab.packet.MacAddress) Reference(org.osgi.service.component.annotations.Reference) NetworkConfigListener(org.onosproject.net.config.NetworkConfigListener) VplsData(org.onosproject.vpls.api.VplsData)

Example 38 with VplsData

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

the class VplsNeighbourHandler method handleReply.

/**
 * Handles reply messages between VLAN tagged interfaces.
 *
 * @param context the message context
 * @param hostService the host service
 */
protected void handleReply(NeighbourMessageContext context, HostService hostService) {
    // Find target VPLS, then reply to the host
    VplsData vplsData = findVpls(context);
    if (vplsData != null) {
        MacAddress dstMac = context.dstMac();
        Set<Host> hosts = hostService.getHostsByMac(dstMac);
        hosts = hosts.stream().filter(host -> vplsData.interfaces().contains(getHostInterface(host))).collect(Collectors.toSet());
        // reply to all host in same VPLS
        hosts.stream().map(this::getHostInterface).filter(Objects::nonNull).forEach(context::forward);
    } else {
        // this might be happened when we remove an interface from VPLS
        // just ignore this message
        log.warn(CAN_NOT_FIND_VPLS, context.inPort(), context.vlan());
        context.drop();
    }
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) Host(org.onosproject.net.Host) MacAddress(org.onlab.packet.MacAddress)

Example 39 with VplsData

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

the class VplsOperationManager method addVplsOperation.

/**
 * Adds a VPLS operation to the queue of pending operations.
 *
 * @param vplsOperation the VPLS operation to add
 */
private void addVplsOperation(VplsOperation vplsOperation) {
    VplsData vplsData = vplsOperation.vpls();
    pendingVplsOperations.compute(vplsData.name(), (name, opQueue) -> {
        opQueue = opQueue == null ? Queues.newArrayDeque() : opQueue;
        // If the operation already exist in queue, ignore it.
        if (opQueue.contains(vplsOperation)) {
            return opQueue;
        }
        opQueue.add(vplsOperation);
        return opQueue;
    });
}
Also used : VplsData(org.onosproject.vpls.api.VplsData)

Example 40 with VplsData

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

the class VplsCommand method removeIface.

/**
 * Removes an interface from a VPLS.
 *
 * @param vplsName the name of the VLPS
 * @param ifaceName the name of the interface to remove
 */
protected void removeIface(String vplsName, String ifaceName) {
    if (vplsName == null) {
        print(INSERT_VPLS_NAME);
        return;
    }
    if (ifaceName == null) {
        print(INSERT_INTERFACE);
        return;
    }
    VplsData vplsData = vpls.getVpls(vplsName);
    Interface iface = getInterface(ifaceName);
    if (vplsData == null) {
        print(VPLS_NOT_FOUND, vplsName);
        return;
    }
    if (CHANGING_STATE.contains(vplsData.state())) {
        // when a VPLS is updating, we shouldn't try modify it.
        print("VPLS %s still updating, please wait it finished", vplsData.name());
        return;
    }
    if (iface == null) {
        print(IFACE_NOT_FOUND, ifaceName);
        return;
    }
    if (!vplsData.interfaces().contains(iface)) {
        print(IFACE_NOT_ASSOCIATED, ifaceName, vplsName);
        return;
    }
    vpls.removeInterface(vplsData, iface);
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) Interface(org.onosproject.net.intf.Interface)

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