2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * Modifications Copyright (C) 2020 Nordix Foundation.
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.ccsdk.features.sdnr.northbound.a1Adapter;
25 import com.google.common.util.concurrent.ListenableFuture;
26 import java.util.concurrent.ExecutorService;
27 import java.util.concurrent.Executors;
28 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
29 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
30 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
31 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
32 import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.A1ADAPTERAPIService;
33 import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.DeleteA1PolicyInput;
34 import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.DeleteA1PolicyOutput;
35 import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyInput;
36 import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyOutput;
37 import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyStatusInput;
38 import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyStatusOutput;
39 import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyTypeInput;
40 import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyTypeOutput;
41 import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.PutA1PolicyInput;
42 import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.PutA1PolicyOutput;
43 import org.opendaylight.yangtools.yang.common.RpcResult;
44 import org.slf4j.Logger;
45 import org.slf4j.LoggerFactory;
48 * Defines a base implementation for your provider. This class extends from a helper class which
49 * provides storage for the most commonly used components of the MD-SAL. Additionally the base class
50 * provides some basic logging and initialization / clean up methods.
53 public class A1AdapterProvider implements AutoCloseable, A1ADAPTERAPIService {
55 private static final Logger LOG = LoggerFactory.getLogger(A1AdapterProvider.class);
57 private static final String APPLICATION_NAME = "a1Adapter-api";
58 private static final String GET_NEARRT_RICS = "getNearRT-RICs";
59 private static final String GET_HEALTH_CHECK = "getHealthCheck";
60 private static final String GET_POLICY_TYPES = "getPolicyTypes";
61 private static final String CREATE_POLICY_TYPE = "createPolicyType";
62 private static final String GET_POLICY_TYPE = "getPolicyType";
63 private static final String DELETE_POLICY_TYPE = "deletePolicyType";
64 private static final String GET_POLICY_INSTANCES = "getPolicyInstances";
65 private static final String CREATE_POLICY_INSTANCES = "createPolicyInstance";
66 private static final String GET_POLICY_INSTANCE = "getPolicyInstance";
67 private static final String DELETE_POLICY_INSTANCE = "deletePolicyInstance";
68 private static final String GET_STATUS = "getStatus";
69 private static final String NOTIFICATION_ENFORECEMENT = "notifyPolicyEnforcementUpdate";
71 private final ExecutorService executor;
72 protected DataBroker dataBroker;
73 protected NotificationPublishService notificationService;
74 protected RpcProviderRegistry rpcRegistry;
75 protected BindingAwareBroker.RpcRegistration<A1ADAPTERAPIService> rpcRegistration;
76 private final A1AdapterClient A1AdapterClient;
78 public A1AdapterProvider(final DataBroker dataBroker, final NotificationPublishService notificationPublishService,
79 final RpcProviderRegistry rpcProviderRegistry, final A1AdapterClient A1AdapterClient) {
81 LOG.info("Creating provider for {}", APPLICATION_NAME);
82 executor = Executors.newFixedThreadPool(1);
83 this.dataBroker = dataBroker;
84 this.notificationService = notificationPublishService;
85 this.rpcRegistry = rpcProviderRegistry;
86 this.A1AdapterClient = A1AdapterClient;
90 public void initialize() {
91 LOG.info("Initializing provider for {}", APPLICATION_NAME);
92 rpcRegistration = rpcRegistry.addRpcImplementation(A1ADAPTERAPIService.class, this);
93 LOG.info("Initialization complete for {}", APPLICATION_NAME);
96 protected void initializeChild() {
97 // Override if you have custom initialization intelligence
101 public void close() throws Exception {
102 LOG.info("Closing provider for {}", APPLICATION_NAME);
104 rpcRegistration.close();
105 LOG.info("Successfully closed provider for {}", APPLICATION_NAME);
109 public ListenableFuture<RpcResult<DeleteA1PolicyOutput>> deleteA1Policy(DeleteA1PolicyInput input) {
110 // TODO Auto-generated method stub
115 public ListenableFuture<RpcResult<GetA1PolicyOutput>> getA1Policy(GetA1PolicyInput input) {
116 // TODO Auto-generated method stub
121 public ListenableFuture<RpcResult<GetA1PolicyStatusOutput>> getA1PolicyStatus(GetA1PolicyStatusInput input) {
122 // TODO Auto-generated method stub
127 public ListenableFuture<RpcResult<GetA1PolicyTypeOutput>> getA1PolicyType(GetA1PolicyTypeInput input) {
128 // TODO Auto-generated method stub
133 public ListenableFuture<RpcResult<PutA1PolicyOutput>> putA1Policy(PutA1PolicyInput input) {
134 // TODO Auto-generated method stub