Introduce cli commands for clustering-test-app
[controller.git] / opendaylight / md-sal / samples / clustering-test-app / karaf-cli / src / main / java / org / opendaylight / clustering / it / karaf / cli / odl / mdsal / lowlevel / control / UnregisterBoundConstantCommand.java
1 /*
2  * Copyright (c) 2021 PANTHEON.tech, s.r.o. 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 package org.opendaylight.clustering.it.karaf.cli.odl.mdsal.lowlevel.control;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import org.apache.karaf.shell.api.action.Argument;
12 import org.apache.karaf.shell.api.action.Command;
13 import org.apache.karaf.shell.api.action.lifecycle.Reference;
14 import org.apache.karaf.shell.api.action.lifecycle.Service;
15 import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
16 import org.opendaylight.clustering.it.karaf.cli.InstanceIdentifierSupport;
17 import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
18 import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.OdlMdsalLowlevelControlService;
19 import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnregisterBoundConstantInputBuilder;
20 import org.opendaylight.yangtools.yang.common.RpcResult;
21
22 @Service
23 @Command(scope = "test-app", name = "unregister-bound-constant", description = "Run an unregister-bound-constant test")
24 public class UnregisterBoundConstantCommand extends AbstractRpcAction {
25     @Reference
26     private RpcConsumerRegistry rpcService;
27     @Reference
28     private InstanceIdentifierSupport iidSupport;
29     @Argument(index = 0, name = "context", required = true)
30     String context;
31
32     @Override
33     protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
34         return rpcService.getRpcService(OdlMdsalLowlevelControlService.class)
35                 .unregisterBoundConstant(new UnregisterBoundConstantInputBuilder()
36                         .setContext(iidSupport.parseArgument(context))
37                         .build());
38     }
39 }