40a6d323bb41e65cf1b533edc27c7da94d26bf35
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18 /**
19  *
20  */
21 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne;
22
23 import java.util.Optional;
24 import javax.annotation.Nonnull;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ONFCoreNetworkElementRepresentation;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InternalConnectionStatus;
27 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
28 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
29 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
30 import org.opendaylight.mdsal.binding.api.DataBroker;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
32 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
33 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPassword;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ConnectionLogStatus;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionEntity;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.network.element.connection.entity.NodeDetailsBuilder;
42 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
43 import org.slf4j.Logger;
44 import org.slf4j.LoggerFactory;
45
46 /**
47  * @author herbert
48  *
49  */
50 @SuppressWarnings("deprecation")
51 public abstract class ONFCoreNetworkElementBase implements AutoCloseable, ONFCoreNetworkElementRepresentation {
52
53     private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElementBase.class);
54
55     protected static final String EMPTY = "";
56
57     private final String mountPointNodeName;
58     private final NodeId nodeId;
59     private final DataBroker netconfNodeDataBroker;
60     private final NetconfAccessor acessor;
61
62     protected ONFCoreNetworkElementBase(NetconfAccessor acessor) {
63         LOG.info("Create ONFCoreNetworkElementBase");
64         this.mountPointNodeName = acessor.getNodeId().getValue();
65         this.nodeId = acessor.getNodeId();
66         this.netconfNodeDataBroker = acessor.getDataBroker();
67         this.acessor = acessor;
68
69     }
70
71     @Override
72     public Optional<NetconfAccessor> getAcessor() {
73         return Optional.of(acessor);
74     }
75
76     @Override
77     public String getMountPointNodeName() {
78         return mountPointNodeName;
79     }
80
81     /**
82      * @return the netconfNodeDataBroker
83      */
84     public DataBroker getNetconfNodeDataBroker() {
85         return netconfNodeDataBroker;
86     }
87
88     @Override
89     public void warmstart() {
90         int problems = removeAllCurrentProblemsOfNode();
91         LOG.debug("Removed all {} problems from database at deregistration for {}", problems, mountPointNodeName);
92     }
93
94     @Override
95     public NodeId getNodeId() {
96         return nodeId;
97     }
98
99     public TransactionUtils getGenericTransactionUtils() {
100         return acessor.getTransactionUtils();
101     }
102
103     /*---------------------------------------------------------------
104      * Getter/ Setter
105      */
106     @Override
107     public String getMountpoint() {
108         return mountPointNodeName;
109     }
110
111     @Override
112     public DataBroker getDataBroker() {
113         return netconfNodeDataBroker;
114     }
115
116 }