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.client.mdsal.NetconfDeviceSchema;
13 import org.opendaylight.netconf.client.mdsal.api.RemoteDeviceId;
14 import org.opendaylight.netconf.client.mdsal.api.RemoteDeviceServices;
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.NetconfDeviceSalFacade;
20 * {@link NetconfDeviceSalFacade} specialization for netconf topology.
22 public class NetconfTopologyDeviceSalFacade extends NetconfDeviceSalFacade {
23 private final NetconfDeviceTopologyAdapter datastoreAdapter;
25 public NetconfTopologyDeviceSalFacade(final RemoteDeviceId id, final DOMMountPointService mountPointService,
26 final boolean lockDatastore, final DataBroker dataBroker) {
27 super(id, mountPointService, NetconfNodeUtils.defaultTopologyMountPath(id), lockDatastore);
28 datastoreAdapter = new NetconfDeviceTopologyAdapter(dataBroker, NetconfNodeUtils.DEFAULT_TOPOLOGY_IID, id);
32 public synchronized void onDeviceConnected(final NetconfDeviceSchema deviceSchema,
33 final NetconfSessionPreferences sessionPreferences, final RemoteDeviceServices services) {
34 super.onDeviceConnected(deviceSchema, sessionPreferences, services);
35 datastoreAdapter.updateDeviceData(true, deviceSchema.capabilities(), sessionPreferences.sessionId());
39 public synchronized void onDeviceDisconnected() {
40 datastoreAdapter.updateDeviceData(false, NetconfDeviceCapabilities.empty(), null);
41 super.onDeviceDisconnected();
45 public synchronized void onDeviceFailed(final Throwable throwable) {
46 datastoreAdapter.setDeviceAsFailed(throwable);
47 super.onDeviceFailed(throwable);
52 datastoreAdapter.close();