Search in sources :

Example 6 with Server

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTest method registerAddress.

/*
    // This registers an IP with a MapRegister, then adds a password via the
    // northbound REST API
    // and checks that the password works
    public void testPasswordExactMatch() throws Exception {
        cleanUP();
        String ipString = "10.0.0.1";
        LispIpv4Address address = LispAddressUtil.asIPAfiAddress(ipString);
        int mask = 32;
        String pass = "pass";

        URL url = createPutURL("key");

        String jsonAuthData = createAuthKeyJSON(pass, address, mask);

        LOG.trace("Sending this JSON to LISP server: \n" + jsonAuthData);
        LOG.trace("Address: " + address);

        byte[] expectedSha = new byte[] { (byte) 146, (byte) 234, (byte) 52, (byte) 247, (byte) 186, (byte) 232,
                (byte) 31, (byte) 249, (byte) 87,
                (byte) 73, (byte) 234, (byte) 54, (byte) 225, (byte) 160, (byte) 129, (byte) 251, (byte) 73, (byte) 53,
                (byte) 196, (byte) 62 };

        byte[] zeros = new byte[20];

        callURL("PUT", "application/json", "text/plain", jsonAuthData, url);

        // build a MapRegister
        MapRegisterBuilder mapRegister = new MapRegisterBuilder();
        mapRegister.setWantMapNotify(true);
        mapRegister.setNonce((long) 8);
        EidToLocatorRecordBuilder etlr = new EidToLocatorRecordBuilder();
        etlr.setLispAddressContainer(LispAddressUtil.toContainer(address));
        etlr.setMaskLength((short) mask);
        etlr.setRecordTtl(254);
        LocatorRecordBuilder record = new LocatorRecordBuilder();
        record.setLispAddressContainer(LispAddressUtil.toContainer(locatorEid));
        etlr.setLocatorRecord(new ArrayList<LocatorRecord>());
        etlr.getLocatorRecord().add(record.build());
        mapRegister.setMappingRecordItem(new ArrayList<MappingRecordItem>());
        mapRegister.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(etlr.build()).build());

        mapRegister.setKeyId((short) 1); // LispKeyIDEnum.SHA1.getKeyID()
        mapRegister.setAuthenticationData(zeros);

        sendMapRegister(mapRegister.build());
        assertNoPacketReceived(3000);

        mapRegister.setAuthenticationData(expectedSha);

        sendMapRegister(mapRegister.build());

        assertMapNotifyReceived();
    }

    public void testPasswordMaskMatch() throws Exception {
        cleanUP();
        LispIpv4Address addressInRange = LispAddressUtil.asIPAfiAddress("10.20.30.40");
        LispIpv4Address addressOutOfRange = LispAddressUtil.asIPAfiAddress("20.40.30.40");
        LispIpv4Address range = LispAddressUtil.asIPAfiAddress("10.20.30.0");

        int mask = 32;
        String pass = "pass";

        URL url = createPutURL("key");
        String jsonAuthData = createAuthKeyJSON(pass, range, 8);

        callURL("PUT", "application/json", "text/plain", jsonAuthData, url);
        // build a MapRegister
        MapRegisterBuilder mapRegister = new MapRegisterBuilder();

        mapRegister.setWantMapNotify(true);
        mapRegister.setNonce((long) 8);
        EidToLocatorRecordBuilder etlr = new EidToLocatorRecordBuilder();
        etlr.setLispAddressContainer(LispAddressUtil.toContainer(addressInRange));
        etlr.setMaskLength((short) mask);
        etlr.setRecordTtl(254);
        LocatorRecordBuilder record = new LocatorRecordBuilder();
        record.setLispAddressContainer(LispAddressUtil.toContainer(locatorEid));
        record.setLispAddressContainer(LispAddressUtil.toContainer(locatorEid));
        etlr.setLocatorRecord(new ArrayList<LocatorRecord>());
        etlr.getLocatorRecord().add(record.build());
        mapRegister.setMappingRecordItem(new ArrayList<MappingRecordItem>());
        mapRegister.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(etlr.build()).build());

        mapRegister.setKeyId((short) 1); // LispKeyIDEnum.SHA1.getKeyID()
        mapRegister
                .setAuthenticationData(new byte[] { -15, -52, 38, -94, 125, -111, -68, -79, 68, 6, 101, 45, -1, 47, -4,
                -67, -113, 104, -110, -71 });

        sendMapRegister(mapRegister.build());

        assertMapNotifyReceived();

        etlr.setLispAddressContainer(LispAddressUtil.toContainer(addressOutOfRange));
        mapRegister
                .setAuthenticationData(new byte[] { -54, 68, -58, -91, -23, 22, -88, -31, 113, 39, 115, 78, -68, -123,
                -71, -14, -99, 67, -23, -73 });

        sendMapRegister(mapRegister.build());
        assertNoPacketReceived(3000);
    }
*/
// takes an address, packs it in a MapRegister and sends it
private void registerAddress(Eid eid) throws SocketTimeoutException {
    mapService.addAuthenticationKey(eid, NULL_AUTH_KEY);
    sleepForSeconds(1);
    MapRegister mapRegister = MappingServiceIntegrationTestUtil.getDefaultMapRegisterBuilder(eid).build();
    sendMapRegister(mapRegister);
    MapNotify mapNotify = receiveMapNotify();
    assertEquals(8, mapNotify.getNonce().longValue());
}
Also used : GotMapNotify(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify) MapNotify(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify) MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister)

Example 7 with Server

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project bgpcep by opendaylight.

the class AbstractBGPDispatcherTest method createServer.

