Minor fixes to new DeviceStorageImpl methods
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java b/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java
index 6b84d32..160587f 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java
@@ -21,24 +21,24 @@
*/
public interface INetMapTopologyObjects {
-public interface IBaseObject extends VertexFrame {
+ public interface IBaseObject extends VertexFrame {
+
+ @JsonProperty("state")
+ @Property("state")
+ public String getState();
+
+ @Property("state")
+ public void setState(final String state);
+
+ @JsonIgnore
+ @Property("type")
+ public String getType();
+ @Property("type")
+ public void setType(final String type);
+
+ }
- @JsonProperty("state")
- @Property("state")
- public String getState();
-
- @Property("state")
- public void setState(final String state);
-
- @JsonIgnore
- @Property("type")
- public String getType();
- @Property("type")
- public void setType(final String type);
-
-}
-
-public interface ISwitchObject extends IBaseObject{
+ public interface ISwitchObject extends IBaseObject{
@JsonProperty("dpid")
@Property("dpid")
@@ -51,7 +51,7 @@
@Adjacency(label="on")
public Iterable<IPortObject> getPorts();
-// Requires Frames 2.3.0
+ // Requires Frames 2.3.0
@JsonIgnore
@GremlinGroovy("it.out('on').has('number',port_num)")
public IPortObject getPort(@GremlinParam("port_num") final short port_num);
@@ -104,7 +104,6 @@
public void setPortState(Integer s);
@JsonIgnore
-// @GremlinGroovy("it.in('on')")
@Adjacency(label="on",direction = Direction.IN)
public ISwitchObject getSwitch();
@@ -136,9 +135,9 @@
@Adjacency(label="link")
public void setLinkPort(final IPortObject dest_port);
-// @JsonIgnore
-// @Adjacency(label="link")
-// public Iterable<ILinkObject> getLinks();
+ // @JsonIgnore
+ // @Adjacency(label="link")
+ // public Iterable<ILinkObject> getLinks();
}
public interface IDeviceObject extends IBaseObject {
@@ -146,6 +145,7 @@
@JsonProperty("mac")
@Property("dl_addr")
public String getMACAddress();
+
@Property("dl_addr")
public void setMACAddress(String macaddr);
@@ -173,7 +173,7 @@
public Iterable<IIpv4Address> getIpv4Addresses();
@JsonIgnore
- @GremlinGroovy("it.out('hasAddress').has('ipv4', ipv4Address)")
+ @GremlinGroovy("it.out('hasAddress').has('ipv4_address', ipv4Address)")
public IIpv4Address getIpv4Address(@GremlinParam("ipv4Address") final int ipv4Address);
@Adjacency(label="hasAddress")
@@ -209,7 +209,7 @@
public IDeviceObject getDevice();
}
-public interface IFlowPath extends IBaseObject {
+ public interface IFlowPath extends IBaseObject {
@JsonProperty("flowId")
@Property("flow_id")
public String getFlowId();
@@ -392,7 +392,7 @@
public String getState();
}
-public interface IFlowEntry extends IBaseObject {
+ public interface IFlowEntry extends IBaseObject {
@Property("flow_entry_id")
public String getFlowEntryId();
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/internal/DeviceStorageImpl.java b/src/main/java/net/onrc/onos/ofcontroller/core/internal/DeviceStorageImpl.java
index ed6d85f..6438ffd 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/internal/DeviceStorageImpl.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/internal/DeviceStorageImpl.java
@@ -75,10 +75,11 @@
}
changeDeviceAttachments(device, obj);
-
- for (Integer intIpv4Address : device.getIPv4Addresses()) {
+
+ changeDeviceIpv4Addresses(device, obj);
+ /*for (Integer intIpv4Address : device.getIPv4Addresses()) {
obj.addIpv4Address(ope.ensureIpv4Address(intIpv4Address));
- }
+ }*/
obj.setMACAddress(device.getMACAddressString());
obj.setType("device");
@@ -228,19 +229,7 @@
IDeviceObject obj;
try {
if ((obj = ope.searchDevice(device.getMACAddressString())) != null) {
- for (int ipv4Address : device.getIPv4Addresses()) {
- if (obj.getIpv4Address(ipv4Address) == null) {
- IIpv4Address dbIpv4Address = ope.ensureIpv4Address(ipv4Address);
- obj.addIpv4Address(dbIpv4Address);
- }
- }
-
- List<Integer> deviceIpv4Addresses = Arrays.asList(device.getIPv4Addresses());
- for (IIpv4Address dbIpv4Address : obj.getIpv4Addresses()) {
- if (!deviceIpv4Addresses.contains(dbIpv4Address.getIpv4Address())) {
- obj.removeIpv4Address(dbIpv4Address);
- }
- }
+ changeDeviceIpv4Addresses(device, obj);
ope.commit();
} else {
@@ -251,5 +240,21 @@
log.error(":changeDeviceIPv4Address mac:{} failed due to exception {}", device.getMACAddressString(), e);
}
}
+
+ private void changeDeviceIpv4Addresses(IDevice device, IDeviceObject deviceObject) {
+ for (int ipv4Address : device.getIPv4Addresses()) {
+ if (deviceObject.getIpv4Address(ipv4Address) == null) {
+ IIpv4Address dbIpv4Address = ope.ensureIpv4Address(ipv4Address);
+ deviceObject.addIpv4Address(dbIpv4Address);
+ }
+ }
+
+ List<Integer> deviceIpv4Addresses = Arrays.asList(device.getIPv4Addresses());
+ for (IIpv4Address dbIpv4Address : deviceObject.getIpv4Addresses()) {
+ if (!deviceIpv4Addresses.contains(dbIpv4Address.getIpv4Address())) {
+ deviceObject.removeIpv4Address(dbIpv4Address);
+ }
+ }
+ }
}