Added interfaces configuration to allow vRouter to be selective about what
interfaces to use.
Change-Id: I4eb069760df0995d9e831e024ddbc0493bccce0b
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/config/RouterConfig.java b/apps/routing-api/src/main/java/org/onosproject/routing/config/RouterConfig.java
index cfe719d..9099019 100644
--- a/apps/routing-api/src/main/java/org/onosproject/routing/config/RouterConfig.java
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/config/RouterConfig.java
@@ -16,10 +16,16 @@
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.net.ConnectPoint;
import org.onosproject.net.config.Config;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
/**
* Routing configuration.
*/
@@ -28,6 +34,7 @@
private static final String CP_CONNECT_POINT = "controlPlaneConnectPoint";
private static final String OSPF_ENABLED = "ospfEnabled";
private static final String PIM_ENABLED = "pimEnabled";
+ private static final String INTERFACES = "interfaces";
/**
* Returns the routing control plane connect point.
@@ -55,4 +62,24 @@
public boolean pimEnabled() {
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;
+ }
+
}