Committed by
Gerrit Code Review
[ONOS-2873]update VTN's bug: failed to create the VM on different
networks Change-Id: Ieb0a11a20420a471d897a65561f88709436f198a
Showing
1 changed file
with
14 additions
and
28 deletions
| ... | @@ -15,6 +15,14 @@ | ... | @@ -15,6 +15,14 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.vtnrsc.virtualport.impl; | 16 | package org.onosproject.vtnrsc.virtualport.impl; |
| 17 | 17 | ||
| 18 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 19 | + | ||
| 20 | +import java.util.Arrays; | ||
| 21 | +import java.util.Collection; | ||
| 22 | +import java.util.Collections; | ||
| 23 | +import java.util.Map; | ||
| 24 | +import java.util.stream.Collectors; | ||
| 25 | + | ||
| 18 | import org.apache.felix.scr.annotations.Activate; | 26 | import org.apache.felix.scr.annotations.Activate; |
| 19 | import org.apache.felix.scr.annotations.Component; | 27 | import org.apache.felix.scr.annotations.Component; |
| 20 | import org.apache.felix.scr.annotations.Deactivate; | 28 | import org.apache.felix.scr.annotations.Deactivate; |
| ... | @@ -43,13 +51,6 @@ import org.onosproject.vtnrsc.virtualport.VirtualPortService; | ... | @@ -43,13 +51,6 @@ import org.onosproject.vtnrsc.virtualport.VirtualPortService; |
| 43 | import org.slf4j.Logger; | 51 | import org.slf4j.Logger; |
| 44 | import org.slf4j.LoggerFactory; | 52 | import org.slf4j.LoggerFactory; |
| 45 | 53 | ||
| 46 | -import java.util.Arrays; | ||
| 47 | -import java.util.Collection; | ||
| 48 | -import java.util.Collections; | ||
| 49 | -import java.util.Map; | ||
| 50 | - | ||
| 51 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
| 52 | - | ||
| 53 | /** | 54 | /** |
| 54 | * Provides implementation of the VirtualPort APIs. | 55 | * Provides implementation of the VirtualPort APIs. |
| 55 | */ | 56 | */ |
| ... | @@ -131,37 +132,22 @@ public class VirtualPortManager implements VirtualPortService { | ... | @@ -131,37 +132,22 @@ public class VirtualPortManager implements VirtualPortService { |
| 131 | @Override | 132 | @Override |
| 132 | public Collection<VirtualPort> getPorts(TenantNetworkId networkId) { | 133 | public Collection<VirtualPort> getPorts(TenantNetworkId networkId) { |
| 133 | checkNotNull(networkId, NETWORKID_NOT_NULL); | 134 | checkNotNull(networkId, NETWORKID_NOT_NULL); |
| 134 | - Collection<VirtualPort> vPortWithNetworkIds = vPortStore.values(); | 135 | + return vPortStore.values().stream().filter(d -> d.networkId().equals(networkId)) |
| 135 | - for (VirtualPort vPort : vPortWithNetworkIds) { | 136 | + .collect(Collectors.toList()); |
| 136 | - if (!vPort.networkId().equals(networkId)) { | ||
| 137 | - vPortWithNetworkIds.remove(vPort); | ||
| 138 | - } | ||
| 139 | - } | ||
| 140 | - return vPortWithNetworkIds; | ||
| 141 | } | 137 | } |
| 142 | 138 | ||
| 143 | @Override | 139 | @Override |
| 144 | public Collection<VirtualPort> getPorts(TenantId tenantId) { | 140 | public Collection<VirtualPort> getPorts(TenantId tenantId) { |
| 145 | checkNotNull(tenantId, TENANTID_NOT_NULL); | 141 | checkNotNull(tenantId, TENANTID_NOT_NULL); |
| 146 | - Collection<VirtualPort> vPortWithTenantIds = vPortStore.values(); | 142 | + return vPortStore.values().stream().filter(d -> d.tenantId().equals(tenantId)) |
| 147 | - for (VirtualPort vPort : vPortWithTenantIds) { | 143 | + .collect(Collectors.toList()); |
| 148 | - if (!vPort.tenantId().equals(tenantId)) { | ||
| 149 | - vPortWithTenantIds.remove(vPort); | ||
| 150 | - } | ||
| 151 | - } | ||
| 152 | - return vPortWithTenantIds; | ||
| 153 | } | 144 | } |
| 154 | 145 | ||
| 155 | @Override | 146 | @Override |
| 156 | public Collection<VirtualPort> getPorts(DeviceId deviceId) { | 147 | public Collection<VirtualPort> getPorts(DeviceId deviceId) { |
| 157 | checkNotNull(deviceId, DEVICEID_NOT_NULL); | 148 | checkNotNull(deviceId, DEVICEID_NOT_NULL); |
| 158 | - Collection<VirtualPort> vPortWithDeviceIds = vPortStore.values(); | 149 | + return vPortStore.values().stream().filter(d -> d.deviceId().equals(deviceId)) |
| 159 | - for (VirtualPort vPort : vPortWithDeviceIds) { | 150 | + .collect(Collectors.toList()); |
| 160 | - if (!vPort.deviceId().equals(deviceId)) { | ||
| 161 | - vPortWithDeviceIds.remove(vPort); | ||
| 162 | - } | ||
| 163 | - } | ||
| 164 | - return vPortWithDeviceIds; | ||
| 165 | } | 151 | } |
| 166 | 152 | ||
| 167 | @Override | 153 | @Override | ... | ... |
-
Please register or login to post a comment