Search in sources :

Example 91 with VlanId

use of org.onlab.packet.VlanId in project onos by opennetworkinglab.

the class BgpConfig method bgpSpeakers.

/**
 * Gets the set of configured BGP speakers.
 *
 * @return BGP speakers
 */
public Set<BgpSpeakerConfig> bgpSpeakers() {
    Set<BgpSpeakerConfig> speakers = Sets.newHashSet();
    JsonNode speakersNode = object.get(SPEAKERS);
    if (speakersNode == null) {
        return speakers;
    }
    speakersNode.forEach(jsonNode -> {
        Set<IpAddress> listenAddresses = Sets.newHashSet();
        jsonNode.path(PEERS).forEach(addressNode -> listenAddresses.add(IpAddress.valueOf(addressNode.asText())));
        Optional<String> name;
        if (jsonNode.get(NAME) == null) {
            name = Optional.empty();
        } else {
            name = Optional.of(jsonNode.get(NAME).asText());
        }
        VlanId vlan = getVlan(jsonNode);
        speakers.add(new BgpSpeakerConfig(name, vlan, ConnectPoint.deviceConnectPoint(jsonNode.path(CONNECT_POINT).asText()), listenAddresses));
    });
    return speakers;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) IpAddress(org.onlab.packet.IpAddress) VlanId(org.onlab.packet.VlanId)

Example 92 with VlanId

use of org.onlab.packet.VlanId in project onos by opennetworkinglab.

the class PeerConnectivityManager method buildSpeakerIntents.

private Collection<PointToPointIntent> buildSpeakerIntents(BgpConfig.BgpSpeakerConfig speaker, EncapsulationType encap) {
    List<PointToPointIntent> intents = new ArrayList<>();
    // Get the BGP Speaker VLAN Id
    VlanId bgpSpeakerVlanId = speaker.vlan();
    for (IpAddress peerAddress : speaker.peers()) {
        Interface peeringInterface = interfaceService.getMatchingInterface(peerAddress);
        if (peeringInterface == null) {
            log.debug("No peering interface found for peer {} on speaker {}", peerAddress, speaker);
            continue;
        }
        IpAddress bgpSpeakerAddress = null;
        for (InterfaceIpAddress address : peeringInterface.ipAddressesList()) {
            if (address.subnetAddress().contains(peerAddress)) {
                bgpSpeakerAddress = address.ipAddress();
                break;
            }
        }
        checkNotNull(bgpSpeakerAddress);
        VlanId peerVlanId = peeringInterface.vlan();
        intents.addAll(buildIntents(speaker.connectPoint(), bgpSpeakerVlanId, bgpSpeakerAddress, peeringInterface.connectPoint(), peerVlanId, peerAddress, encap));
    }
    return intents;
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) ArrayList(java.util.ArrayList) IpAddress(org.onlab.packet.IpAddress) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) VlanId(org.onlab.packet.VlanId) Interface(org.onosproject.net.intf.Interface) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress)

Example 93 with VlanId

use of org.onlab.packet.VlanId in project onos by opennetworkinglab.

the class SdnIpFib method buildTrafficSelector.

/*
     * Builds a traffic selector builder based on interface tagging settings.
     */
private TrafficSelector.Builder buildTrafficSelector(Interface intf) {
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    // TODO: Consider other tag types
    // Match the VlanId if specified in the network interface configuration
    VlanId vlanId = intf.vlan();
    if (!vlanId.equals(VlanId.NONE)) {
        selector.matchVlanId(vlanId);
    }
    return selector;
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) VlanId(org.onlab.packet.VlanId)

Example 94 with VlanId

use of org.onlab.packet.VlanId in project onos by opennetworkinglab.

the class DefaultFabricNetworkTest method createInterface.

private static Interface createInterface(int index) {
    String name = "INTF_NAME_" + index;
    ConnectPoint cp = ConnectPoint.fromString("of:0011223344556677/" + index);
    InterfaceIpAddress intfIp1 = InterfaceIpAddress.valueOf("10.10.10." + index + "/32");
    InterfaceIpAddress intfIp2 = InterfaceIpAddress.valueOf("20.20.20." + index + "/32");
    List<InterfaceIpAddress> intfIps = ImmutableList.of(intfIp1, intfIp2);
    MacAddress mac = MacAddress.valueOf("00:00:00:00:00:00");
    VlanId vlanId = VlanId.NONE;
    return new Interface(name, cp, intfIps, mac, vlanId);
}
Also used : MacAddress(org.onlab.packet.MacAddress) ConnectPoint(org.onosproject.net.ConnectPoint) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) VlanId(org.onlab.packet.VlanId) Interface(org.onosproject.net.intf.Interface)

Example 95 with VlanId

use of org.onlab.packet.VlanId in project onos by opennetworkinglab.

the class VirtualHostCodec method decode.

@Override
public VirtualHost decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    NetworkId nId = NetworkId.networkId(Long.parseLong(extractMember(NETWORK_ID, json)));
    MacAddress mac = MacAddress.valueOf(json.get("mac").asText());
    VlanId vlanId = VlanId.vlanId((short) json.get("vlan").asInt(VlanId.UNTAGGED));
    Set<HostLocation> locations = new HashSet<>();
    JsonNode locationNodes = json.get("locations");
    locationNodes.forEach(locationNode -> {
        PortNumber portNumber = PortNumber.portNumber(locationNode.get("port").asText());
        DeviceId deviceId = DeviceId.deviceId(locationNode.get("elementId").asText());
        locations.add(new HostLocation(deviceId, portNumber, 0));
    });
    HostId id = HostId.hostId(mac, vlanId);
    Iterator<JsonNode> ipStrings = json.get("ipAddresses").elements();
    Set<IpAddress> ips = new HashSet<>();
    while (ipStrings.hasNext()) {
        ips.add(IpAddress.valueOf(ipStrings.next().asText()));
    }
    return new DefaultVirtualHost(nId, id, mac, vlanId, locations, ips);
}
Also used : DefaultVirtualHost(org.onosproject.incubator.net.virtual.DefaultVirtualHost) DeviceId(org.onosproject.net.DeviceId) JsonNode(com.fasterxml.jackson.databind.JsonNode) NetworkId(org.onosproject.incubator.net.virtual.NetworkId) MacAddress(org.onlab.packet.MacAddress) HostId(org.onosproject.net.HostId) HostLocation(org.onosproject.net.HostLocation) IpAddress(org.onlab.packet.IpAddress) PortNumber(org.onosproject.net.PortNumber) VlanId(org.onlab.packet.VlanId) HashSet(java.util.HashSet)

Aggregations

VlanId (org.onlab.packet.VlanId)147 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)60 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)56 DeviceId (org.onosproject.net.DeviceId)55 List (java.util.List)53 Test (org.junit.Test)53 MacAddress (org.onlab.packet.MacAddress)49 Collection (java.util.Collection)45 Ethernet (org.onlab.packet.Ethernet)44 CoreService (org.onosproject.core.CoreService)43 FlowRule (org.onosproject.net.flow.FlowRule)43 Collections (java.util.Collections)41 Collectors (java.util.stream.Collectors)41 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)41 TrafficSelector (org.onosproject.net.flow.TrafficSelector)38 ImmutableSet (com.google.common.collect.ImmutableSet)37 ConnectPoint (org.onosproject.net.ConnectPoint)37 VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)37 MplsLabel (org.onlab.packet.MplsLabel)35 Intent (org.onosproject.net.intent.Intent)34