Print out physnet bridge information of kubevirt via CLI
Change-Id: I02b55ce4e455ef6df11462334414675bcb5ccfcf
(cherry picked from commit ffd3e0af7e8cc84e9b520367b76cb203fa1f69fe)
diff --git a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/cli/KubevirtCheckNodeCommand.java b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/cli/KubevirtCheckNodeCommand.java
index 3df42bb..975da59 100644
--- a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/cli/KubevirtCheckNodeCommand.java
+++ b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/cli/KubevirtCheckNodeCommand.java
@@ -22,6 +22,7 @@
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.kubevirtnode.api.KubevirtNode;
import org.onosproject.kubevirtnode.api.KubevirtNodeService;
+import org.onosproject.kubevirtnode.api.KubevirtPhyInterface;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Port;
@@ -51,6 +52,8 @@
private static final String MSG_PASS = "PASS";
private static final String MSG_FAIL = "FAIL";
+ private static final String BRIDGE_PREFIX = "br-";
+
@Override
protected void doExecute() throws Exception {
KubevirtNodeService nodeService = get(KubevirtNodeService.class);
@@ -91,6 +94,23 @@
printPortState(deviceService, node.tunBridge(), STT);
}
}
+
+ if (node.phyIntfs().size() > 0) {
+ print("");
+ print("[Physical Network Bridge Status]");
+ for (KubevirtPhyInterface phyIntf : node.phyIntfs()) {
+ Device physBridge = deviceService.getDevice(phyIntf.physBridge());
+ if (physBridge != null) {
+ print("%s %s=%s available=%s %s",
+ deviceService.isAvailable(physBridge.id()) ? MSG_PASS : MSG_FAIL,
+ BRIDGE_PREFIX + phyIntf.network(),
+ physBridge.id(),
+ deviceService.isAvailable(physBridge.id()),
+ physBridge.annotations());
+ printPortState(deviceService, physBridge.id(), phyIntf.intf());
+ }
+ }
+ }
}
private void printPortState(DeviceService deviceService,
diff --git a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/KubevirtNodeManager.java b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/KubevirtNodeManager.java
index f16837e..c2b9aad 100644
--- a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/KubevirtNodeManager.java
+++ b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/KubevirtNodeManager.java
@@ -316,9 +316,7 @@
private boolean hasPhyBridge(KubevirtNode node, DeviceId deviceId) {
return node.phyIntfs().stream()
- .filter(phyIntf -> phyIntf.physBridge().equals(deviceId))
- .findAny()
- .isPresent();
+ .anyMatch(phyIntf -> phyIntf.physBridge().equals(deviceId));
}
private boolean hasIntgBridge(DeviceId deviceId, String hostname) {