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);
480 - for (Host h : hostSet) { 484 + Set<Host> sfcHostSet = new HashSet<Host>();
481 - String ifaceId = h.annotations().value(IFACEID); 485 + if (hostSet != null) {
482 - VirtualPortId hPortId = VirtualPortId.portId(ifaceId); 486 + for (Host h : hostSet) {
483 - if (virtualPortService.getPort(hPortId).tenantId() != tenantId) { 487 + String ifaceId = h.annotations().value(IFACEID);
484 - hostSet.remove(h); 488 + if (ifaceId != null) {
485 - } else { 489 + VirtualPortId hPortId = VirtualPortId.portId(ifaceId);
486 - if (!isServiceFunction(hPortId)) { 490 + if (virtualPortService.getPort(hPortId).tenantId().tenantId()
487 - hostSet.remove(h); 491 + .equals(tenantId.tenantId())
492 + && isServiceFunction(hPortId)) {
493 + sfcHostSet.add(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);
512 - for (Host h : hostSet) { 519 + Set<Host> sfcHostSet = new HashSet<Host>();
513 - String ifaceId = h.annotations().value(IFACEID); 520 + if (hostSet != null) {
514 - VirtualPortId hPortId = VirtualPortId.portId(ifaceId); 521 + for (Host h : hostSet) {
515 - if (virtualPortService.getPort(hPortId).tenantId() != tenantId) { 522 + String ifaceId = h.annotations().value(IFACEID);
516 - hostSet.remove(h); 523 + if (ifaceId != null) {
517 - } else { 524 + VirtualPortId hPortId = VirtualPortId.portId(ifaceId);
518 - if (isServiceFunction(hPortId)) { 525 + if (virtualPortService.getPort(hPortId).tenantId().tenantId()
519 - hostSet.remove(h); 526 + .equals(tenantId.tenantId())
527 + && !isServiceFunction(hPortId)) {
528 + sfcHostSet.add(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;
......