mirror of
https://github.com/opennetworkinglab/onos.git
synced 2026-05-10 14:46:10 +02:00
Fix: do not create patch port when it is already existed on bridge
Change-Id: I3d631a91196c66fb987bacafb50985574b980709 (cherry picked from commit 90561b6d5c7a3e738432c90dc94cb0b4ae817392)
This commit is contained in:
parent
b91b0a85f8
commit
f3a3c5acd2
@ -16,7 +16,6 @@
|
||||
package org.onosproject.kubevirtnetworking.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.onlab.osgi.DefaultServiceDirectory;
|
||||
import org.onlab.packet.ARP;
|
||||
import org.onlab.packet.EthType;
|
||||
import org.onlab.packet.Ethernet;
|
||||
@ -64,7 +63,6 @@ import org.onosproject.net.behaviour.DefaultPatchDescription;
|
||||
import org.onosproject.net.behaviour.InterfaceConfig;
|
||||
import org.onosproject.net.behaviour.PatchDescription;
|
||||
import org.onosproject.net.device.DeviceAdminService;
|
||||
import org.onosproject.net.device.DeviceService;
|
||||
import org.onosproject.net.driver.DriverService;
|
||||
import org.onosproject.net.flow.DefaultTrafficSelector;
|
||||
import org.onosproject.net.flow.DefaultTrafficTreatment;
|
||||
@ -302,8 +300,8 @@ public class KubevirtNetworkHandler {
|
||||
String tunToTenantIntf =
|
||||
TUNNEL_TO_TENANT_PREFIX + segmentIdHex(network.segmentId());
|
||||
|
||||
if (!hasPort(DeviceId.deviceId(network.tenantBridgeName()), tenantToTunIntf)) {
|
||||
// tenant bridge -> tunnel bridge
|
||||
if (!hasPort(network.tenantDeviceId(node.hostname()), tenantToTunIntf)) {
|
||||
// patch ports for tenant bridge -> tunnel bridge
|
||||
PatchDescription brTenantTunPatchDesc =
|
||||
DefaultPatchDescription.builder()
|
||||
.deviceId(network.tenantBridgeName())
|
||||
@ -316,7 +314,7 @@ public class KubevirtNetworkHandler {
|
||||
waitFor(1);
|
||||
}
|
||||
|
||||
if (!hasPort(DeviceId.deviceId(TUNNEL_BRIDGE), tunToTenantIntf)) {
|
||||
if (!hasPort(node.tunBridge(), tunToTenantIntf)) {
|
||||
// tunnel bridge -> tenant bridge
|
||||
PatchDescription brTunTenantPatchDesc =
|
||||
DefaultPatchDescription.builder()
|
||||
@ -941,11 +939,12 @@ public class KubevirtNetworkHandler {
|
||||
}
|
||||
|
||||
private boolean hasPort(DeviceId deviceId, String portName) {
|
||||
DeviceService deviceService = DefaultServiceDirectory.getService(DeviceService.class);
|
||||
Port port = deviceService.getPorts(deviceId).stream()
|
||||
.filter(p -> p.isEnabled() &&
|
||||
Objects.equals(p.annotations().value(PORT_NAME), portName))
|
||||
.findAny().orElse(null);
|
||||
log.info("The port {} already existed on device {}", portName, deviceId);
|
||||
|
||||
return port != null;
|
||||
}
|
||||
|
||||
|
||||
@ -335,7 +335,7 @@ public class NetworkAttachmentDefinitionWatcher {
|
||||
return builder.build();
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
log.error("Failed to parse network attachment definition object");
|
||||
log.error("Failed to parse network attachment definition object", e);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user