Search in sources :

Example 41 with Device

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.

the class MeterStatisticsToNotificationTransformer method transformToNotification.

/**
 * Transform statistics to notification.
 *
 * @param mpReplyList   raw multipart response from device
 * @param deviceInfo    device state
 * @param ofVersion     device version
 * @param emulatedTxId  emulated transaction Id
 * @param convertorExecutor convertor executor
 * @return notification containing flow stats
 */
public static MeterStatisticsUpdated transformToNotification(final List<MultipartReply> mpReplyList, final DeviceInfo deviceInfo, final OpenflowVersion ofVersion, final TransactionId emulatedTxId, final ConvertorExecutor convertorExecutor) {
    VersionConvertorData data = new VersionConvertorData(deviceInfo.getVersion());
    final var stats = BindingMap.<MeterStatsKey, MeterStats>orderedBuilder();
    for (MultipartReply mpReply : mpReplyList) {
        MultipartReplyMeterCase caseBody = (MultipartReplyMeterCase) mpReply.getMultipartReplyBody();
        MultipartReplyMeter replyBody = caseBody.getMultipartReplyMeter();
        final Optional<List<MeterStats>> meterStatsList = convertorExecutor.convert(replyBody.getMeterStats(), data);
        meterStatsList.ifPresent(stats::addAll);
    }
    return new MeterStatisticsUpdatedBuilder().setId(deviceInfo.getNodeId()).setMoreReplies(Boolean.FALSE).setTransactionId(emulatedTxId).setMeterStats(stats.build()).build();
}
Also used : VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) MeterStats(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats) MultipartReplyMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter) MeterStatisticsUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdatedBuilder) MultipartReplyMeterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) List(java.util.List) MeterStatsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsKey)

Example 42 with Device

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.

the class DeviceInitializationUtil method makeEmptyTables.

/**
 * Create specified number of empty tables on device.
 * FIXME: remove after ovs table features fix
 *
 * @param txFacade   transaction facade
 * @param deviceInfo device info
 * @param nrOfTables number of tables
 */
public static void makeEmptyTables(final TxFacade txFacade, final DeviceInfo deviceInfo, final short nrOfTables) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("About to create {} empty tables for node {}.", nrOfTables, deviceInfo);
    }
    for (int i = 0; i < nrOfTables; i++) {
        final Uint8 tableId = Uint8.valueOf(i);
        txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId)), new TableBuilder().setId(tableId).addAugmentation(new FlowTableStatisticsDataBuilder().build()).build());
    }
}
Also used : Uint8(org.opendaylight.yangtools.yang.common.Uint8) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) FlowTableStatisticsDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsDataBuilder) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) TableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder)

Example 43 with Device

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.

the class AbstractRequestCallbackTest method testOnFailureWithDeviceRequestFailedException.

@Test
public void testOnFailureWithDeviceRequestFailedException() throws Exception {
    ErrorMessage dummyErrorMessage = new ErrorMessageBuilder().build();
    abstractRequestCallback.onFailure(new DeviceRequestFailedException(DUMMY_EXCEPTION_DESCRIPTION, dummyErrorMessage));
    final ListenableFuture futureResult = dummyRequestContext.getFuture();
    RpcError rpcError = provideRpcError(futureResult);
    assertEquals("Device reported error type null code null", rpcError.getMessage());
}
Also used : ErrorMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder) RpcError(org.opendaylight.yangtools.yang.common.RpcError) DeviceRequestFailedException(org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ErrorMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage) Test(org.junit.Test)

Example 44 with Device

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.

the class OF13DeviceInitializer method initializeNodeInformation.

