Search in sources :

Example 1 with KeyMapping

use of org.opendaylight.protocol.concepts.KeyMapping in project bgpcep by opendaylight.

the class KeyConstructorUtil method constructKeys.

public static KeyMapping constructKeys(final List<MonitoredRouter> mrs) {
    final KeyMapping ret = KeyMapping.getKeyMapping();
    if (mrs != null) {
        mrs.stream().filter(Objects::nonNull).filter(KeyConstructorUtil::isNotNullorEmpty).forEach(mr -> {
            final Rfc2385Key rfc2385KeyPassword = mr.getPassword();
            ret.put(IetfInetUtil.INSTANCE.inetAddressFor(mr.getAddress()), rfc2385KeyPassword.getValue().getBytes(StandardCharsets.US_ASCII));
        });
    }
    return ret;
}
Also used : Objects(java.util.Objects) KeyMapping(org.opendaylight.protocol.concepts.KeyMapping) Rfc2385Key(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.rfc2385.cfg.rev160324.Rfc2385Key)

Example 2 with KeyMapping

use of org.opendaylight.protocol.concepts.KeyMapping in project bgpcep by opendaylight.

the class PCEPDispatcherImplTest method testCustomizeBootstrap.

@Test
public void testCustomizeBootstrap() {
    final int port = InetSocketAddressUtil.getRandomPort();
    final InetSocketAddress clientAddr1 = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(port);
    final InetSocketAddress clientAddr2 = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(port);
    final KeyMapping keys = KeyMapping.getKeyMapping(clientAddr1.getAddress(), "CLIENT1_ADDRESS");
    keys.put(clientAddr2.getAddress(), "CLIENT2_ADDRESS".getBytes());
    doReturn(new InetSocketAddress("0.0.0.0", port)).when(this.dispatcherDependencies).getAddress();
    doReturn(this.listenerFactory).when(this.dispatcherDependencies).getListenerFactory();
    doReturn(new SimpleSessionListener()).when(this.listenerFactory).getSessionListener();
    final ChannelFuture futureChannel = this.disp2Spy.createServer(this.dispatcherDependencies);
    waitFutureSuccess(futureChannel);
    Mockito.verify(this.disp2Spy).createServerBootstrap(any(PCEPDispatcherImpl.ChannelPipelineInitializer.class));
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) InetSocketAddress(java.net.InetSocketAddress) KeyMapping(org.opendaylight.protocol.concepts.KeyMapping) Test(org.junit.Test)

Example 3 with KeyMapping

use of org.opendaylight.protocol.concepts.KeyMapping in project bgpcep by opendaylight.

the class BmpMonitoringStationImpl method connectMonitoredRouters.

private void connectMonitoredRouters(final BmpDispatcher pdispatcher) {
    if (this.monitoredRouters != null) {
        for (final MonitoredRouter mr : this.monitoredRouters) {
            if (mr.isActive()) {
                requireNonNull(mr.getAddress());
                requireNonNull(mr.getPort());
                final String s = mr.getAddress().getIpv4Address().getValue();
                final InetAddress addr = InetAddresses.forString(s);
                final KeyMapping ret;
                final Rfc2385Key rfc2385KeyPassword = mr.getPassword();
                ret = KeyMapping.getKeyMapping(addr, rfc2385KeyPassword.getValue());
                pdispatcher.createClient(Ipv4Util.toInetSocketAddress(mr.getAddress(), mr.getPort()), this.sessionManager, ret);
            }
        }
    }
}
Also used : MonitoredRouter(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev171207.odl.bmp.monitors.bmp.monitor.config.MonitoredRouter) KeyMapping(org.opendaylight.protocol.concepts.KeyMapping) Rfc2385Key(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.rfc2385.cfg.rev160324.Rfc2385Key) InetAddress(java.net.InetAddress)

Example 4 with KeyMapping

use of org.opendaylight.protocol.concepts.KeyMapping in project bgpcep by opendaylight.

the class PCEPTopologyProviderUtil method contructKeys.

static KeyMapping contructKeys(@Nonnull final Topology topology) {
    final KeyMapping ret = KeyMapping.getKeyMapping();
    topology.getNode().stream().filter(Objects::nonNull).filter(node -> node.getAugmentation(PcepNodeConfig.class) != null).filter(node -> node.getAugmentation(PcepNodeConfig.class).getSessionConfig() != null).filter(node -> node.getAugmentation(PcepNodeConfig.class).getSessionConfig().getPassword() != null).filter(node -> !node.getAugmentation(PcepNodeConfig.class).getSessionConfig().getPassword().getValue().isEmpty()).forEach(node -> {
        final PcepNodeConfig config = node.getAugmentation(PcepNodeConfig.class);
        final Rfc2385Key rfc2385KeyPassword = config.getSessionConfig().getPassword();
        final InetAddress address = InetAddresses.forString(node.getNodeId().getValue());
        ret.put(address, rfc2385KeyPassword.getValue().getBytes(StandardCharsets.US_ASCII));
    });
    return ret;
}
Also used : PcepNodeSyncConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.sync.optimizations.config.rev171025.PcepNodeSyncConfig) PcepNodeConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.config.rev171025.PcepNodeConfig) Logger(org.slf4j.Logger) KeyMapping(org.opendaylight.protocol.concepts.KeyMapping) TopologyTypes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.TopologyTypes1) LoggerFactory(org.slf4j.LoggerFactory) Rfc2385Key(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.rfc2385.cfg.rev160324.Rfc2385Key) InetSocketAddress(java.net.InetSocketAddress) StandardCharsets(java.nio.charset.StandardCharsets) InetAddress(java.net.InetAddress) Objects(java.util.Objects) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) TopologyTypes(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.TopologyTypes) IetfInetUtil(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) SpeakerIdMapping(org.opendaylight.protocol.pcep.SpeakerIdMapping) InetAddresses(com.google.common.net.InetAddresses) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) PcepNodeConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.config.rev171025.PcepNodeConfig) KeyMapping(org.opendaylight.protocol.concepts.KeyMapping) Rfc2385Key(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.rfc2385.cfg.rev160324.Rfc2385Key) InetAddress(java.net.InetAddress)

Aggregations

KeyMapping (org.opendaylight.protocol.concepts.KeyMapping)4 Rfc2385Key (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.rfc2385.cfg.rev160324.Rfc2385Key)3 InetAddress (java.net.InetAddress)2 InetSocketAddress (java.net.InetSocketAddress)2 Objects (java.util.Objects)2 InetAddresses (com.google.common.net.InetAddresses)1 ChannelFuture (io.netty.channel.ChannelFuture)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 Test (org.junit.Test)1 SpeakerIdMapping (org.opendaylight.protocol.pcep.SpeakerIdMapping)1 IetfInetUtil (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)1 MonitoredRouter (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev171207.odl.bmp.monitors.bmp.monitor.config.MonitoredRouter)1 PcepNodeConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.config.rev171025.PcepNodeConfig)1 TopologyTypes1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.TopologyTypes1)1 PcepNodeSyncConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.sync.optimizations.config.rev171025.PcepNodeSyncConfig)1 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)1