Channel createServer(final InetSocketAddress serverAddress) {
    this.registry.addPeer(new IpAddressNoZone(new Ipv4AddressNoZone(serverAddress.getAddress().getHostAddress())), this.serverListener, createPreferences(serverAddress));
    LoggerFactory.getLogger(AbstractBGPDispatcherTest.class).info("createServer");
    final ChannelFuture future = this.serverDispatcher.createServer(serverAddress);
    future.addListener(future1 -> Preconditions.checkArgument(future1.isSuccess(), "Unable to start bgp server on %s", future1.cause()));
    waitFutureSuccess(future);
    return future.channel();
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) IpAddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone)

Example 8 with Server

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project bgpcep by opendaylight.

the class BmpDeployerImpl method updateBmpMonitor.

@SuppressWarnings("checkstyle:IllegalCatch")
private synchronized void updateBmpMonitor(final BmpMonitorConfig bmpConfig) {
    final MonitorId monitorId = bmpConfig.getMonitorId();
    final BmpMonitoringStationImpl oldService = bmpMonitorServices.remove(monitorId);
    try {
        if (oldService != null) {
            oldService.closeServiceInstance().get(TIMEOUT_NS, TimeUnit.NANOSECONDS);
            oldService.close();
        }
        final Server server = bmpConfig.getServer();
        final InetSocketAddress inetAddress = Ipv4Util.toInetSocketAddress(server.getBindingAddress(), server.getBindingPort());
        final BmpMonitoringStationImpl monitor = new BmpMonitoringStationImpl(domDataBroker, dispatcher, extensions, codecTree, singletonProvider, monitorId, inetAddress, bmpConfig.nonnullMonitoredRouter().values());
        bmpMonitorServices.put(monitorId, monitor);
    } catch (final Exception e) {
        LOG.error("Failed to create Bmp Monitor {}.", monitorId, e);
    }
}
Also used : Server(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server) InetSocketAddress(java.net.InetSocketAddress) MonitorId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId) BmpMonitoringStationImpl(org.opendaylight.protocol.bmp.impl.app.BmpMonitoringStationImpl)

Example 9 with Server

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project bgpcep by opendaylight.

the class AbstractTopologySessionListener method updatePccState.

synchronized void updatePccState(final PccSyncState pccSyncState) {
    if (this.nodeState == null) {
        LOG.info("Server Session Manager is closed.");
        AbstractTopologySessionListener.this.session.close(TerminationReason.UNKNOWN);
        return;
    }
    final MessageContext ctx = new MessageContext(this.nodeState.getChain().newWriteOnlyTransaction());
    updatePccNode(ctx, new PathComputationClientBuilder().setStateSync(pccSyncState).build());
    if (pccSyncState != PccSyncState.Synchronized) {
        this.synced.set(false);
        this.triggeredResyncInProcess = true;
    }
    // All set, commit the modifications
    ctx.trans.commit().addCallback(new FutureCallback<CommitInfo>() {

        @Override
        public void onSuccess(final CommitInfo result) {
            LOG.trace("Pcc Internal state for session {} updated successfully", AbstractTopologySessionListener.this.session);
        }

        @Override
        public void onFailure(final Throwable throwable) {
            LOG.error("Failed to update Pcc internal state for session {}", AbstractTopologySessionListener.this.session, throwable);
            AbstractTopologySessionListener.this.session.close(TerminationReason.UNKNOWN);
        }
    }, MoreExecutors.directExecutor());
}
Also used : PathComputationClientBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.PathComputationClientBuilder) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo)

Example 10 with Server

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project bgpcep by opendaylight.

the class PCEPTopologyProvider method enableRPCs.

private synchronized void enableRPCs(final SettableFuture<Empty> future, final ChannelFuture channelFuture) {
    final var channelFailure = channelFuture.cause();
    if (channelFailure != null) {
        LOG.error("Topology Provider {} failed to initialize server channel", topologyId(), channelFailure);
        disableManager(future);
        return;
    }
    channel = channelFuture.channel();
    // Register RPCs
    final RpcProviderService rpcRegistry = dependencies.getRpcProviderRegistry();
    elementReg = rpcRegistry.registerRpcImplementation(NetworkTopologyPcepService.class, new TopologyRPCs(manager), Set.of(instanceIdentifier));
    networkReg = rpcRegistry.registerRpcImplementation(NetworkTopologyPcepProgrammingService.class, new TopologyProgramming(scheduler, manager), Set.of(instanceIdentifier));
    // We are now completely initialized
    LOG.info("PCEP Topology Provider {} enabled", topologyId());
    finishOperation(future);
}
Also used : NetworkTopologyPcepService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.NetworkTopologyPcepService) RpcProviderService(org.opendaylight.mdsal.binding.api.RpcProviderService) NetworkTopologyPcepProgrammingService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev181109.NetworkTopologyPcepProgrammingService)

Aggregations

Test (org.junit.Test)7 ArrayList (java.util.ArrayList)6 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)6 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)5 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)5 AllowedAddressPairs (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs)5 MatchEthernetSource (org.opendaylight.genius.mdsalutil.matches.MatchEthernetSource)4 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)4 AddLspOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.AddLspOutput)3 AddLspOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.AddLspOutput)3 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)2 AsId (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.AsId)2 GracefulRestart (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.GracefulRestart)2 Logging (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Logging)2 Multipath (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.multipathcontainer.Multipath)2 MultipathKey (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.multipathcontainer.MultipathKey)2 Neighbors (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighborscontainer.Neighbors)2 NeighborsKey (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighborscontainer.NeighborsKey)2 Networks (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.Networks)2 NetworksKey (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.NetworksKey)2