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