Jonathan Hart
Committed by Gerrit Code Review

Remove redundant interface object from interface configuration

Change-Id: I1eb0afab750fc15dba8aa13990147235232bd8ec
...@@ -60,7 +60,8 @@ public class BasicNetworkConfigs { ...@@ -60,7 +60,8 @@ public class BasicNetworkConfigs {
60 }, 60 },
61 new ConfigFactory<ConnectPoint, InterfaceConfig>(CONNECT_POINT_SUBJECT_FACTORY, 61 new ConfigFactory<ConnectPoint, InterfaceConfig>(CONNECT_POINT_SUBJECT_FACTORY,
62 InterfaceConfig.class, 62 InterfaceConfig.class,
63 - "interfaces") { 63 + "interfaces",
64 + true) {
64 @Override 65 @Override
65 public InterfaceConfig createConfig() { 66 public InterfaceConfig createConfig() {
66 return new InterfaceConfig(); 67 return new InterfaceConfig();
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onosproject.net.config.impl; 16 package org.onosproject.net.config.impl;
17 17
18 +import com.fasterxml.jackson.databind.JsonNode;
18 import com.fasterxml.jackson.databind.ObjectMapper; 19 import com.fasterxml.jackson.databind.ObjectMapper;
19 import com.fasterxml.jackson.databind.node.ObjectNode; 20 import com.fasterxml.jackson.databind.node.ObjectNode;
20 import com.google.common.collect.Maps; 21 import com.google.common.collect.Maps;
...@@ -50,7 +51,7 @@ public class NetworkConfigLoader { ...@@ -50,7 +51,7 @@ public class NetworkConfigLoader {
50 51
51 // FIXME: Add mutual exclusion to make sure this happens only once per startup. 52 // FIXME: Add mutual exclusion to make sure this happens only once per startup.
52 53
53 - private final Map<InnerConfigPosition, ObjectNode> jsons = Maps.newConcurrentMap(); 54 + private final Map<InnerConfigPosition, JsonNode> jsons = Maps.newConcurrentMap();
54 55
55 private final NetworkConfigListener configListener = new InnerConfigListener(); 56 private final NetworkConfigListener configListener = new InnerConfigListener();
56 57
...@@ -163,7 +164,7 @@ public class NetworkConfigLoader { ...@@ -163,7 +164,7 @@ public class NetworkConfigLoader {
163 private void saveSubjectJson(String sk, 164 private void saveSubjectJson(String sk,
164 String s, ObjectNode node) { 165 String s, ObjectNode node) {
165 node.fieldNames().forEachRemaining(c -> 166 node.fieldNames().forEachRemaining(c ->
166 - this.jsons.put(new InnerConfigPosition(sk, s, c), (ObjectNode) node.path(c))); 167 + this.jsons.put(new InnerConfigPosition(sk, s, c), node.path(c)));
167 } 168 }
168 169
169 /** 170 /**
...@@ -180,11 +181,11 @@ public class NetworkConfigLoader { ...@@ -180,11 +181,11 @@ public class NetworkConfigLoader {
180 * are imported and have not yet been applied. 181 * are imported and have not yet been applied.
181 */ 182 */
182 private void applyConfigurations() { 183 private void applyConfigurations() {
183 - Iterator<Map.Entry<InnerConfigPosition, ObjectNode>> iter = jsons.entrySet().iterator(); 184 + Iterator<Map.Entry<InnerConfigPosition, JsonNode>> iter = jsons.entrySet().iterator();
184 185
185 - Map.Entry<InnerConfigPosition, ObjectNode> entry; 186 + Map.Entry<InnerConfigPosition, JsonNode> entry;
186 InnerConfigPosition key; 187 InnerConfigPosition key;
187 - ObjectNode node; 188 + JsonNode node;
188 String subjectKey; 189 String subjectKey;
189 String subjectString; 190 String subjectString;
190 String configKey; 191 String configKey;
......
...@@ -31,7 +31,6 @@ import java.util.Set; ...@@ -31,7 +31,6 @@ import java.util.Set;
31 * Configuration for interfaces. 31 * Configuration for interfaces.
32 */ 32 */
33 public class InterfaceConfig extends Config<ConnectPoint> { 33 public class InterfaceConfig extends Config<ConnectPoint> {
34 - public static final String INTERFACES = "interfaces";
35 public static final String IPS = "ips"; 34 public static final String IPS = "ips";
36 public static final String MAC = "mac"; 35 public static final String MAC = "mac";
37 public static final String VLAN = "vlan"; 36 public static final String VLAN = "vlan";
...@@ -50,8 +49,7 @@ public class InterfaceConfig extends Config<ConnectPoint> { ...@@ -50,8 +49,7 @@ public class InterfaceConfig extends Config<ConnectPoint> {
50 Set<Interface> interfaces = Sets.newHashSet(); 49 Set<Interface> interfaces = Sets.newHashSet();
51 50
52 try { 51 try {
53 - // TODO: rework this to take advantage of ArrayNode backing 52 + for (JsonNode intfNode : array) {
54 - for (JsonNode intfNode : object.path(INTERFACES)) {
55 Set<InterfaceIpAddress> ips = getIps(intfNode); 53 Set<InterfaceIpAddress> ips = getIps(intfNode);
56 if (ips.isEmpty()) { 54 if (ips.isEmpty()) {
57 throw new ConfigException(IP_MISSING_ERROR); 55 throw new ConfigException(IP_MISSING_ERROR);
......