Search in sources :

Example 1 with CapabilitiesV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10 in project openflowplugin by opendaylight.

the class OF10DeviceInitializer 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 CapabilitiesV10 capabilitiesV10 = connectionContext.getFeatures().getCapabilitiesV10();
    // Set capabilities for this device based on capabilities of connection context
    LOG.debug("Setting capabilities for device {}", deviceInfo);
    DeviceStateUtil.setDeviceStateBasedOnV10Capabilities(deviceState, capabilitiesV10);
    final ListenableFuture<Boolean> future = requestMultipart(MultipartType.OFPMPDESC, deviceContext);
    Futures.addCallback(future, new FutureCallback<Boolean>() {

        @Override
        public void onSuccess(@Nullable final Boolean result) {
            if (Boolean.TRUE.equals(result)) {
                LOG.debug("Creating empty flow capable node: {}", deviceInfo);
                makeEmptyFlowCapableNode(deviceContext, deviceInfo);
                LOG.debug("Creating empty tables for {}", deviceInfo);
                DeviceInitializationUtil.makeEmptyTables(deviceContext, deviceInfo, deviceContext.getPrimaryConnectionContext().getFeatures().getTables());
            }
        }

        @Override
        public void onFailure(@Nonnull final Throwable throwable) {
            LOG.warn("Error occurred in preparation node {} for protocol 1.0", deviceInfo);
            LOG.trace("Error for node {} : ", deviceInfo, throwable);
        }
    }, MoreExecutors.directExecutor());
    return Futures.transform(future, new Function<Boolean, Void>() {

        @Nullable
        @Override
        public Void apply(@Nullable final Boolean input) {
            LOG.debug("Writing physical port information for {}", deviceInfo);
            writePhyPortInformation(deviceContext);
            return null;
        }
    }, MoreExecutors.directExecutor());
}
Also used : DeviceState(org.opendaylight.openflowplugin.api.openflow.device.DeviceState) DeviceInfo(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo) ConnectionContext(org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext) CapabilitiesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10) Nullable(javax.annotation.Nullable)

Example 2 with CapabilitiesV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10 in project openflowplugin by opendaylight.

the class SwitchFeaturesUtilTest method testSwFeaturesCapabilitiesV10.

/**
 * Test method for
 * {@link SwitchFeaturesUtil#buildSwitchFeatures} for OF 1.0 version
 * and switch feature capabilities.
 * .
 */
@Test
public void testSwFeaturesCapabilitiesV10() {
    CapabilitiesV10 capabilities = new CapabilitiesV10(true, false, true, false, true, false, true, false);
    featuresOutputBuilder.setCapabilitiesV10(capabilities).setVersion((short) 1);
    Assert.assertNotNull(swUtil.buildSwitchFeatures(featuresOutputBuilder.build()));
}
Also used : CapabilitiesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10) Test(org.junit.Test)

Example 3 with CapabilitiesV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10 in project openflowplugin by opendaylight.

the class SwitchFeaturesUtilTest method testSwFeaturesCapabilitiesVersionMismatch.

/**
 * Test method for
 * {@link SwitchFeaturesUtil#buildSwitchFeatures} for mismatch between
 * version and switch feature capabilities
 * .
 */
@Test
public void testSwFeaturesCapabilitiesVersionMismatch() {
    CapabilitiesV10 capabilities = new CapabilitiesV10(true, false, true, false, true, false, true, false);
    featuresOutputBuilder.setCapabilitiesV10(capabilities).setCapabilities(null).setVersion((short) 4);
    Assert.assertNull(swUtil.buildSwitchFeatures(featuresOutputBuilder.build()));
}
Also used : CapabilitiesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10) Test(org.junit.Test)

Example 4 with CapabilitiesV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10 in project openflowplugin by opendaylight.

the class SwitchFeaturesUtilTest method testSwFeaturesCapabilitiesNonexistingVersion.

