HIGUCHI Yuta | 2d01158 | 2013-06-15 01:47:11 -0700 | [diff] [blame] | 1 | package net.onrc.onos.ofcontroller.core.internal; |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 2 | |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 3 | import java.util.ArrayList; |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 4 | import java.util.Arrays; |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 5 | import java.util.List; |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 6 | |
| 7 | import net.floodlightcontroller.devicemanager.IDevice; |
| 8 | import net.floodlightcontroller.devicemanager.SwitchPort; |
| 9 | import net.onrc.onos.graph.GraphDBOperation; |
| 10 | import net.onrc.onos.ofcontroller.core.IDeviceStorage; |
| 11 | import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject; |
| 12 | import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IIpv4Address; |
| 13 | import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject; |
| 14 | |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 15 | import org.openflow.util.HexString; |
| 16 | import org.slf4j.Logger; |
| 17 | import org.slf4j.LoggerFactory; |
| 18 | |
| 19 | import com.google.common.collect.Lists; |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 20 | import com.google.common.net.InetAddresses; |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 21 | import com.thinkaurelius.titan.core.TitanException; |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 22 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 23 | /** |
| 24 | * This is the class for storing the information of devices into CassandraDB |
| 25 | * @author Pankaj |
| 26 | */ |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 27 | public class DeviceStorageImpl implements IDeviceStorage { |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 28 | protected final static Logger log = LoggerFactory.getLogger(DeviceStorageImpl.class); |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 29 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 30 | private GraphDBOperation ope; |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 31 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 32 | /*** |
| 33 | * Initialize function. Before you use this class, please call this method |
| 34 | * @param conf configuration file for Cassandra DB |
| 35 | */ |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 36 | @Override |
| 37 | public void init(String conf) { |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 38 | try { |
Toshio Koide | bfe9b92 | 2013-06-18 10:56:05 -0700 | [diff] [blame] | 39 | ope = new GraphDBOperation(conf); |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 40 | } catch (TitanException e) { |
| 41 | log.error("Couldn't open graph operation", e); |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 42 | } |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 43 | } |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 44 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 45 | /*** |
| 46 | * Finalize/close function. After you use this class, please call this method. |
| 47 | * It will close the DB connection. |
| 48 | */ |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 49 | @Override |
| 50 | public void close() { |
Toshio Koide | bfe9b92 | 2013-06-18 10:56:05 -0700 | [diff] [blame] | 51 | ope.close(); |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | /*** |
| 55 | * Finalize/close function. After you use this class, please call this method. |
Pavlin Radoslavov | ef0cb00 | 2013-06-21 14:55:23 -0700 | [diff] [blame] | 56 | * It will close the DB connection. This is for Java garbage collection. |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 57 | */ |
| 58 | @Override |
| 59 | public void finalize() { |
| 60 | close(); |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 61 | } |
| 62 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 63 | /*** |
| 64 | * This function is for adding the device into the DB. |
| 65 | * @param device The device you want to add into the DB. |
| 66 | * @return IDeviceObject which was added in the DB. |
| 67 | */ |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 68 | @Override |
| 69 | public IDeviceObject addDevice(IDevice device) { |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 70 | IDeviceObject obj = null; |
Jonathan Hart | ba9ced9 | 2013-11-24 16:52:13 -0800 | [diff] [blame] | 71 | for (int i = 0; i < 6; i++) { |
| 72 | try { |
| 73 | if (i > 0) { |
| 74 | log.debug("Retrying add device: i is {}", i); |
| 75 | } |
| 76 | if ((obj = ope.searchDevice(device.getMACAddressString())) != null) { |
| 77 | log.debug("Adding device {}: found existing device", device.getMACAddressString()); |
| 78 | } else { |
| 79 | obj = ope.newDevice(); |
| 80 | log.debug("Adding device {}: creating new device", device.getMACAddressString()); |
| 81 | } |
| 82 | |
| 83 | changeDeviceAttachments(device, obj); |
| 84 | |
| 85 | changeDeviceIpv4Addresses(device, obj); |
| 86 | |
| 87 | obj.setMACAddress(device.getMACAddressString()); |
| 88 | obj.setType("device"); |
| 89 | obj.setState("ACTIVE"); |
| 90 | ope.commit(); |
| 91 | |
| 92 | break; |
| 93 | //log.debug("Adding device {}",device.getMACAddressString()); |
| 94 | } catch (TitanException e) { |
| 95 | ope.rollback(); |
| 96 | log.error("Adding device {} failed", device.getMACAddressString(), e); |
| 97 | obj = null; |
| 98 | } |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | return obj; |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 102 | } |
| 103 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 104 | /*** |
| 105 | * This function is for updating the Device properties. |
| 106 | * @param device The device you want to add into the DB. |
| 107 | * @return IDeviceObject which was added in the DB. |
| 108 | */ |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 109 | @Override |
| 110 | public IDeviceObject updateDevice(IDevice device) { |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 111 | return addDevice(device); |
| 112 | } |
| 113 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 114 | /*** |
| 115 | * This function is for removing the Device from the DB. |
| 116 | * @param device The device you want to delete from the DB. |
| 117 | */ |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 118 | @Override |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 119 | public void removeDevice(IDevice device) { |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 120 | IDeviceObject dev; |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 121 | |
| 122 | if ((dev = ope.searchDevice(device.getMACAddressString())) != null) { |
| 123 | removeDevice(dev); |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | public void removeDevice(IDeviceObject deviceObject) { |
| 128 | String deviceMac = deviceObject.getMACAddress(); |
| 129 | |
Jonathan Hart | 4cfd193 | 2013-11-19 16:42:25 -0800 | [diff] [blame] | 130 | removeDeviceImpl(deviceObject); |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 131 | |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 132 | try { |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 133 | ope.commit(); |
Jonathan Hart | 4cfd193 | 2013-11-19 16:42:25 -0800 | [diff] [blame] | 134 | log.debug("DeviceStorage:removeDevice mac:{} done", deviceMac); |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 135 | } catch (TitanException e) { |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 136 | ope.rollback(); |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 137 | log.error("DeviceStorage:removeDevice mac:{} failed", deviceMac); |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 138 | } |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 139 | } |
Jonathan Hart | 4cfd193 | 2013-11-19 16:42:25 -0800 | [diff] [blame] | 140 | |
| 141 | public void removeDeviceImpl(IDeviceObject deviceObject) { |
| 142 | for (IIpv4Address ipv4AddressVertex : deviceObject.getIpv4Addresses()) { |
| 143 | ope.removeIpv4Address(ipv4AddressVertex); |
| 144 | } |
| 145 | |
| 146 | ope.removeDevice(deviceObject); |
| 147 | } |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 148 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 149 | /*** |
| 150 | * This function is for getting the Device from the DB by Mac address of the device. |
| 151 | * @param mac The device mac address you want to get from the DB. |
| 152 | * @return IDeviceObject you want to get. |
| 153 | */ |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 154 | @Override |
| 155 | public IDeviceObject getDeviceByMac(String mac) { |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 156 | return ope.searchDevice(mac); |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 157 | } |
| 158 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 159 | /*** |
| 160 | * This function is for getting the Device from the DB by IP address of the device. |
| 161 | * @param ip The device ip address you want to get from the DB. |
| 162 | * @return IDeviceObject you want to get. |
| 163 | */ |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 164 | @Override |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 165 | public IDeviceObject getDeviceByIP(int ipv4Address) { |
| 166 | try { |
| 167 | IIpv4Address ipv4AddressVertex = ope.searchIpv4Address(ipv4Address); |
| 168 | if (ipv4AddressVertex != null) { |
| 169 | return ipv4AddressVertex.getDevice(); |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 170 | } |
| 171 | return null; |
| 172 | } |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 173 | catch (TitanException e) { |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 174 | log.error("DeviceStorage:getDeviceByIP:{} failed"); |
| 175 | return null; |
| 176 | } |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 177 | } |
| 178 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 179 | /*** |
| 180 | * This function is for changing the Device attachment point. |
| 181 | * @param device The device you want change the attachment point |
| 182 | */ |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 183 | @Override |
| 184 | public void changeDeviceAttachments(IDevice device) { |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 185 | IDeviceObject obj = null; |
| 186 | try { |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 187 | if ((obj = ope.searchDevice(device.getMACAddressString())) != null) { |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 188 | log.debug("Changing device ports {}: found existing device", device.getMACAddressString()); |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 189 | changeDeviceAttachments(device, obj); |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 190 | ope.commit(); |
| 191 | } else { |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 192 | log.debug("failed to search device...now adding {}", device.getMACAddressString()); |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 193 | addDevice(device); |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 194 | } |
| 195 | } catch (TitanException e) { |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 196 | ope.rollback(); |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 197 | log.error(":addDevice mac:{} failed", device.getMACAddressString()); |
| 198 | } |
| 199 | } |
| 200 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 201 | /*** |
| 202 | * This function is for changing the Device attachment point. |
| 203 | * @param device The new device you want change the attachment point |
| 204 | * @param obj The old device IDeviceObject that is going to change the attachment point. |
| 205 | */ |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 206 | public void changeDeviceAttachments(IDevice device, IDeviceObject obj) { |
| 207 | SwitchPort[] attachmentPoints = device.getAttachmentPoints(); |
| 208 | List<IPortObject> attachedPorts = Lists.newArrayList(obj.getAttachedPorts()); |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 209 | |
| 210 | for (SwitchPort ap : attachmentPoints) { |
| 211 | //Check if there is the port |
| 212 | IPortObject port = ope.searchPort(HexString.toHexString(ap.getSwitchDPID()), |
| 213 | (short) ap.getPort()); |
| 214 | log.debug("New Switch Port is {},{}", |
| 215 | HexString.toHexString(ap.getSwitchDPID()), (short) ap.getPort()); |
| 216 | |
| 217 | if (port != null){ |
| 218 | if (attachedPorts.contains(port)) { |
| 219 | log.debug("This is the port you already attached {}: do nothing", device.getMACAddressString()); |
| 220 | //This port will be remained, so remove from the removed port lists. |
| 221 | attachedPorts.remove(port); |
| 222 | } else { |
| 223 | log.debug("Adding device {}: attaching to port", device.getMACAddressString()); |
| 224 | port.setDevice(obj); |
| 225 | } |
| 226 | |
| 227 | log.debug("port number is {}", port.getNumber().toString()); |
| 228 | log.debug("port desc is {}", port.getDesc()); |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | for (IPortObject port: attachedPorts) { |
| 233 | log.debug("Detaching the device {}: detaching from port", device.getMACAddressString()); |
| 234 | port.removeDevice(obj); |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 235 | |
| 236 | if (!obj.getAttachedPorts().iterator().hasNext()) { |
| 237 | // XXX If there are no more ports attached to the device, |
| 238 | // delete it. Otherwise we have a situation where the |
| 239 | // device remains forever with an IP address attached. |
| 240 | // When we implement device probing we should get rid of this. |
| 241 | removeDevice(obj); |
| 242 | } |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 243 | } |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 244 | } |
| 245 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 246 | /*** |
| 247 | * This function is for changing the Device IPv4 address. |
| 248 | * @param device The new device you want change the ipaddress |
| 249 | */ |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 250 | @Override |
| 251 | public void changeDeviceIPv4Address(IDevice device) { |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 252 | log.debug("Changing IP address for {} to {}", device.getMACAddressString(), |
| 253 | device.getIPv4Addresses()); |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 254 | IDeviceObject obj; |
| 255 | try { |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 256 | if ((obj = ope.searchDevice(device.getMACAddressString())) != null) { |
Jonathan Hart | c8ae36c | 2013-11-03 19:06:40 -0800 | [diff] [blame] | 257 | changeDeviceIpv4Addresses(device, obj); |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 258 | |
| 259 | ope.commit(); |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 260 | } else { |
| 261 | log.error(":changeDeviceIPv4Address mac:{} failed", device.getMACAddressString()); |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 262 | } |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 263 | } catch (TitanException e) { |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 264 | ope.rollback(); |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 265 | log.error(":changeDeviceIPv4Address mac:{} failed due to exception {}", device.getMACAddressString(), e); |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 266 | } |
| 267 | } |
Jonathan Hart | c8ae36c | 2013-11-03 19:06:40 -0800 | [diff] [blame] | 268 | |
| 269 | private void changeDeviceIpv4Addresses(IDevice device, IDeviceObject deviceObject) { |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 270 | List<String> dbIpv4Addresses = new ArrayList<String>(); |
Jonathan Hart | ba9ced9 | 2013-11-24 16:52:13 -0800 | [diff] [blame] | 271 | List<Integer> intDbIpv4Addresses = new ArrayList<Integer>(); |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 272 | for (IIpv4Address ipv4Vertex : deviceObject.getIpv4Addresses()) { |
| 273 | dbIpv4Addresses.add(InetAddresses.fromInteger(ipv4Vertex.getIpv4Address()).getHostAddress()); |
Jonathan Hart | ba9ced9 | 2013-11-24 16:52:13 -0800 | [diff] [blame] | 274 | intDbIpv4Addresses.add(ipv4Vertex.getIpv4Address()); |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | List<String> memIpv4Addresses = new ArrayList<String>(); |
| 278 | for (int addr : device.getIPv4Addresses()) { |
| 279 | memIpv4Addresses.add(InetAddresses.fromInteger(addr).getHostAddress()); |
| 280 | } |
| 281 | |
| 282 | log.debug("Device IP addresses {}, database IP addresses {}", |
| 283 | memIpv4Addresses, dbIpv4Addresses); |
| 284 | |
Jonathan Hart | c8ae36c | 2013-11-03 19:06:40 -0800 | [diff] [blame] | 285 | for (int ipv4Address : device.getIPv4Addresses()) { |
Jonathan Hart | ba9ced9 | 2013-11-24 16:52:13 -0800 | [diff] [blame] | 286 | //if (deviceObject.getIpv4Address(ipv4Address) == null) { |
| 287 | if (!intDbIpv4Addresses.contains(ipv4Address)) { |
Jonathan Hart | c8ae36c | 2013-11-03 19:06:40 -0800 | [diff] [blame] | 288 | IIpv4Address dbIpv4Address = ope.ensureIpv4Address(ipv4Address); |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 289 | |
Jonathan Hart | ba9ced9 | 2013-11-24 16:52:13 -0800 | [diff] [blame] | 290 | /* |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 291 | IDeviceObject oldDevice = dbIpv4Address.getDevice(); |
| 292 | if (oldDevice != null) { |
| 293 | oldDevice.removeIpv4Address(dbIpv4Address); |
| 294 | } |
Jonathan Hart | ba9ced9 | 2013-11-24 16:52:13 -0800 | [diff] [blame] | 295 | */ |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 296 | |
| 297 | log.debug("Adding IP address {}", |
| 298 | InetAddresses.fromInteger(ipv4Address).getHostAddress()); |
Jonathan Hart | c8ae36c | 2013-11-03 19:06:40 -0800 | [diff] [blame] | 299 | deviceObject.addIpv4Address(dbIpv4Address); |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | List<Integer> deviceIpv4Addresses = Arrays.asList(device.getIPv4Addresses()); |
| 304 | for (IIpv4Address dbIpv4Address : deviceObject.getIpv4Addresses()) { |
| 305 | if (!deviceIpv4Addresses.contains(dbIpv4Address.getIpv4Address())) { |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 306 | log.debug("Removing IP address {}", |
| 307 | InetAddresses.fromInteger(dbIpv4Address.getIpv4Address()) |
| 308 | .getHostAddress()); |
Jonathan Hart | c8ae36c | 2013-11-03 19:06:40 -0800 | [diff] [blame] | 309 | deviceObject.removeIpv4Address(dbIpv4Address); |
| 310 | } |
| 311 | } |
| 312 | } |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 313 | |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 314 | } |