Do not use RpcService in srm-impl components 63/107763/11
authorlubos-cicut <lubos.cicut@pantheon.tech>
Tue, 12 Sep 2023 11:45:52 +0000 (13:45 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 26 Sep 2023 19:38:08 +0000 (21:38 +0200)
Ditch the dependency on OdlSrmRpcsService and define a more natural
interface, RegistryControl, for use with the shell. This avoids some amount
of boiler plate, as we do not have to deal with the entire RPC dispatch
stack.

While we are here, also clean up pom.xmls to eliminate dependency
warnings.

JIRA: SRVUTILS-10
Change-Id: I218d7b6681270ea72fbc103f15199431a64fe50e
Signed-off-by: lubos-cicut <lubos.cicut@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
srm/api/src/main/java/org/opendaylight/serviceutils/srm/spi/RegistryControl.java [new file with mode: 0644]
srm/impl/pom.xml
srm/impl/src/main/java/org/opendaylight/serviceutils/srm/impl/RegistryControlImpl.java [moved from srm/impl/src/main/java/org/opendaylight/serviceutils/srm/impl/SrmRpcUtils.java with 84% similarity]
srm/impl/src/main/java/org/opendaylight/serviceutils/srm/impl/SrmRpcProvider.java [deleted file]
srm/shell/pom.xml
srm/shell/src/main/java/org/opendaylight/serviceutils/srm/shell/RecoverCommand.java
srm/shell/src/main/java/org/opendaylight/serviceutils/srm/shell/ReinstallCommand.java

diff --git a/srm/api/src/main/java/org/opendaylight/serviceutils/srm/spi/RegistryControl.java b/srm/api/src/main/java/org/opendaylight/serviceutils/srm/spi/RegistryControl.java
new file mode 100644 (file)
index 0000000..ac19d63
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.serviceutils.srm.spi;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.RecoverInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.RecoverOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.ReinstallInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.ReinstallOutput;
+
+/**
+ * Control interface for ServiceRecoveryRegistry implementation.
+ */
+public interface RegistryControl {
+
+    RecoverOutput recover(RecoverInput input);
+
+    ReinstallOutput reinstall(ReinstallInput input);
+}
index e660372ffa7cc0cc51bb5c388e602a30d26a5dd8..d0d0ceb012e4c6e34e694076f881a4e88b495f82 100644 (file)
@@ -39,10 +39,26 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <artifactId>tools-api</artifactId>
       <version>${project.version}</version>
     </dependency>
+    <dependency>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.mdsal</groupId>
       <artifactId>mdsal-binding-api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.mdsal</groupId>
+      <artifactId>mdsal-common-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.mdsal</groupId>
+      <artifactId>yang-binding</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>concepts</artifactId>
+    </dependency>
     <dependency>
       <groupId>com.guicedee.services</groupId>
       <artifactId>javax.inject</artifactId>
similarity index 84%
rename from srm/impl/src/main/java/org/opendaylight/serviceutils/srm/impl/SrmRpcUtils.java
rename to srm/impl/src/main/java/org/opendaylight/serviceutils/srm/impl/RegistryControlImpl.java
index 7d2768b0a2cb8c3f7ffbc82ff94b21c4168970f7..983db718807db84b8fbcac87fced9f1a455b47bc 100644 (file)
@@ -7,19 +7,30 @@
  */
 package org.opendaylight.serviceutils.srm.impl;
 
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ImmutableClassToInstanceMap;
 import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.Futures;
 import java.util.concurrent.ExecutionException;
+import javax.annotation.PreDestroy;
+import javax.inject.Singleton;
 import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.mdsal.binding.api.WriteTransaction;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.serviceutils.srm.spi.RegistryControl;
+import org.opendaylight.serviceutils.tools.rpc.FutureRpcResults;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.ops.rev180626.ServiceOps;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.ops.rev180626.service.ops.Services;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.ops.rev180626.service.ops.ServicesKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.ops.rev180626.service.ops.services.Operations;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.ops.rev180626.service.ops.services.OperationsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.Recover;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.RecoverInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.RecoverOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.RecoverOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.Reinstall;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.ReinstallInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.ReinstallOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.ReinstallOutputBuilder;
@@ -53,22 +64,23 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.types.rev1
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.types.rev180626.Ofplugin;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.types.rev180626.ServiceOpRecover;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.types.rev180626.ServiceOpReinstall;
+import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.Rpc;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- * The Utility class for SRM Shell.
- */
-public final class SrmRpcUtils {
-    private static final Logger LOG = LoggerFactory.getLogger(SrmRpcUtils.class);
+@Singleton
+@Component(immediate = true, service = RegistryControl.class)
+public final class RegistryControlImpl implements RegistryControl, AutoCloseable {
+    private static final Logger LOG = LoggerFactory.getLogger(RegistryControlImpl.class);
     private static final Boolean REINSTALL_FAILED = Boolean.FALSE;
     private static final Boolean REINSTALL_SUCCESS = Boolean.TRUE;
 
-    private SrmRpcUtils() {
-        // Hidden on purpose
-    }
-
     private static final ImmutableMap<EntityNameBase, EntityTypeBase> NAME_TO_TYPE_MAP =
         ImmutableMap.<EntityNameBase, EntityTypeBase>builder()
             .put(GeniusItm.VALUE, EntityTypeService.VALUE)
@@ -115,8 +127,29 @@ public final class SrmRpcUtils {
             .put(NetvirtQosPolicyInstance.VALUE, NetvirtQos.VALUE)
             .build();
 
+    private final DataBroker dataBroker;
+    private final Registration reg;
+
+    @Activate
+    public RegistryControlImpl(@Reference DataBroker dataBroker, @Reference RpcProviderService rpcProvider) {
+        this.dataBroker = requireNonNull(dataBroker);
+        reg = rpcProvider.registerRpcImplementations(ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
+            .put(Recover.class, input -> FutureRpcResults.fromListenableFuture(LOG, "recover", input,
+                () -> Futures.immediateFuture(recover(input))).build())
+            .put(Reinstall.class, input -> FutureRpcResults.fromListenableFuture(LOG, "reinstall", input,
+                () -> Futures.immediateFuture(reinstall(input))).build())
+            .build());
+    }
+
+    @Override
+    @Deactivate
+    @PreDestroy
+    public void close() {
+        reg.close();
+    }
 
-    public static RecoverOutput callSrmOp(DataBroker broker, RecoverInput input) {
+    @Override
+    public RecoverOutput recover(RecoverInput input) {
         RecoverOutputBuilder outputBuilder = new RecoverOutputBuilder();
         if (input.getEntityName() == null) {
             outputBuilder.setResponse(RpcFailEntityName.VALUE)
@@ -159,9 +192,10 @@ public final class SrmRpcUtils {
         }
         Operations operation = opsBuilder.build();
         InstanceIdentifier<Operations> opsIid = getInstanceIdentifier(operation, serviceName);
-        WriteTransaction tx = broker.newWriteOnlyTransaction();
+        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
         tx.mergeParentStructurePut(LogicalDatastoreType.OPERATIONAL, opsIid, operation);
         try {
+            // FIXME: we are in RPC invocation path, we should not be blocking here
             tx.commit().get();
         } catch (InterruptedException | ExecutionException e) {
             LOG.error("Error writing RecoveryOp to datastore. path:{}, data:{}", opsIid, operation);
@@ -172,7 +206,8 @@ public final class SrmRpcUtils {
         return outputBuilder.build();
     }
 
-    public static ReinstallOutput callSrmOp(DataBroker broker, ReinstallInput input) {
+    @Override
+    public ReinstallOutput reinstall(ReinstallInput input) {
         ReinstallOutputBuilder outputBuilder = new ReinstallOutputBuilder();
         if (input.getEntityName() == null) {
             outputBuilder.setSuccessful(REINSTALL_FAILED)
@@ -213,9 +248,10 @@ public final class SrmRpcUtils {
             .setTriggerOperation(ServiceOpReinstall.VALUE);
         Operations operation = opsBuilder.build();
         InstanceIdentifier<Operations> opsIid = getInstanceIdentifier(operation, serviceName);
-        WriteTransaction tx = broker.newWriteOnlyTransaction();
+        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
         tx.mergeParentStructurePut(LogicalDatastoreType.OPERATIONAL, opsIid, operation);
         try {
+            // FIXME: we are in RPC invocation path, we should not be blocking here
             tx.commit().get();
         } catch (InterruptedException | ExecutionException e) {
             LOG.error("Error writing RecoveryOp to datastore. path:{}, data:{}", opsIid, operation);
diff --git a/srm/impl/src/main/java/org/opendaylight/serviceutils/srm/impl/SrmRpcProvider.java b/srm/impl/src/main/java/org/opendaylight/serviceutils/srm/impl/SrmRpcProvider.java
deleted file mode 100644 (file)
index 0f0bc17..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.serviceutils.srm.impl;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import javax.annotation.PreDestroy;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.RpcProviderService;
-import org.opendaylight.serviceutils.tools.rpc.FutureRpcResults;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.OdlSrmRpcsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.RecoverInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.RecoverOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.ReinstallInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.ReinstallOutput;
-import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.RequireServiceComponentRuntime;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Singleton
-@Component(immediate = true, service = OdlSrmRpcsService.class)
-@RequireServiceComponentRuntime
-public final class SrmRpcProvider implements OdlSrmRpcsService, AutoCloseable {
-    private static final Logger LOG = LoggerFactory.getLogger(SrmRpcProvider.class);
-
-    private final DataBroker dataBroker;
-    private final Registration reg;
-
-    @Inject
-    @Activate
-    public SrmRpcProvider(@Reference DataBroker dataBroker, @Reference RpcProviderService rpcProvider) {
-        this.dataBroker = dataBroker;
-        reg = rpcProvider.registerRpcImplementation(OdlSrmRpcsService.class, this);
-    }
-
-    @Override
-    @Deactivate
-    @PreDestroy
-    public void close() {
-        reg.close();
-    }
-
-    @Override
-    public ListenableFuture<RpcResult<RecoverOutput>> recover(RecoverInput input) {
-        return FutureRpcResults.fromListenableFuture(LOG, "recover", input,
-            () -> Futures.immediateFuture(SrmRpcUtils.callSrmOp(dataBroker, input))).build();
-    }
-
-    @Override
-    public ListenableFuture<RpcResult<ReinstallOutput>> reinstall(ReinstallInput input) {
-        return FutureRpcResults.fromListenableFuture(LOG, "reinstall", input,
-            () -> Futures.immediateFuture(SrmRpcUtils.callSrmOp(dataBroker, input))).build();
-    }
-}
index 0f8deac79e085c7129bb4231d2fca4992e098ebf..f97801f7ec0eaebf26ce8dca63f7658359544cba 100644 (file)
@@ -33,29 +33,25 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <scope>provided</scope>
     </dependency>
     <dependency>
-        <groupId>org.eclipse.jdt</groupId>
-        <artifactId>org.eclipse.jdt.annotation</artifactId>
+      <groupId>org.eclipse.jdt</groupId>
+      <artifactId>org.eclipse.jdt.annotation</artifactId>
     </dependency>
     <dependency>
-        <groupId>org.opendaylight.mdsal</groupId>
-        <artifactId>mdsal-binding-api</artifactId>
+      <groupId>org.opendaylight.mdsal</groupId>
+      <artifactId>mdsal-binding-api</artifactId>
     </dependency>
     <dependency>
-        <groupId>org.opendaylight.mdsal</groupId>
-        <artifactId>mdsal-common-api</artifactId>
+      <groupId>org.opendaylight.mdsal</groupId>
+      <artifactId>mdsal-common-api</artifactId>
     </dependency>
     <dependency>
-        <groupId>org.opendaylight.mdsal</groupId>
-        <artifactId>yang-binding</artifactId>
+      <groupId>org.opendaylight.mdsal</groupId>
+      <artifactId>yang-binding</artifactId>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.serviceutils</groupId>
       <artifactId>srm-api</artifactId>
     </dependency>
-    <dependency>
-        <groupId>org.opendaylight.yangtools</groupId>
-        <artifactId>yang-common</artifactId>
-    </dependency>
   </dependencies>
 
   <build>
index 92ee7275b1c17e9a3afd08d8a592edb0d297a51b..84ad9263354be1662d6ff6eb52b1e05fb9b3f8a4 100644 (file)
@@ -7,20 +7,14 @@
  */
 package org.opendaylight.serviceutils.srm.shell;
 
-import java.util.concurrent.Future;
 import org.apache.karaf.shell.api.action.Action;
 import org.apache.karaf.shell.api.action.Argument;
 import org.apache.karaf.shell.api.action.Command;
 import org.apache.karaf.shell.api.action.lifecycle.Reference;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.OdlSrmRpcsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.RecoverInput;
+import org.opendaylight.serviceutils.srm.spi.RegistryControl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.RecoverInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.RecoverOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.types.rev180626.EntityNameBase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.types.rev180626.EntityTypeBase;
-import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.RpcSuccess;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -39,57 +33,44 @@ public class RecoverCommand implements Action {
     @Argument(index = 2, name = "id", description = "EntityId, optional", required = false, multiValued = false)
     private String id;
     @Reference
-    private OdlSrmRpcsService srmRpcService;
+    private RegistryControl control;
 
     @Override
-    public @Nullable Object execute() throws Exception {
-        RecoverInput input = getInput();
-        if (input == null || srmRpcService == null) {
-            // We've already shown the relevant error msg
-            return null;
-        }
-        Future<RpcResult<RecoverOutput>> result = srmRpcService.recover(input);
-        RpcResult<RecoverOutput> recoverResult = result.get();
-        printResult(recoverResult);
-        return null;
-    }
-
-    @SuppressWarnings("checkstyle:RegexpSinglelineJava")
-    private static void printResult(RpcResult<RecoverOutput> recoverResult) {
-        var sb = new StringBuilder("");
-        if (recoverResult.isSuccessful()) {
-            sb.append("RPC call to recover was successful");
-            LOG.trace("RPC Result: {}", recoverResult.getResult());
-        } else {
-            sb.append("RPC Call to recover failed.\n")
-                .append("ErrorCode: ").append(recoverResult.getResult().getResponse())
-                .append("ErrorMsg: ").append(recoverResult.getResult().getMessage());
-            LOG.trace("RPC Result: {}", recoverResult.getResult());
-        }
-        System.out.println(sb.toString());
-    }
-
     @SuppressWarnings("checkstyle:RegexpSinglelineJava")
-    private @Nullable RecoverInput getInput() {
+    public Object execute() {
         if (type == null || name == null) {
             return null;
         }
-        EntityTypeBase entityType = SrmCliUtils.getEntityType(type);
+        var entityType = SrmCliUtils.getEntityType(type);
         if (entityType == null) {
             System.out.println(SrmCliUtils.getTypeHelp());
             return null;
         }
-        EntityNameBase entityName = SrmCliUtils.getEntityName(entityType, name);
+        var entityName = SrmCliUtils.getEntityName(entityType, name);
         if (entityName == null) {
             System.out.println(SrmCliUtils.getNameHelp(entityType));
             return null;
         }
-        var inputBuilder = new RecoverInputBuilder()
-            .setEntityType(entityType)
-            .setEntityName(entityName);
-        if (id != null) {
-            inputBuilder.setEntityId(id);
+
+        if (control != null) {
+            var inputBuilder = new RecoverInputBuilder()
+                .setEntityType(entityType)
+                .setEntityName(entityName);
+            if (id != null) {
+                inputBuilder.setEntityId(id);
+            }
+            var output = control.recover(inputBuilder.build());
+
+            LOG.trace("RPC Result: {}", output);
+            var response = output.getResponse();
+            if (RpcSuccess.VALUE.equals(response)) {
+                System.out.println("RPC call to recover was successful");
+            } else {
+                System.out.println("RPC call to recover failed.");
+                System.out.println("ErrorCode: " + response);
+                System.out.println("ErrorMsg: " + output.getMessage());
+            }
         }
-        return inputBuilder.build();
+        return null;
     }
 }
index a8280b82cc8ab4d60196e4b559585b75bd008349..68de0e84a7e90a99ba21c4172a299c63603ce078 100644 (file)
@@ -7,21 +7,15 @@
  */
 package org.opendaylight.serviceutils.srm.shell;
 
-import java.util.concurrent.Future;
 import org.apache.karaf.shell.api.action.Action;
 import org.apache.karaf.shell.api.action.Argument;
 import org.apache.karaf.shell.api.action.Command;
 import org.apache.karaf.shell.api.action.lifecycle.Reference;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.OdlSrmRpcsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.ReinstallInput;
+import org.opendaylight.serviceutils.srm.spi.RegistryControl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.ReinstallInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.rpc.rev180626.ReinstallOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.types.rev180626.EntityNameBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.types.rev180626.EntityTypeBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.types.rev180626.EntityTypeService;
-import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -38,44 +32,31 @@ public class ReinstallCommand implements Action {
         required = false, multiValued = false)
     private String name;
     @Reference
-    private OdlSrmRpcsService srmRpcService;
+    private RegistryControl control;
 
     @Override
-    public @Nullable Object execute() throws Exception {
-        ReinstallInput input = getInput();
-        if (input == null || srmRpcService == null) {
-            return null;
-        }
-        Future<RpcResult<ReinstallOutput>> result = srmRpcService.reinstall(input);
-        RpcResult<ReinstallOutput> reinstallResult = result.get();
-        printResult(reinstallResult);
-        return null;
-    }
-
     @SuppressWarnings("checkstyle:RegexpSinglelineJava")
-    private static void printResult(RpcResult<ReinstallOutput> reinstallResult) {
-        var sb = new StringBuilder("");
-        if (reinstallResult.isSuccessful()) {
-            sb.append("RPC call to reinstall was successful");
-            LOG.trace("RPC Result: {}", reinstallResult.getResult());
-        } else {
-            sb.append("RPC Call to reinstall failed.\n")
-                .append("ErrorMsg: ").append(reinstallResult.getResult().getMessage());
-            LOG.trace("RPC Result: {}", reinstallResult.getResult());
-        }
-        System.out.println(sb.toString());
-    }
-
-    @SuppressWarnings("checkstyle:RegexpSinglelineJava")
-    private @Nullable ReinstallInput getInput() {
-        EntityNameBase entityName = SrmCliUtils.getEntityName(ENTITY_TYPE, name);
+    public Object execute() {
+        var entityName = SrmCliUtils.getEntityName(ENTITY_TYPE, name);
         if (entityName == null) {
             System.out.println(SrmCliUtils.getNameHelp(ENTITY_TYPE));
             return null;
         }
-        return new ReinstallInputBuilder()
-            .setEntityType(ENTITY_TYPE)
-            .setEntityName(entityName)
-            .build();
+
+        if (control != null) {
+            var output = control.reinstall(new ReinstallInputBuilder()
+                .setEntityType(ENTITY_TYPE)
+                .setEntityName(entityName)
+                .build());
+
+            LOG.trace("RPC Result: {}", output);
+            if (Boolean.TRUE.equals(output.getSuccessful())) {
+                System.out.println("RPC call to reinstall was successful");
+            } else {
+                System.out.println("RPC Call to reinstall failed.");
+                System.out.println("ErrorMsg: " + output.getMessage());
+            }
+        }
+        return null;
     }
 }