Fix: correct the k8s node type, enhance k8s node check and list cmd
Change-Id: I6da0be677ab4372d7581aa23a6c45dfbfb27ead4
diff --git a/apps/k8s-node/app/src/main/java/org/onosproject/k8snode/cli/K8sNodeCheckCommand.java b/apps/k8s-node/app/src/main/java/org/onosproject/k8snode/cli/K8sNodeCheckCommand.java
index 9879415..69c64b9 100644
--- a/apps/k8s-node/app/src/main/java/org/onosproject/k8snode/cli/K8sNodeCheckCommand.java
+++ b/apps/k8s-node/app/src/main/java/org/onosproject/k8snode/cli/K8sNodeCheckCommand.java
@@ -27,9 +27,12 @@
import org.onosproject.net.Port;
import org.onosproject.net.device.DeviceService;
+import static org.onosproject.k8snode.api.Constants.EXTERNAL_BRIDGE;
import static org.onosproject.k8snode.api.Constants.GENEVE_TUNNEL;
import static org.onosproject.k8snode.api.Constants.GRE_TUNNEL;
import static org.onosproject.k8snode.api.Constants.INTEGRATION_BRIDGE;
+import static org.onosproject.k8snode.api.Constants.INTEGRATION_TO_EXTERNAL_BRIDGE;
+import static org.onosproject.k8snode.api.Constants.PHYSICAL_EXTERNAL_BRIDGE;
import static org.onosproject.k8snode.api.Constants.VXLAN_TUNNEL;
import static org.onosproject.net.AnnotationKeys.PORT_NAME;
@@ -61,14 +64,16 @@
}
print("[Integration Bridge Status]");
- Device device = deviceService.getDevice(node.intgBridge());
- if (device != null) {
+ Device intgBridge = deviceService.getDevice(node.intgBridge());
+ if (intgBridge != null) {
print("%s %s=%s available=%s %s",
- deviceService.isAvailable(device.id()) ? MSG_OK : MSG_ERROR,
+ deviceService.isAvailable(intgBridge.id()) ? MSG_OK : MSG_ERROR,
INTEGRATION_BRIDGE,
- device.id(),
- deviceService.isAvailable(device.id()),
- device.annotations());
+ intgBridge.id(),
+ deviceService.isAvailable(intgBridge.id()),
+ intgBridge.annotations());
+ printPortState(deviceService, node.intgBridge(), INTEGRATION_BRIDGE);
+ printPortState(deviceService, node.intgBridge(), INTEGRATION_TO_EXTERNAL_BRIDGE);
if (node.dataIp() != null) {
printPortState(deviceService, node.intgBridge(), VXLAN_TUNNEL);
printPortState(deviceService, node.intgBridge(), GRE_TUNNEL);
@@ -80,6 +85,24 @@
INTEGRATION_BRIDGE,
node.intgBridge());
}
+
+ print("[External Bridge Status]");
+ Device extBridge = deviceService.getDevice(node.extBridge());
+ if (extBridge != null) {
+ print("%s %s=%s available=%s %s",
+ deviceService.isAvailable(extBridge.id()) ? MSG_OK : MSG_ERROR,
+ EXTERNAL_BRIDGE,
+ extBridge.id(),
+ deviceService.isAvailable(extBridge.id()),
+ extBridge.annotations());
+ printPortState(deviceService, node.extBridge(), EXTERNAL_BRIDGE);
+ printPortState(deviceService, node.extBridge(), PHYSICAL_EXTERNAL_BRIDGE);
+ } else {
+ print("%s %s=%s is not available",
+ MSG_ERROR,
+ EXTERNAL_BRIDGE,
+ node.extBridge());
+ }
}
private void printPortState(DeviceService deviceService,
diff --git a/apps/k8s-node/app/src/main/java/org/onosproject/k8snode/cli/K8sNodeListCommand.java b/apps/k8s-node/app/src/main/java/org/onosproject/k8snode/cli/K8sNodeListCommand.java
index 04601cf..aea2130 100644
--- a/apps/k8s-node/app/src/main/java/org/onosproject/k8snode/cli/K8sNodeListCommand.java
+++ b/apps/k8s-node/app/src/main/java/org/onosproject/k8snode/cli/K8sNodeListCommand.java
@@ -37,7 +37,7 @@
description = "Lists all nodes registered in kubernetes node service")
public class K8sNodeListCommand extends AbstractShellCommand {
- private static final String FORMAT = "%-20s%-15s%-24s%-24s%-20s%-15s";
+ private static final String FORMAT = "%-28s%-15s%-24s%-20s%-15s";
@Override
protected void doExecute() {
@@ -48,13 +48,11 @@
if (outputJson()) {
print("%s", json(nodes));
} else {
- print(FORMAT, "Hostname", "Type", "Integration Bridge",
- "Management IP", "Data IP", "State");
+ print(FORMAT, "Hostname", "Type", "Management IP", "Data IP", "State");
for (K8sNode node : nodes) {
print(FORMAT,
node.hostname(),
node.type(),
- node.intgBridge(),
node.managementIp(),
node.dataIp() != null ? node.dataIp() : "",
node.state());
diff --git a/apps/k8s-node/app/src/main/java/org/onosproject/k8snode/impl/DefaultK8sApiConfigHandler.java b/apps/k8s-node/app/src/main/java/org/onosproject/k8snode/impl/DefaultK8sApiConfigHandler.java
index 7415395..ab04556 100644
--- a/apps/k8s-node/app/src/main/java/org/onosproject/k8snode/impl/DefaultK8sApiConfigHandler.java
+++ b/apps/k8s-node/app/src/main/java/org/onosproject/k8snode/impl/DefaultK8sApiConfigHandler.java
@@ -145,7 +145,7 @@
.filter(l -> l.contains(K8S_ROLE))
.findFirst().orElse(null);
- K8sNode.Type nodeType = MASTER;
+ K8sNode.Type nodeType = MINION;
if (roleStr != null) {
String role = roleStr.split("/")[1];