use of org.onosproject.net.host.InterfaceIpAddress in project onos by opennetworkinglab.
the class ControlPlaneRedirectManagerTest method testRemoveInterface.
@Test
public void testRemoveInterface() {
ConnectPoint sw1eth4 = new ConnectPoint(DEVICE_ID, PortNumber.portNumber(4));
List<InterfaceIpAddress> interfaceIpAddresses = new ArrayList<>();
interfaceIpAddresses.add(new InterfaceIpAddress(IpAddress.valueOf("192.168.40.101"), IpPrefix.valueOf("192.168.40.0/24")));
interfaceIpAddresses.add(new InterfaceIpAddress(IpAddress.valueOf("2000::ff"), IpPrefix.valueOf("2000::ff/120")));
Interface sw1Eth4 = new Interface(sw1eth4.deviceId().toString(), sw1eth4, interfaceIpAddresses, MacAddress.valueOf("00:00:00:00:00:04"), VlanId.NONE);
EasyMock.reset(flowObjectiveService);
expect(flowObjectiveService.allocateNextId()).andReturn(1).anyTimes();
setUpInterfaceConfiguration(sw1Eth4, false);
replay(flowObjectiveService);
interfaceListener.event(new InterfaceEvent(InterfaceEvent.Type.INTERFACE_REMOVED, sw1Eth4, 500L));
verify(flowObjectiveService);
}
use of org.onosproject.net.host.InterfaceIpAddress in project onos by opennetworkinglab.
the class RouterAdvertisementManager method loadGlobalPrefixConfig.
@SuppressWarnings("GuardedBy")
private synchronized // Loading global prefixes for devices from network configuration
void loadGlobalPrefixConfig() {
globalPrefixes.clear();
Set<DeviceId> deviceSubjects = networkConfigRegistry.getSubjects(DeviceId.class, RouterAdvertisementDeviceConfig.class);
deviceSubjects.forEach(subject -> {
RouterAdvertisementDeviceConfig config = networkConfigRegistry.getConfig(subject, RouterAdvertisementDeviceConfig.class);
if (config != null) {
List<InterfaceIpAddress> ips = config.prefixes();
globalPrefixes.put(subject, ips);
}
});
}
use of org.onosproject.net.host.InterfaceIpAddress in project onos by opennetworkinglab.
the class RouterAdvertisementDeviceConfig method prefixes.
/**
* Gets global router advertisement prefixes for device.
*
* @return global prefixes. Or null if not configured.
*/
public List<InterfaceIpAddress> prefixes() {
if (!object.has(PREFIXES)) {
return null;
}
List<InterfaceIpAddress> ips = Lists.newArrayList();
ArrayNode prefixes = (ArrayNode) object.path(PREFIXES);
prefixes.forEach(i -> ips.add(InterfaceIpAddress.valueOf(i.asText())));
return ips;
}
use of org.onosproject.net.host.InterfaceIpAddress in project onos by opennetworkinglab.
the class FpmManager method modified.
@Modified
protected void modified(ComponentContext context) {
Ip4Address rurIPv4Address;
Ip6Address rurIPv6Address;
Dictionary<?, ?> properties = context.getProperties();
if (properties == null) {
return;
}
String strClearRoutes = Tools.get(properties, CLEAR_ROUTES);
if (strClearRoutes != null) {
clearRoutes = Boolean.parseBoolean(strClearRoutes);
log.info("clearRoutes is {}", clearRoutes);
}
String strPdPushEnabled = Tools.get(properties, PD_PUSH_ENABLED);
if (strPdPushEnabled != null) {
boolean oldValue = pdPushEnabled;
pdPushEnabled = Boolean.parseBoolean(strPdPushEnabled);
if (pdPushEnabled) {
pdPushNextHopIPv4 = new ArrayList<Ip4Address>();
pdPushNextHopIPv6 = new ArrayList<Ip6Address>();
String strPdPushNextHopIPv4 = Tools.get(properties, PD_PUSH_NEXT_HOP_IPV4);
if (strPdPushNextHopIPv4 != null) {
List<String> strPdPushNextHopIPv4List = Arrays.asList(strPdPushNextHopIPv4.split(","));
for (String nextHop : strPdPushNextHopIPv4List) {
log.trace("IPv4 next hop added is:" + nextHop);
pdPushNextHopIPv4.add(Ip4Address.valueOf(nextHop));
}
}
String strPdPushNextHopIPv6 = Tools.get(properties, PD_PUSH_NEXT_HOP_IPV6);
if (strPdPushNextHopIPv6 != null) {
List<String> strPdPushNextHopIPv6List = Arrays.asList(strPdPushNextHopIPv6.split(","));
for (String nextHop : strPdPushNextHopIPv6List) {
log.trace("IPv6 next hop added is:" + nextHop);
pdPushNextHopIPv6.add(Ip6Address.valueOf(nextHop));
}
}
if (pdPushNextHopIPv4.size() == 0) {
rurIPv4Address = interfaceService.getInterfaces().stream().filter(iface -> iface.name().contains("RUR")).map(Interface::ipAddressesList).flatMap(Collection::stream).map(InterfaceIpAddress::ipAddress).filter(IpAddress::isIp4).map(IpAddress::getIp4Address).findFirst().orElse(null);
log.debug("RUR IPv4 address extracted from netcfg is: {}", rurIPv4Address);
if (rurIPv4Address != null) {
pdPushNextHopIPv4.add(rurIPv4Address);
} else {
log.debug("Unable to extract RUR IPv4 address from netcfg");
}
}
if (pdPushNextHopIPv6 == null || pdPushNextHopIPv6.size() == 0) {
rurIPv6Address = interfaceService.getInterfaces().stream().filter(iface -> iface.name().contains("RUR")).map(Interface::ipAddressesList).flatMap(Collection::stream).map(InterfaceIpAddress::ipAddress).filter(IpAddress::isIp6).map(IpAddress::getIp6Address).findFirst().orElse(null);
log.debug("RUR IPv6 address extracted from netcfg is: {}", rurIPv6Address);
if (rurIPv6Address != null) {
pdPushNextHopIPv6.add(rurIPv6Address);
} else {
log.debug("Unable to extract RUR IPv6 address from netcfg");
}
}
log.info("PD pushing is enabled.");
if (pdPushNextHopIPv4.size() != 0) {
log.info("ipv4 next-hop {} with {} items", pdPushNextHopIPv4.toString(), pdPushNextHopIPv4.size());
} else {
log.info("ipv4 next-hop is null");
}
if (pdPushNextHopIPv6.size() != 0) {
log.info("ipv6 next-hop={} with {} items", pdPushNextHopIPv6.toString(), pdPushNextHopIPv6.size());
} else {
log.info("ipv6 next-hop is null");
}
processStaticRoutes();
} else {
log.info("PD pushing is disabled.");
}
}
}
use of org.onosproject.net.host.InterfaceIpAddress 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;
}
Aggregations