Search in sources :

Example 51 with Device

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.

the class ConnectionManagerImplTest method testOnSwitchConnected2.

/**
 * Test method for
 * {@link org.opendaylight.openflowplugin.impl.connection.ConnectionManagerImpl#onSwitchConnected(
 * org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter)}.
 * invoking onHelloMessage, scenario:
 * <ol>
 * <li>receive hello from device (notification)</li>
 * <li>send hello to device (rpc with void output)</li>
 * <li>send getFeature to device (rpc with getFeatureOutput)</li>
 * <li>wait for rpc to finish with getFeatureOutput</li>
 * </ol>
 *
 * @throws InterruptedException - interrupted exception
 */
@Test
public void testOnSwitchConnected2() throws Exception {
    connectionManagerImpl.onSwitchConnected(connection);
    Mockito.verify(connection).setConnectionReadyListener(connectionReadyListenerAC.capture());
    Mockito.verify(connection).setMessageListener(ofpListenerAC.capture());
    // prepare void reply (hello rpc output)
    final SettableFuture<RpcResult<HelloOutput>> voidResponseFx = SettableFuture.create();
    Mockito.when(connection.hello(any(HelloInput.class))).thenReturn(voidResponseFx);
    // prepare getFeature reply (getFeture rpc output)
    final SettableFuture<RpcResult<GetFeaturesOutput>> featureResponseFx = SettableFuture.create();
    Mockito.when(connection.getFeatures(any(GetFeaturesInput.class))).thenReturn(featureResponseFx);
    // set dpn last connected time to be before dpn hold time seconds from now
    connectionManagerImpl.getDeviceConnectionStatusProvider().addDeviceLastConnectionTime(BigInteger.TEN, LocalDateTime.now().minusSeconds(DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS.toJava()));
    // fire handshake - send hello reply
    final HelloMessage hello = new HelloMessageBuilder().setVersion(EncodeConstants.OF_VERSION_1_3).setXid(Uint32.ONE).build();
    ofpListenerAC.getValue().onHelloMessage(hello);
    // notify about connection ready
    connectionReadyListenerAC.getValue().onConnectionReady();
    // deliver hello send output (void)
    Thread.sleep(100L);
    final RpcResult<HelloOutput> helloResponse = RpcResultBuilder.success((HelloOutput) null).build();
    voidResponseFx.set(helloResponse);
    // deliver getFeature output
    Thread.sleep(100L);
    final GetFeaturesOutput getFeatureOutput = new GetFeaturesOutputBuilder().setDatapathId(Uint64.TEN).setVersion(EncodeConstants.OF_VERSION_1_3).setXid(Uint32.TWO).setTables(Uint8.valueOf(15)).build();
    final RpcResult<GetFeaturesOutput> rpcFeaturesOutput = RpcResultBuilder.success(getFeatureOutput).build();
    featureResponseFx.set(rpcFeaturesOutput);
    Mockito.verify(deviceConnectedHandler, Mockito.timeout(FINAL_STEP_TIMEOUT)).deviceConnected(any(ConnectionContext.class));
}
Also used : HelloOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloOutput) GetFeaturesOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder) GetFeaturesInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput) HelloMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) HelloInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput) GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) ConnectionContext(org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext) Test(org.junit.Test)

Example 52 with Device

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.

the class HandshakeListenerImplTest method testOnHandshakeFailure1.

@Test
public void testOnHandshakeFailure1() {
    connectionContextSpy.setNodeId(new NodeId("ut-device:10"));
    handshakeListener.onHandshakeFailure();
    verify(handshakeContext).close();
    verify(connectionContextSpy).closeConnection(false);
}
Also used : NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) Test(org.junit.Test)

Example 53 with Device

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.

the class BundleFlowForwarder method remove.

@Override
public void remove(final InstanceIdentifier<Flow> identifier, final Flow flow, final InstanceIdentifier<FlowCapableNode> nodeIdent, final BundleId bundleId) {
    final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
    nodeConfigurator.enqueueJob(nodeId, () -> {
        final List<Message> messages = new ArrayList<>(1);
        String node = nodeIdent.firstKeyOf(Node.class).getId().getValue();
        BundleInnerMessage bundleInnerMessage = new BundleRemoveFlowCaseBuilder().setRemoveFlowCaseData(new RemoveFlowCaseDataBuilder(flow).build()).build();
        Message message = new MessageBuilder().setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class))).setBundleInnerMessage(bundleInnerMessage).build();
        messages.add(message);
        AddBundleMessagesInput addBundleMessagesInput = new AddBundleMessagesInputBuilder().setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class))).setBundleId(bundleId).setFlags(BUNDLE_FLAGS).setMessages(new MessagesBuilder().setMessage(messages).build()).build();
        final ListenableFuture<RpcResult<AddBundleMessagesOutput>> resultFuture = forwardingRulesManager.getSalBundleService().addBundleMessages(addBundleMessagesInput);
        LOG.trace("Pushing flow remove message {} to bundle {} for device {}", addBundleMessagesInput, bundleId.getValue(), node);
        LoggingFutures.addErrorLogging(resultFuture, LOG, "removeBundleFlow");
        return resultFuture;
    });
}
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) BundleRemoveFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.bundle.inner.message.BundleRemoveFlowCaseBuilder) AddBundleMessagesInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.AddBundleMessagesInput) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message) BundleInnerMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.BundleInnerMessage) AddBundleMessagesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.AddBundleMessagesInputBuilder) ArrayList(java.util.ArrayList) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MessagesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.MessagesBuilder) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) MessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.MessageBuilder) BundleInnerMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.BundleInnerMessage)

