use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.
the class ControlPlaneRedirectManagerTest method testUpdateNetworkConfig.
/**
* Tests adding while updating the networkConfig.
*/
@Test
public void testUpdateNetworkConfig() {
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);
interfaces.add(sw1Eth4);
EasyMock.reset(flowObjectiveService);
setUpFlowObjectiveService();
networkConfigListener.event(new NetworkConfigEvent(Type.CONFIG_UPDATED, dev3, RoutingService.ROUTER_CONFIG_CLASS));
networkConfigService.addListener(networkConfigListener);
verify(flowObjectiveService);
}
use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.
the class ControlPlaneRedirectManagerTest method testAddInterface.
/**
* Tests adding while updating the networkConfig.
*/
@Test
public void testAddInterface() {
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);
interfaces.add(sw1Eth4);
EasyMock.reset(flowObjectiveService);
expect(flowObjectiveService.allocateNextId()).andReturn(1).anyTimes();
setUpInterfaceConfiguration(sw1Eth4, true);
replay(flowObjectiveService);
interfaceListener.event(new InterfaceEvent(InterfaceEvent.Type.INTERFACE_ADDED, sw1Eth4, 500L));
verify(flowObjectiveService);
}
use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.
the class BgpConfigTest method createInitialSpeaker.
private BgpConfig.BgpSpeakerConfig createInitialSpeaker() {
Optional<String> speakerName = Optional.of("bgp1");
ConnectPoint connectPoint = CONNECT_POINT1;
Set<IpAddress> connectedPeers = new HashSet<>(Arrays.asList(IP1, IP2, IP3));
return new BgpConfig.BgpSpeakerConfig(speakerName, NO_VLAN, connectPoint, connectedPeers);
}
use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.
the class SimpleIntManager method configDevice.
protected boolean configDevice(DeviceId deviceId) {
// Returns true if config was successful, false if not and a clean up is
// needed.
final Device device = deviceService.getDevice(deviceId);
if (device == null || !device.is(IntProgrammable.class)) {
return true;
}
if (isNotIntConfigured()) {
log.warn("Missing INT config, aborting programming of INT device {}", deviceId);
return true;
}
final boolean isEdge = !hostService.getConnectedHosts(deviceId).isEmpty();
final IntDeviceRole intDeviceRole = isEdge ? IntDeviceRole.SOURCE_SINK : IntDeviceRole.TRANSIT;
log.info("Started programming of INT device {} with role {}...", deviceId, intDeviceRole);
final IntProgrammable intProg = device.as(IntProgrammable.class);
if (!isIntStarted()) {
// Leave device with no INT configuration.
return true;
}
if (!intProg.init()) {
log.warn("Unable to init INT pipeline on {}", deviceId);
return false;
}
boolean supportSource = intProg.supportsFunctionality(IntProgrammable.IntFunctionality.SOURCE);
boolean supportSink = intProg.supportsFunctionality(IntProgrammable.IntFunctionality.SINK);
boolean supportPostcard = intProg.supportsFunctionality(IntProgrammable.IntFunctionality.POSTCARD);
if (intDeviceRole != IntDeviceRole.SOURCE_SINK && !supportPostcard) {
// Stop here, no more configuration needed for transit devices unless it support postcard.
return true;
}
if (supportSink || supportPostcard) {
if (!intProg.setupIntConfig(intConfig.get())) {
log.warn("Unable to apply INT report config on {}", deviceId);
return false;
}
}
// Port configuration.
final Set<PortNumber> hostPorts = deviceService.getPorts(deviceId).stream().map(port -> new ConnectPoint(deviceId, port.number())).filter(cp -> !hostService.getConnectedHosts(cp).isEmpty()).map(ConnectPoint::port).collect(Collectors.toSet());
for (PortNumber port : hostPorts) {
if (supportSource) {
log.info("Setting port {}/{} as INT source port...", deviceId, port);
if (!intProg.setSourcePort(port)) {
log.warn("Unable to set INT source port {} on {}", port, deviceId);
return false;
}
}
if (supportSink) {
log.info("Setting port {}/{} as INT sink port...", deviceId, port);
if (!intProg.setSinkPort(port)) {
log.warn("Unable to set INT sink port {} on {}", port, deviceId);
return false;
}
}
}
if (!supportSource && !supportPostcard) {
// it supports postcard mode.
return true;
}
// Apply intents.
// This is a trivial implementation where we simply get the
// corresponding INT objective from an intent and we apply to all
// device which support reporting.
int appliedCount = 0;
for (Versioned<IntIntent> versionedIntent : intentMap.values()) {
IntIntent intent = versionedIntent.value();
IntObjective intObjective = getIntObjective(intent);
if (intent.telemetryMode() == IntIntent.TelemetryMode.INBAND_TELEMETRY && supportSource) {
intProg.addIntObjective(intObjective);
appliedCount++;
} else if (intent.telemetryMode() == IntIntent.TelemetryMode.POSTCARD && supportPostcard) {
intProg.addIntObjective(intObjective);
appliedCount++;
} else {
log.warn("Device {} does not support intent {}.", deviceId, intent);
}
}
log.info("Completed programming of {}, applied {} INT objectives of {} total", deviceId, appliedCount, intentMap.size());
return true;
}
use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.
the class IntentSynchronizerTest method intentBuilder.
/**
* MultiPointToSinglePointIntent builder.
*
* @param ipPrefix the ipPrefix to match
* @param nextHopMacAddress to which the destination MAC address in packet
* should be rewritten
* @param egressPoint to which packets should be sent
* @return the constructed MultiPointToSinglePointIntent
*/
private MultiPointToSinglePointIntent intentBuilder(IpPrefix ipPrefix, String nextHopMacAddress, ConnectPoint egressPoint) {
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
if (ipPrefix.isIp4()) {
selectorBuilder.matchEthType(Ethernet.TYPE_IPV4);
selectorBuilder.matchIPDst(ipPrefix);
} else {
selectorBuilder.matchEthType(Ethernet.TYPE_IPV6);
selectorBuilder.matchIPv6Dst(ipPrefix);
}
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
treatmentBuilder.setEthDst(MacAddress.valueOf(nextHopMacAddress));
Set<ConnectPoint> ingressPoints = new HashSet<>(connectPoints);
ingressPoints.remove(egressPoint);
MultiPointToSinglePointIntent intent = MultiPointToSinglePointIntent.builder().appId(APPID).key(Key.of(ipPrefix.toString(), APPID)).selector(selectorBuilder.build()).treatment(treatmentBuilder.build()).ingressPoints(ingressPoints).egressPoint(egressPoint).build();
return intent;
}
Aggregations