use of org.opendaylight.genius.datastoreutils.ExpectedDataObjectNotFoundException in project netvirt by opendaylight.
the class ShowFibCommand method doExecute.
@Override
protected Object doExecute() {
PrintStream console = session.getConsole();
if (prefixOrSubnetOption != null && prefixOrSubnetOption.length() > 0) {
prefixOrSubnet = prefixOrSubnetOption.replace("[", "");
prefixOrSubnet = prefixOrSubnet.replace("]", "");
if (prefixOrSubnet.indexOf("/") < 0) {
String maskFull = null;
try {
Inet4Address tempAdd = (Inet4Address) InetAddress.getByName(prefixOrSubnet);
maskFull = "/32";
} catch (SecurityException | UnknownHostException | ClassCastException e) {
maskFull = null;
}
if (maskFull == null) {
try {
Inet6Address tempAdd = (Inet6Address) InetAddress.getByName(prefixOrSubnet);
maskFull = "/128";
} catch (SecurityException | UnknownHostException | ClassCastException e) {
maskFull = null;
}
}
if (maskFull == null) {
console.println("a part of cli " + SUBNET + " is wrong => " + prefixOrSubnet);
return usage(console);
}
prefixOrSubnet += maskFull;
}
}
console.println(HEADER);
if (options == null && prefixOrSubnet == null && (addrFamList == null || addrFamList.isEmpty())) {
InstanceIdentifier<FibEntries> id = InstanceIdentifier.create(FibEntries.class);
try {
FibEntries fibEntries = singleTxDb.syncRead(LogicalDatastoreType.CONFIGURATION, id);
List<VrfTables> vrfTablesList = fibEntries.getVrfTables();
if (vrfTablesList == null || vrfTablesList.isEmpty()) {
console.println(" No Fib entries found");
return null;
}
for (VrfTables vrfTable : vrfTablesList) {
printVrfTable(vrfTable, console);
}
} catch (ExpectedDataObjectNotFoundException e404) {
String errMsg = "FATAL: fib-entries container is missing from MD-SAL";
console.println("\n" + errMsg);
LOG.error(errMsg, e404);
} catch (ReadFailedException rfe) {
String errMsg = "Internal Error occurred while processing vpnservice:fib-show command";
console.println("\n" + errMsg);
LOG.error(errMsg, rfe);
}
return null;
} else {
String optionsLowerCase = options != null ? options.toLowerCase(Locale.getDefault()) : "";
switch(optionsLowerCase) {
case "fullhelp":
return usage(console);
default:
}
if ((addrFamList == null || addrFamList.isEmpty()) && (prefixOrSubnet == null || prefixOrSubnet.indexOf("/") < 5)) {
console.println("any address family is requiered or " + SUBNET + " is wrong");
usage(console);
} else {
boolean isIpv4 = false;
boolean isIpv6 = false;
boolean isL2vpn = false;
if (addrFamList != null && addrFamList.size() > 0) {
for (String addF : addrFamList) {
switch(addF.toLowerCase(Locale.getDefault())) {
case "ipv4":
isIpv4 = true;
break;
case "ipv6":
isIpv6 = true;
break;
case "l2vpn":
isL2vpn = true;
break;
default:
}
}
}
InstanceIdentifier<FibEntries> id = InstanceIdentifier.create(FibEntries.class);
try {
FibEntries fibEntries = singleTxDb.syncRead(LogicalDatastoreType.CONFIGURATION, id);
List<VrfTables> vrfTablesList = fibEntries.getVrfTables();
if (vrfTablesList == null || vrfTablesList.isEmpty()) {
console.println(" No Fib entries found");
return null;
}
for (VrfTables vrfTable : vrfTablesList) {
printVrfTable(vrfTable, console, isIpv4, isIpv6, isL2vpn, prefixOrSubnet);
}
} catch (ExpectedDataObjectNotFoundException e404) {
String errMsg = "FATAL: fib-entries container is missing from MD-SAL";
console.println("\n" + errMsg);
LOG.error(errMsg, e404);
} catch (ReadFailedException rfe) {
String errMsg = "Internal Error occurred while processing vpnservice:fib-show command";
console.println("\n" + errMsg);
LOG.error(errMsg, rfe);
}
return null;
}
}
return null;
}
Aggregations