use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef in project openflowplugin by opendaylight.
the class OpenflowpluginStatsTestCommandProvider method _flowStats.
public void _flowStats(CommandInterpreter ci) {
int flowCount = 0;
int flowStatsCount = 0;
List<Node> nodes = getNodes();
for (Node node2 : nodes) {
NodeKey nodeKey = node2.getKey();
InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
if (node != null) {
List<Table> tables = node.getTable();
for (Table table2 : tables) {
TableKey tableKey = table2.getKey();
InstanceIdentifier<Table> tableRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey);
Table table = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, tableRef);
if (table != null) {
if (table.getFlow() != null) {
List<Flow> flows = table.getFlow();
for (Flow flow2 : flows) {
flowCount++;
FlowKey flowKey = flow2.getKey();
InstanceIdentifier<Flow> flowRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
Flow flow = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, flowRef);
if (flow != null) {
FlowStatisticsData data = flow.getAugmentation(FlowStatisticsData.class);
if (null != data) {
flowStatsCount++;
LOG.debug("--------------------------------------------");
ci.print(data);
}
}
}
}
}
}
}
}
if (flowCount == flowStatsCount) {
LOG.debug("flowStats - Success");
} else {
LOG.debug("flowStats - Failed");
LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef in project openflowplugin by opendaylight.
the class SalFlowServiceImplTest method updateFlow.
private void updateFlow(short version) throws Exception {
UpdateFlowInput mockedUpdateFlowInput = mock(UpdateFlowInput.class);
UpdateFlowInput mockedUpdateFlowInput1 = mock(UpdateFlowInput.class);
UpdatedFlow mockedUpdateFlow = new UpdatedFlowBuilder().setMatch(match).setTableId((short) 1).build();
UpdatedFlow mockedUpdateFlow1 = new UpdatedFlowBuilder().setMatch(match).setTableId((short) 1).setPriority(1).build();
when(mockedUpdateFlowInput.getUpdatedFlow()).thenReturn(mockedUpdateFlow);
when(mockedUpdateFlowInput1.getUpdatedFlow()).thenReturn(mockedUpdateFlow1);
FlowRef mockedFlowRef = mock(FlowRef.class);
Mockito.doReturn(TABLE_II.child(Flow.class, new FlowKey(new FlowId(DUMMY_FLOW_ID)))).when(mockedFlowRef).getValue();
when(mockedUpdateFlowInput.getFlowRef()).thenReturn(mockedFlowRef);
when(mockedUpdateFlowInput1.getFlowRef()).thenReturn(mockedFlowRef);
OriginalFlow mockedOriginalFlow = new OriginalFlowBuilder().setMatch(match).setTableId((short) 1).build();
OriginalFlow mockedOriginalFlow1 = new OriginalFlowBuilder().setMatch(match).setTableId((short) 1).setPriority(2).build();
when(mockedUpdateFlowInput.getOriginalFlow()).thenReturn(mockedOriginalFlow);
when(mockedUpdateFlowInput1.getOriginalFlow()).thenReturn(mockedOriginalFlow1);
SalFlowServiceImpl salFlowService = mockSalFlowService(version);
verifyOutput(salFlowService.updateFlow(mockedUpdateFlowInput));
verifyOutput(salFlowService.updateFlow(mockedUpdateFlowInput1));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef in project openflowplugin by opendaylight.
the class FlowForwarder method update.
@Override
public void update(final InstanceIdentifier<Flow> identifier, final Flow original, final Flow update, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
final TableKey tableKey = identifier.firstKeyOf(Table.class, TableKey.class);
if (tableIdValidationPrecondition(tableKey, update)) {
final UpdateFlowInputBuilder builder = new UpdateFlowInputBuilder();
builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
builder.setFlowRef(new FlowRef(identifier));
builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
// This method is called only when a given flow object in datastore
// has been updated. So FRM always needs to set strict flag into
// update-flow input so that only a flow entry associated with
// a given flow object is updated.
builder.setUpdatedFlow(new UpdatedFlowBuilder(update).setStrict(Boolean.TRUE).build());
builder.setOriginalFlow(new OriginalFlowBuilder(original).setStrict(Boolean.TRUE).build());
final Future<RpcResult<UpdateFlowOutput>> resultFuture = provider.getSalFlowService().updateFlow(builder.build());
JdkFutures.addErrorLogging(resultFuture, LOG, "updateFlow");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef in project openflowplugin by opendaylight.
the class FlowForwarder method removeWithResult.
// TODO: Pull this into ForwardingRulesCommiter and override it here
@Override
public Future<RpcResult<RemoveFlowOutput>> removeWithResult(final InstanceIdentifier<Flow> identifier, final Flow removeDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
Future<RpcResult<RemoveFlowOutput>> resultFuture = SettableFuture.create();
final TableKey tableKey = identifier.firstKeyOf(Table.class, TableKey.class);
if (tableIdValidationPrecondition(tableKey, removeDataObj)) {
final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(removeDataObj);
builder.setFlowRef(new FlowRef(identifier));
builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
builder.setFlowTable(new FlowTableRef(nodeIdent.child(Table.class, tableKey)));
// This method is called only when a given flow object has been
// removed from datastore. So FRM always needs to set strict flag
// into remove-flow input so that only a flow entry associated with
// a given flow object is removed.
builder.setTransactionUri(new Uri(provider.getNewTransactionId())).setStrict(Boolean.TRUE);
resultFuture = provider.getSalFlowService().removeFlow(builder.build());
}
return resultFuture;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef in project openflowplugin by opendaylight.
the class FlowForwarder method add.
@Override
public Future<RpcResult<AddFlowOutput>> add(final InstanceIdentifier<Flow> identifier, final Flow addDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
Future<RpcResult<AddFlowOutput>> future;
final TableKey tableKey = identifier.firstKeyOf(Table.class, TableKey.class);
if (tableIdValidationPrecondition(tableKey, addDataObj)) {
final AddFlowInputBuilder builder = new AddFlowInputBuilder(addDataObj);
builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
builder.setFlowRef(new FlowRef(identifier));
builder.setFlowTable(new FlowTableRef(nodeIdent.child(Table.class, tableKey)));
builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
future = provider.getSalFlowService().addFlow(builder.build());
} else {
future = Futures.<RpcResult<AddFlowOutput>>immediateFuture(null);
}
return future;
}
Aggregations