[ONOS-2873]update VTN's bug: failed to create the VM on different
networks
Change-Id: Ieb0a11a20420a471d897a65561f88709436f198a
diff --git a/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java b/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
index bea0fd5..926809c 100644
--- a/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
+++ b/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
@@ -15,6 +15,14 @@
*/
package org.onosproject.vtnrsc.virtualport.impl;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.stream.Collectors;
+
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -43,13 +51,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* Provides implementation of the VirtualPort APIs.
*/
@@ -131,37 +132,22 @@
@Override
public Collection<VirtualPort> getPorts(TenantNetworkId networkId) {
checkNotNull(networkId, NETWORKID_NOT_NULL);
- Collection<VirtualPort> vPortWithNetworkIds = vPortStore.values();
- for (VirtualPort vPort : vPortWithNetworkIds) {
- if (!vPort.networkId().equals(networkId)) {
- vPortWithNetworkIds.remove(vPort);
- }
- }
- return vPortWithNetworkIds;
+ return vPortStore.values().stream().filter(d -> d.networkId().equals(networkId))
+ .collect(Collectors.toList());
}
@Override
public Collection<VirtualPort> getPorts(TenantId tenantId) {
checkNotNull(tenantId, TENANTID_NOT_NULL);
- Collection<VirtualPort> vPortWithTenantIds = vPortStore.values();
- for (VirtualPort vPort : vPortWithTenantIds) {
- if (!vPort.tenantId().equals(tenantId)) {
- vPortWithTenantIds.remove(vPort);
- }
- }
- return vPortWithTenantIds;
+ return vPortStore.values().stream().filter(d -> d.tenantId().equals(tenantId))
+ .collect(Collectors.toList());
}
@Override
public Collection<VirtualPort> getPorts(DeviceId deviceId) {
checkNotNull(deviceId, DEVICEID_NOT_NULL);
- Collection<VirtualPort> vPortWithDeviceIds = vPortStore.values();
- for (VirtualPort vPort : vPortWithDeviceIds) {
- if (!vPort.deviceId().equals(deviceId)) {
- vPortWithDeviceIds.remove(vPort);
- }
- }
- return vPortWithDeviceIds;
+ return vPortStore.values().stream().filter(d -> d.deviceId().equals(deviceId))
+ .collect(Collectors.toList());
}
@Override