Search in sources :

Example 1 with NetconfDataTreeService

use of org.opendaylight.netconf.dom.api.NetconfDataTreeService in project netconf by opendaylight.

the class MasterSalFacade method registerMasterMountPoint.

private void registerMasterMountPoint() {
    requireNonNull(id);
    requireNonNull(currentMountContext, "Device has no remote schema context yet. Probably not fully connected.");
    requireNonNull(netconfSessionPreferences, "Device has no capabilities yet. Probably not fully connected.");
    final NetconfDeviceNotificationService notificationService = new NetconfDeviceNotificationService();
    deviceDataBroker = newDeviceDataBroker();
    netconfService = newNetconfDataTreeService();
    // We need to create ProxyDOMDataBroker so accessing mountpoint
    // on leader node would be same as on follower node
    final ProxyDOMDataBroker proxyDataBroker = new ProxyDOMDataBroker(id, masterActorRef, actorSystem.dispatcher(), actorResponseWaitTime);
    final NetconfDataTreeService proxyNetconfService = new ProxyNetconfDataTreeService(id, masterActorRef, actorSystem.dispatcher(), actorResponseWaitTime);
    salProvider.getMountInstance().onTopologyDeviceConnected(currentMountContext.getEffectiveModelContext(), proxyDataBroker, proxyNetconfService, deviceRpc, notificationService, deviceAction);
}
Also used : AbstractNetconfDataTreeService(org.opendaylight.netconf.sal.connect.netconf.sal.AbstractNetconfDataTreeService) NetconfDataTreeService(org.opendaylight.netconf.dom.api.NetconfDataTreeService) NetconfDeviceNotificationService(org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceNotificationService)

Example 2 with NetconfDataTreeService

use of org.opendaylight.netconf.dom.api.NetconfDataTreeService in project netconf by opendaylight.

the class NetconfNodeActorTest method testSlaveNewNetconfDataTreeServiceRequest.

@Test
public void testSlaveNewNetconfDataTreeServiceRequest() {
    initializeMaster(Collections.emptyList());
    registerSlaveMountPoint();
    ArgumentCaptor<NetconfDataTreeService> netconfCaptor = ArgumentCaptor.forClass(NetconfDataTreeService.class);
    verify(mockMountPointBuilder).addService(eq(NetconfDataTreeService.class), netconfCaptor.capture());
    final NetconfDataTreeService slaveNetconfService = netconfCaptor.getValue();
    assertTrue(slaveNetconfService instanceof ProxyNetconfDataTreeService);
    final YangInstanceIdentifier PATH = YangInstanceIdentifier.empty();
    final LogicalDatastoreType STORE = LogicalDatastoreType.CONFIGURATION;
    final ContainerNode NODE = Builders.containerBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("", "cont"))).build();
    final FluentFuture<Optional<Object>> result = immediateFluentFuture(Optional.of(NODE));
    doReturn(result).when(netconfService).get(PATH);
    doReturn(result).when(netconfService).getConfig(PATH);
    doReturn(emptyFluentFuture()).when(netconfService).commit();
    slaveNetconfService.get(PATH);
    slaveNetconfService.getConfig(PATH);
    slaveNetconfService.lock();
    slaveNetconfService.merge(STORE, PATH, NODE, Optional.empty());
    slaveNetconfService.replace(STORE, PATH, NODE, Optional.empty());
    slaveNetconfService.create(STORE, PATH, NODE, Optional.empty());
    slaveNetconfService.delete(STORE, PATH);
    slaveNetconfService.remove(STORE, PATH);
    slaveNetconfService.discardChanges();
    slaveNetconfService.commit();
    verify(netconfService, timeout(1000)).get(PATH);
    verify(netconfService, timeout(1000)).getConfig(PATH);
    verify(netconfService, timeout(1000)).lock();
    verify(netconfService, timeout(1000)).merge(STORE, PATH, NODE, Optional.empty());
    verify(netconfService, timeout(1000)).replace(STORE, PATH, NODE, Optional.empty());
    verify(netconfService, timeout(1000)).create(STORE, PATH, NODE, Optional.empty());
    verify(netconfService, timeout(1000)).delete(STORE, PATH);
    verify(netconfService, timeout(1000)).remove(STORE, PATH);
    verify(netconfService, timeout(1000)).discardChanges();
    verify(netconfService, timeout(1000)).commit();
}
Also used : NetconfDataTreeService(org.opendaylight.netconf.dom.api.NetconfDataTreeService) Optional(java.util.Optional) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Example 3 with NetconfDataTreeService

use of org.opendaylight.netconf.dom.api.NetconfDataTreeService in project netconf by opendaylight.

the class SlaveSalFacade method registerSlaveMountPoint.

public void registerSlaveMountPoint(final EffectiveModelContext remoteSchemaContext, final DOMRpcService deviceRpc, final DOMActionService deviceAction, final ActorRef masterActorRef) {
    if (!registered.compareAndSet(false, true)) {
        return;
    }
    final NetconfDeviceNotificationService notificationService = new NetconfDeviceNotificationService();
    final ProxyDOMDataBroker netconfDeviceDataBroker = new ProxyDOMDataBroker(id, masterActorRef, actorSystem.dispatcher(), actorResponseWaitTime);
    final NetconfDataTreeService proxyNetconfService = new ProxyNetconfDataTreeService(id, masterActorRef, actorSystem.dispatcher(), actorResponseWaitTime);
    salProvider.getMountInstance().onTopologyDeviceConnected(remoteSchemaContext, netconfDeviceDataBroker, proxyNetconfService, deviceRpc, notificationService, deviceAction);
    LOG.info("{}: Slave mount point registered.", id);
}
Also used : NetconfDataTreeService(org.opendaylight.netconf.dom.api.NetconfDataTreeService) NetconfDeviceNotificationService(org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceNotificationService)

Example 4 with NetconfDataTreeService

use of org.opendaylight.netconf.dom.api.NetconfDataTreeService in project netconf by opendaylight.

the class NetconfDeviceSalFacade method onDeviceConnected.

@Override
public synchronized void onDeviceConnected(final MountPointContext mountContext, final NetconfSessionPreferences netconfSessionPreferences, final DOMRpcService deviceRpc, final DOMActionService deviceAction) {
    final EffectiveModelContext schemaContext = mountContext.getEffectiveModelContext();
    final NetconfDeviceDataBroker netconfDeviceDataBroker = new NetconfDeviceDataBroker(id, mountContext, deviceRpc, netconfSessionPreferences);
    final NetconfDataTreeService netconfService = AbstractNetconfDataTreeService.of(id, mountContext, deviceRpc, netconfSessionPreferences);
    registerLockListener(netconfDeviceDataBroker, netconfService);
    final NetconfDeviceNotificationService notificationService = new NetconfDeviceNotificationService();
    salProvider.getMountInstance().onTopologyDeviceConnected(schemaContext, netconfDeviceDataBroker, netconfService, deviceRpc, notificationService, deviceAction);
    salProvider.getTopologyDatastoreAdapter().updateDeviceData(true, netconfSessionPreferences.getNetconfDeviceCapabilities());
}
Also used : NetconfDataTreeService(org.opendaylight.netconf.dom.api.NetconfDataTreeService) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)

Aggregations

NetconfDataTreeService (org.opendaylight.netconf.dom.api.NetconfDataTreeService)4 NetconfDeviceNotificationService (org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceNotificationService)2 Optional (java.util.Optional)1 Test (org.junit.Test)1 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)1 AbstractNetconfDataTreeService (org.opendaylight.netconf.sal.connect.netconf.sal.AbstractNetconfDataTreeService)1 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)1 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)1 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)1