Search in sources :

Example 76 with NodeRef

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef in project openflowplugin by opendaylight.

the class TableForwarder method update.

@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);
    final TableFeatures originalTableFeatures = original;
    TableFeatures updatedTableFeatures;
    if (null == update) {
        updatedTableFeatures = original;
    } else {
        updatedTableFeatures = update;
    }
    final UpdateTableInputBuilder builder = new UpdateTableInputBuilder();
    builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
    // TODO: reconsider model - this particular field is not used in service
    // implementation
    builder.setTableRef(new TableRef(identifier));
    builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
    builder.setUpdatedTable(new UpdatedTableBuilder().setTableFeatures(Collections.singletonList(updatedTableFeatures)).build());
    builder.setOriginalTable(new OriginalTableBuilder().setTableFeatures(Collections.singletonList(originalTableFeatures)).build());
    LOG.debug("Invoking SalTableService ");
    if (this.provider.getSalTableService() != null) {
        LOG.debug(" Handle to SalTableServices" + this.provider.getSalTableService());
    }
    final Future<RpcResult<UpdateTableOutput>> resultFuture = this.provider.getSalTableService().updateTable(builder.build());
    JdkFutures.addErrorLogging(resultFuture, LOG, "updateTable");
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) OriginalTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.OriginalTableBuilder) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UpdatedTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder) UpdateTableInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInputBuilder) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) TableRef(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableRef)

Example 77 with NodeRef

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef in project openflowplugin by opendaylight.

the class FlowForwarder method remove.

@Override
public void remove(final InstanceIdentifier<Flow> identifier, final Flow removeDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
    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);
        final Future<RpcResult<RemoveFlowOutput>> resultFuture = provider.getSalFlowService().removeFlow(builder.build());
        JdkFutures.addErrorLogging(resultFuture, LOG, "removeFlow");
    }
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) FlowTableRef(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowTableRef) FlowRef(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RemoveFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)

Example 78 with NodeRef

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef in project openflowplugin by opendaylight.

the class FlowNodeReconciliationImpl method createMessages.

private Messages createMessages(final NodeRef nodeRef, final Optional<FlowCapableNode> flowNode) {
    final List<Message> messages = new ArrayList<>();
    messages.add(new MessageBuilder().setNode(nodeRef).setBundleInnerMessage(new BundleRemoveFlowCaseBuilder().setRemoveFlowCaseData(new RemoveFlowCaseDataBuilder(getDeleteAllFlow()).build()).build()).build());
    messages.add(new MessageBuilder().setNode(nodeRef).setBundleInnerMessage(new BundleRemoveGroupCaseBuilder().setRemoveGroupCaseData(new RemoveGroupCaseDataBuilder(getDeleteAllGroup()).build()).build()).build());
    if (flowNode.get().getGroup() != null) {
        for (Group gr : flowNode.get().getGroup()) {
            messages.add(new MessageBuilder().setNode(nodeRef).setBundleInnerMessage(new BundleAddGroupCaseBuilder().setAddGroupCaseData(new AddGroupCaseDataBuilder(gr).build()).build()).build());
        }
    }
    if (flowNode.get().getTable() != null) {
        for (Table table : flowNode.get().getTable()) {
            for (Flow flow : table.getFlow()) {
                messages.add(new MessageBuilder().setNode(nodeRef).setBundleInnerMessage(new BundleAddFlowCaseBuilder().setAddFlowCaseData(new AddFlowCaseDataBuilder(flow).build()).build()).build());
            }
        }
    }
    LOG.debug("The size of the flows and group messages created in createMessage() {}", messages.size());
    return new MessagesBuilder().setMessage(messages).build();
}
Also used : RemoveFlowCaseDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.bundle.inner.message.bundle.remove.flow._case.RemoveFlowCaseDataBuilder) BundleRemoveGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.bundle.inner.message.BundleRemoveGroupCaseBuilder) BundleRemoveFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.bundle.inner.message.BundleRemoveFlowCaseBuilder) StaleGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) AddFlowCaseDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.bundle.inner.message.bundle.add.flow._case.AddFlowCaseDataBuilder) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message) BundleAddFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.bundle.inner.message.BundleAddFlowCaseBuilder) ArrayList(java.util.ArrayList) BundleAddGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.bundle.inner.message.BundleAddGroupCaseBuilder) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) StaleFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlow) MessagesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.MessagesBuilder) RemoveGroupCaseDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.bundle.inner.message.bundle.remove.group._case.RemoveGroupCaseDataBuilder) MessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.MessageBuilder) AddGroupCaseDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.bundle.inner.message.bundle.add.group._case.AddGroupCaseDataBuilder)

Example 79 with NodeRef

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef in project openflowplugin by opendaylight.

the class SalBulkFlowServiceImplTest method testAddRemoveFlowsRpc.

