Added NASId, IP Address for a device and auto pick data from external or ONOS configuration
Change-Id: Ib3ecd911c43dd1cd0d03cef3916b1e513f9bbdaf
diff --git a/src/main/java/org/opencord/sadis/SadisConfig.java b/src/main/java/org/opencord/sadis/SadisConfig.java
index ab6128d..fd9689f 100644
--- a/src/main/java/org/opencord/sadis/SadisConfig.java
+++ b/src/main/java/org/opencord/sadis/SadisConfig.java
@@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.onlab.packet.Ip4Address;
import org.onlab.packet.VlanId;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.config.Config;
@@ -58,7 +59,9 @@
* "nasportid" : string,
* "port" : int,
* "slot" : int,
- * "hardwareidentifier" : string
+ * "hardwareidentifier" : string,
+ * "ipAddress" : string,
+ * "nasId" : string
* }, ...
* ]
* }
@@ -151,6 +154,7 @@
ObjectMapper mapper = new ObjectMapper();
SimpleModule module = new SimpleModule();
module.addDeserializer(VlanId.class, new VlanIdDeserializer());
+ module.addDeserializer(Ip4Address.class, new Ip4AddressDeserializer());
mapper.registerModule(module);
final JsonNode entries = this.object.path(SADIS_ENTRIES);
entries.forEach(entry -> {
@@ -173,4 +177,14 @@
return VlanId.vlanId((short) node.asInt());
}
}
+
+ public class Ip4AddressDeserializer extends JsonDeserializer<Ip4Address> {
+ @Override
+ public Ip4Address deserialize(JsonParser jp, DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+ ObjectCodec oc = jp.getCodec();
+ JsonNode node = oc.readTree(jp);
+ return Ip4Address.valueOf((String) node.asText());
+ }
+ }
}