<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Karaf-Commands>*</Karaf-Commands>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
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.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder;
-@Command(name = "netconf:connect-device", scope = "netconf", description = "Connect to a netconf device.")
+@Service
+@Command(name = "connect-device", scope = "netconf", description = "Connect to a netconf device.")
public class NetconfConnectDeviceCommand implements Action {
- protected final NetconfCommands service;
+ @Reference
+ private NetconfCommands service;
+
+ public NetconfConnectDeviceCommand() {
- public NetconfConnectDeviceCommand(final NetconfCommands service) {
- this.service = service;
}
@VisibleForTesting
- NetconfConnectDeviceCommand(final NetconfCommands service, final String deviceIp, final String devicePort) {
+ NetconfConnectDeviceCommand(final NetconfCommands service) {
this.service = service;
- this.deviceIp = deviceIp;
- this.devicePort = devicePort;
}
@VisibleForTesting
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;
-@Command(name = "netconf:disconnect-device", scope = "netconf", description = "Disconnect netconf device.")
+@Service
+@Command(name = "disconnect-device", scope = "netconf", description = "Disconnect netconf device.")
public class NetconfDisconnectDeviceCommand implements Action {
- protected final NetconfCommands service;
+ @Reference
+ private NetconfCommands service;
- public NetconfDisconnectDeviceCommand(final NetconfCommands service) {
+ public NetconfDisconnectDeviceCommand() {
+
+ }
+
+ @VisibleForTesting
+ NetconfDisconnectDeviceCommand(final NetconfCommands service) {
this.service = service;
}
package org.opendaylight.netconf.console.commands;
+import com.google.common.annotations.VisibleForTesting;
import java.util.Map;
import javax.annotation.Nonnull;
import org.apache.karaf.shell.api.action.Action;
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.apache.karaf.shell.support.table.ShellTable;
import org.opendaylight.netconf.console.api.NetconfCommands;
import org.opendaylight.netconf.console.utils.NetconfConsoleConstants;
-@Command(name = "netconf:list-devices", scope = "netconf", description = "List all netconf devices in the topology.")
+@Service
+@Command(name = "list-devices", scope = "netconf", description = "List all netconf devices in the topology.")
public class NetconfListDevicesCommand implements Action {
- protected final NetconfCommands service;
+ @Reference
+ private NetconfCommands service;
- public NetconfListDevicesCommand(final NetconfCommands service) {
+ public NetconfListDevicesCommand() {
+
+ }
+
+ @VisibleForTesting
+ NetconfListDevicesCommand(final NetconfCommands service) {
this.service = service;
}
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.apache.karaf.shell.support.table.ShellTable;
import org.opendaylight.netconf.console.api.NetconfCommands;
import org.opendaylight.netconf.console.utils.NetconfConsoleConstants;
-@Command(name = "netconf:show-device", scope = "netconf", description = "Shows netconf device attributes.")
+@Service
+@Command(name = "show-device", scope = "netconf", description = "Shows netconf device attributes.")
public class NetconfShowDeviceCommand implements Action {
- protected final NetconfCommands service;
+ @Reference
+ private NetconfCommands service;
- public NetconfShowDeviceCommand(final NetconfCommands service) {
+ public NetconfShowDeviceCommand() {
+
+ }
+
+ @VisibleForTesting
+ NetconfShowDeviceCommand(final NetconfCommands service) {
this.service = service;
}
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
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);
</bean>
<service ref="netconfCommandsImpl" interface="org.opendaylight.netconf.console.api.NetconfCommands" />
- <!--Karaf CLI-->
-
- <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
- <command name="netconf:connect-device">
- <action class="org.opendaylight.netconf.console.commands.NetconfConnectDeviceCommand">
- <argument ref="netconfCommandsImpl"/>
- </action>
- </command>
- <command name="netconf:list-devices">
- <action class="org.opendaylight.netconf.console.commands.NetconfListDevicesCommand">
- <argument ref="netconfCommandsImpl"/>
- </action>
- </command>
- <command name="netconf:show-device">
- <action class="org.opendaylight.netconf.console.commands.NetconfShowDeviceCommand">
- <argument ref="netconfCommandsImpl"/>
- </action>
- </command>
- <command name="netconf:disconnect-device">
- <action class="org.opendaylight.netconf.console.commands.NetconfDisconnectDeviceCommand">
- <argument ref="netconfCommandsImpl"/>
- </action>
- </command>
- <command name="netconf:update-device">
- <action class="org.opendaylight.netconf.console.commands.NetconfUpdateDeviceCommand">
- <argument ref="netconfCommandsImpl"/>
- </action>
- </command>
- </command-bundle>
-
</blueprint>