Search in sources :

Example 6 with ErrorType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.ErrorType in project bgpcep by opendaylight.

the class Stateful07RSVPErrorSpecTlvParser method parseTlv.

@Override
public RsvpErrorSpec parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
    if (buffer == null) {
        return null;
    }
    // throw away contents of length field
    buffer.readUnsignedShort();
    final int classNum = buffer.readUnsignedByte();
    final int classType = buffer.readUnsignedByte();
    ErrorType errorType = null;
    if (classNum == RSVP_ERROR_CLASS_NUM) {
        errorType = parseRsvp(classType, buffer.slice());
    } else if (classNum == USER_ERROR_CLASS_NUM && classType == USER_ERROR_CLASS_TYPE) {
        errorType = parseUserError(buffer.slice());
    }
    return new RsvpErrorSpecBuilder().setErrorType(errorType).build();
}
Also used : ErrorType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.ErrorType) RsvpErrorSpecBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.RsvpErrorSpecBuilder)

Example 7 with ErrorType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.ErrorType in project bgpcep by opendaylight.

the class StatefulRSVPErrorSpecTlvParser method parseTlv.

@Override
public RsvpErrorSpec parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
    if (buffer == null) {
        return null;
    }
    // throw away contents of length field
    buffer.readUnsignedShort();
    final int classNum = buffer.readUnsignedByte();
    final int classType = buffer.readUnsignedByte();
    ErrorType errorType = null;
    if (classNum == RSVP_ERROR_CLASS_NUM) {
        errorType = parseRsvp(classType, buffer.slice());
    } else if (classNum == USER_ERROR_CLASS_NUM && classType == USER_ERROR_CLASS_TYPE) {
        errorType = parseUserError(buffer.slice());
    }
    return new RsvpErrorSpecBuilder().setErrorType(errorType).build();
}
Also used : ErrorType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.rsvp.error.spec.ErrorType) RsvpErrorSpecBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.RsvpErrorSpecBuilder)

Example 8 with ErrorType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.ErrorType in project openflowplugin by opendaylight.

the class OnfExperimenterErrorFactory method deserialize.

@Override
public ErrorMessage deserialize(ByteBuf message) {
    ErrorMessageBuilder builder = new ErrorMessageBuilder();
    builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    builder.setXid(message.readUnsignedInt());
    int type = message.readUnsignedShort();
    ErrorType errorType = ErrorType.forValue(type);
    if (errorType != null && errorType.equals(ErrorType.EXPERIMENTER)) {
        builder.setType(errorType.getIntValue());
        builder.setTypeString(errorType.getName());
    } else {
        LOG.warn("Deserializing other than {} error message with {}", ErrorType.EXPERIMENTER.getName(), this.getClass().getCanonicalName());
        builder.setType(type);
        builder.setTypeString(UNKNOWN_TYPE);
    }
    int code = message.readUnsignedShort();
    OnfExperimenterErrorCode errorCode = OnfExperimenterErrorCode.forValue(code);
    if (errorCode != null) {
        builder.setCode(errorCode.getIntValue());
        builder.setCodeString(errorCode.getName());
    } else {
        builder.setCode(code);
        builder.setCodeString(UNKNOWN_CODE);
    }
    builder.addAugmentation(ExperimenterIdError.class, new ExperimenterIdErrorBuilder().setExperimenter(new ExperimenterId(message.readUnsignedInt())).build());
    if (message.readableBytes() > 0) {
        byte[] data = new byte[message.readableBytes()];
        message.readBytes(data);
        builder.setData(data);
    }
    return builder.build();
}
Also used : ErrorMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder) ErrorType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorType) OnfExperimenterErrorCode(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.OnfExperimenterErrorCode) ExperimenterIdErrorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdErrorBuilder) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)

Example 9 with ErrorType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.ErrorType in project openflowplugin by opendaylight.

the class ErrorMessageFactory method deserialize.

@Override
// FB doesn't recognize Objects.requireNonNull
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public ErrorMessage deserialize(ByteBuf rawMessage) {
    Objects.requireNonNull(registry);
    int startIndex = rawMessage.readerIndex();
    ErrorMessageBuilder builder = new ErrorMessageBuilder();
    builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    int type = rawMessage.readUnsignedShort();
    ErrorType errorType = ErrorType.forValue(type);
    if (ErrorType.EXPERIMENTER.equals(errorType)) {
        OFDeserializer<ErrorMessage> deserializer = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createExperimenterErrorDeserializerKey(EncodeConstants.OF13_VERSION_ID, rawMessage.getUnsignedInt(rawMessage.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES)));
        rawMessage.readerIndex(startIndex);
        return deserializer.deserialize(rawMessage);
    }
    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();
}
Also used : ErrorMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder) ErrorType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorType) ErrorMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 10 with ErrorType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.ErrorType 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 ListenableFuture<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) {
            LOG.debug("dissociateNetworks RPC: VpnId {}, networkList {}", vpnId.getValue(), input.getNetworkId());
            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;
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) DissociateNetworksOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateNetworksOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) DissociateNetworksOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateNetworksOutputBuilder) ExecutionException(java.util.concurrent.ExecutionException) OptimisticLockFailedException(org.opendaylight.mdsal.common.api.OptimisticLockFailedException) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException)

Aggregations

RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)6 ExecutionException (java.util.concurrent.ExecutionException)5 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)5 ArrayList (java.util.ArrayList)4 RpcError (org.opendaylight.yangtools.yang.common.RpcError)4 OptimisticLockFailedException (org.opendaylight.mdsal.common.api.OptimisticLockFailedException)3 TransactionCommitFailedException (org.opendaylight.mdsal.common.api.TransactionCommitFailedException)3 ErrorMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder)3 VpnInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance)2 ErrorType (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorType)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 VpnInstanceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstanceKey)1 AssociateNetworksOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateNetworksOutput)1 AssociateNetworksOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateNetworksOutputBuilder)1 CreateEVPNOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.CreateEVPNOutputBuilder)1 CreateL3VPNOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.CreateL3VPNOutputBuilder)1 DeleteEVPNOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DeleteEVPNOutputBuilder)1 DeleteL3VPNOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DeleteL3VPNOutputBuilder)1 DissociateNetworksOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateNetworksOutput)1 DissociateNetworksOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateNetworksOutputBuilder)1