import com.google.common.annotations.VisibleForTesting;
import java.util.HashMap;
import java.util.Map;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.console.AbstractAction;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.netconf.console.api.NetconfCommands;
import org.opendaylight.netconf.console.utils.NetconfConsoleConstants;
-@Command(name = "netconf:update-device", scope = "netconf", description = "Update netconf device attributes.")
-public class NetconfUpdateDeviceCommand extends AbstractAction {
+@Service
+@Command(name = "update-device", scope = "netconf", description = "Update netconf device attributes.")
+public class NetconfUpdateDeviceCommand implements Action {
- protected final NetconfCommands service;
+ @Reference
+ private NetconfCommands service;
+
+ public NetconfUpdateDeviceCommand() {
- public NetconfUpdateDeviceCommand(final NetconfCommands service) {
- this.service = service;
}
@VisibleForTesting
aliases = { "--username" },
description = "Username for NETCONF connection",
required = true,
+ censor = true,
multiValued = false)
private String username;
aliases = { "--password" },
description = "Password for NETCONF connection",
required = true,
+ censor = true,
multiValued = false)
private String password;
private String newSchemaless = "false";
@Override
- protected Object doExecute() throws Exception {
-
+ public Object execute() {
Map<String, String> updated = new HashMap<>();
updated.put(NetconfConsoleConstants.NETCONF_IP, newIp);
updated.put(NetconfConsoleConstants.NETCONF_PORT, newPort);
if (updated.isEmpty()) {
return "Nothing to update.";
- } else {
- String statusMessage = service.updateDevice(deviceId, username, password, updated);
- return statusMessage;
}
- }
+ return service.updateDevice(deviceId, username, password, updated);
+ }
}