2 * Copyright (c) 2023 PANTHEON.tech, s.r.o. 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.topology.spi;
10 import org.opendaylight.mdsal.binding.api.DataBroker;
11 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
12 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceId;
13 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceServices;
14 import org.opendaylight.netconf.sal.connect.netconf.NetconfDeviceSchema;
15 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCapabilities;
16 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
17 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceMount;
18 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceSalFacade;
21 * {@link NetconfDeviceSalFacade} specialization for netconf topology.
23 public class NetconfTopologyDeviceSalFacade extends NetconfDeviceSalFacade {
24 private final NetconfDeviceTopologyAdapter datastoreAdapter;
26 public NetconfTopologyDeviceSalFacade(final RemoteDeviceId id, final DOMMountPointService mountPointService,
27 final boolean lockDatastore, final DataBroker dataBroker) {
28 super(id, mountPointService, NetconfDeviceMount.defaultTopologyMountPath(id), lockDatastore);
29 datastoreAdapter = new NetconfDeviceTopologyAdapter(dataBroker, AbstractNetconfTopology.DEFAULT_TOPOLOGY_IID,
34 public synchronized void onDeviceConnected(final NetconfDeviceSchema deviceSchema,
35 final NetconfSessionPreferences sessionPreferences, final RemoteDeviceServices services) {
36 super.onDeviceConnected(deviceSchema, sessionPreferences, services);
37 datastoreAdapter.updateDeviceData(true, deviceSchema.capabilities());
42 public synchronized void onDeviceDisconnected() {
43 datastoreAdapter.updateDeviceData(false, NetconfDeviceCapabilities.empty());
44 super.onDeviceDisconnected();
48 public synchronized void onDeviceFailed(final Throwable throwable) {
49 datastoreAdapter.setDeviceAsFailed(throwable);
50 super.onDeviceFailed(throwable);
55 datastoreAdapter.close();