Supports Mm5 Interface in KubevirtNode app.
- Adds datacenter and cluster id parameter to KubevirtApiConfig
- Implements related REST API web resource
Change-Id: Ib1b6cbc1dbbe11def4d97d78c2e74b5eeec560dc
diff --git a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/cli/KubevirtListApiConfigsCommand.java b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/cli/KubevirtListApiConfigsCommand.java
index 5b9c268..75d4ced 100644
--- a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/cli/KubevirtListApiConfigsCommand.java
+++ b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/cli/KubevirtListApiConfigsCommand.java
@@ -33,7 +33,7 @@
description = "Lists all KubeVirt API server configs registered to the service")
public class KubevirtListApiConfigsCommand extends AbstractShellCommand {
- private static final String FORMAT = "%-10s%-20s%-10s%-25s%-10s";
+ private static final String FORMAT = "%-10s%-20s%-10s%-25s%-10s%-20s%-20s";
@Override
protected void doExecute() throws Exception {
@@ -43,14 +43,14 @@
if (outputJson()) {
print("%s", json(config));
} else {
- print(FORMAT, "Scheme", "Server IP", "Port", "Controller IP", "State");
+ print(FORMAT, "Scheme", "Server IP", "Port", "Controller IP", "State", "Datacenter ID", "Cluster ID");
String controllerIp = "N/A";
if (config != null) {
if (config.controllerIp() != null) {
controllerIp = config.controllerIp().toString();
}
print(FORMAT, config.scheme().name(), config.ipAddress().toString(),
- config.port(), controllerIp, config.state().name());
+ config.port(), controllerIp, config.state().name(), config.datacenterId(), config.clusterId());
} else {
print("Kubevirt config not found!");
}
diff --git a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/codec/KubevirtApiConfigCodec.java b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/codec/KubevirtApiConfigCodec.java
index 9fc2099..e79843f 100644
--- a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/codec/KubevirtApiConfigCodec.java
+++ b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/codec/KubevirtApiConfigCodec.java
@@ -44,6 +44,8 @@
private static final String SERVICE_FQDN = "serviceFqdn";
private static final String API_SERVER_FQDN = "apiServerFqdn";
private static final String CONTROLLER_IP = "controllerIp";
+ private static final String DATACENTER_ID = "datacenterId";
+ private static final String CLUSTER_ID = "clusterId";
private static final String MISSING_MESSAGE = " is required in KubevirtApiConfig";
@@ -53,7 +55,9 @@
.put(SCHEME, entity.scheme().name())
.put(IP_ADDRESS, entity.ipAddress().toString())
.put(PORT, entity.port())
- .put(STATE, entity.state().name());
+ .put(STATE, entity.state().name())
+ .put(DATACENTER_ID, entity.datacenterId())
+ .put(CLUSTER_ID, entity.clusterId());
if (entity.scheme() == HTTPS) {
node.put(CA_CERT_DATA, entity.caCertData())
@@ -122,6 +126,8 @@
JsonNode serviceFqdn = json.get(SERVICE_FQDN);
JsonNode apiServerFqdn = json.get(API_SERVER_FQDN);
JsonNode controllerIp = json.get(CONTROLLER_IP);
+ JsonNode datacenterId = json.get(DATACENTER_ID);
+ JsonNode clusterId = json.get(CLUSTER_ID);
String token = "";
String caCertData = "";
@@ -186,6 +192,14 @@
builder.controllerIp(IpAddress.valueOf(controllerIp.asText()));
}
+ if (datacenterId != null) {
+ builder.datacenterId(datacenterId.asText());
+ }
+
+ if (clusterId != null) {
+ builder.clusterId(clusterId.asText());
+ }
+
return builder.build();
}
}
diff --git a/apps/kubevirt-node/app/src/main/resources/definitions/KubevirtApiConfig.json b/apps/kubevirt-node/app/src/main/resources/definitions/KubevirtApiConfig.json
index 4e0800d..88c5520 100644
--- a/apps/kubevirt-node/app/src/main/resources/definitions/KubevirtApiConfig.json
+++ b/apps/kubevirt-node/app/src/main/resources/definitions/KubevirtApiConfig.json
@@ -5,7 +5,9 @@
"segmentId",
"scheme",
"ipAddress",
- "port"
+ "port",
+ "datacenterId",
+ "clusterId"
],
"properties": {
"clusterName": {
@@ -27,6 +29,14 @@
"port": {
"type": "integer",
"example": 6443
+ },
+ "datacenterId": {
+ "type": "string",
+ "example": "BD"
+ },
+ "clusterId": {
+ "type": "string",
+ "example": "BD-MEH-CT01"
}
}
}
\ No newline at end of file