@Test
public void testAddRemoveFlowsRpc() throws Exception {
    Mockito.when(mockSalFlowService.addFlow(Matchers.<AddFlowInput>any())).thenReturn(RpcResultBuilder.success(new AddFlowOutputBuilder().build()).buildFuture());
    Mockito.when(mockSalFlowService.removeFlow(Matchers.<RemoveFlowInput>any())).thenReturn(RpcResultBuilder.success(new RemoveFlowOutputBuilder().build()).buildFuture());
    final BulkFlowItemBuilder bulkFlowItemBuilder = new BulkFlowItemBuilder();
    final InstanceIdentifier<Node> nodeId = BulkOMaticUtils.getFlowCapableNodeId("1");
    bulkFlowItemBuilder.setNode(new NodeRef(nodeId));
    final BulkFlowItem bulkFlowItem = bulkFlowItemBuilder.build();
    final List<BulkFlowItem> bulkFlowItems = new ArrayList<>();
    bulkFlowItems.add(bulkFlowItem);
    final AddFlowsRpcInputBuilder addFlowsRpcInputBuilder = new AddFlowsRpcInputBuilder();
    addFlowsRpcInputBuilder.setBulkFlowItem(bulkFlowItems);
    final AddFlowsRpcInput addFlowsRpcInput = addFlowsRpcInputBuilder.build();
    salBulkFlowService.addFlowsRpc(addFlowsRpcInput);
    verify(mockSalFlowService).addFlow(Matchers.<AddFlowInput>any());
    final RemoveFlowsRpcInputBuilder removeFlowsRpcInputBuilder = new RemoveFlowsRpcInputBuilder();
    removeFlowsRpcInputBuilder.setBulkFlowItem(bulkFlowItems);
    final RemoveFlowsRpcInput removeFlowsRpcInput = removeFlowsRpcInputBuilder.build();
    salBulkFlowService.removeFlowsRpc(removeFlowsRpcInput);
    verify(mockSalFlowService).removeFlow(Matchers.<RemoveFlowInput>any());
}
Also used : BulkFlowItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.list.grouping.BulkFlowItemBuilder) BulkFlowItem(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.list.grouping.BulkFlowItem) RemoveFlowOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ArrayList(java.util.ArrayList) AddFlowOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutputBuilder) RemoveFlowsRpcInput(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsRpcInput) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) AddFlowsRpcInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInputBuilder) AddFlowsRpcInput(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInput) RemoveFlowsRpcInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsRpcInputBuilder) Test(org.junit.Test)

Example 80 with NodeRef

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef in project openflowplugin by opendaylight.

the class SalBulkFlowServiceImplTest method testAddRemoveFlowsDs.

@Test
public void testAddRemoveFlowsDs() throws Exception {
    Mockito.when(writeTransaction.submit()).thenReturn(Futures.immediateCheckedFuture(null));
    final BulkFlowDsItemBuilder bulkFlowDsItemBuilder = new BulkFlowDsItemBuilder().setFlowId(new FlowId("1")).setTableId((short) 2);
    final InstanceIdentifier<Node> nodeId = BulkOMaticUtils.getFlowCapableNodeId("1");
    bulkFlowDsItemBuilder.setNode(new NodeRef(nodeId));
    final BulkFlowDsItem bulkFlowDsItem = bulkFlowDsItemBuilder.build();
    final List<BulkFlowDsItem> bulkFlowDsItems = new ArrayList<>();
    bulkFlowDsItems.add(bulkFlowDsItem);
    final AddFlowsDsInputBuilder addFlowsDsInputBuilder = new AddFlowsDsInputBuilder();
    addFlowsDsInputBuilder.setBulkFlowDsItem(bulkFlowDsItems);
    final AddFlowsDsInput addFlowsDsInput = addFlowsDsInputBuilder.build();
    salBulkFlowService.addFlowsDs(addFlowsDsInput);
    verify(writeTransaction).submit();
    verify(writeTransaction).put(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<Flow>>any(), flowArgumentCaptor.capture(), Mockito.anyBoolean());
    Flow flow = flowArgumentCaptor.getValue();
    Assert.assertEquals("1", flow.getId().getValue());
    Assert.assertEquals((short) 2, flow.getTableId().shortValue());
    final RemoveFlowsDsInputBuilder removeFlowsDsInputBuilder = new RemoveFlowsDsInputBuilder();
    removeFlowsDsInputBuilder.setBulkFlowDsItem(bulkFlowDsItems);
    final RemoveFlowsDsInput removeFlowsDsInput = removeFlowsDsInputBuilder.build();
    salBulkFlowService.removeFlowsDs(removeFlowsDsInput);
    verify(writeTransaction).delete(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<Flow>>any());
    verify(writeTransaction, times(2)).submit();
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ArrayList(java.util.ArrayList) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) RemoveFlowsDsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsDsInputBuilder) AddFlowsDsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInput) BulkFlowDsItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.ds.list.grouping.BulkFlowDsItemBuilder) BulkFlowDsItem(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.ds.list.grouping.BulkFlowDsItem) AddFlowsDsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInputBuilder) RemoveFlowsDsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsDsInput) Test(org.junit.Test)

Aggregations

NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)69 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)30 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)29 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)27 ArrayList (java.util.ArrayList)23 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)18 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)17 Test (org.junit.Test)16 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)14 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)14 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)12 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)12 TransmitPacketInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder)12 BigInteger (java.math.BigInteger)11 TransmitPacketInput (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput)11 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)10 FlowRef (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef)8 GroupRef (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupRef)8 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)8 AddFlowInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder)7