Fixes OpenstackNetworking just sends warn msg when unsupported ovs-based sr-iov event occurs.
Change-Id: I375c55e55be2669224743e1412d02975989e30ad
(cherry picked from commit ec9d11387b6d4955c09d876d163359fe4043fdd9)
diff --git a/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/Constants.java b/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/Constants.java
index e966db1..123cacc 100644
--- a/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/Constants.java
+++ b/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/Constants.java
@@ -57,6 +57,7 @@
public static final String ANNOTATION_PORT_ID = "portId";
public static final String ANNOTATION_CREATE_TIME = "createTime";
public static final String ANNOTATION_SEGMENT_ID = "segId";
+ public static final String UNSUPPORTED_VENDOR = "unsupported_vendor";
public static final int PRIORITY_TUNNEL_TAG_RULE = 30000;
public static final int PRIORITY_FLOATING_INTERNAL = 42000;
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackDirectPortAddCommand.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackDirectPortAddCommand.java
index 399b564..c6ff793 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackDirectPortAddCommand.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackDirectPortAddCommand.java
@@ -27,6 +27,8 @@
import java.util.Optional;
+import static org.onosproject.openstacknetworking.api.Constants.UNSUPPORTED_VENDOR;
+import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getIntfNameFromPciAddress;
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE;
/**
@@ -61,10 +63,13 @@
return;
}
- String intfName = OpenstackNetworkingUtil.getIntfNameFromPciAddress(port);
+ String intfName = getIntfNameFromPciAddress(port);
if (intfName == null) {
log.error("Failed to retrieve interface name from a port {}", portId);
return;
+ } else if (intfName.equals(UNSUPPORTED_VENDOR)) {
+ log.warn("Failed to retrieve interface name from a port {} because of unsupported ovs-based sr-iov");
+ return;
}
if (OpenstackNetworkingUtil.hasIntfAleadyInDevice(osNode.get().intgBridge(),
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenStackSwitchingDirectPortProvider.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenStackSwitchingDirectPortProvider.java
index 14e6aa1..f661f5a 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenStackSwitchingDirectPortProvider.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenStackSwitchingDirectPortProvider.java
@@ -18,11 +18,8 @@
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Modified;
-import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.onlab.util.Tools;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.cluster.ClusterService;
import org.onosproject.cluster.LeadershipService;
@@ -46,11 +43,9 @@
import org.onosproject.ovsdb.controller.OvsdbController;
import org.openstack4j.model.network.Port;
import org.openstack4j.model.network.State;
-import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Dictionary;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
@@ -59,6 +54,7 @@
import static java.lang.Thread.sleep;
import static org.onosproject.openstacknetworking.api.Constants.DIRECT;
import static org.onosproject.openstacknetworking.api.Constants.OPENSTACK_NETWORKING_APP_ID;
+import static org.onosproject.openstacknetworking.api.Constants.UNSUPPORTED_VENDOR;
import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getIntfNameFromPciAddress;
import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.hasIntfAleadyInDevice;
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE;
@@ -68,8 +64,6 @@
public final class OpenStackSwitchingDirectPortProvider {
private final Logger log = LoggerFactory.getLogger(getClass());
- private static final String OVSDB_PORT = "ovsdbPortNum";
- private static final int DEFAULT_OVSDB_PORT = 6640;
private static final String UNBOUND = "unbound";
private static final String PORT_NAME = "portName";
private static final long SLEEP_MS = 3000;
@@ -104,10 +98,6 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected MastershipService mastershipService;
- @Property(name = OVSDB_PORT, intValue = DEFAULT_OVSDB_PORT,
- label = "OVSDB server listen port")
- private int ovsdbPort = DEFAULT_OVSDB_PORT;
-
private final OpenstackNetworkListener openstackNetworkListener = new InternalOpenstackNetworkListener();
private final InternalOpenstackNodeListener internalNodeListener = new InternalOpenstackNodeListener();
@@ -136,17 +126,6 @@
log.info("Stopped");
}
-
- @Modified
- protected void modified(ComponentContext context) {
- Dictionary<?, ?> properties = context.getProperties();
- int updatedOvsdbPort = Tools.getIntegerProperty(properties, OVSDB_PORT);
- if (!Objects.equals(updatedOvsdbPort, ovsdbPort)) {
- ovsdbPort = updatedOvsdbPort;
- }
-
- log.info("Modified");
- }
private void processPortAdded(Port port) {
if (!port.getvNicType().equals(DIRECT)) {
return;
@@ -169,6 +148,9 @@
if (intfName == null) {
log.error("Failed to execute processPortAdded because of null interface name");
return;
+ } else if (intfName.equals(UNSUPPORTED_VENDOR)) {
+ log.warn("Failed to execute processPortAdded because of unsupported vendor for ovs-based sr-iov");
+ return;
}
log.trace("Retrieved interface name: {}", intfName);
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtil.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtil.java
index 32f4fdf..b6937c5 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtil.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtil.java
@@ -74,6 +74,7 @@
import static org.onosproject.openstacknetworking.api.Constants.PCI_VENDOR_INFO;
import static org.onosproject.openstacknetworking.api.Constants.PORT_NAME_PREFIX_VM;
import static org.onosproject.openstacknetworking.api.Constants.PORT_NAME_VHOST_USER_PREFIX_VM;
+import static org.onosproject.openstacknetworking.api.Constants.UNSUPPORTED_VENDOR;
import static org.onosproject.openstacknetworking.api.Constants.portNamePrefixMap;
import static org.openstack4j.core.transport.ObjectMapperSingleton.getContext;
@@ -93,7 +94,6 @@
private static final String DOMAIN_DEFAULT = "default";
private static final String KEYSTONE_V2 = "v2.0";
private static final String KEYSTONE_V3 = "v3";
- private static final String IDENTITY_PATH = "identity/";
private static final String SSL_TYPE = "SSL";
private static final String PROXY_MODE = "proxy";
@@ -324,9 +324,9 @@
String vendorInfoForPort = String.valueOf(port.getProfile().get(PCI_VENDOR_INFO));
if (!portNamePrefixMap().containsKey(vendorInfoForPort)) {
- log.error("Failed to retrieve the interface name because of no port name prefix for vendor ID {}",
+ log.warn("Failed to retrieve the interface name because of unsupported prefix for vendor ID {}",
vendorInfoForPort);
- return null;
+ return UNSUPPORTED_VENDOR;
}
String portNamePrefix = portNamePrefixMap().get(vendorInfoForPort);
@@ -482,7 +482,7 @@
}
private static boolean isDirectPort(String portName) {
- return portNamePrefixMap().values().stream().filter(p -> portName.startsWith(p)).findAny().isPresent();
+ return portNamePrefixMap().values().stream().anyMatch(p -> portName.startsWith(p));
}
/**
diff --git a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtilTest.java b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtilTest.java
index daf0a9a..3545d06 100644
--- a/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtilTest.java
+++ b/apps/openstacknetworking/app/src/test/java/org/onosproject/openstacknetworking/util/OpenstackNetworkingUtilTest.java
@@ -72,6 +72,7 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.onosproject.net.AnnotationKeys.PORT_NAME;
+import static org.onosproject.openstacknetworking.api.Constants.UNSUPPORTED_VENDOR;
import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.addRouterIface;
import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.associatedFloatingIp;
import static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.checkArpMode;
@@ -300,7 +301,7 @@
assertNull(getIntfNameFromPciAddress(openstackPort));
assertEquals(expectedIntfName1, getIntfNameFromPciAddress(openstackSriovPort1));
assertEquals(expectedIntfName2, getIntfNameFromPciAddress(openstackSriovPort2));
- assertNull(getIntfNameFromPciAddress(openstackSriovPort3));
+ assertEquals(UNSUPPORTED_VENDOR, getIntfNameFromPciAddress(openstackSriovPort3));
}
/**