/**
 * Test method for
 * {@link SwitchFeaturesUtil#buildSwitchFeatures} for nonexisting version
 * .
 */
@Test
public void testSwFeaturesCapabilitiesNonexistingVersion() {
    CapabilitiesV10 capabilities = new CapabilitiesV10(true, false, true, false, true, false, true, false);
    featuresOutputBuilder.setCapabilitiesV10(capabilities).setCapabilities(null).setVersion((short) 0);
    Assert.assertNull(swUtil.buildSwitchFeatures(featuresOutputBuilder.build()));
}
Also used : CapabilitiesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10) Test(org.junit.Test)

Example 5 with CapabilitiesV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10 in project openflowplugin by opendaylight.

the class DeviceManagerImplTest method setUp.

@Before
public void setUp() throws Exception {
    when(mockConnectionContext.getNodeId()).thenReturn(DUMMY_NODE_ID);
    when(mockConnectionContext.getFeatures()).thenReturn(mockFeatures);
    when(mockConnectionContext.getConnectionAdapter()).thenReturn(mockedConnectionAdapter);
    when(mockConnectionContext.getDeviceInfo()).thenReturn(deviceInfo);
    when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockConnectionContext);
    when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(DUMMY_IDENTIFIER);
    when(deviceInfo.getNodeId()).thenReturn(DUMMY_NODE_ID);
    when(mockFeatures.getCapabilities()).thenReturn(capabilities);
    when(mockFeatures.getCapabilitiesV10()).thenReturn(capabilitiesV10);
    when(mockFeatures.getDatapathId()).thenReturn(BigInteger.valueOf(21L));
    when(mockedFuture.isDone()).thenReturn(true);
    when(writeTransaction.submit()).thenReturn(mockedFuture);
    when(transactionChain.newWriteOnlyTransaction()).thenReturn(writeTransaction);
    when(dataBroker.createTransactionChain(any(TransactionChainListener.class))).thenReturn(transactionChain);
    when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction);
    deviceManager = new DeviceManagerImpl(new OpenflowProviderConfigBuilder().setBarrierCountLimit(new NonZeroUint16Type(BARRIER_COUNT_LIMIT)).setBarrierIntervalTimeoutLimit(new NonZeroUint32Type(BARRIER_INTERVAL_NANOS)).setGlobalNotificationQuota(TEST_VALUE_GLOBAL_NOTIFICATION_QUOTA).setSwitchFeaturesMandatory(false).setEnableFlowRemovedNotification(true).setSkipTableFeatures(false).setUseSingleLayerSerialization(true).build(), dataBroker, messageIntelligenceAgency, notificationPublishService, new HashedWheelTimer(), convertorExecutor, DeviceInitializerProviderFactory.createDefaultProvider());
    deviceManager.setTranslatorLibrary(translatorLibrary);
    verify(dataBroker).newWriteOnlyTransaction();
    verify(writeTransaction).merge(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
    verify(writeTransaction).submit();
}
Also used : NonZeroUint16Type(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint16Type) OpenflowProviderConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfigBuilder) TransactionChainListener(org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener) NonZeroUint32Type(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint32Type) HashedWheelTimer(io.netty.util.HashedWheelTimer) Before(org.junit.Before)

Aggregations

CapabilitiesV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10)9 Test (org.junit.Test)7 ByteBuf (io.netty.buffer.ByteBuf)3 ActionTypeV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10)3 GetFeaturesOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput)3 Before (org.junit.Before)2 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)2 PhyPort (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort)2 HashedWheelTimer (io.netty.util.HashedWheelTimer)1 Nullable (javax.annotation.Nullable)1 TransactionChainListener (org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener)1 ConnectionContext (org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext)1 DeviceInfo (org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo)1 DeviceState (org.opendaylight.openflowplugin.api.openflow.device.DeviceState)1 Xid (org.opendaylight.openflowplugin.api.openflow.device.Xid)1 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)1 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)1 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)1 PortConfigV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10)1 PortFeaturesV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10)1