@Override
protected Future<Void> initializeNodeInformation(@NonNull final DeviceContext deviceContext, final boolean switchFeaturesMandatory, final boolean skipTableFeatures, @Nullable final MultipartWriterProvider multipartWriterProvider, @Nullable final ConvertorExecutor convertorExecutor) {
    final ConnectionContext connectionContext = Preconditions.checkNotNull(deviceContext.getPrimaryConnectionContext());
    final DeviceState deviceState = Preconditions.checkNotNull(deviceContext.getDeviceState());
    final DeviceInfo deviceInfo = Preconditions.checkNotNull(deviceContext.getDeviceInfo());
    final Capabilities capabilities = connectionContext.getFeatures().getCapabilities();
    LOG.debug("Setting capabilities for device {}", deviceInfo);
    DeviceStateUtil.setDeviceStateBasedOnV13Capabilities(deviceState, capabilities);
    // First process description reply, write data to DS and write consequent data if successful
    return Futures.transformAsync(requestMultipart(MultipartType.OFPMPDESC, deviceContext), input -> {
        translateAndWriteResult(MultipartType.OFPMPDESC, input.getResult(), deviceContext, multipartWriterProvider, convertorExecutor);
        final List<ListenableFuture<RpcResult<List<OfHeader>>>> futures = new ArrayList<>();
        futures.add(requestAndProcessMultipart(MultipartType.OFPMPMETERFEATURES, deviceContext, skipTableFeatures, multipartWriterProvider, convertorExecutor));
        futures.add(requestAndProcessMultipart(MultipartType.OFPMPGROUPFEATURES, deviceContext, skipTableFeatures, multipartWriterProvider, convertorExecutor));
        futures.add(requestAndProcessMultipart(MultipartType.OFPMPTABLEFEATURES, deviceContext, skipTableFeatures, multipartWriterProvider, convertorExecutor));
        futures.add(requestAndProcessMultipart(MultipartType.OFPMPPORTDESC, deviceContext, skipTableFeatures, multipartWriterProvider, convertorExecutor));
        return Futures.transform(switchFeaturesMandatory ? Futures.allAsList(futures) : Futures.successfulAsList(futures), input1 -> {
            LOG.info("Static node {} successfully finished collecting", deviceContext.getDeviceInfo());
            return null;
        }, MoreExecutors.directExecutor());
    }, MoreExecutors.directExecutor());
}
Also used : DeviceState(org.opendaylight.openflowplugin.api.openflow.device.DeviceState) Capabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities) DeviceInfo(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ArrayList(java.util.ArrayList) List(java.util.List) ConnectionContext(org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext)

Example 45 with Device

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.

the class SalExperimenterMessageServiceImpl method buildRequest.

@Override
protected OfHeader buildRequest(Xid xid, SendExperimenterInput input) throws ServiceException {
    final TypeVersionKey key = new TypeVersionKey(input.getExperimenterMessageOfChoice().implementedInterface(), getVersion());
    final ConverterMessageToOFJava<ExperimenterMessageOfChoice, ExperimenterDataOfChoice, ExtensionConvertorData> messageConverter = extensionConverterProvider.getMessageConverter(key);
    if (messageConverter == null) {
        LOG.warn("Unable to find message converter for experimenter xid {} for device {}", xid, extractDatapathId(input.getNode()));
        throw new ServiceException(new ConverterNotFoundException(key.toString()));
    }
    final ExperimenterInputBuilder experimenterInputBld;
    try {
        final ExtensionConvertorData data = new ExtensionConvertorData(OFConstants.OFP_VERSION_1_3);
        data.setXid(xid.getValue());
        data.setDatapathId(extractDatapathId(input.getNode()));
        experimenterInputBld = new ExperimenterInputBuilder().setExperimenter(messageConverter.getExperimenterId()).setExpType(messageConverter.getType()).setExperimenterDataOfChoice(messageConverter.convert(input.getExperimenterMessageOfChoice(), data)).setVersion(getVersion()).setXid(xid.getValue());
    } catch (ConversionException e) {
        LOG.warn("Error while building experimenter message with id {} and xid {} for device {}", messageConverter.getExperimenterId(), xid, extractDatapathId(input.getNode()), e);
        throw new ServiceException(e);
    }
    return experimenterInputBld.build();
}
Also used : TypeVersionKey(org.opendaylight.openflowplugin.extension.api.TypeVersionKey) ConversionException(org.opendaylight.openflowplugin.extension.api.exception.ConversionException) ExperimenterInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder) ServiceException(org.opendaylight.openflowplugin.impl.services.util.ServiceException) ExtensionConvertorData(org.opendaylight.openflowplugin.extension.api.ExtensionConvertorData) ExperimenterMessageOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice) ConverterNotFoundException(org.opendaylight.openflowplugin.extension.api.exception.ConverterNotFoundException) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice)

Aggregations

ArrayList (java.util.ArrayList)50 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)34 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)30 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)29 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)25 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)24 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)24 List (java.util.List)21 ExecutionException (java.util.concurrent.ExecutionException)18 Collection (java.util.Collection)16 Map (java.util.Map)16 Collections (java.util.Collections)15 HashMap (java.util.HashMap)15 Test (org.junit.Test)14 BigInteger (java.math.BigInteger)13 Set (java.util.Set)13 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)13 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)12 Logger (org.slf4j.Logger)12 LoggerFactory (org.slf4j.LoggerFactory)12