Search in sources :

Example 86 with NodeRef

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

the class SalRoleServiceImplTest method testDuplicateRoles.

@Test
public void testDuplicateRoles() throws Exception {
    // set role to slave
    RoleRequestOutput roleRequestOutput = (new RoleRequestOutputBuilder()).setXid(testXid).setGenerationId(BigInteger.valueOf(1)).build();
    ListenableFuture<RpcResult<RoleRequestOutput>> futureOutput = RpcResultBuilder.<RoleRequestOutput>success().withResult(roleRequestOutput).buildFuture();
    Mockito.when(mockRequestContext.getFuture()).thenReturn(futureOutput);
    SalRoleService salRoleService = new SalRoleServiceImpl(mockRequestContextStack, mockDeviceContext);
    SetRoleInput setRoleInput = new SetRoleInputBuilder().setControllerRole(OfpRole.BECOMESLAVE).setNode(nodeRef).build();
    Future<RpcResult<SetRoleOutput>> future = salRoleService.setRole(setRoleInput);
    RpcResult<SetRoleOutput> roleOutputRpcResult = future.get(5, TimeUnit.SECONDS);
    assertNotNull("RpcResult from future cannot be null.", roleOutputRpcResult);
    assertTrue("RpcResult from future is not successful.", roleOutputRpcResult.isSuccessful());
    SetRoleOutput setRoleOutput = roleOutputRpcResult.getResult();
    assertNotNull(setRoleOutput);
    assertEquals(BigInteger.valueOf(testXid), setRoleOutput.getTransactionId().getValue());
    // make another role change with the same role - slave
    Future<RpcResult<SetRoleOutput>> future2 = salRoleService.setRole(setRoleInput);
    RpcResult<SetRoleOutput> roleOutputRpcResult2 = future2.get(5, TimeUnit.SECONDS);
    assertNotNull("RpcResult from future cannot be null.", roleOutputRpcResult2);
    assertTrue("RpcResult from future for duplicate role is not successful.", roleOutputRpcResult2.isSuccessful());
}
Also used : RoleRequestOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput) RoleRequestOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutputBuilder) SetRoleInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetRoleInputBuilder) SetRoleOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetRoleOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) SetRoleInput(org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetRoleInput) SalRoleService(org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SalRoleService) Test(org.junit.Test)

Example 87 with NodeRef

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

the class OpenflowpluginGroupTestCommandProvider method createUserNode.

private void createUserNode(String nodeRef) {
    NodeBuilder builder = new NodeBuilder();
    builder.setId(new NodeId(nodeRef));
    builder.setKey(new NodeKey(builder.getId()));
    testNode = builder.build();
}
Also used : NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Example 88 with NodeRef

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

the class OpenflowpluginMeterTestCommandProvider method createUserNode.

private void createUserNode(String nodeRef) {
    NodeBuilder builder = new NodeBuilder();
    builder.setId(new NodeId(nodeRef));
    builder.setKey(new NodeKey(builder.getId()));
    testNode = builder.build();
}
Also used : NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Example 89 with NodeRef

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

the class OpenflowpluginStatsTestCommandProvider method _tableStats.

public void _tableStats(CommandInterpreter ci) {
    int tableCount = 0;
    int tableStatsCount = 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) {
                tableCount++;
                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) {
                    FlowTableStatisticsData data = table.getAugmentation(FlowTableStatisticsData.class);
                    if (null != data) {
                        tableStatsCount++;
                    }
                }
            }
        }
    }
    if (tableCount == tableStatsCount) {
        LOG.debug("tableStats - Success");
    } else {
        LOG.debug("tableStats - Failed");
        LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
    }
}
Also used : Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) FlowTableStatisticsData(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsData) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Example 90 with NodeRef

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

the class OpenflowpluginStatsTestCommandProvider method _aggregateStats.

public void _aggregateStats(CommandInterpreter ci) {
    int aggregateFlowCount = 0;
    int aggerateFlowStatsCount = 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) {
                aggregateFlowCount++;
                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) {
                    AggregateFlowStatisticsData data = table.getAugmentation(AggregateFlowStatisticsData.class);
                    if (null != data) {
                        aggerateFlowStatsCount++;
                    }
                }
            }
        }
    }
    if (aggregateFlowCount == aggerateFlowStatsCount) {
        LOG.debug("aggregateStats - Success");
    } else {
        LOG.debug("aggregateStats - Failed");
        LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
    }
}
Also used : Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) AggregateFlowStatisticsData(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsData)

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