use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.
the class NetconfNodeActorTest method testInitializeAndRefreshMasterData.
@Test
public void testInitializeAndRefreshMasterData() {
// Test CreateInitialMasterActorData.
initializeMaster(new ArrayList<>());
// Test RefreshSetupMasterActorData.
final RemoteDeviceId newRemoteDeviceId = new RemoteDeviceId("netconf-topology2", new InetSocketAddress(InetAddresses.forString("127.0.0.2"), 9999));
final NetconfTopologySetup newSetup = NetconfTopologySetupBuilder.create().setBaseSchemas(BASE_SCHEMAS).setSchemaResourceDTO(schemaResourceDTO).setActorSystem(system).build();
masterRef.tell(new RefreshSetupMasterActorData(newSetup, newRemoteDeviceId), testKit.getRef());
testKit.expectMsgClass(MasterActorDataInitialized.class);
}
use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.
the class NetconfNodeActorTest method setup.
@Before
public void setup() {
remoteDeviceId = new RemoteDeviceId("netconf-topology", new InetSocketAddress(InetAddresses.forString("127.0.0.1"), 9999));
masterSchemaRepository.registerSchemaSourceListener(TextToIRTransformer.create(masterSchemaRepository, masterSchemaRepository));
doReturn(masterSchemaRepository).when(schemaResourceDTO).getSchemaRepository();
doReturn(mockRegistry).when(schemaResourceDTO).getSchemaRegistry();
final NetconfTopologySetup setup = NetconfTopologySetupBuilder.create().setActorSystem(system).setIdleTimeout(Duration.apply(1, TimeUnit.SECONDS)).setSchemaResourceDTO(schemaResourceDTO).setBaseSchemas(BASE_SCHEMAS).build();
final Props props = NetconfNodeActor.props(setup, remoteDeviceId, TIMEOUT, mockMountPointService);
masterRef = TestActorRef.create(system, props, "master_messages");
resetMountPointMocks();
doReturn(mockMountPointBuilder).when(mockMountPointService).createMountPoint(any());
doReturn(mockSchemaSourceReg1).when(mockRegistry).registerSchemaSource(any(), withSourceId(SOURCE_IDENTIFIER1));
doReturn(mockSchemaSourceReg2).when(mockRegistry).registerSchemaSource(any(), withSourceId(SOURCE_IDENTIFIER2));
doReturn(mockSchemaContextFactory).when(mockSchemaRepository).createEffectiveModelContextFactory();
}
use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.
the class AbstractNetconfTopology method createDeviceCommunicator.
protected NetconfConnectorDTO createDeviceCommunicator(final NodeId nodeId, final NetconfNode node, final NetconfNodeAugmentedOptional nodeOptional) {
final Host host = node.getHost();
final IpAddress ipAddress = host.getIpAddress();
final InetSocketAddress address;
if (ipAddress != null) {
address = new InetSocketAddress(IetfInetUtil.INSTANCE.inetAddressFor(ipAddress), node.getPort().getValue().toJava());
} else {
address = new InetSocketAddress(host.getDomainName().getValue(), node.getPort().getValue().toJava());
}
final RemoteDeviceId remoteDeviceId = new RemoteDeviceId(nodeId.getValue(), address);
final long keepaliveDelay = node.requireKeepaliveDelay().toJava();
RemoteDeviceHandler<NetconfSessionPreferences> salFacade = createSalFacade(remoteDeviceId);
if (keepaliveDelay > 0) {
LOG.info("Adding keepalive facade, for device {}", nodeId);
salFacade = new KeepaliveSalFacade(remoteDeviceId, salFacade, this.keepaliveExecutor.getExecutor(), keepaliveDelay, node.requireDefaultRequestTimeoutMillis().toJava());
}
final RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> device;
final List<SchemaSourceRegistration<?>> yanglibRegistrations;
if (node.requireSchemaless()) {
device = new SchemalessNetconfDevice(baseSchemas, remoteDeviceId, salFacade);
yanglibRegistrations = List.of();
} else {
final boolean reconnectOnChangedSchema = node.requireReconnectOnChangedSchema();
final SchemaResourcesDTO resources = schemaManager.getSchemaResources(node, nodeId.getValue());
device = new NetconfDeviceBuilder().setReconnectOnSchemasChange(reconnectOnChangedSchema).setSchemaResourcesDTO(resources).setGlobalProcessingExecutor(this.processingExecutor).setId(remoteDeviceId).setSalFacade(salFacade).setNode(node).setEventExecutor(eventExecutor).setNodeOptional(nodeOptional).setDeviceActionFactory(deviceActionFactory).setBaseSchemas(baseSchemas).build();
yanglibRegistrations = registerDeviceSchemaSources(remoteDeviceId, node, resources);
}
final Optional<UserPreferences> userCapabilities = getUserCapabilities(node);
final int rpcMessageLimit = node.requireConcurrentRpcLimit().toJava();
if (rpcMessageLimit < 1) {
LOG.info("Concurrent rpc limit is smaller than 1, no limit will be enforced for device {}", remoteDeviceId);
}
final NetconfDeviceCommunicator netconfDeviceCommunicator = userCapabilities.isPresent() ? new NetconfDeviceCommunicator(remoteDeviceId, device, userCapabilities.get(), rpcMessageLimit) : new NetconfDeviceCommunicator(remoteDeviceId, device, rpcMessageLimit);
if (salFacade instanceof KeepaliveSalFacade) {
((KeepaliveSalFacade) salFacade).setListener(netconfDeviceCommunicator);
}
return new NetconfConnectorDTO(netconfDeviceCommunicator, salFacade, yanglibRegistrations);
}
use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.
the class RemoteDeviceConnectorImplTest method setUp.
@Before
public void setUp() {
remoteDeviceId = new RemoteDeviceId(TOPOLOGY_ID, new InetSocketAddress(InetAddresses.forString("127.0.0.1"), 9999));
builder = new NetconfTopologySetup.NetconfTopologySetupBuilder().setBaseSchemas(BASE_SCHEMAS).setDataBroker(dataBroker).setRpcProviderRegistry(rpcProviderRegistry).setClusterSingletonServiceProvider(clusterSingletonServiceProvider).setKeepaliveExecutor(keepaliveExecutor).setProcessingExecutor(processingExecutor).setActorSystem(actorSystem).setEventExecutor(eventExecutor).setNetconfClientDispatcher(clientDispatcher).setTopologyId(TOPOLOGY_ID);
}
use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.
the class NetconfTopologyUtils method createRemoteDeviceId.
public static RemoteDeviceId createRemoteDeviceId(final NodeId nodeId, final NetconfNode node) {
final IpAddress ipAddress = node.getHost().getIpAddress();
final InetSocketAddress address = new InetSocketAddress(ipAddress.getIpv4Address() != null ? ipAddress.getIpv4Address().getValue() : ipAddress.getIpv6Address().getValue(), node.getPort().getValue().toJava());
return new RemoteDeviceId(nodeId.getValue(), address);
}
Aggregations