mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-12-16 06:41:29 +01:00
Added interfaces configuration to allow vRouter to be selective about what
interfaces to use. Change-Id: I4eb069760df0995d9e831e024ddbc0493bccce0b
This commit is contained in:
parent
133fd793ad
commit
883fd378cc
@ -16,10 +16,16 @@
|
|||||||
|
|
||||||
package org.onosproject.routing.config;
|
package org.onosproject.routing.config;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
import org.onosproject.core.ApplicationId;
|
import org.onosproject.core.ApplicationId;
|
||||||
import org.onosproject.net.ConnectPoint;
|
import org.onosproject.net.ConnectPoint;
|
||||||
import org.onosproject.net.config.Config;
|
import org.onosproject.net.config.Config;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Routing configuration.
|
* Routing configuration.
|
||||||
*/
|
*/
|
||||||
@ -28,6 +34,7 @@ public class RouterConfig extends Config<ApplicationId> {
|
|||||||
private static final String CP_CONNECT_POINT = "controlPlaneConnectPoint";
|
private static final String CP_CONNECT_POINT = "controlPlaneConnectPoint";
|
||||||
private static final String OSPF_ENABLED = "ospfEnabled";
|
private static final String OSPF_ENABLED = "ospfEnabled";
|
||||||
private static final String PIM_ENABLED = "pimEnabled";
|
private static final String PIM_ENABLED = "pimEnabled";
|
||||||
|
private static final String INTERFACES = "interfaces";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the routing control plane connect point.
|
* Returns the routing control plane connect point.
|
||||||
@ -55,4 +62,24 @@ public class RouterConfig extends Config<ApplicationId> {
|
|||||||
public boolean pimEnabled() {
|
public boolean pimEnabled() {
|
||||||
return object.path(PIM_ENABLED).asBoolean(false);
|
return object.path(PIM_ENABLED).asBoolean(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the list of interfaces enabled on this router.
|
||||||
|
*
|
||||||
|
* @return list of interface names that are enabled, or an empty list if
|
||||||
|
* all available interfaces should be used
|
||||||
|
*/
|
||||||
|
public List<String> getInterfaces() {
|
||||||
|
JsonNode intfNode = object.path(INTERFACES);
|
||||||
|
if (intfNode.isMissingNode() || !intfNode.isArray()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
ArrayNode array = (ArrayNode) intfNode;
|
||||||
|
List<String> interfaces = new ArrayList<>(array.size());
|
||||||
|
for (JsonNode intf : array) {
|
||||||
|
interfaces.add(intf.asText());
|
||||||
|
}
|
||||||
|
return interfaces;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,6 +50,9 @@ import org.onosproject.routing.RoutingService;
|
|||||||
import org.onosproject.routing.config.RouterConfig;
|
import org.onosproject.routing.config.RouterConfig;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,6 +72,7 @@ public class ControlPlaneRedirectManager {
|
|||||||
|
|
||||||
private ConnectPoint controlPlaneConnectPoint;
|
private ConnectPoint controlPlaneConnectPoint;
|
||||||
private boolean ospfEnabled = false;
|
private boolean ospfEnabled = false;
|
||||||
|
private List<String> interfaces = Collections.emptyList();
|
||||||
|
|
||||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||||
protected CoreService coreService;
|
protected CoreService coreService;
|
||||||
@ -119,6 +123,7 @@ public class ControlPlaneRedirectManager {
|
|||||||
|
|
||||||
controlPlaneConnectPoint = config.getControlPlaneConnectPoint();
|
controlPlaneConnectPoint = config.getControlPlaneConnectPoint();
|
||||||
ospfEnabled = config.getOspfEnabled();
|
ospfEnabled = config.getOspfEnabled();
|
||||||
|
interfaces = config.getInterfaces();
|
||||||
|
|
||||||
updateDevice();
|
updateDevice();
|
||||||
}
|
}
|
||||||
@ -130,6 +135,7 @@ public class ControlPlaneRedirectManager {
|
|||||||
|
|
||||||
interfaceService.getInterfaces().stream()
|
interfaceService.getInterfaces().stream()
|
||||||
.filter(intf -> intf.connectPoint().deviceId().equals(deviceId))
|
.filter(intf -> intf.connectPoint().deviceId().equals(deviceId))
|
||||||
|
.filter(intf -> interfaces.isEmpty() || interfaces.contains(intf.name()))
|
||||||
.forEach(this::provisionInterface);
|
.forEach(this::provisionInterface);
|
||||||
|
|
||||||
log.info("Set up interfaces on {}", controlPlaneConnectPoint.deviceId());
|
log.info("Set up interfaces on {}", controlPlaneConnectPoint.deviceId());
|
||||||
|
|||||||
@ -67,8 +67,10 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Programs routes to a single OpenFlow switch.
|
* Programs routes to a single OpenFlow switch.
|
||||||
@ -108,6 +110,8 @@ public class SingleSwitchFibInstaller {
|
|||||||
|
|
||||||
private ConnectPoint controlPlaneConnectPoint;
|
private ConnectPoint controlPlaneConnectPoint;
|
||||||
|
|
||||||
|
private List<String> interfaces;
|
||||||
|
|
||||||
private ApplicationId routerAppId;
|
private ApplicationId routerAppId;
|
||||||
|
|
||||||
// Reference count for how many times a next hop is used by a route
|
// Reference count for how many times a next hop is used by a route
|
||||||
@ -161,15 +165,29 @@ public class SingleSwitchFibInstaller {
|
|||||||
log.info("Control Plane Connect Point: {}", controlPlaneConnectPoint);
|
log.info("Control Plane Connect Point: {}", controlPlaneConnectPoint);
|
||||||
|
|
||||||
deviceId = routerConfig.getControlPlaneConnectPoint().deviceId();
|
deviceId = routerConfig.getControlPlaneConnectPoint().deviceId();
|
||||||
|
|
||||||
log.info("Router device ID is {}", deviceId);
|
log.info("Router device ID is {}", deviceId);
|
||||||
|
|
||||||
|
interfaces = routerConfig.getInterfaces();
|
||||||
|
log.info("Using interfaces: {}", interfaces.isEmpty() ? "all" : interfaces);
|
||||||
|
|
||||||
updateDevice();
|
updateDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDevice() {
|
private void updateDevice() {
|
||||||
if (deviceId != null && deviceService.isAvailable(deviceId)) {
|
if (deviceId != null && deviceService.isAvailable(deviceId)) {
|
||||||
processIntfFilters(true, interfaceService.getInterfaces());
|
|
||||||
|
Set<Interface> intfs;
|
||||||
|
if (interfaces.isEmpty()) {
|
||||||
|
intfs = interfaceService.getInterfaces();
|
||||||
|
} else {
|
||||||
|
// TODO need to fix by making interface names globally unique
|
||||||
|
intfs = interfaceService.getInterfaces().stream()
|
||||||
|
.filter(intf -> intf.connectPoint().deviceId().equals(deviceId))
|
||||||
|
.filter(intf -> interfaces.contains(intf.name()))
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
processIntfFilters(true, intfs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user