2 * Copyright (c) 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
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
8 package org.opendaylight.serviceutils.srm.shell;
10 import org.apache.karaf.shell.commands.Command;
11 import org.apache.karaf.shell.commands.Option;
12 import org.apache.karaf.shell.console.OsgiCommandSupport;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.eclipse.jdt.annotation.Nullable;
15 import org.opendaylight.mdsal.binding.api.DataBroker;
16 import org.opendaylight.mdsal.binding.api.WriteTransaction;
17 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.ops.rev180626.ServiceOps;
19 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
21 @Command(scope = "srm", name = "debug", description = "SRM debug commands")
22 public class SrmDebugCommand extends OsgiCommandSupport {
23 @Option(name = "-c", aliases = {"--clear-ops"}, description = "Clear operations DS",
24 required = true, multiValued = false)
26 private final DataBroker txDataBroker;
28 public SrmDebugCommand(DataBroker dataBroker) {
29 txDataBroker = dataBroker;
34 protected @Nullable Object doExecute() throws Exception {
41 private void clearOpsDs() throws Exception {
42 InstanceIdentifier<ServiceOps> path = getInstanceIdentifier();
43 @NonNull WriteTransaction tx = txDataBroker.newWriteOnlyTransaction();
44 tx.delete(LogicalDatastoreType.OPERATIONAL, path);
48 private static InstanceIdentifier<ServiceOps> getInstanceIdentifier() {
49 return InstanceIdentifier.create(ServiceOps.class);