Added ip info for CLI (show host)
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java b/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
index b591044..4f20a81 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
@@ -395,7 +395,6 @@
ConfigState.NOT_CONFIGURED.toString());
}
switchData.freeze();
- System.out.println("getOnosInstanceId().toString():\n\n\n\n\n"+getOnosInstanceId());
// The Port events
List<PortData> portDataEntries = new ArrayList<PortData>();
for (OFPortDesc port : sw.getPorts()) {
diff --git a/src/main/java/net/onrc/onos/core/topology/web/serializers/HostDataSerializer.java b/src/main/java/net/onrc/onos/core/topology/web/serializers/HostDataSerializer.java
index 7099c83..86d92dc 100644
--- a/src/main/java/net/onrc/onos/core/topology/web/serializers/HostDataSerializer.java
+++ b/src/main/java/net/onrc/onos/core/topology/web/serializers/HostDataSerializer.java
@@ -44,6 +44,7 @@
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField(TopologyElement.TYPE, hostData.getType());
jsonGenerator.writeStringField("mac", hostData.getMac().toString());
+ jsonGenerator.writeStringField("ipv4", IPAddressToString(hostData.getIp()));
jsonGenerator.writeFieldName("attachmentPoints");
jsonGenerator.writeStartArray();
for (SwitchPort switchPort : hostData.getAttachmentPoints()) {
@@ -57,4 +58,10 @@
jsonGenerator.writeEndObject(); // stringAttributes
jsonGenerator.writeEndObject();
}
+ public String IPAddressToString(int ip) {
+ return ((ip >> 24) & 0xFF) + "." +
+ ((ip >> 16) & 0xFF) + "." +
+ ((ip >> 8) & 0xFF) + "." +
+ (ip & 0xFF);
+ }
}
diff --git a/src/main/java/net/onrc/onos/core/topology/web/serializers/HostSerializer.java b/src/main/java/net/onrc/onos/core/topology/web/serializers/HostSerializer.java
index b0f7824..d03c820 100644
--- a/src/main/java/net/onrc/onos/core/topology/web/serializers/HostSerializer.java
+++ b/src/main/java/net/onrc/onos/core/topology/web/serializers/HostSerializer.java
@@ -43,6 +43,7 @@
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField(TopologyElement.TYPE, host.getType());
jsonGenerator.writeStringField("mac", host.getMacAddress().toString());
+ jsonGenerator.writeStringField("ipv4", IPAddressToString(host.getIpAddress()));
jsonGenerator.writeFieldName("attachmentPoints");
jsonGenerator.writeStartArray();
for (Port port : host.getAttachmentPoints()) {
@@ -62,4 +63,10 @@
jsonGenerator.writeEndObject(); // stringAttributes
jsonGenerator.writeEndObject();
}
+ public String IPAddressToString(int ip) {
+ return ((ip >> 24) & 0xFF) + "." +
+ ((ip >> 16) & 0xFF) + "." +
+ ((ip >> 8) & 0xFF) + "." +
+ (ip & 0xFF);
+ }
}