lishuai

[ONOS-3583] Update VTNRSC's bug:null exception.

Change-Id: I6edbef13270acf75899bccca383602caa5b1a562
...@@ -227,6 +227,10 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi ...@@ -227,6 +227,10 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi
227 checkNotNull(event, EVENT_NOT_NULL); 227 checkNotNull(event, EVENT_NOT_NULL);
228 Host host = event.subject(); 228 Host host = event.subject();
229 String ifaceId = host.annotations().value(IFACEID); 229 String ifaceId = host.annotations().value(IFACEID);
230 + if (ifaceId == null) {
231 + log.error("The ifaceId of Host is null");
232 + return;
233 + }
230 VirtualPortId hPortId = VirtualPortId.portId(ifaceId); 234 VirtualPortId hPortId = VirtualPortId.portId(ifaceId);
231 TenantId tenantId = virtualPortService.getPort(hPortId).tenantId(); 235 TenantId tenantId = virtualPortService.getPort(hPortId).tenantId();
232 DeviceId deviceId = host.location().deviceId(); 236 DeviceId deviceId = host.location().deviceId();
...@@ -477,18 +481,21 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi ...@@ -477,18 +481,21 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi
477 checkNotNull(deviceId, DEVICEID_NOT_NULL); 481 checkNotNull(deviceId, DEVICEID_NOT_NULL);
478 checkNotNull(tenantId, TENANTID_NOT_NULL); 482 checkNotNull(tenantId, TENANTID_NOT_NULL);
479 Set<Host> hostSet = hostService.getConnectedHosts(deviceId); 483 Set<Host> hostSet = hostService.getConnectedHosts(deviceId);
484 + Set<Host> sfcHostSet = new HashSet<Host>();
485 + if (hostSet != null) {
480 for (Host h : hostSet) { 486 for (Host h : hostSet) {
481 String ifaceId = h.annotations().value(IFACEID); 487 String ifaceId = h.annotations().value(IFACEID);
488 + if (ifaceId != null) {
482 VirtualPortId hPortId = VirtualPortId.portId(ifaceId); 489 VirtualPortId hPortId = VirtualPortId.portId(ifaceId);
483 - if (virtualPortService.getPort(hPortId).tenantId() != tenantId) { 490 + if (virtualPortService.getPort(hPortId).tenantId().tenantId()
484 - hostSet.remove(h); 491 + .equals(tenantId.tenantId())
485 - } else { 492 + && isServiceFunction(hPortId)) {
486 - if (!isServiceFunction(hPortId)) { 493 + sfcHostSet.add(h);
487 - hostSet.remove(h); 494 + }
488 } 495 }
489 } 496 }
490 } 497 }
491 - if (hostSet.size() == 1 && hostSet.contains(host)) { 498 + if (sfcHostSet.size() == 1 && sfcHostSet.contains(host)) {
492 return true; 499 return true;
493 } 500 }
494 return false; 501 return false;
...@@ -509,18 +516,21 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi ...@@ -509,18 +516,21 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi
509 checkNotNull(deviceId, DEVICEID_NOT_NULL); 516 checkNotNull(deviceId, DEVICEID_NOT_NULL);
510 checkNotNull(tenantId, TENANTID_NOT_NULL); 517 checkNotNull(tenantId, TENANTID_NOT_NULL);
511 Set<Host> hostSet = hostService.getConnectedHosts(deviceId); 518 Set<Host> hostSet = hostService.getConnectedHosts(deviceId);
519 + Set<Host> sfcHostSet = new HashSet<Host>();
520 + if (hostSet != null) {
512 for (Host h : hostSet) { 521 for (Host h : hostSet) {
513 String ifaceId = h.annotations().value(IFACEID); 522 String ifaceId = h.annotations().value(IFACEID);
523 + if (ifaceId != null) {
514 VirtualPortId hPortId = VirtualPortId.portId(ifaceId); 524 VirtualPortId hPortId = VirtualPortId.portId(ifaceId);
515 - if (virtualPortService.getPort(hPortId).tenantId() != tenantId) { 525 + if (virtualPortService.getPort(hPortId).tenantId().tenantId()
516 - hostSet.remove(h); 526 + .equals(tenantId.tenantId())
517 - } else { 527 + && !isServiceFunction(hPortId)) {
518 - if (isServiceFunction(hPortId)) { 528 + sfcHostSet.add(h);
519 - hostSet.remove(h); 529 + }
520 } 530 }
521 } 531 }
522 } 532 }
523 - if (hostSet.size() == 1 && hostSet.contains(host)) { 533 + if (sfcHostSet.size() == 1 && sfcHostSet.contains(host)) {
524 return true; 534 return true;
525 } 535 }
526 return false; 536 return false;
......