if (flowNode.isPresent()) {
/* Tables - have to be pushed before groups */
// CHECK if while pusing the update, updateTableInput can be null to emulate a table add
- List<Table> tableList = flowNode.get().getTable() != null
- ? flowNode.get().getTable() : Collections.<Table> emptyList() ;
- for (Table table : tableList) {
- TableKey tableKey = table.getKey();
+ List<TableFeatures> tableList = flowNode.get().getTableFeatures() != null
+ ? flowNode.get().getTableFeatures() : Collections.<TableFeatures> emptyList() ;
+ for (TableFeatures tableFeaturesItem : tableList) {
+ TableFeaturesKey tableKey = tableFeaturesItem.getKey();
KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> tableFeaturesII
- = nodeIdent.child(Table.class, tableKey).child(TableFeatures.class, new TableFeaturesKey(tableKey.getId()));
- List<TableFeatures> tableFeatures = table.getTableFeatures();
- if (tableFeatures != null) {
- for (TableFeatures tableFeaturesItem : tableFeatures) {
+ = nodeIdent.child(TableFeatures.class, new TableFeaturesKey(tableKey.getTableId()));
provider.getTableFeaturesCommiter().update(tableFeaturesII, tableFeaturesItem, null, nodeIdent);
- }
- }
}
/* Groups - have to be first */
import java.util.Collections;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
private ListenerRegistration<TableForwarder> listenerRegistration;
- public TableForwarder (final ForwardingRulesManager manager, final DataBroker db) {
+ public TableForwarder(final ForwardingRulesManager manager, final DataBroker db) {
super(manager, TableFeatures.class);
Preconditions.checkNotNull(db, "DataBroker can not be null!");
final DataTreeIdentifier<TableFeatures> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getWildCardPath());
@Override
protected InstanceIdentifier<TableFeatures> getWildCardPath() {
return InstanceIdentifier.create(Nodes.class).child(Node.class)
- .augmentation(FlowCapableNode.class).child(Table.class).child(TableFeatures.class);
+ .augmentation(FlowCapableNode.class).child(TableFeatures.class);
}
@Override
public void remove(final InstanceIdentifier<TableFeatures> identifier, final TableFeatures removeDataObj,
final InstanceIdentifier<FlowCapableNode> nodeIdent) {
- // DO Nothing
+ // DO Nothing
}
@Override
public void update(final InstanceIdentifier<TableFeatures> identifier,
final TableFeatures original, final TableFeatures update,
final InstanceIdentifier<FlowCapableNode> nodeIdent) {
- LOG.debug( "Received the Table Update request [Tbl id, node Id, original, upd" +
- " " + identifier + " " + nodeIdent + " " + original + " " + update );
+ LOG.debug("Received the Table Update request [Tbl id, node Id, original, upd" +
+ " " + identifier + " " + nodeIdent + " " + original + " " + update);
final TableFeatures originalTableFeatures = original;
- TableFeatures updatedTableFeatures ;
- if( null == update)
- updatedTableFeatures = original;
+ TableFeatures updatedTableFeatures;
+ if (null == update)
+ updatedTableFeatures = original;
else
- updatedTableFeatures = update;
+ updatedTableFeatures = update;
final UpdateTableInputBuilder builder = new UpdateTableInputBuilder();
builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
- InstanceIdentifier<Table> iiToTable = identifier.firstIdentifierOf(Table.class);
- builder.setTableRef(new TableRef(iiToTable));
+ // TODO: reconsider model - this particular field is not used in service implementation
+ builder.setTableRef(new TableRef(identifier));
builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
builder.setOriginalTable(new OriginalTableBuilder().setTableFeatures(
Collections.singletonList(originalTableFeatures)).build());
- LOG.debug( "Invoking SalTableService " ) ;
+ LOG.debug("Invoking SalTableService ");
- if( this.provider.getSalTableService() != null )
- LOG.debug( " Handle to SalTableServices" + this.provider.getSalTableService()) ;
+ if (this.provider.getSalTableService() != null)
+ LOG.debug(" Handle to SalTableServices" + this.provider.getSalTableService());
this.provider.getSalTableService().updateTable(builder.build());
}
@Override
public void add(final InstanceIdentifier<TableFeatures> identifier, final TableFeatures addDataObj,
final InstanceIdentifier<FlowCapableNode> nodeIdent) {
- //DO NOthing
+ //DO NOthing
}
@Override
*/
package test.mock;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
+import static org.junit.Assert.assertEquals;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput;
-import test.mock.util.EntityOwnershipServiceMock;
-import test.mock.util.SalTableServiceMock;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
+import java.util.List;
import org.junit.Test;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import test.mock.util.EntityOwnershipServiceMock;
import test.mock.util.FRMTest;
import test.mock.util.RpcProviderRegistryMock;
-import java.util.List;
-import static org.junit.Assert.assertEquals;
+import test.mock.util.SalTableServiceMock;
public class TableFeaturesListenerTest extends FRMTest {
RpcProviderRegistry rpcProviderRegistryMock = new RpcProviderRegistryMock();
TableFeatures tableFeaturesData = new TableFeaturesBuilder().setKey(tableFeaturesKey).build();
InstanceIdentifier<TableFeatures> tableFeaturesII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
- .augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(TableFeatures.class, tableFeaturesKey);
+ .augmentation(FlowCapableNode.class).child(TableFeatures.class, tableFeaturesKey);
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, tableFeaturesII, tableFeaturesData);
assertCommit(writeTx.submit());
package org.opendaylight.openflowplugin.applications.inventory.manager;
import com.google.common.base.Preconditions;
+import java.util.List;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.TableUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.List;
-
/**
* Class receives and processes table feature updates. It augment table feature on table node
* in the inventory tree (node/table/{table-id}).
for (final TableFeatures tableFeatureData : swTablesFeatures) {
final Short tableId = tableFeatureData.getTableId();
final KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> tableFeaturesII = flowCapableNodeII
- .child(Table.class, new TableKey(tableId))
.child(TableFeatures.class,new TableFeaturesKey(tableId));
LOG.trace("Updating table feature for table {} of node {}", tableId, nodeId.getValue());
type uint8;
}
- uses table:table-features;
-
list flow {
key "id";
}
uses tables;
+ uses table:table-features;
uses group:groups;
uses meters;
uses ip-address-grouping;
revision "2013-12-15" {
description "Initial revision of flow table statistics model";
}
-
+
augment "/inv:nodes/inv:node/flow-node:table" {
description "Openflow flow table statistics data into the table node.";
ext:augment-identifier "flow-table-statistics-data";
uses flow-table-statistics;
}
-
- augment "/inv:nodes/inv:node/flow-node:table" {
- description "Openflow flow table features data into the table node.";
- ext:augment-identifier "node-table-features";
- container table-feature-container {
- uses table-types:table-features;
- }
- }
-
+
grouping flow-table-statistics {
description "TODO:: simplify.";
container flow-table-statistics {
uses stat-types:generic-table-statistics;
}
- }
-
+ }
+
grouping flow-table-and-statistics-map {
status deprecated;
description "RPC calls to fetch flow table statistics.";
uses stat-types:generic-table-statistics;
}
}
-
+
rpc get-flow-tables-statistics {
status deprecated;
description "Fetch statistics of all the flow tables present on the tarnet node";
uses tr:transaction-aware;
}
}
-
+
//Notification to receive table statistics update
-
+
notification flow-table-statistics-update {
status deprecated;
description "Receive flow table statistics update";
-
+
uses inv:node;
uses flow-table-and-statistics-map;
uses tr:multipart-transaction-aware;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesConvertor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesReplyConvertor;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
for (final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures tableFeatureData : salTableFeatures) {
final Short tableId = tableFeatureData.getTableId();
final KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures, TableFeaturesKey> tableFeaturesII = flowCapableNodeII
- .child(Table.class, new TableKey(tableId))
.child(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures.class,
new TableFeaturesKey(tableId));
deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, tableFeaturesII,
package org.opendaylight.openflowplugin.impl.util;
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.AsyncFunction;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
import java.math.BigInteger;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import java.util.concurrent.Future;
-
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.AsyncFunction;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowplugin.api.ConnectionException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsDataBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
final ConnectionContext connectionContext = Preconditions.checkNotNull(deviceContext.getPrimaryConnectionContext());
final short version = deviceState.getVersion();
LOG.trace("initalizeNodeInformation for node {}", deviceState.getNodeId());
- final SettableFuture<Void> returnFuture = SettableFuture.<Void> create();
+ final SettableFuture<Void> returnFuture = SettableFuture.<Void>create();
addNodeToOperDS(deviceContext, returnFuture);
final ListenableFuture<List<RpcResult<List<MultipartReply>>>> deviceFeaturesFuture;
if (OFConstants.OFP_VERSION_1_0 == version) {
Preconditions.checkArgument(deviceContext != null);
final DeviceState deviceState = deviceContext.getDeviceState();
final NodeBuilder nodeBuilder = new NodeBuilder().setId(deviceState.getNodeId()).setNodeConnector(
- Collections.<NodeConnector> emptyList());
+ Collections.<NodeConnector>emptyList());
try {
deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, deviceState.getNodeInstanceIdentifier(),
nodeBuilder.build());
}
static void translateAndWriteReply(final MultipartType type, final DeviceContext dContext,
- final InstanceIdentifier<Node> nodeII, final Collection<MultipartReply> result) {
+ final InstanceIdentifier<Node> nodeII, final Collection<MultipartReply> result) {
try {
for (final MultipartReply reply : result) {
final MultipartReplyBody body = reply.getMultipartReplyBody();
switch (type) {
- case OFPMPDESC:
- Preconditions.checkArgument(body instanceof MultipartReplyDescCase);
- final MultipartReplyDesc replyDesc = ((MultipartReplyDescCase) body).getMultipartReplyDesc();
- final FlowCapableNode fcNode = NodeStaticReplyTranslatorUtil.nodeDescTranslator(replyDesc,
- getIpAddressOf(dContext));
- final InstanceIdentifier<FlowCapableNode> fNodeII = nodeII.augmentation(FlowCapableNode.class);
- dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, fNodeII, fcNode);
- break;
-
- case OFPMPTABLEFEATURES:
- Preconditions.checkArgument(body instanceof MultipartReplyTableFeaturesCase);
- final MultipartReplyTableFeatures tableFeatures = ((MultipartReplyTableFeaturesCase) body)
- .getMultipartReplyTableFeatures();
- final List<TableFeatures> tables = NodeStaticReplyTranslatorUtil
- .nodeTableFeatureTranslator(tableFeatures);
- for (final TableFeatures table : tables) {
- final Short tableId = table.getTableId();
- final InstanceIdentifier<Table> tableII = nodeII.augmentation(FlowCapableNode.class).child(
- Table.class, new TableKey(tableId));
- final TableBuilder tableBuilder = new TableBuilder().setId(tableId).setTableFeatures(
- Collections.singletonList(table));
- tableBuilder.addAugmentation(FlowTableStatisticsData.class,
- new FlowTableStatisticsDataBuilder().build());
- dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, tableII, tableBuilder.build());
- }
- break;
-
- case OFPMPMETERFEATURES:
- Preconditions.checkArgument(body instanceof MultipartReplyMeterFeaturesCase);
- final MultipartReplyMeterFeatures meterFeatures = ((MultipartReplyMeterFeaturesCase) body)
- .getMultipartReplyMeterFeatures();
- final NodeMeterFeatures mFeature = NodeStaticReplyTranslatorUtil
- .nodeMeterFeatureTranslator(meterFeatures);
- final InstanceIdentifier<NodeMeterFeatures> mFeatureII = nodeII
- .augmentation(NodeMeterFeatures.class);
- dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, mFeatureII, mFeature);
- if (0L < mFeature.getMeterFeatures().getMaxMeter().getValue()) {
- dContext.getDeviceState().setMeterAvailable(true);
- }
- break;
-
- case OFPMPGROUPFEATURES:
- Preconditions.checkArgument(body instanceof MultipartReplyGroupFeaturesCase);
- final MultipartReplyGroupFeatures groupFeatures = ((MultipartReplyGroupFeaturesCase) body)
- .getMultipartReplyGroupFeatures();
- final NodeGroupFeatures gFeature = NodeStaticReplyTranslatorUtil
- .nodeGroupFeatureTranslator(groupFeatures);
- final InstanceIdentifier<NodeGroupFeatures> gFeatureII = nodeII
- .augmentation(NodeGroupFeatures.class);
- dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, gFeatureII, gFeature);
- break;
-
- case OFPMPPORTDESC:
- Preconditions.checkArgument(body instanceof MultipartReplyPortDescCase);
- final MultipartReplyPortDesc portDesc = ((MultipartReplyPortDescCase) body)
- .getMultipartReplyPortDesc();
- for (final PortGrouping port : portDesc.getPorts()) {
- final short ofVersion = dContext.getDeviceState().getVersion();
- final TranslatorKey translatorKey = new TranslatorKey(ofVersion, PortGrouping.class.getName());
- final MessageTranslator<PortGrouping, FlowCapableNodeConnector> translator = dContext.oook()
- .lookupTranslator(translatorKey);
- final FlowCapableNodeConnector fcNodeConnector = translator.translate(port, dContext, null);
-
- final BigInteger dataPathId = dContext.getPrimaryConnectionContext().getFeatures()
- .getDatapathId();
- final NodeConnectorId nodeConnectorId = NodeStaticReplyTranslatorUtil.nodeConnectorId(
- dataPathId.toString(), port.getPortNo(), ofVersion);
- final NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder().setId(nodeConnectorId);
- ncBuilder.addAugmentation(FlowCapableNodeConnector.class, fcNodeConnector);
-
- ncBuilder.addAugmentation(FlowCapableNodeConnectorStatisticsData.class,
- new FlowCapableNodeConnectorStatisticsDataBuilder().build());
- final NodeConnector connector = ncBuilder.build();
-
- final InstanceIdentifier<NodeConnector> connectorII = nodeII.child(NodeConnector.class,
- connector.getKey());
- dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, connectorII, connector);
- }
+ case OFPMPDESC:
+ Preconditions.checkArgument(body instanceof MultipartReplyDescCase);
+ final MultipartReplyDesc replyDesc = ((MultipartReplyDescCase) body).getMultipartReplyDesc();
+ final FlowCapableNode fcNode = NodeStaticReplyTranslatorUtil.nodeDescTranslator(replyDesc,
+ getIpAddressOf(dContext));
+ final InstanceIdentifier<FlowCapableNode> fNodeII = nodeII.augmentation(FlowCapableNode.class);
+ dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, fNodeII, fcNode);
+ break;
+
+ case OFPMPTABLEFEATURES:
+ Preconditions.checkArgument(body instanceof MultipartReplyTableFeaturesCase);
+ final MultipartReplyTableFeatures tableFeaturesMP = ((MultipartReplyTableFeaturesCase) body)
+ .getMultipartReplyTableFeatures();
+ final List<TableFeatures> tableFeatures = NodeStaticReplyTranslatorUtil
+ .nodeTableFeatureTranslator(tableFeaturesMP);
+ for (final TableFeatures tableFeature : tableFeatures) {
+ final Short tableId = tableFeature.getTableId();
+ final KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> tableFeaturesII =
+ nodeII.augmentation(FlowCapableNode.class)
+ .child(TableFeatures.class, new TableFeaturesKey(tableId));
+ dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, tableFeaturesII, tableFeature);
+
+ // write parent for table statistics
+ final KeyedInstanceIdentifier<Table, TableKey> tableII =
+ nodeII.augmentation(FlowCapableNode.class)
+ .child(Table.class, new TableKey(tableId));
+ final TableBuilder tableBld = new TableBuilder().setId(tableId)
+ .addAugmentation(FlowTableStatisticsData.class,
+ new FlowTableStatisticsDataBuilder().build());
+
+ dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, tableII, tableBld.build());
+ }
+ break;
+
+ case OFPMPMETERFEATURES:
+ Preconditions.checkArgument(body instanceof MultipartReplyMeterFeaturesCase);
+ final MultipartReplyMeterFeatures meterFeatures = ((MultipartReplyMeterFeaturesCase) body)
+ .getMultipartReplyMeterFeatures();
+ final NodeMeterFeatures mFeature = NodeStaticReplyTranslatorUtil
+ .nodeMeterFeatureTranslator(meterFeatures);
+ final InstanceIdentifier<NodeMeterFeatures> mFeatureII = nodeII
+ .augmentation(NodeMeterFeatures.class);
+ dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, mFeatureII, mFeature);
+ if (0L < mFeature.getMeterFeatures().getMaxMeter().getValue()) {
+ dContext.getDeviceState().setMeterAvailable(true);
+ }
+ break;
+
+ case OFPMPGROUPFEATURES:
+ Preconditions.checkArgument(body instanceof MultipartReplyGroupFeaturesCase);
+ final MultipartReplyGroupFeatures groupFeatures = ((MultipartReplyGroupFeaturesCase) body)
+ .getMultipartReplyGroupFeatures();
+ final NodeGroupFeatures gFeature = NodeStaticReplyTranslatorUtil
+ .nodeGroupFeatureTranslator(groupFeatures);
+ final InstanceIdentifier<NodeGroupFeatures> gFeatureII = nodeII
+ .augmentation(NodeGroupFeatures.class);
+ dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, gFeatureII, gFeature);
+ break;
+
+ case OFPMPPORTDESC:
+ Preconditions.checkArgument(body instanceof MultipartReplyPortDescCase);
+ final MultipartReplyPortDesc portDesc = ((MultipartReplyPortDescCase) body)
+ .getMultipartReplyPortDesc();
+ for (final PortGrouping port : portDesc.getPorts()) {
+ final short ofVersion = dContext.getDeviceState().getVersion();
+ final TranslatorKey translatorKey = new TranslatorKey(ofVersion, PortGrouping.class.getName());
+ final MessageTranslator<PortGrouping, FlowCapableNodeConnector> translator = dContext.oook()
+ .lookupTranslator(translatorKey);
+ final FlowCapableNodeConnector fcNodeConnector = translator.translate(port, dContext, null);
+
+ final BigInteger dataPathId = dContext.getPrimaryConnectionContext().getFeatures()
+ .getDatapathId();
+ final NodeConnectorId nodeConnectorId = NodeStaticReplyTranslatorUtil.nodeConnectorId(
+ dataPathId.toString(), port.getPortNo(), ofVersion);
+ final NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder().setId(nodeConnectorId);
+ ncBuilder.addAugmentation(FlowCapableNodeConnector.class, fcNodeConnector);
+
+ ncBuilder.addAugmentation(FlowCapableNodeConnectorStatisticsData.class,
+ new FlowCapableNodeConnectorStatisticsDataBuilder().build());
+ final NodeConnector connector = ncBuilder.build();
+
+ final InstanceIdentifier<NodeConnector> connectorII = nodeII.child(NodeConnector.class,
+ connector.getKey());
+ dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, connectorII, connector);
+ }
- break;
+ break;
- default:
- throw new IllegalArgumentException("Unnexpected MultipartType " + type);
+ default:
+ throw new IllegalArgumentException("Unnexpected MultipartType " + type);
}
}
} catch (final Exception e) {
// FIXME : remove after ovs tableFeatures fix
private static void makeEmptyTables(final DeviceContext dContext, final InstanceIdentifier<Node> nodeII,
- final Short nrOfTables) {
+ final Short nrOfTables) {
LOG.debug("About to create {} empty tables.", nrOfTables);
for (int i = 0; i < nrOfTables; i++) {
final short tId = (short) i;
}
static void createSuccessProcessingCallback(final MultipartType type, final DeviceContext deviceContext,
- final InstanceIdentifier<Node> nodeII,
- final ListenableFuture<RpcResult<List<MultipartReply>>> requestContextFuture) {
+ final InstanceIdentifier<Node> nodeII,
+ final ListenableFuture<RpcResult<List<MultipartReply>>> requestContextFuture) {
Futures.addCallback(requestContextFuture, new FutureCallback<RpcResult<List<MultipartReply>>>() {
@Override
public void onSuccess(final RpcResult<List<MultipartReply>> rpcResult) {
}
private static ListenableFuture<RpcResult<List<MultipartReply>>> getNodeStaticInfo(final MultipartType type,
- final DeviceContext deviceContext, final InstanceIdentifier<Node> nodeII, final short version) {
+ final DeviceContext deviceContext, final InstanceIdentifier<Node> nodeII, final short version) {
final OutboundQueue queue = deviceContext.getPrimaryConnectionContext().getOutboundQueueProvider();
public void onFailure(final Throwable t) {
LOG.info("Fail response from OutboundQueue for multipart type {}.", type);
final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder
- .<List<MultipartReply>> failed().build();
+ .<List<MultipartReply>>failed().build();
requestContext.setResult(rpcResult);
if (MultipartType.OFPMPTABLEFEATURES.equals(type)) {
makeEmptyTables(deviceContext, nodeII, deviceContext.getPrimaryConnectionContext()
}
static void chainTableTrunkWriteOF10(final DeviceContext deviceContext,
- final ListenableFuture<List<RpcResult<List<MultipartReply>>>> deviceFeaturesFuture) {
+ final ListenableFuture<List<RpcResult<List<MultipartReply>>>> deviceFeaturesFuture) {
Futures.addCallback(deviceFeaturesFuture, new FutureCallback<List<RpcResult<List<MultipartReply>>>>() {
@Override
public void onSuccess(final List<RpcResult<List<MultipartReply>>> results) {
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.wildcards.WildcardSetfieldBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.osgi.framework.BundleContext;
private DataBroker dataBroker;
private ProviderContext pc;
private final BundleContext ctx;
- private Table testTable;
+ private TableFeatures testTable;
private Node testNode;
private final String originalTableName = "Foo";
private final String updatedTableName = "Bar";
dataBroker = session.getSALService(DataBroker.class);
ctx.registerService(CommandProvider.class.getName(), this, null);
// createTestNode();
- // createTestTable();
+ // createTestTableFeatures();
}
private void createUserNode(String nodeRef) {
return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey());
}
- private TableBuilder createTestTable(String tableFeatureTypeArg) {
+ private TableFeaturesBuilder createTestTableFeatures(String tableFeatureTypeArg) {
String tableFeatureType = tableFeatureTypeArg;
if (tableFeatureType == null) {
tableFeatureType = "t1";
}
- // Sample data , committing to DataStore
- short id = 12;
- TableKey key = new TableKey(id);
-
- TableBuilder table = new TableBuilder();
- table.setId((short) 12);
- table.setId(id);
- table.setKey(key);
-
- List<TableFeatures> ofTablefeatures = new ArrayList<TableFeatures>();
-
- // Skip this to send empty table features
+ final TableFeaturesBuilder tableFeature = new TableFeaturesBuilder();
+ // Sample data , committing to DataStore
if (!tableFeatureType.equals("t1")) {
- TableFeaturesBuilder tableFeature1 = new TableFeaturesBuilder();
- tableFeature1.setTableId((short) 0);
- tableFeature1.setName("Table 0");
+ tableFeature.setTableId((short) 0);
+ tableFeature.setName("Table 0");
- tableFeature1.setMetadataMatch(BigInteger.valueOf(10));
- tableFeature1.setMetadataWrite(BigInteger.valueOf(10));
- tableFeature1.setMaxEntries(10000L);
+ tableFeature.setMetadataMatch(BigInteger.valueOf(10));
+ tableFeature.setMetadataWrite(BigInteger.valueOf(10));
+ tableFeature.setMaxEntries(10000L);
- tableFeature1.setConfig(new TableConfig(false));
+ tableFeature.setConfig(new TableConfig(false));
List<TableFeatureProperties> properties = new ArrayList<TableFeatureProperties>();
TablePropertiesBuilder propertyBld = new TablePropertiesBuilder();
propertyBld.setTableFeatureProperties(properties);
- tableFeature1.setTableProperties(propertyBld.build());
-
-
- ofTablefeatures.add(tableFeature1.build());
-
+ tableFeature.setTableProperties(propertyBld.build());
}
- table.setTableFeatures(ofTablefeatures);
-
- testTable = table.build();
- return table;
+ testTable = tableFeature.build();
+ return tableFeature;
}
private TableFeaturePropertiesBuilder createApplyActionsMissTblFeatureProp() {
}
- private void writeTable(final CommandInterpreter ci, Table table) {
+ private void writeTableFeatures(final CommandInterpreter ci, TableFeatures tableFeatures) {
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
- InstanceIdentifier<Table> path1 = InstanceIdentifier.create(Nodes.class)
+ KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> path1 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).
- child(Table.class, new TableKey(table.getId()));
+ child(TableFeatures.class, new TableFeaturesKey(tableFeatures.getTableId()));
modification.merge(LogicalDatastoreType.OPERATIONAL, nodeToInstanceId(testNode), testNode, true);
- modification.merge(LogicalDatastoreType.OPERATIONAL, path1, table, true);
+ modification.merge(LogicalDatastoreType.OPERATIONAL, path1, tableFeatures, true);
modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, path1, table, true);
+ modification.merge(LogicalDatastoreType.CONFIGURATION, path1, tableFeatures, true);
CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
Futures.addCallback(commitFuture, new FutureCallback<Void>() {
@Override
createUserNode(nref);
}
String tableFeatureType = ci.nextArgument();
- TableBuilder table = createTestTable(tableFeatureType);
+ TableFeaturesBuilder tableFeaturesBld = createTestTableFeatures(tableFeatureType);
- writeTable(ci, table.build());
+ writeTableFeatures(ci, tableFeaturesBld.build());
}
@Override