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());
}
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()));
}
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()));
}
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()));
}
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();
}
Aggregations