use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.Errors in project netvirt by opendaylight.
the class AclServiceUtils method allocateId.
public static Integer allocateId(IdManagerService idManager, String poolName, String idKey, Integer defaultId) {
AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(poolName).setIdKey(idKey).build();
try {
Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
RpcResult<AllocateIdOutput> rpcResult = result.get();
if (rpcResult.isSuccessful()) {
Integer allocatedId = rpcResult.getResult().getIdValue().intValue();
LOG.debug("Allocated ACL ID: {} with key: {} into pool: {}", allocatedId, idKey, poolName);
return allocatedId;
} else {
LOG.error("RPC Call to Get Unique Id for key {} from pool {} returned with Errors {}", idKey, poolName, rpcResult.getErrors());
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Exception when getting Unique Id for key {} from pool {} ", idKey, poolName, e);
}
return defaultId;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.Errors in project netvirt by opendaylight.
the class NeutronvpnUtils method getUniqueRDId.
protected Integer getUniqueRDId(String poolName, String idKey) {
AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(poolName).setIdKey(idKey).build();
try {
Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
RpcResult<AllocateIdOutput> rpcResult = result.get();
if (rpcResult.isSuccessful()) {
return rpcResult.getResult().getIdValue().intValue();
} else {
LOG.error("RPC call to get unique ID for pool name {} with ID key {} returned with errors {}", poolName, idKey, rpcResult.getErrors());
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Exception when getting Unique Id for poolname {} and ID Key {}", poolName, idKey, e);
}
LOG.error("getUniqueRdId: Failed to return ID for poolname {} and ID Key {}", poolName, idKey);
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.Errors in project netvirt by opendaylight.
the class NeutronvpnUtils method releaseRDId.
protected void releaseRDId(String poolName, String idKey) {
ReleaseIdInput idInput = new ReleaseIdInputBuilder().setPoolName(poolName).setIdKey(idKey).build();
try {
Future<RpcResult<Void>> result = idManager.releaseId(idInput);
RpcResult<Void> rpcResult = result.get();
if (!rpcResult.isSuccessful()) {
LOG.error("RPC Call to Get Unique Id returned with errors for poolname {} and ID Key {}: {}", poolName, idKey, rpcResult.getErrors());
} else {
LOG.info("ID {} for RD released successfully", idKey);
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Exception when trying to release ID for poolname {} and ID Key {}", poolName, idKey, e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.Errors in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testQueueSerialize.
@Test
public void testQueueSerialize() throws Exception {
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setFlags(new MultipartRequestFlags(true));
builder.setType(MultipartType.forValue(5));
MultipartReplyQueueCaseBuilder queueCase = new MultipartReplyQueueCaseBuilder();
MultipartReplyQueueBuilder queue = new MultipartReplyQueueBuilder();
queue.setQueueStats(createQueueStats());
queueCase.setMultipartReplyQueue(queue.build());
builder.setMultipartReplyBody(queueCase.build());
MultipartReplyMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 56);
Assert.assertEquals("Wrong type", MultipartType.OFPMPQUEUE.getIntValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
serializedBuffer.skipBytes(PADDING);
MultipartReplyQueueCase body = (MultipartReplyQueueCase) message.getMultipartReplyBody();
MultipartReplyQueue messageOutput = body.getMultipartReplyQueue();
QueueStats queueStats = messageOutput.getQueueStats().get(0);
Assert.assertEquals("Wrong PortNo", queueStats.getPortNo().intValue(), serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong queue id", queueStats.getQueueId().intValue(), serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong tx bytes", queueStats.getTxBytes().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong tx packets", queueStats.getTxPackets().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong tx errors", queueStats.getTxErrors().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong duration sec", queueStats.getDurationSec().intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong duration nsec", queueStats.getDurationNsec().intValue(), serializedBuffer.readInt());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.Errors in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testPortStatsSerialize.
@Test
public void testPortStatsSerialize() throws Exception {
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setFlags(new MultipartRequestFlags(true));
builder.setType(MultipartType.forValue(4));
MultipartReplyPortStatsCaseBuilder portStatsCase = new MultipartReplyPortStatsCaseBuilder();
MultipartReplyPortStatsBuilder portStats = new MultipartReplyPortStatsBuilder();
portStats.setPortStats(createPortStats());
portStatsCase.setMultipartReplyPortStats(portStats.build());
builder.setMultipartReplyBody(portStatsCase.build());
MultipartReplyMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 128);
Assert.assertEquals("Wrong type", MultipartType.OFPMPPORTSTATS.getIntValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
serializedBuffer.skipBytes(PADDING);
MultipartReplyPortStatsCase body = (MultipartReplyPortStatsCase) message.getMultipartReplyBody();
MultipartReplyPortStats messageOutput = body.getMultipartReplyPortStats();
PortStats portStatsOutput = messageOutput.getPortStats().get(0);
Assert.assertEquals("Wrong port no", portStatsOutput.getPortNo().intValue(), serializedBuffer.readInt());
serializedBuffer.skipBytes(4);
Assert.assertEquals("Wrong rx packets", portStatsOutput.getRxPackets().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong tx packets", portStatsOutput.getTxPackets().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong rx bytes", portStatsOutput.getRxBytes().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong tx bytes", portStatsOutput.getTxBytes().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong rx dropped", portStatsOutput.getRxDropped().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong tx dropped", portStatsOutput.getTxDropped().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong rx errors", portStatsOutput.getRxErrors().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong tx errors", portStatsOutput.getTxErrors().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong rx frame err", portStatsOutput.getRxFrameErr().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong rx over err", portStatsOutput.getRxOverErr().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong rx crc err", portStatsOutput.getRxCrcErr().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong collisions", portStatsOutput.getCollisions().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong duration sec", portStatsOutput.getDurationSec().intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong duration nsec", portStatsOutput.getDurationNsec().intValue(), serializedBuffer.readInt());
}
Aggregations