use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.ProtocolBuilder in project genius by opendaylight.
the class ItmMonitorToggleWorker method toggleTunnelMonitoring.
private void toggleTunnelMonitoring(WriteTransaction transaction) {
List<String> tunnelList = ItmUtils.getInternalTunnelInterfaces(dataBroker);
LOG.debug("toggleTunnelMonitoring: TunnelList size {}", tunnelList.size());
InstanceIdentifier<TunnelMonitorParams> iid = InstanceIdentifier.builder(TunnelMonitorParams.class).build();
TunnelMonitorParams protocolBuilder = new TunnelMonitorParamsBuilder().setEnabled(enabled).setMonitorProtocol(monitorProtocol).build();
LOG.debug("toggleTunnelMonitoring: Updating Operational DS");
ItmUtils.asyncUpdate(LogicalDatastoreType.OPERATIONAL, iid, protocolBuilder, dataBroker, ItmUtils.DEFAULT_CALLBACK);
for (String tunnel : tunnelList) {
toggle(tunnel, transaction);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.ProtocolBuilder in project netconf by opendaylight.
the class NetconfConnectDeviceCommand method execute.
@Override
public Object execute() {
if (!NetconfCommandUtils.isIpValid(deviceIp) || !NetconfCommandUtils.isPortValid(devicePort)) {
return "Invalid IP:" + deviceIp + " or Port:" + devicePort + "Please enter a valid entry to proceed.";
}
final boolean isTcpOnly = connectionType.equals("true");
final boolean isSchemaless = schemaless.equals("true");
final NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder();
netconfNodeBuilder.setHost(new Host(new IpAddress(new Ipv4Address(deviceIp)))).setPort(new PortNumber(Uint16.valueOf(Integer.decode(devicePort)))).setTcpOnly(isTcpOnly).setSchemaless(isSchemaless);
if (isTcpOnly || protocol.equalsIgnoreCase("ssh")) {
if (Strings.isNullOrEmpty(username) || Strings.isNullOrEmpty(password)) {
return "Empty Username:" + username + " or Password:" + password + ". In TCP or SSH mode, you must provide valid username and password.";
}
final Credentials credentials = new LoginPasswordBuilder().setPassword(password).setUsername(username).build();
netconfNodeBuilder.setCredentials(credentials);
if (!isTcpOnly) {
netconfNodeBuilder.setProtocol(new ProtocolBuilder().setName(Name.SSH).build());
}
} else if (protocol.equalsIgnoreCase("tls")) {
TlsCase tlsCase = null;
if (!Strings.isNullOrEmpty(excludedTlsVersions)) {
tlsCase = new TlsCaseBuilder().setTls(new TlsBuilder().setExcludedVersions(Arrays.asList(excludedTlsVersions.split(","))).build()).build();
}
netconfNodeBuilder.setProtocol(new ProtocolBuilder().setName(Name.TLS).setSpecification(tlsCase).build());
} else {
return "Invalid protocol: " + protocol + ". Only SSH and TLS are supported.";
}
service.connectDevice(netconfNodeBuilder.build(), deviceId);
final String message = "Netconf connector added succesfully";
return message;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.ProtocolBuilder in project netconf by opendaylight.
the class NetconfTopologyImplTest method hideCredentialsTest.
@Test
public void hideCredentialsTest() {
final String userName = "admin";
final String password = "pa$$word";
final Node node = new NodeBuilder().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)).setKeepaliveDelay(Uint32.valueOf(1000)).setTcpOnly(false).setProtocol(new ProtocolBuilder().setName(Name.TLS).build()).setCredentials(new LoginPasswordBuilder().setUsername(userName).setPassword(password).build()).build()).setNodeId(NodeId.getDefaultInstance("junos")).build();
final String transformedNetconfNode = AbstractNetconfTopology.hideCredentials(node);
assertTrue(transformedNetconfNode.contains("credentials=***"));
assertFalse(transformedNetconfNode.contains(userName));
assertFalse(transformedNetconfNode.contains(password));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.ProtocolBuilder in project netconf by opendaylight.
the class NetconfTopologyImplTest method testGetClientConfig.
@Test
public void testGetClientConfig() {
final NetconfClientSessionListener sessionListener = mock(NetconfClientSessionListener.class);
final NetconfNodeBuilder nodeBuilder = 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)).setKeepaliveDelay(Uint32.valueOf(1000)).setCredentials(new LoginPasswordBuilder().setUsername("testuser").setPassword("testpassword").build()).setMaxConnectionAttempts(Uint32.ZERO).setSleepFactor(new BigDecimal("1.5")).setConnectionTimeoutMillis(Uint32.valueOf(20000));
final NetconfReconnectingClientConfiguration configuration = spyTopology.getClientConfig(sessionListener, nodeBuilder.setTcpOnly(true).build());
assertEquals(NetconfClientConfiguration.NetconfClientProtocol.TCP, configuration.getProtocol());
assertNotNull(configuration.getAuthHandler());
assertNull(configuration.getSslHandlerFactory());
final NetconfReconnectingClientConfiguration configuration2 = spyTopology.getClientConfig(sessionListener, nodeBuilder.setTcpOnly(false).build());
assertEquals(NetconfClientConfiguration.NetconfClientProtocol.SSH, configuration2.getProtocol());
assertNotNull(configuration2.getAuthHandler());
assertNull(configuration2.getSslHandlerFactory());
final NetconfReconnectingClientConfiguration configuration3 = spyTopology.getClientConfig(sessionListener, nodeBuilder.setProtocol(new ProtocolBuilder().setName(Name.SSH).build()).build());
assertEquals(NetconfClientConfiguration.NetconfClientProtocol.SSH, configuration3.getProtocol());
assertNotNull(configuration3.getAuthHandler());
assertNull(configuration3.getSslHandlerFactory());
final NetconfReconnectingClientConfiguration configuration4 = spyTopology.getClientConfig(sessionListener, nodeBuilder.setProtocol(new ProtocolBuilder().setName(Name.TLS).build()).build());
assertEquals(NetconfClientConfiguration.NetconfClientProtocol.TLS, configuration4.getProtocol());
assertNull(configuration4.getAuthHandler());
assertNotNull(configuration4.getSslHandlerFactory());
}
Aggregations