2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.sal.connect.netconf.sal;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.annotations.VisibleForTesting;
13 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
14 import org.opendaylight.mdsal.dom.api.DOMNotification;
15 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler;
16 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceServices;
17 import org.opendaylight.netconf.sal.connect.netconf.NetconfDeviceSchema;
18 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
19 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
21 public class NetconfDeviceSalFacade implements RemoteDeviceHandler, AutoCloseable {
22 private final RemoteDeviceId id;
23 private final NetconfDeviceMount mount;
24 private final boolean lockDatastore;
26 public NetconfDeviceSalFacade(final RemoteDeviceId id, final DOMMountPointService mountPointService,
27 final boolean lockDatastore) {
28 this(id, new NetconfDeviceMount(mountPointService, id), lockDatastore);
32 NetconfDeviceSalFacade(final RemoteDeviceId id, final NetconfDeviceMount mount, final boolean lockDatastore) {
33 this.id = requireNonNull(id);
34 this.mount = requireNonNull(mount);
35 this.lockDatastore = lockDatastore;
39 public synchronized void onNotification(final DOMNotification domNotification) {
40 mount.publish(domNotification);
44 public synchronized void onDeviceConnected(final NetconfDeviceSchema deviceSchema,
45 final NetconfSessionPreferences sessionPreferences, final RemoteDeviceServices services) {
46 final var mountContext = deviceSchema.mountContext();
47 final var modelContext = mountContext.getEffectiveModelContext();
49 final var deviceRpc = services.rpcs();
51 final var netconfDataTree = AbstractNetconfDataTreeService.of(id, mountContext, deviceRpc, sessionPreferences,
53 final var netconfDataBroker = new NetconfDeviceDataBroker(id, mountContext, deviceRpc, sessionPreferences,
56 mount.onDeviceConnected(modelContext, services, netconfDataBroker, netconfDataTree);
60 public synchronized void onDeviceDisconnected() {
61 mount.onDeviceDisconnected();
65 public synchronized void onDeviceFailed(final Throwable throwable) {
66 mount.onDeviceDisconnected();
70 public synchronized void close() {