use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project netvirt by opendaylight.
the class StatisticsImpl method acquireElementCountersRequestHandler.
@Override
public ListenableFuture<RpcResult<AcquireElementCountersRequestHandlerOutput>> acquireElementCountersRequestHandler(AcquireElementCountersRequestHandlerInput input) {
AcquireElementCountersRequestHandlerOutputBuilder aecrhob = new AcquireElementCountersRequestHandlerOutputBuilder();
UUID randomNumber = UUID.randomUUID();
Integer intRequestKey = allocateId(randomNumber.toString());
if (intRequestKey == null) {
LOG.warn("failed generating unique request identifier");
statisticsCounters.failedGeneratingUniqueRequestId();
return RpcResultBuilder.<AcquireElementCountersRequestHandlerOutput>failed().withError(ErrorType.APPLICATION, "failed generating unique request identifier").buildFuture();
}
String requestKey = String.valueOf(intRequestKey);
SettableFuture<RpcResult<AcquireElementCountersRequestHandlerOutput>> result = SettableFuture.create();
LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(transaction -> {
if (input.getIncomingTraffic() != null) {
Optional<EgressElementCountersRequestConfig> eecrcOpt = transaction.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.EECRC_IDENTIFIER).get();
if (!eecrcOpt.isPresent()) {
LOG.warn("failed creating incoming traffic counter request data container in DB");
statisticsCounters.failedCreatingEgressCounterDataConfig();
result.setFuture(RpcResultBuilder.<AcquireElementCountersRequestHandlerOutput>failed().withError(ErrorType.APPLICATION, "failed creating egress counter request data container in DB").buildFuture());
return;
}
if (!isIdenticalCounterRequestExist(input.getPortId(), ElementCountersDirection.EGRESS.toString(), input.getIncomingTraffic().getFilters(), eecrcOpt.get().getCounterRequests())) {
installCounterSpecificRules(input.getPortId(), getLportTag(input.getPortId()), getDpn(input.getPortId()), ElementCountersDirection.EGRESS, input.getIncomingTraffic().getFilters());
}
putEgressElementCounterRequestInConfig(input, ElementCountersDirection.EGRESS, transaction, requestKey, CountersServiceUtils.EECRC_IDENTIFIER, eecrcOpt, randomNumber.toString());
aecrhob.setIncomingTrafficHandler(requestKey);
bindCountersServiceIfUnbound(input.getPortId(), ElementCountersDirection.EGRESS);
}
if (input.getOutgoingTraffic() != null) {
Optional<IngressElementCountersRequestConfig> iecrcOpt = transaction.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.IECRC_IDENTIFIER).get();
if (!iecrcOpt.isPresent()) {
LOG.warn("failed creating outgoing traffc counter request data container in DB");
statisticsCounters.failedCreatingIngressCounterDataConfig();
result.setFuture(RpcResultBuilder.<AcquireElementCountersRequestHandlerOutput>failed().withError(ErrorType.APPLICATION, "failed creating ingress counter request data container in DB").buildFuture());
return;
}
if (!isIdenticalCounterRequestExist(input.getPortId(), ElementCountersDirection.INGRESS.toString(), input.getOutgoingTraffic().getFilters(), iecrcOpt.get().getCounterRequests())) {
installCounterSpecificRules(input.getPortId(), getLportTag(input.getPortId()), getDpn(input.getPortId()), ElementCountersDirection.INGRESS, input.getOutgoingTraffic().getFilters());
}
putIngressElementCounterRequestInConfig(input, ElementCountersDirection.INGRESS, transaction, requestKey, CountersServiceUtils.IECRC_IDENTIFIER, iecrcOpt, randomNumber.toString());
aecrhob.setIncomingTrafficHandler(requestKey);
bindCountersServiceIfUnbound(input.getPortId(), ElementCountersDirection.INGRESS);
result.setFuture(RpcResultBuilder.success(aecrhob.build()).buildFuture());
}
}), LOG, "Error acquiring element counters");
return result;
}
use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project netvirt by opendaylight.
the class ShowFibCommand method doExecute.
@Override
@Nullable
protected Object doExecute() {
PrintStream console = session.getConsole();
if (prefixOrSubnetOption != null && prefixOrSubnetOption.length() > 0) {
prefixOrSubnet = prefixOrSubnetOption.replace("[", "");
prefixOrSubnet = prefixOrSubnet.replace("]", "");
if (!prefixOrSubnet.contains("/")) {
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);
Map<VrfTablesKey, VrfTables> keyVrfTablesMap = fibEntries.getVrfTables();
if (keyVrfTablesMap == null || keyVrfTablesMap.isEmpty()) {
console.println(" No Fib entries found");
return null;
}
for (VrfTables vrfTable : keyVrfTablesMap.values()) {
printVrfTable(vrfTable, console);
}
} catch (ExpectedDataObjectNotFoundException e404) {
/* This is always thrown the first time FIB DS is accessed,
and no route have yet been configured in it. So, no need to print FATAL on the console.
*/
String errMsg = "FATAL: fib-entries container is missing from MD-SAL";
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);
Map<VrfTablesKey, VrfTables> keyVrfTablesMap = fibEntries.getVrfTables();
if (keyVrfTablesMap == null || keyVrfTablesMap.isEmpty()) {
console.println(" No Fib entries found");
return null;
}
for (VrfTables vrfTable : keyVrfTablesMap.values()) {
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;
}
use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project bgpcep by opendaylight.
the class SimpleXROSubobjectRegistryTest method testUnrecognizedType.
@Test
public void testUnrecognizedType() throws RSVPParsingException {
final int wrongType = 99;
assertNull(this.simpleXROSubobjectRegistry.parseSubobject(wrongType, this.input, false));
final ByteBuf output = Unpooled.EMPTY_BUFFER;
final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new LabelCaseBuilder().build()).build();
this.simpleXROSubobjectRegistry.serializeSubobject(container, output);
assertEquals(0, output.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project bgpcep by opendaylight.
the class SimpleRROSubobjectRegistryTest method testUnrecognizedType.
@Test
public void testUnrecognizedType() throws RSVPParsingException {
final int wrongType = 99;
assertNull(this.simpleRROSubobjectRegistry.parseSubobject(wrongType, this.input));
final ByteBuf output = Unpooled.EMPTY_BUFFER;
final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new LabelCaseBuilder().build()).build();
this.simpleRROSubobjectRegistry.serializeSubobject(container, output);
assertEquals(0, output.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project bgpcep by opendaylight.
the class SimpleRROSubobjectRegistryTest method testSerializerRegistration.
@Test
public void testSerializerRegistration() {
assertNotNull(this.simpleRROSubobjectRegistry.registerSubobjectSerializer(LabelCase.class, this.rroSubobjectSerializer));
final ByteBuf output = Unpooled.buffer();
final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new LabelCaseBuilder().build()).build();
this.simpleRROSubobjectRegistry.serializeSubobject(container, output);
assertEquals(1, output.readableBytes());
}
Aggregations