Add .gitreview
[serviceutils.git] / srm / impl / src / main / java / org / opendaylight / serviceutils / srm / impl / SrmRpcProvider.java
1 /*
2  * Copyright (c) 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.serviceutils.srm.impl;
10
11 import com.google.common.util.concurrent.Futures;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import javax.inject.Inject;
14 import javax.inject.Singleton;
15
16 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
17 import org.opendaylight.serviceutils.tools.mdsal.rpc.FutureRpcResults;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpcs.rev170711.RecoverInput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpcs.rev170711.RecoverOutput;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpcs.rev170711.ReinstallInput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpcs.rev170711.ReinstallOutput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpcs.rev170711.SrmRpcsService;
23 import org.opendaylight.yangtools.yang.common.RpcResult;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26
27 @Singleton
28 public class SrmRpcProvider implements SrmRpcsService {
29
30     private static final Logger LOG = LoggerFactory.getLogger(SrmRpcProvider.class);
31
32     private final DataBroker dataBroker;
33
34     @Inject
35     public SrmRpcProvider(final DataBroker dataBroker) {
36         this.dataBroker = dataBroker;
37     }
38
39     @Override
40     public ListenableFuture<RpcResult<RecoverOutput>> recover(RecoverInput input) {
41         return FutureRpcResults.fromListenableFuture(LOG, "recover", input,
42             () -> Futures.immediateFuture(SrmRpcUtils.callSrmOp(dataBroker, input))).build();
43     }
44
45     @Override
46     public ListenableFuture<RpcResult<ReinstallOutput>> reinstall(ReinstallInput input) {
47         return FutureRpcResults.fromListenableFuture(LOG, "reinstall", input,
48             () -> Futures.immediateFuture(SrmRpcUtils.callSrmOp(dataBroker, input))).build();
49     }
50
51 }