use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage in project openflowplugin by opendaylight.
the class ErrorMessageFactoryTest method testWithIncorrectTypeEnum.
/**
* Test of {@link ErrorMessageFactory} for correct translation into POJO.
*/
@Test
public void testWithIncorrectTypeEnum() {
ByteBuf bb = BufferHelper.buildBuffer("00 20 00 05 00 01 02 03");
ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 32, builtByFactory.getType().intValue());
Assert.assertEquals("Wrong code", 5, builtByFactory.getCode().intValue());
Assert.assertEquals("Wrong type string", "UNKNOWN_TYPE", builtByFactory.getTypeString());
Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
Assert.assertArrayEquals("Wrong data", new byte[] { 0x00, 0x01, 0x02, 0x03 }, builtByFactory.getData());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage in project openflowplugin by opendaylight.
the class OF10ErrorMessageFactory method deserialize.
@Override
public ErrorMessage deserialize(ByteBuf rawMessage) {
ErrorMessageBuilder builder = new ErrorMessageBuilder();
builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
int type = rawMessage.readUnsignedShort();
ErrorTypeV10 errorType = ErrorTypeV10.forValue(type);
decodeType(builder, errorType, type);
decodeCode(rawMessage, builder, errorType);
int remainingBytes = rawMessage.readableBytes();
if (remainingBytes > 0) {
byte[] data = new byte[remainingBytes];
rawMessage.readBytes(data);
builder.setData(data);
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage in project openflowplugin by opendaylight.
the class OF10ErrorMessageFactoryTest method testWithoutData2.
/**
* Test of {@link ErrorMessageFactory} for correct translation into POJO.
* - not existing code used
*/
@Test
public void testWithoutData2() {
ByteBuf bb = BufferHelper.buildBuffer("00 00 FF FF");
ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 0, builtByFactory.getType().intValue());
Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
Assert.assertEquals("Wrong type string", "HELLOFAILED", builtByFactory.getTypeString());
Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
Assert.assertNull("Data is not null", builtByFactory.getData());
bb = BufferHelper.buildBuffer("00 01 FF FF");
builtByFactory = BufferHelper.deserialize(errorFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 1, builtByFactory.getType().intValue());
Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
Assert.assertEquals("Wrong type string", "BADREQUEST", builtByFactory.getTypeString());
Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
Assert.assertNull("Data is not null", builtByFactory.getData());
bb = BufferHelper.buildBuffer("00 02 FF FF");
builtByFactory = BufferHelper.deserialize(errorFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 2, builtByFactory.getType().intValue());
Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
Assert.assertEquals("Wrong type string", "BADACTION", builtByFactory.getTypeString());
Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
Assert.assertNull("Data is not null", builtByFactory.getData());
bb = BufferHelper.buildBuffer("00 03 FF FF");
builtByFactory = BufferHelper.deserialize(errorFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 3, builtByFactory.getType().intValue());
Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
Assert.assertEquals("Wrong type string", "FLOWMODFAILED", builtByFactory.getTypeString());
Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
Assert.assertNull("Data is not null", builtByFactory.getData());
bb = BufferHelper.buildBuffer("00 04 FF FF");
builtByFactory = BufferHelper.deserialize(errorFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 4, builtByFactory.getType().intValue());
Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
Assert.assertEquals("Wrong type string", "PORTMODFAILED", builtByFactory.getTypeString());
Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
Assert.assertNull("Data is not null", builtByFactory.getData());
bb = BufferHelper.buildBuffer("00 05 FF FF");
builtByFactory = BufferHelper.deserialize(errorFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 5, builtByFactory.getType().intValue());
Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
Assert.assertEquals("Wrong type string", "QUEUEOPFAILED", builtByFactory.getTypeString());
Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
Assert.assertNull("Data is not null", builtByFactory.getData());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage in project openflowplugin by opendaylight.
the class OF10ErrorMessageFactoryTest method testWithIncorrectTypeEnum.
/**
* Test of {@link OF10ErrorMessageFactory} for correct translation into POJO.
*/
@Test
public void testWithIncorrectTypeEnum() {
ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 05 00 01 02 03");
ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 10, builtByFactory.getType().intValue());
Assert.assertEquals("Wrong code", 5, builtByFactory.getCode().intValue());
Assert.assertEquals("Wrong type string", "UNKNOWN_TYPE", builtByFactory.getTypeString());
Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
Assert.assertArrayEquals("Wrong data", new byte[] { 0x00, 0x01, 0x02, 0x03 }, builtByFactory.getData());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage in project netvirt by opendaylight.
the class NeutronvpnManager method dissociateNetworks.
/**
* It handles the invocations to the neutronvpn:dissociateNetworks RPC method.
*/
@Override
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public Future<RpcResult<DissociateNetworksOutput>> dissociateNetworks(DissociateNetworksInput input) {
DissociateNetworksOutputBuilder opBuilder = new DissociateNetworksOutputBuilder();
SettableFuture<RpcResult<DissociateNetworksOutput>> result = SettableFuture.create();
LOG.debug("dissociateNetworks {}", input);
StringBuilder returnMsg = new StringBuilder();
Uuid vpnId = input.getVpnId();
try {
if (neutronvpnUtils.getVpnMap(vpnId) != null) {
List<Uuid> netIds = input.getNetworkId();
if (netIds != null && !netIds.isEmpty()) {
List<String> failed = dissociateNetworksFromVpn(vpnId, netIds);
if (!failed.isEmpty()) {
returnMsg.append(failed);
}
}
} else {
returnMsg.append("VPN not found : ").append(vpnId.getValue());
}
if (returnMsg.length() != 0) {
opBuilder.setResponse("ErrorType: PROTOCOL, ErrorTag: invalid-value, ErrorMessage: " + formatAndLog(LOG::error, "dissociate Networks to vpn {} failed due to {}", vpnId.getValue(), returnMsg));
result.set(RpcResultBuilder.<DissociateNetworksOutput>success().withResult(opBuilder.build()).build());
} else {
result.set(RpcResultBuilder.<DissociateNetworksOutput>success().build());
}
} catch (Exception ex) {
result.set(RpcResultBuilder.<DissociateNetworksOutput>failed().withError(ErrorType.APPLICATION, formatAndLog(LOG::error, "dissociate Networks to vpn {} failed due to {}", input.getVpnId().getValue(), ex.getMessage(), ex)).build());
}
LOG.debug("dissociateNetworks returns..");
return result;
}
Aggregations