1 package org.opendaylight.mwtn.base.netconf;
3 import javax.annotation.Nullable;
5 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
6 import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
7 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
8 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
9 import org.opendaylight.mwtn.devicemanager.impl.ProviderClient;
10 import org.opendaylight.mwtn.devicemanager.impl.database.service.HtDatabaseEventsService;
11 import org.opendaylight.mwtn.devicemanager.impl.xml.WebSocketServiceClient;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus;
14 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
15 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 import com.google.common.base.Optional;
22 * Create a Network Element representation according to the capability information.
23 * The capabilities are more than an ODL-QName. After the ? other terms than "revision" are provided.
26 public class ONFCoreNetworkElementFactory {
28 private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElementFactory.class);
30 public static ONFCoreNetworkElementRepresentation create( String mountPointNodeName,
31 DataBroker dataBroker, WebSocketServiceClient webSocketService, HtDatabaseEventsService databaseService, InstanceIdentifier<Node> instanceIdentifier,
32 DataBroker mountpointDataBroker, ProviderClient dcaeProvider, @Nullable ProviderClient aotsmClient ) {
34 ReadTransaction tx=dataBroker.newReadOnlyTransaction();
35 ONFCoreNetworkElementRepresentation res = null;
38 Optional<Node> nodeOption = tx.read(LogicalDatastoreType.OPERATIONAL,instanceIdentifier).checkedGet();
39 if (nodeOption.isPresent()) {
40 Node node = nodeOption.get();
41 NetconfNode nnode=node.getAugmentation(NetconfNode.class);
43 ConnectionStatus csts=nnode.getConnectionStatus();
44 if (csts == ConnectionStatus.Connected) {
45 Capabilities capabilities = new Capabilities(nnode);
46 LOG.info("Mountpoint {} capabilities {}",mountPointNodeName, capabilities);
48 res = ONFCoreNetworkElement10.build(mountPointNodeName, capabilities, mountpointDataBroker, webSocketService, databaseService, dcaeProvider,aotsmClient);
50 res = ONFCoreNetworkElement12.build(mountPointNodeName, capabilities, mountpointDataBroker, webSocketService, databaseService, dcaeProvider,aotsmClient);
55 } catch (ReadFailedException | IllegalArgumentException e) {
56 LOG.warn("Can not generate specific NE Version representation. ", e);
59 res = new ONFCoreEmpty(mountPointNodeName);
62 LOG.info("Mointpoint {} started as {}", mountPointNodeName,res.getClass().getSimpleName() );