Use censor attribute for CLI commands
[netconf.git] / netconf / netconf-console / src / main / java / org / opendaylight / netconf / console / commands / NetconfUpdateDeviceCommand.java
index 054d1154118d7445f8bd39c9448e88dc2a598f52..9d0581b8a47e4862f143b690e34e2a4378246f32 100644 (file)
@@ -14,16 +14,20 @@ import java.util.Map;
 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.")
+@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
@@ -43,6 +47,7 @@ public class NetconfUpdateDeviceCommand implements Action {
             aliases = { "--username" },
             description = "Username for NETCONF connection",
             required = true,
+            censor = true,
             multiValued = false)
     private String username;
 
@@ -50,6 +55,7 @@ public class NetconfUpdateDeviceCommand implements Action {
             aliases = { "--password" },
             description = "Password for NETCONF connection",
             required = true,
+            censor = true,
             multiValued = false)
     private String password;
 
@@ -96,8 +102,7 @@ public class NetconfUpdateDeviceCommand implements Action {
     private String newSchemaless = "false";
 
     @Override
-    public  Object execute() {
-
+    public Object execute() {
         Map<String, String> updated = new HashMap<>();
         updated.put(NetconfConsoleConstants.NETCONF_IP, newIp);
         updated.put(NetconfConsoleConstants.NETCONF_PORT, newPort);