Example 54 with Device

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.

the class BundleGroupForwarder method remove.

@Override
public void remove(final InstanceIdentifier<Group> identifier, final Group group, final InstanceIdentifier<FlowCapableNode> nodeIdent, final BundleId bundleId) {
    final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
    nodeConfigurator.enqueueJob(nodeId, () -> {
        final List<Message> messages = new ArrayList<>(1);
        BundleInnerMessage bundleInnerMessage = new BundleRemoveGroupCaseBuilder().setRemoveGroupCaseData(new RemoveGroupCaseDataBuilder(group).build()).build();
        Message message = new MessageBuilder().setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class))).setBundleInnerMessage(bundleInnerMessage).build();
        messages.add(message);
        AddBundleMessagesInput addBundleMessagesInput = new AddBundleMessagesInputBuilder().setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class))).setBundleId(bundleId).setFlags(BUNDLE_FLAGS).setMessages(new MessagesBuilder().setMessage(messages).build()).build();
        LOG.trace("Pushing group remove message {} to bundle {} for device {}", addBundleMessagesInput, bundleId.getValue(), nodeId);
        final ListenableFuture<RpcResult<AddBundleMessagesOutput>> resultFuture = forwardingRulesManager.getSalBundleService().addBundleMessages(addBundleMessagesInput);
        Futures.addCallback(resultFuture, new BundleRemoveGroupCallBack(group.getGroupId().getValue(), nodeId), MoreExecutors.directExecutor());
        LoggingFutures.addErrorLogging(resultFuture, LOG, "removeBundleGroup");
        return resultFuture;
    });
}
Also used : BundleRemoveGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.bundle.inner.message.BundleRemoveGroupCaseBuilder) AddBundleMessagesInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.AddBundleMessagesInput) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message) BundleInnerMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.BundleInnerMessage) AddBundleMessagesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.AddBundleMessagesInputBuilder) ArrayList(java.util.ArrayList) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) 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) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) MessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.MessageBuilder) BundleInnerMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.BundleInnerMessage)

Example 55 with Device

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.

the class BundleGroupForwarder method add.

@Override
public ListenableFuture<RpcResult<AddBundleMessagesOutput>> add(final InstanceIdentifier<Group> identifier, final Group group, final InstanceIdentifier<FlowCapableNode> nodeIdent, final BundleId bundleId) {
    final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
    final Uint32 groupId = group.getGroupId().getValue();
    return nodeConfigurator.enqueueJob(nodeId, () -> {
        if (isGroupExistsOnDevice(nodeIdent, groupId, forwardingRulesManager)) {
            LOG.debug("Group {} already exists in the device. Ignoring the add DTCN", groupId);
            return Futures.immediateFuture(RpcResultBuilder.<AddBundleMessagesOutput>success().build());
        }
        final List<Message> messages = new ArrayList<>(1);
        BundleInnerMessage bundleInnerMessage = new BundleAddGroupCaseBuilder().setAddGroupCaseData(new AddGroupCaseDataBuilder(group).build()).build();
        Message message = new MessageBuilder().setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class))).setBundleInnerMessage(bundleInnerMessage).build();
        messages.add(message);
        AddBundleMessagesInput addBundleMessagesInput = new AddBundleMessagesInputBuilder().setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class))).setBundleId(bundleId).setFlags(BUNDLE_FLAGS).setMessages(new MessagesBuilder().setMessage(messages).build()).build();
        LOG.trace("Pushing group add message {} to bundle {} for device {}", addBundleMessagesInput, bundleId.getValue(), nodeId);
        ListenableFuture<RpcResult<AddBundleMessagesOutput>> resultFuture = forwardingRulesManager.getSalBundleService().addBundleMessages(addBundleMessagesInput);
        Futures.addCallback(resultFuture, new BundleAddGroupCallBack(groupId, nodeId), MoreExecutors.directExecutor());
        return resultFuture;
    });
}
Also used : AddBundleMessagesInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.AddBundleMessagesInput) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message) BundleInnerMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.BundleInnerMessage) AddBundleMessagesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.AddBundleMessagesInputBuilder) AddBundleMessagesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.AddBundleMessagesOutput) ArrayList(java.util.ArrayList) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) BundleAddGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.bundle.inner.message.BundleAddGroupCaseBuilder) MessagesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.MessagesBuilder) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) 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) MessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.MessageBuilder) BundleInnerMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.BundleInnerMessage) Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Aggregations

ArrayList (java.util.ArrayList)50 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)34 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)30 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)29 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)25 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)24 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)24 List (java.util.List)21 ExecutionException (java.util.concurrent.ExecutionException)18 Collection (java.util.Collection)16 Map (java.util.Map)16 Collections (java.util.Collections)15 HashMap (java.util.HashMap)15 Test (org.junit.Test)14 BigInteger (java.math.BigInteger)13 Set (java.util.Set)13 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)13 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)12 Logger (org.slf4j.Logger)12 LoggerFactory (org.slf4j.LoggerFactory)12