blob: aee9c7ec6d3a1b0a2da94dc8c4ad69804235a8c3 [file] [log] [blame]
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -08001package net.onrc.onos.datastore.topology;
2
3import java.nio.ByteBuffer;
4import java.util.Arrays;
5import java.util.Collection;
6import java.util.Collections;
Yuta HIGUCHI10eebea2014-02-03 10:41:41 -08007import java.util.Iterator;
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -08008import java.util.Map;
9import java.util.HashMap;
10import java.util.Set;
11import java.util.TreeSet;
12
13import net.onrc.onos.datastore.RCObject;
14import net.onrc.onos.datastore.RCTable;
15import net.onrc.onos.datastore.utils.ByteArrayComparator;
16
17import org.slf4j.Logger;
18import org.slf4j.LoggerFactory;
19
20import com.esotericsoftware.kryo.Kryo;
21
Yuta HIGUCHI10eebea2014-02-03 10:41:41 -080022import edu.stanford.ramcloud.JRamCloud;
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -080023import edu.stanford.ramcloud.JRamCloud.ObjectDoesntExistException;
24import edu.stanford.ramcloud.JRamCloud.ObjectExistsException;
25import edu.stanford.ramcloud.JRamCloud.WrongVersionException;
26
27/**
28 * Switch Object in RC.
29 *
30 * @note This class will not maintain invariants. e.g. It will NOT automatically
31 * remove Ports on Switch, when deleting a Switch.
32 *
33 */
34public class RCSwitch extends RCObject {
35 private static final Logger log = LoggerFactory.getLogger(RCSwitch.class);
36
37 private static final ThreadLocal<Kryo> switchKryo = new ThreadLocal<Kryo>() {
38 @Override
39 protected Kryo initialValue() {
40 Kryo kryo = new Kryo();
41 kryo.setRegistrationRequired(true);
42 kryo.setReferences(false);
43 kryo.register(byte[].class);
44 kryo.register(byte[][].class);
45 kryo.register(HashMap.class);
46 // TODO check if we should explicitly specify EnumSerializer
47 kryo.register(STATUS.class);
48 return kryo;
49 }
50 };
51
52 public static final String GLOBAL_SWITCH_TABLE_NAME = "G:Switch";
53
54 // FIXME these should be Enum or some number, not String
55 private static final String PROP_DPID = "dpid";
56 private static final String PROP_STATUS = "status";
57 private static final String PROP_PORT_IDS = "port-ids";
58
59 // must not re-order enum members, ordinal will be sent over wire
60 public enum STATUS {
61 INACTIVE, ACTIVE;
62 }
63
64 private final Long dpid;
65 private STATUS status;
66 private TreeSet<byte[]> portIds;
67 transient private boolean isPortIdsModified;
68
69 public static final int SWITCHID_BYTES = 2 + 8;
70
Yuta HIGUCHI10eebea2014-02-03 10:41:41 -080071 public static byte[] getSwitchID(Long dpid) {
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -080072 if (dpid == null) {
73 throw new IllegalArgumentException("dpid cannot be null");
74 }
75 return ByteBuffer.allocate(SWITCHID_BYTES).putChar('S').putLong(dpid)
76 .array();
77 }
78
79 public static long getDpidFromKey(byte[] key) {
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -080080 return getDpidFromKey(ByteBuffer.wrap(key));
81 }
82
83 public static long getDpidFromKey(ByteBuffer keyBuf) {
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -080084 if (keyBuf.getChar() != 'S') {
85 throw new IllegalArgumentException("Invalid Switch key");
86 }
87 return keyBuf.getLong();
88 }
89
90 // FIXME specify DPID here, or Should caller specify the key it self?
91 // In other words, should layer above have the control of the ID?
92 public RCSwitch(Long dpid) {
Yuta HIGUCHI10eebea2014-02-03 10:41:41 -080093 super(RCTable.getTable(GLOBAL_SWITCH_TABLE_NAME), getSwitchID(dpid));
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -080094
95 this.dpid = dpid;
96 this.status = STATUS.INACTIVE;
97 this.portIds = new TreeSet<>(ByteArrayComparator.BYTEARRAY_COMPARATOR);
98 this.isPortIdsModified = true;
99 }
100
Yuta HIGUCHI10eebea2014-02-03 10:41:41 -0800101 /**
102 * Get an instance from Key.
103 *
104 * @note You need to call `read()` to get the DB content.
105 * @param key
106 * @return RCSwitch instance
107 */
108 public static <SW extends RCObject> SW createFromKey(byte[] key) {
109 @SuppressWarnings("unchecked")
110 SW sw = (SW) new RCSwitch(getDpidFromKey(key));
111 return sw;
112 }
113
114 public static Iterable<RCSwitch> getAllSwitches() {
115 return new SwitchEnumerator();
116 }
117
118 public static class SwitchEnumerator implements Iterable<RCSwitch> {
119
120 @Override
121 public Iterator<RCSwitch> iterator() {
122 return new SwitchIterator();
123 }
124 }
125
126 public static class SwitchIterator extends ObjectIterator<RCSwitch> {
127
128 public SwitchIterator() {
129 super(RCTable.getTable(GLOBAL_SWITCH_TABLE_NAME));
130 }
131
132 @Override
133 public RCSwitch next() {
134 JRamCloud.Object o = enumerator.next();
135 RCSwitch e = RCSwitch.createFromKey(o.key);
136 e.setValueAndDeserialize(o.value, o.version);
137 return e;
138 }
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800139 }
140
141 public STATUS getStatus() {
142 return status;
143 }
144
145 public void setStatus(STATUS status) {
146 this.status = status;
147 getObjectMap().put(PROP_STATUS, status);
148 }
149
150 public Long getDpid() {
151 return dpid;
152 }
153
154 public byte[] getId() {
155 return getKey();
156 }
157
158 public void addPortId(byte[] portId) {
159 // TODO: Should we copy portId, or reference is OK.
160 isPortIdsModified |= portIds.add(portId);
161 }
162
163 public void removePortId(byte[] portId) {
164 isPortIdsModified |= portIds.remove(portId);
165 }
166
167 public void emptyPortIds() {
168 portIds.clear();
169 this.isPortIdsModified = true;
170 }
171
172 public void addAllToPortIds(Collection<byte[]> portIds) {
173 // TODO: Should we copy portId, or reference is OK.
174 isPortIdsModified |= this.portIds.addAll(portIds);
175 }
176
177 /**
178 *
179 * @return Unmodifiable Set view of all the PortIds;
180 */
181 public Set<byte[]> getAllPortIds() {
182 return Collections.unmodifiableSet(portIds);
183 }
184
185 @Override
186 public void serializeAndSetValue() {
187 Map<Object, Object> map = getObjectMap();
188
189 map.put(PROP_DPID, this.dpid);
190 if (isPortIdsModified) {
191 byte[] portIdArray[] = new byte[portIds.size()][];
192 map.put(PROP_PORT_IDS, portIds.toArray(portIdArray));
193 isPortIdsModified = false;
194 }
195
196 serializeAndSetValue(switchKryo.get(), map);
197 }
198
199 @Override
200 public Map<Object, Object> deserializeObjectFromValue() {
201 Map<Object, Object> map = deserializeObjectFromValue(switchKryo.get());
202
203 this.status = (STATUS) map.get(PROP_STATUS);
204
205 if (this.portIds == null) {
206 this.portIds = new TreeSet<>(
207 ByteArrayComparator.BYTEARRAY_COMPARATOR);
208 }
209 byte[] portIdArray[] = (byte[][]) map.get(PROP_PORT_IDS);
210 if (portIdArray != null) {
211 this.portIds.clear();
212 this.portIds.addAll(Arrays.asList(portIdArray));
213 isPortIdsModified = false;
214 } else {
215 // trigger write on next serialize
216 isPortIdsModified = true;
217 }
218 return map;
219 }
220
221 @Override
222 public String toString() {
223 // TODO OUTPUT ALL?
224 return "[RCSwitch 0x" + Long.toHexString(dpid) + " STATUS:" + status
225 + "]";
226 }
227
228 public static void main(String argv[]) {
229 // create active switch 0x1 with 2 ports
230 RCSwitch sw = new RCSwitch(0x1L);
231 sw.setStatus(STATUS.ACTIVE);
232 sw.addPortId("SW0x0001P001".getBytes());
233 sw.addPortId("SW0x0001P002".getBytes());
234
235 try {
236 sw.create();
237 } catch (ObjectExistsException e) {
238 log.debug("Create Switch Failed", e);
239 e.printStackTrace();
240 }
241
242 // read switch 0x1
243 RCSwitch swRead = new RCSwitch(0x1L);
244 try {
245 swRead.read();
246 } catch (ObjectDoesntExistException e) {
247 log.debug("Reading Switch Failed", e);
248 }
249 assert (swRead.getStatus() == STATUS.ACTIVE);
250 for (byte[] portId : swRead.getAllPortIds()) {
251 // bad example code, portId is not expected to be ASCII string
252 log.debug("PortId: {}", new String(portId));
253 }
254 assert (swRead.getAllPortIds().size() == 2);
255
256 // update 0x1
257 swRead.setStatus(STATUS.INACTIVE);
258 swRead.removePortId("SW0x0001P001".getBytes());
259 try {
260 swRead.update();
261 } catch (ObjectDoesntExistException | WrongVersionException e) {
262 log.debug("Updating Switch Failed", e);
263 }
264
265 // read 0x1 again and delete
266 RCSwitch swRead2 = new RCSwitch(0x1L);
267 try {
268 swRead2.read();
269 } catch (ObjectDoesntExistException e) {
270 log.debug("Reading Switch Again Failed", e);
271 }
272 assert (swRead2.getStatus() == STATUS.INACTIVE);
273 for (byte[] portId : swRead2.getAllPortIds()) {
274 // bad example code, portId is not expected to be ASCII string
275 log.debug("PortId: {}", new String(portId));
276 }
277 assert (swRead2.getAllPortIds().size() == 1);
278 try {
279 swRead2.delete();
Yuta HIGUCHIc9ca4ac2014-01-31 19:48:31 -0800280 } catch (ObjectDoesntExistException | WrongVersionException e) {
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800281 log.debug("Deleting Switch Failed", e);
282 }
283
284 RCSwitch swRead3 = new RCSwitch(0x1L);
285 try {
286 swRead3.read();
287 } catch (ObjectDoesntExistException e) {
288 log.debug("Switch not found as expected");
289 }
290
291 topology_setup();
292 topology_walk();
293 topology_delete();
294 }
295
Yuta HIGUCHI10eebea2014-02-03 10:41:41 -0800296 @Deprecated
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800297 private static void topology_setup() {
298 log.debug("topology_setup start.");
299
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800300 // d1 - s1p1 - s1 - s1p2 - s2p1 - s2 - s2p2
301
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800302 RCSwitch sw1 = new RCSwitch(0x1L);
303 sw1.setStatus(STATUS.ACTIVE);
304 try {
305 sw1.create();
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800306 log.debug("Create {}", sw1);
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800307 } catch (ObjectExistsException e) {
308 log.error("Switch creation failed", e);
309 }
310
311 RCPort sw1p1 = new RCPort(0x1L, 1L);
312 sw1p1.setStatus(RCPort.STATUS.ACTIVE);
313 RCPort sw1p2 = new RCPort(0x1L, 2L);
314 sw1p2.setStatus(RCPort.STATUS.ACTIVE);
315 try {
316 sw1p1.create();
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800317 log.debug("Create {}", sw1p1);
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800318 sw1p2.create();
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800319 log.debug("Create {}", sw1p2);
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800320 } catch (ObjectExistsException e) {
321 log.error("Port creation failed", e);
322 }
323
324 sw1.emptyPortIds();
325 sw1.addPortId(sw1p1.getId());
326 sw1.addPortId(sw1p2.getId());
327 try {
328 sw1.update();
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800329 log.debug("Update {} - {}", sw1, sw1.getAllPortIds());
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800330 } catch (ObjectDoesntExistException | WrongVersionException e) {
331 log.error("Switch update failed", e);
332 }
333
334 RCDevice d1 = new RCDevice(new byte[] { 0, 1, 2, 3, 4, 5, 6 });
335 d1.addPortId(sw1p1.getId());
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800336 sw1p1.addDeviceId(d1.getId());
337
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800338 try {
339 d1.create();
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800340 log.debug("Create {}", d1);
341 try {
342 sw1p1.update();
343 } catch (ObjectDoesntExistException | WrongVersionException e) {
344 log.error("Link update failed", e);
345 }
346 log.debug("Create {}", sw1p1);
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800347 } catch (ObjectExistsException e) {
348 log.error("Device creation failed", e);
349 }
350
351 RCSwitch sw2 = new RCSwitch(0x2L);
352 sw2.setStatus(STATUS.ACTIVE);
353 RCPort sw2p1 = new RCPort(0x2L, 1L);
354 sw2p1.setStatus(RCPort.STATUS.ACTIVE);
355 RCPort sw2p2 = new RCPort(0x2L, 2L);
356 sw2p2.setStatus(RCPort.STATUS.ACTIVE);
357
358 sw2.addPortId(sw2p1.getId());
359 sw2.addPortId(sw2p2.getId());
360 sw2.addAllToPortIds(Arrays.asList(sw2p1.getId(), sw2p2.getId()));
361 assert (sw2.getAllPortIds().size() == 2);
362
363 RCDevice d2 = new RCDevice(new byte[] { 6, 5, 4, 3, 2, 1, 0 });
364 d2.addPortId(sw2p2.getId());
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800365 sw2p2.addDeviceId(d2.getId());
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800366
367 try {
368 sw2.create();
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800369 log.debug("Create {}", sw2);
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800370 sw2p1.create();
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800371 log.debug("Create {}", sw2p1);
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800372 sw2p2.create();
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800373 log.debug("Create {}", sw2p2);
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800374 d2.create();
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800375 log.debug("Create {}", d2);
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800376 } catch (ObjectExistsException e) {
377 log.error("One of Switch/Port/Device creation failed", e);
378 }
379
380 RCLink l1 = new RCLink(0x1L, 2L, 0x2L, 1L);
381 l1.setStatus(RCLink.STATUS.ACTIVE);
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800382
383 sw1p2.addLinkId(l1.getId());
384 sw2p1.addLinkId(l1.getId());
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800385 try {
386 l1.create();
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800387 log.debug("Create {}", l1);
388 try {
389 sw1p2.update();
390 log.debug("Update {}", sw1p2);
391 sw2p1.update();
392 log.debug("Update {}", sw2p1);
393 } catch (ObjectDoesntExistException | WrongVersionException e) {
394 log.error("Port update failed", e);
395 }
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800396 } catch (ObjectExistsException e) {
397 log.error("Link creation failed", e);
398 }
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800399
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800400 log.debug("topology_setup end.");
401 }
402
Yuta HIGUCHI10eebea2014-02-03 10:41:41 -0800403 @Deprecated
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800404 private static void topology_walk() {
405 log.debug("topology_walk start.");
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800406
Yuta HIGUCHI10eebea2014-02-03 10:41:41 -0800407 Iterable<RCSwitch> swIt = RCSwitch.getAllSwitches();
408 log.debug("Enumerating Switches start");
409 for (RCSwitch sw : swIt) {
410 log.debug("{}", sw);
411 }
412 log.debug("Enumerating Switches end");
413
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800414 RCSwitch sw1 = new RCSwitch(0x1L);
415 try {
416 sw1.read();
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800417 log.debug("{}", sw1);
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800418 } catch (ObjectDoesntExistException e) {
419 log.error("Reading switch failed", e);
420 }
421
422 assert (sw1.getDpid() == 0x1L);
423 assert (sw1.getStatus() == STATUS.ACTIVE);
424 assert (sw1.getAllPortIds().size() == 2);
425 for (byte[] portId : sw1.getAllPortIds()) {
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800426 RCPort port = RCPort.createFromKey(portId);
427 try {
428 port.read();
429 assert (port.getDpid() == 0x1L);
430 log.debug("Port 0x1:{} - LinkIDs:{} DeviceIDs:{}",
431 port.getNumber(), port.getAllLinkIds(),
432 port.getAllDeviceIds());
433
434 for (byte[] deviceId : port.getAllDeviceIds()) {
435 RCDevice device = RCDevice.createFromKey(deviceId);
436 try {
437 device.read();
438 log.debug("Device {} - PortIDs:{}", device.getMac(),
439 device.getAllPortIds());
440 } catch (ObjectDoesntExistException e) {
441 log.error("Reading Device failed", e);
442 }
443 }
444
445 for (byte[] linkId : port.getAllLinkIds()) {
446 RCLink link = RCLink.createFromKey(linkId);
447 try {
448 link.read();
449 log.debug("Link {}", link);
450 } catch (ObjectDoesntExistException e) {
451 log.error("Reading Link failed", e);
452 }
453 }
454
455 } catch (ObjectDoesntExistException e) {
456 log.error("Reading Port failed", e);
457 }
458 }
459
460 RCSwitch sw2 = new RCSwitch(0x1L);
461 try {
462 sw2.read();
463 log.debug("{}", sw2);
464 } catch (ObjectDoesntExistException e) {
465 log.error("Reading switch failed", e);
466 }
467
468 assert (sw2.getDpid() == 0x2L);
469 assert (sw2.getStatus() == STATUS.ACTIVE);
470 assert (sw2.getAllPortIds().size() == 2);
471 for (byte[] portId : sw2.getAllPortIds()) {
472 RCPort port = RCPort.createFromKey(portId);
473 try {
474 port.read();
475 assert (port.getDpid() == 0x1L);
476 log.debug("Port 0x2:{} - LinkIDs:{} DeviceIDs:{}",
477 port.getNumber(), port.getAllLinkIds(),
478 port.getAllDeviceIds());
479
480 for (byte[] deviceId : port.getAllDeviceIds()) {
481 RCDevice device = RCDevice.createFromKey(deviceId);
482 try {
483 device.read();
484 log.debug("Device {} - PortIDs:{}", device,
485 device.getAllPortIds());
486 } catch (ObjectDoesntExistException e) {
487 log.error("Reading Device failed", e);
488 }
489 }
490
491 for (byte[] linkId : port.getAllLinkIds()) {
492 RCLink link = RCLink.createFromKey(linkId);
493 try {
494 link.read();
495 log.debug("Link {}", link);
496 } catch (ObjectDoesntExistException e) {
497 log.error("Reading Link failed", e);
498 }
499 }
500
501 } catch (ObjectDoesntExistException e) {
502 log.error("Reading Port failed", e);
503 }
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800504 }
505
506 log.debug("topology_walk end.");
507 }
508
Yuta HIGUCHI10eebea2014-02-03 10:41:41 -0800509 @Deprecated
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800510 private static void topology_delete() {
511 log.debug("topology_delete start.");
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800512
513 // TODO implement get all kind of API
514 RCSwitch sw1 = new RCSwitch(0x1L);
515 RCPort sw1p1 = new RCPort(0x1L, 1L);
516 RCPort sw1p2 = new RCPort(0x1L, 2L);
517 RCDevice d1 = new RCDevice(new byte[] { 0, 1, 2, 3, 4, 5, 6 });
518 RCLink l1 = new RCLink(0x1L, 2L, 0x2L, 1L);
519 RCSwitch sw2 = new RCSwitch(0x2L);
520 RCPort sw2p1 = new RCPort(0x2L, 1L);
521 RCPort sw2p2 = new RCPort(0x2L, 2L);
522 RCDevice d2 = new RCDevice(new byte[] { 6, 5, 4, 3, 2, 1, 0 });
523
524 try {
525 sw1.read();
526 sw1.delete();
Yuta HIGUCHIc9ca4ac2014-01-31 19:48:31 -0800527 } catch (ObjectDoesntExistException | WrongVersionException e) {
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800528 log.debug("Delete Switch Failed", e);
529 }
530 try {
531 sw1p1.read();
532 sw1p1.delete();
Yuta HIGUCHIc9ca4ac2014-01-31 19:48:31 -0800533 } catch (ObjectDoesntExistException | WrongVersionException e) {
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800534 log.debug("Delete Port Failed", e);
535 }
536 try {
537 sw1p2.read();
538 sw1p2.delete();
Yuta HIGUCHIc9ca4ac2014-01-31 19:48:31 -0800539 } catch (ObjectDoesntExistException | WrongVersionException e) {
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800540 log.debug("Delete Port Failed", e);
541 }
542 try {
543 d1.read();
544 d1.delete();
Yuta HIGUCHIc9ca4ac2014-01-31 19:48:31 -0800545 } catch (ObjectDoesntExistException | WrongVersionException e) {
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800546 log.debug("Delete Device Failed", e);
547 }
548
549 try {
550 l1.read();
551 l1.delete();
Yuta HIGUCHIc9ca4ac2014-01-31 19:48:31 -0800552 } catch (ObjectDoesntExistException | WrongVersionException e) {
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800553 log.debug("Delete Link Failed", e);
554 }
555
556 try {
557 sw2.read();
558 sw2.delete();
Yuta HIGUCHIc9ca4ac2014-01-31 19:48:31 -0800559 } catch (ObjectDoesntExistException | WrongVersionException e) {
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800560 log.debug("Delete Switch Failed", e);
561 }
562 try {
563 sw2p1.read();
564 sw2p1.delete();
Yuta HIGUCHIc9ca4ac2014-01-31 19:48:31 -0800565 } catch (ObjectDoesntExistException | WrongVersionException e) {
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800566 log.debug("Delete Port Failed", e);
567 }
568 try {
569 sw2p2.read();
570 sw2p2.delete();
Yuta HIGUCHIc9ca4ac2014-01-31 19:48:31 -0800571 } catch (ObjectDoesntExistException | WrongVersionException e) {
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800572 log.debug("Delete Port Failed", e);
573 }
574 try {
575 d2.read();
576 d2.delete();
Yuta HIGUCHIc9ca4ac2014-01-31 19:48:31 -0800577 } catch (ObjectDoesntExistException | WrongVersionException e) {
Yuta HIGUCHIc9d06ef2014-01-31 15:55:12 -0800578 log.debug("Delete Device Failed", e);
579 }
580
Yuta HIGUCHI1ef85c42014-01-29 17:23:21 -0800581 log.debug("topology_delete end.");
582 }
583
584}