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; |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 71 | try { |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 72 | if ((obj = ope.searchDevice(device.getMACAddressString())) != null) { |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 73 | log.debug("Adding device {}: found existing device", device.getMACAddressString()); |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 74 | } else { |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 75 | obj = ope.newDevice(); |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 76 | log.debug("Adding device {}: creating new device", device.getMACAddressString()); |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 77 | } |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 78 | |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 79 | changeDeviceAttachments(device, obj); |
Jonathan Hart | c8ae36c | 2013-11-03 19:06:40 -0800 | [diff] [blame] | 80 | |
| 81 | changeDeviceIpv4Addresses(device, obj); |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 82 | |
| 83 | obj.setMACAddress(device.getMACAddressString()); |
| 84 | obj.setType("device"); |
| 85 | obj.setState("ACTIVE"); |
| 86 | ope.commit(); |
| 87 | |
| 88 | //log.debug("Adding device {}",device.getMACAddressString()); |
| 89 | } catch (TitanException e) { |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 90 | ope.rollback(); |
Jonathan Hart | 9ec4c6a | 2013-11-04 22:01:50 -0800 | [diff] [blame] | 91 | log.error("Adding device {} failed", device.getMACAddressString(), e); |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 92 | obj = null; |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | return obj; |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 96 | } |
| 97 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 98 | /*** |
| 99 | * This function is for updating the Device properties. |
| 100 | * @param device The device you want to add into the DB. |
| 101 | * @return IDeviceObject which was added in the DB. |
| 102 | */ |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 103 | @Override |
| 104 | public IDeviceObject updateDevice(IDevice device) { |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 105 | return addDevice(device); |
| 106 | } |
| 107 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 108 | /*** |
| 109 | * This function is for removing the Device from the DB. |
| 110 | * @param device The device you want to delete from the DB. |
| 111 | */ |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 112 | @Override |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 113 | public void removeDevice(IDevice device) { |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 114 | IDeviceObject dev; |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 115 | |
| 116 | if ((dev = ope.searchDevice(device.getMACAddressString())) != null) { |
| 117 | removeDevice(dev); |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | public void removeDevice(IDeviceObject deviceObject) { |
| 122 | String deviceMac = deviceObject.getMACAddress(); |
| 123 | |
Jonathan Hart | 4cfd193 | 2013-11-19 16:42:25 -0800 | [diff] [blame] | 124 | removeDeviceImpl(deviceObject); |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 125 | |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 126 | try { |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 127 | ope.commit(); |
Jonathan Hart | 4cfd193 | 2013-11-19 16:42:25 -0800 | [diff] [blame] | 128 | log.debug("DeviceStorage:removeDevice mac:{} done", deviceMac); |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 129 | } catch (TitanException e) { |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 130 | ope.rollback(); |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 131 | log.error("DeviceStorage:removeDevice mac:{} failed", deviceMac); |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 132 | } |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 133 | } |
Jonathan Hart | 4cfd193 | 2013-11-19 16:42:25 -0800 | [diff] [blame] | 134 | |
| 135 | public void removeDeviceImpl(IDeviceObject deviceObject) { |
| 136 | for (IIpv4Address ipv4AddressVertex : deviceObject.getIpv4Addresses()) { |
| 137 | ope.removeIpv4Address(ipv4AddressVertex); |
| 138 | } |
| 139 | |
| 140 | ope.removeDevice(deviceObject); |
| 141 | } |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 142 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 143 | /*** |
| 144 | * This function is for getting the Device from the DB by Mac address of the device. |
| 145 | * @param mac The device mac address you want to get from the DB. |
| 146 | * @return IDeviceObject you want to get. |
| 147 | */ |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 148 | @Override |
| 149 | public IDeviceObject getDeviceByMac(String mac) { |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 150 | return ope.searchDevice(mac); |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 151 | } |
| 152 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 153 | /*** |
| 154 | * This function is for getting the Device from the DB by IP address of the device. |
| 155 | * @param ip The device ip address you want to get from the DB. |
| 156 | * @return IDeviceObject you want to get. |
| 157 | */ |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 158 | @Override |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 159 | public IDeviceObject getDeviceByIP(int ipv4Address) { |
| 160 | try { |
| 161 | IIpv4Address ipv4AddressVertex = ope.searchIpv4Address(ipv4Address); |
| 162 | if (ipv4AddressVertex != null) { |
| 163 | return ipv4AddressVertex.getDevice(); |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 164 | } |
| 165 | return null; |
| 166 | } |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 167 | catch (TitanException e) { |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 168 | log.error("DeviceStorage:getDeviceByIP:{} failed"); |
| 169 | return null; |
| 170 | } |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 171 | } |
| 172 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 173 | /*** |
| 174 | * This function is for changing the Device attachment point. |
| 175 | * @param device The device you want change the attachment point |
| 176 | */ |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 177 | @Override |
| 178 | public void changeDeviceAttachments(IDevice device) { |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 179 | IDeviceObject obj = null; |
| 180 | try { |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 181 | if ((obj = ope.searchDevice(device.getMACAddressString())) != null) { |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 182 | log.debug("Changing device ports {}: found existing device", device.getMACAddressString()); |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 183 | changeDeviceAttachments(device, obj); |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 184 | ope.commit(); |
| 185 | } else { |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 186 | log.debug("failed to search device...now adding {}", device.getMACAddressString()); |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 187 | addDevice(device); |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 188 | } |
| 189 | } catch (TitanException e) { |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 190 | ope.rollback(); |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 191 | log.error(":addDevice mac:{} failed", device.getMACAddressString()); |
| 192 | } |
| 193 | } |
| 194 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 195 | /*** |
| 196 | * This function is for changing the Device attachment point. |
| 197 | * @param device The new device you want change the attachment point |
| 198 | * @param obj The old device IDeviceObject that is going to change the attachment point. |
| 199 | */ |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 200 | public void changeDeviceAttachments(IDevice device, IDeviceObject obj) { |
| 201 | SwitchPort[] attachmentPoints = device.getAttachmentPoints(); |
| 202 | List<IPortObject> attachedPorts = Lists.newArrayList(obj.getAttachedPorts()); |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 203 | |
| 204 | for (SwitchPort ap : attachmentPoints) { |
| 205 | //Check if there is the port |
| 206 | IPortObject port = ope.searchPort(HexString.toHexString(ap.getSwitchDPID()), |
| 207 | (short) ap.getPort()); |
| 208 | log.debug("New Switch Port is {},{}", |
| 209 | HexString.toHexString(ap.getSwitchDPID()), (short) ap.getPort()); |
| 210 | |
| 211 | if (port != null){ |
| 212 | if (attachedPorts.contains(port)) { |
| 213 | log.debug("This is the port you already attached {}: do nothing", device.getMACAddressString()); |
| 214 | //This port will be remained, so remove from the removed port lists. |
| 215 | attachedPorts.remove(port); |
| 216 | } else { |
| 217 | log.debug("Adding device {}: attaching to port", device.getMACAddressString()); |
| 218 | port.setDevice(obj); |
| 219 | } |
| 220 | |
| 221 | log.debug("port number is {}", port.getNumber().toString()); |
| 222 | log.debug("port desc is {}", port.getDesc()); |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | for (IPortObject port: attachedPorts) { |
| 227 | log.debug("Detaching the device {}: detaching from port", device.getMACAddressString()); |
| 228 | port.removeDevice(obj); |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 229 | |
| 230 | if (!obj.getAttachedPorts().iterator().hasNext()) { |
| 231 | // XXX If there are no more ports attached to the device, |
| 232 | // delete it. Otherwise we have a situation where the |
| 233 | // device remains forever with an IP address attached. |
| 234 | // When we implement device probing we should get rid of this. |
| 235 | removeDevice(obj); |
| 236 | } |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 237 | } |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 238 | } |
| 239 | |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 240 | /*** |
| 241 | * This function is for changing the Device IPv4 address. |
| 242 | * @param device The new device you want change the ipaddress |
| 243 | */ |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 244 | @Override |
| 245 | public void changeDeviceIPv4Address(IDevice device) { |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 246 | log.debug("Changing IP address for {} to {}", device.getMACAddressString(), |
| 247 | device.getIPv4Addresses()); |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 248 | IDeviceObject obj; |
| 249 | try { |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 250 | if ((obj = ope.searchDevice(device.getMACAddressString())) != null) { |
Jonathan Hart | c8ae36c | 2013-11-03 19:06:40 -0800 | [diff] [blame] | 251 | changeDeviceIpv4Addresses(device, obj); |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 252 | |
| 253 | ope.commit(); |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 254 | } else { |
| 255 | log.error(":changeDeviceIPv4Address mac:{} failed", device.getMACAddressString()); |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 256 | } |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 257 | } catch (TitanException e) { |
Teru | 87cd2da | 2013-06-15 20:33:08 -0700 | [diff] [blame] | 258 | ope.rollback(); |
Jonathan Hart | d6ed62b | 2013-11-01 13:18:25 -0700 | [diff] [blame] | 259 | log.error(":changeDeviceIPv4Address mac:{} failed due to exception {}", device.getMACAddressString(), e); |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 260 | } |
| 261 | } |
Jonathan Hart | c8ae36c | 2013-11-03 19:06:40 -0800 | [diff] [blame] | 262 | |
| 263 | private void changeDeviceIpv4Addresses(IDevice device, IDeviceObject deviceObject) { |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 264 | List<String> dbIpv4Addresses = new ArrayList<String>(); |
| 265 | for (IIpv4Address ipv4Vertex : deviceObject.getIpv4Addresses()) { |
| 266 | dbIpv4Addresses.add(InetAddresses.fromInteger(ipv4Vertex.getIpv4Address()).getHostAddress()); |
| 267 | } |
| 268 | |
| 269 | List<String> memIpv4Addresses = new ArrayList<String>(); |
| 270 | for (int addr : device.getIPv4Addresses()) { |
| 271 | memIpv4Addresses.add(InetAddresses.fromInteger(addr).getHostAddress()); |
| 272 | } |
| 273 | |
| 274 | log.debug("Device IP addresses {}, database IP addresses {}", |
| 275 | memIpv4Addresses, dbIpv4Addresses); |
| 276 | |
Jonathan Hart | c8ae36c | 2013-11-03 19:06:40 -0800 | [diff] [blame] | 277 | for (int ipv4Address : device.getIPv4Addresses()) { |
| 278 | if (deviceObject.getIpv4Address(ipv4Address) == null) { |
| 279 | IIpv4Address dbIpv4Address = ope.ensureIpv4Address(ipv4Address); |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 280 | |
| 281 | IDeviceObject oldDevice = dbIpv4Address.getDevice(); |
| 282 | if (oldDevice != null) { |
| 283 | oldDevice.removeIpv4Address(dbIpv4Address); |
| 284 | } |
| 285 | |
| 286 | log.debug("Adding IP address {}", |
| 287 | InetAddresses.fromInteger(ipv4Address).getHostAddress()); |
Jonathan Hart | c8ae36c | 2013-11-03 19:06:40 -0800 | [diff] [blame] | 288 | deviceObject.addIpv4Address(dbIpv4Address); |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | List<Integer> deviceIpv4Addresses = Arrays.asList(device.getIPv4Addresses()); |
| 293 | for (IIpv4Address dbIpv4Address : deviceObject.getIpv4Addresses()) { |
| 294 | if (!deviceIpv4Addresses.contains(dbIpv4Address.getIpv4Address())) { |
Jonathan Hart | 1a6f1d6 | 2013-11-14 11:33:46 -0800 | [diff] [blame] | 295 | log.debug("Removing IP address {}", |
| 296 | InetAddresses.fromInteger(dbIpv4Address.getIpv4Address()) |
| 297 | .getHostAddress()); |
Jonathan Hart | c8ae36c | 2013-11-03 19:06:40 -0800 | [diff] [blame] | 298 | deviceObject.removeIpv4Address(dbIpv4Address); |
| 299 | } |
| 300 | } |
| 301 | } |
Pankaj Berde | da80957 | 2013-02-22 15:31:20 -0800 | [diff] [blame] | 302 | |
Pankaj Berde | b603134 | 2013-02-19 18:51:51 -0800 | [diff] [blame] | 303 | } |