Show more info in CLIs, don't swallow REST connectivity errors.
Change-Id: I94a5d7029af24fbe586f94c693ff04023e23f8b2
diff --git a/src/main/java/org/opencord/cordvtn/cli/CordVtnNetworkListCommand.java b/src/main/java/org/opencord/cordvtn/cli/CordVtnNetworkListCommand.java
index 27cb32d..1511c9f 100644
--- a/src/main/java/org/opencord/cordvtn/cli/CordVtnNetworkListCommand.java
+++ b/src/main/java/org/opencord/cordvtn/cli/CordVtnNetworkListCommand.java
@@ -36,7 +36,7 @@
description = "Lists all VTN networks")
public class CordVtnNetworkListCommand extends AbstractShellCommand {
- private static final String FORMAT = "%-40s%-30s%-20s%-8s%-20s%s";
+ private static final String FORMAT = "%-40s%-30s%-20s%-8s%-20s%-20s%s";
@Override
protected void execute() {
@@ -51,14 +51,15 @@
print("Failed to list networks in JSON format");
}
} else {
- print(FORMAT, "ID", "Name", "Type", "VNI", "Subnet", "Service IP");
+ print(FORMAT, "ID", "Name", "Type", "VNI", "Subnet", "Service IP", "Providers");
for (ServiceNetwork net: networks) {
print(FORMAT, net.id(),
net.name(),
net.type(),
net.segmentId(),
net.subnet(),
- net.serviceIp());
+ net.serviceIp(),
+ net.providers());
}
}
}
diff --git a/src/main/java/org/opencord/cordvtn/cli/CordVtnPortListCommand.java b/src/main/java/org/opencord/cordvtn/cli/CordVtnPortListCommand.java
index 5ea83da..54ed75a 100644
--- a/src/main/java/org/opencord/cordvtn/cli/CordVtnPortListCommand.java
+++ b/src/main/java/org/opencord/cordvtn/cli/CordVtnPortListCommand.java
@@ -39,7 +39,7 @@
description = "Lists all VTN ports")
public class CordVtnPortListCommand extends AbstractShellCommand {
- private static final String FORMAT = "%-40s%-30s%-20s%-18s%-10s%s";
+ private static final String FORMAT = "%-40s%-40s%-30s%-20s%-18s%-10s%s";
@Argument(name = "networkId", description = "Network ID")
private String networkId = null;
@@ -61,12 +61,13 @@
print("Failed to list networks in JSON format");
}
} else {
- print(FORMAT, "ID", "Name", "MAC", "IP", "VLAN", "WAN IPs");
+ print(FORMAT, "ID", "Network ID", "Name", "MAC", "IP", "VLAN", "WAN IPs");
for (ServicePort port: ports) {
List<String> floatingIps = port.addressPairs().stream()
.map(ip -> ip.ip().toString())
.collect(Collectors.toList());
print(FORMAT, port.id(),
+ port.networkId(),
port.name(),
port.mac(),
port.ip(),
diff --git a/src/main/java/org/opencord/cordvtn/rest/XosVtnNetworkingClient.java b/src/main/java/org/opencord/cordvtn/rest/XosVtnNetworkingClient.java
index 9dbf2cb..73fe855 100644
--- a/src/main/java/org/opencord/cordvtn/rest/XosVtnNetworkingClient.java
+++ b/src/main/java/org/opencord/cordvtn/rest/XosVtnNetworkingClient.java
@@ -76,14 +76,11 @@
private String restGet(String path) {
WebTarget wt = client.target("http://" + endpoint + URL_BASE).path(path);
Invocation.Builder builder = wt.request(JSON_UTF_8.toString());
- try {
- Response response = builder.get();
- if (response.getStatus() != HTTP_OK) {
- log.warn("Failed to get resource {}", endpoint + URL_BASE + path);
- log.warn("reason {}", response.readEntity(String.class));
- return EMPTY_JSON_STRING;
- }
- } catch (javax.ws.rs.ProcessingException e) {
+
+ Response response = builder.get();
+ if (response.getStatus() != HTTP_OK) {
+ log.warn("Failed to get resource {}", endpoint + URL_BASE + path);
+ log.warn("reason {}", response.readEntity(String.class));
return EMPTY_JSON_STRING;
}
return builder.get(String.class);
@@ -94,18 +91,14 @@
Invocation.Builder builder = wt.request(MediaType.APPLICATION_JSON)
.accept(JSON_UTF_8.toString());
- try {
- Response response = builder.put(Entity.entity(request.toString(),
- MediaType.APPLICATION_JSON_TYPE));
- String strResponse = response.readEntity(String.class);
- if (response.getStatus() != HTTP_OK) {
- throw new IllegalArgumentException("Failed to put resource "
- + response.getStatus() + ": " + strResponse);
- }
- return strResponse;
- } catch (javax.ws.rs.ProcessingException e) {
- return EMPTY_JSON_STRING;
+ Response response = builder.put(Entity.entity(request.toString(),
+ MediaType.APPLICATION_JSON_TYPE));
+ String strResponse = response.readEntity(String.class);
+ if (response.getStatus() != HTTP_OK) {
+ throw new IllegalArgumentException("Failed to put resource "
+ + response.getStatus() + ": " + strResponse);
}
+ return strResponse;
}
public void requestSync() {