use of org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences in project netconf by opendaylight.
the class RemoteDeviceConnectorImpl method getUserCapabilities.
private static Optional<NetconfSessionPreferences> getUserCapabilities(final NetconfNode node) {
if (node.getYangModuleCapabilities() == null && node.getNonModuleCapabilities() == null) {
return Optional.empty();
}
final List<String> capabilities = new ArrayList<>();
if (node.getYangModuleCapabilities() != null) {
capabilities.addAll(node.getYangModuleCapabilities().getCapability());
}
// non-module capabilities should not exist in yang module capabilities
final NetconfSessionPreferences netconfSessionPreferences = NetconfSessionPreferences.fromStrings(capabilities);
checkState(netconfSessionPreferences.getNonModuleCaps().isEmpty(), "List yang-module-capabilities/capability should contain only module based capabilities. " + "Non-module capabilities used: " + netconfSessionPreferences.getNonModuleCaps());
if (node.getNonModuleCapabilities() != null) {
capabilities.addAll(node.getNonModuleCapabilities().getCapability());
}
return Optional.of(NetconfSessionPreferences.fromStrings(capabilities, CapabilityOrigin.UserDefined));
}
use of org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences in project netconf by opendaylight.
the class RemoteDeviceConnectorImplTest method testKeapAliveFacade.
@SuppressWarnings("unchecked")
@Test
public void testKeapAliveFacade() {
final Credentials credentials = new LoginPasswordBuilder().setPassword("admin").setUsername("admin").build();
final NetconfNode netconfNode = new NetconfNodeBuilder().setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1")))).setPort(new PortNumber(Uint16.valueOf(9999))).setReconnectOnChangedSchema(true).setDefaultRequestTimeoutMillis(Uint32.valueOf(1000)).setBetweenAttemptsTimeoutMillis(Uint16.valueOf(100)).setSchemaless(false).setTcpOnly(false).setCredentials(credentials).setKeepaliveDelay(Uint32.ONE).build();
final Node node = new NodeBuilder().setNodeId(NODE_ID).addAugmentation(netconfNode).build();
builder.setSchemaResourceDTO(new DefaultSchemaResourceManager(new DefaultYangParserFactory()).getSchemaResources(netconfNode, "foo"));
final RemoteDeviceConnectorImpl remoteDeviceConnection = new RemoteDeviceConnectorImpl(builder.build(), remoteDeviceId, deviceActionFactory);
final RemoteDeviceHandler<NetconfSessionPreferences> salFacade = mock(RemoteDeviceHandler.class);
final NetconfConnectorDTO connectorDTO = remoteDeviceConnection.createDeviceCommunicator(NODE_ID, netconfNode, salFacade);
assertTrue(connectorDTO.getFacade() instanceof KeepaliveSalFacade);
}
use of org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences in project netconf by opendaylight.
the class RemoteDeviceConnectorImplTest method testStopRemoteDeviceConnection.
@SuppressWarnings("unchecked")
@Test
public void testStopRemoteDeviceConnection() {
builder.setNode(new NodeBuilder().setNodeId(NODE_ID).addAugmentation(new NetconfNodeBuilder().setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1")))).setPort(new PortNumber(Uint16.valueOf(9999))).setReconnectOnChangedSchema(true).setDefaultRequestTimeoutMillis(Uint32.valueOf(1000)).setBetweenAttemptsTimeoutMillis(Uint16.valueOf(100)).setSchemaless(false).setTcpOnly(false).setCredentials(new LoginPasswordBuilder().setPassword("admin").setUsername("admin").build()).build()).build());
final NetconfDeviceCommunicator communicator = mock(NetconfDeviceCommunicator.class);
final RemoteDeviceHandler<NetconfSessionPreferences> salFacade = mock(RemoteDeviceHandler.class);
final TestingRemoteDeviceConnectorImpl remoteDeviceConnection = new TestingRemoteDeviceConnectorImpl(builder.build(), remoteDeviceId, communicator, deviceActionFactory);
remoteDeviceConnection.startRemoteDeviceConnection(salFacade);
remoteDeviceConnection.stopRemoteDeviceConnection();
verify(communicator, times(1)).close();
verify(salFacade, times(1)).close();
}
use of org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences in project netconf by opendaylight.
the class AbstractNetconfTopology method getUserCapabilities.
private static Optional<UserPreferences> getUserCapabilities(final NetconfNode node) {
// just return absent
if (node.getYangModuleCapabilities() == null && node.getNonModuleCapabilities() == null) {
return Optional.empty();
}
final List<String> capabilities = new ArrayList<>();
boolean overrideYangModuleCaps = false;
if (node.getYangModuleCapabilities() != null) {
capabilities.addAll(node.getYangModuleCapabilities().getCapability());
overrideYangModuleCaps = node.getYangModuleCapabilities().getOverride();
}
// non-module capabilities should not exist in yang module capabilities
final NetconfSessionPreferences netconfSessionPreferences = NetconfSessionPreferences.fromStrings(capabilities);
Preconditions.checkState(netconfSessionPreferences.getNonModuleCaps().isEmpty(), "List yang-module-capabilities/capability should contain only module based capabilities. " + "Non-module capabilities used: " + netconfSessionPreferences.getNonModuleCaps());
boolean overrideNonModuleCaps = false;
if (node.getNonModuleCapabilities() != null) {
capabilities.addAll(node.getNonModuleCapabilities().getCapability());
overrideNonModuleCaps = node.getNonModuleCapabilities().getOverride();
}
return Optional.of(new UserPreferences(NetconfSessionPreferences.fromStrings(capabilities, CapabilityOrigin.UserDefined), overrideYangModuleCaps, overrideNonModuleCaps));
}
use of org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences in project netconf by opendaylight.
the class NetconfDeviceDataBrokerTest method getDataBroker.
private NetconfDeviceDataBroker getDataBroker(final String... caps) {
NetconfSessionPreferences prefs = NetconfSessionPreferences.fromStrings(Arrays.asList(caps));
final RemoteDeviceId id = new RemoteDeviceId("device-1", InetSocketAddress.createUnresolved("localhost", 17830));
return new NetconfDeviceDataBroker(id, new EmptyMountPointContext(SCHEMA_CONTEXT), rpcService, prefs);
}
Aggregations