<config.netconf.client.configfile>01-netconf.xml</config.netconf.client.configfile>
<config.netconf.topology.configfile>02-netconf-topology.xml</config.netconf.topology.configfile>
<config.netconf.connector.configfile>99-netconf-connector.xml</config.netconf.connector.configfile>
- <config.netconf.console.configfile>100-netconf-console.xml</config.netconf.console.configfile>
</properties>
<dependencyManagement>
<artifactId>netconf-console</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-console</artifactId>
- <version>${project.version}</version>
- <classifier>config</classifier>
- <type>xml</type>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>abstract-topology</artifactId>
<feature version='${project.version}'>odl-netconf-connector-all</feature>
<feature version='${project.version}'>odl-netconf-topology</feature>
<bundle>mvn:org.opendaylight.netconf/netconf-console/{{VERSION}}</bundle>
- <configfile finalname='${config.configfile.directory}/${config.netconf.console.configfile}'>mvn:org.opendaylight.netconf/netconf-console/{{VERSION}}/xml/config</configfile>
</feature>
</features>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (c) 2016 Inocybe Technologies. 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 INTERNAL
--->
-<snapshot>
- <required-capabilities>
- <capability>urn:opendaylight:netconf:console:provider:impl?module=netconf-console-provider-impl&revision=2016-03-23</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability>
- </required-capabilities>
-
- <configuration>
- <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
- <module>
- <type xmlns:prefix="urn:opendaylight:netconf:console:provider:impl">prefix:netconf-console-provider-impl</type>
- <name>netconf-console-default</name>
- <broker>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
- <name>binding-osgi-broker</name>
- </broker>
- </module>
- </modules>
- </data>
- </configuration>
-</snapshot>
\ No newline at end of file
package org.opendaylight.netconf.console.commands;
+import com.google.common.base.Strings;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import com.google.common.base.Strings;
-
public class NetconfCommandUtils {
private static final Pattern IP_PATTERN = Pattern.compile(
package org.opendaylight.netconf.console.commands;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Strings;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option;
import org.apache.karaf.shell.console.AbstractAction;
import org.opendaylight.netconf.console.api.NetconfCommands;
-import com.google.common.base.Strings;
-
@Command(name = "netconf:disconnect-device", scope = "netconf", description = "Disconnect netconf device.")
public class NetconfDisconnectDeviceCommand extends AbstractAction {
package org.opendaylight.netconf.console.commands;
import java.util.Map;
-
import javax.annotation.Nonnull;
-
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.console.AbstractAction;
import org.apache.karaf.shell.table.ShellTable;
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 java.util.UUID;
import java.util.stream.Collectors;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
private static final Logger LOG = LoggerFactory.getLogger(NetconfCommandsImpl.class);
private final DataBroker dataBroker;
- private final MountPointService mountPointService;
- public NetconfCommandsImpl(final DataBroker db, final MountPointService mountPointService) {
+ public NetconfCommandsImpl(final DataBroker db) {
LOG.debug("NetconfConsoleProviderImpl initialized");
this.dataBroker = db;
- this.mountPointService = mountPointService;
}
@Override
public Map<String, Map<String, String>> listDevices() {
final Topology topology = NetconfConsoleUtils.read(LogicalDatastoreType.OPERATIONAL, NetconfIidFactory.NETCONF_TOPOLOGY_IID, dataBroker);
+ if (topology == null) {
+ return new HashMap<>();
+ }
final Map<String, Map<String, String>> netconfNodes = new HashMap<>();
for (final Node node : topology.getNode()) {
final NetconfNode netconfNode = node.getAugmentation(NetconfNode.class);
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies 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.netconf.console.impl;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
-import org.opendaylight.netconf.console.api.NetconfCommands;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NetconfConsoleProvider implements BindingAwareProvider, AutoCloseable {
-
- private static final Logger LOG = LoggerFactory.getLogger(NetconfConsoleProvider.class);
- private ServiceRegistration<NetconfCommands> netconfConsoleRegistration;
-
- @Override
- public void onSessionInitiated(ProviderContext session) {
- LOG.info("NetconfProvider Session Initiated");
-
- // Retrieve DataBroker service to interact with md-sal
- final DataBroker dataBroker = session.getSALService(DataBroker.class);
-
- // Retrieve MountPointService to interact with NETCONF remote devices connected to ODL and register it
- final MountPointService mountService = session.getSALService(MountPointService.class);
- final BundleContext context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
-
- // Initialization of NETCONF Console Provider service implementation
- initializeNetconfConsoleProvider(dataBroker, context, mountService);
- }
-
- private void initializeNetconfConsoleProvider(DataBroker dataBroker, BundleContext context, MountPointService mountService) {
- // Initialize NetconfConsoleProviderImpl class
- final NetconfCommandsImpl consoleProvider = new NetconfCommandsImpl(dataBroker, mountService);
-
- // Register the NetconfConsoleProvider service
- netconfConsoleRegistration = context.registerService(NetconfCommands.class, consoleProvider, null);
- }
-
- @Override
- public void close() throws Exception {
- LOG.info("NetconfProvider closed.");
- netconfConsoleRegistration.unregister();
- }
-}
+++ /dev/null
-package org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.console.provider.impl.rev160323;
-
-import org.opendaylight.netconf.console.impl.NetconfConsoleProvider;
-
-public class NetconfConsoleProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.console.provider.impl.rev160323.AbstractNetconfConsoleProviderModule {
- public NetconfConsoleProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(identifier, dependencyResolver);
- }
-
- public NetconfConsoleProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.console.provider.impl.rev160323.NetconfConsoleProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
- super(identifier, dependencyResolver, oldModule, oldInstance);
- }
-
- @Override
- public void customValidation() {
- // add custom validation form module attributes here.
- }
-
- @Override
- public java.lang.AutoCloseable createInstance() {
- final NetconfConsoleProvider provider = new NetconfConsoleProvider();
- getBrokerDependency().registerProvider(provider);
- return provider;
- }
-}
+++ /dev/null
-/*
-* Generated file
-*
-* Generated from: yang module name: netconf-console-provider-impl yang module local name: netconf-console-provider-impl
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed Mar 23 18:01:12 EDT 2016
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.console.provider.impl.rev160323;
-public class NetconfConsoleProviderModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.console.provider.impl.rev160323.AbstractNetconfConsoleProviderModuleFactory {
-
-}
+++ /dev/null
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
- <reference id="netconfConsoleProvider" availability="mandatory"
- activation="eager" interface="org.opendaylight.netconf.console.api.NetconfCommands">
- </reference>
- <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="netconfConsoleProvider"/>
- </action>
- </command>
- <command name="netconf:list-devices">
- <action class="org.opendaylight.netconf.console.commands.NetconfListDevicesCommand">
- <argument ref="netconfConsoleProvider"/>
- </action>
- </command>
- <command name="netconf:show-device">
- <action class="org.opendaylight.netconf.console.commands.NetconfShowDeviceCommand">
- <argument ref="netconfConsoleProvider"/>
- </action>
- </command>
- <command name="netconf:disconnect-device">
- <action class="org.opendaylight.netconf.console.commands.NetconfDisconnectDeviceCommand">
- <argument ref="netconfConsoleProvider"/>
- </action>
- </command>
- <command name="netconf:update-device">
- <action class="org.opendaylight.netconf.console.commands.NetconfUpdateDeviceCommand">
- <argument ref="netconfConsoleProvider"/>
- </action>
- </command>
- </command-bundle>
-</blueprint>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016 Inocybe Technologies Inc. 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
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <reference id="dataBroker"
+ interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+ odl:type="default"/>
+
+ <bean id="netconfCommandsImpl" class="org.opendaylight.netconf.console.impl.NetconfCommandsImpl">
+ <argument ref="dataBroker"/>
+ </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>
+++ /dev/null
-module netconf-console-provider-impl {
- namespace "urn:opendaylight:netconf:console:provider:impl";
- prefix "netconf-console-provider-impl";
-
- import config { prefix config; revision-date 2013-04-05; }
- import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
-
- revision 2016-03-23 {
- description "Initial revision";
- }
-
- identity netconf-console-provider-impl {
- base config:module-type;
- config:java-name-prefix NetconfConsoleProvider;
- }
-
- augment "/config:modules/config:module/config:configuration" {
- case netconf-console-provider-impl {
- when "/config:modules/config:module/config:type = 'netconf-console-provider-impl'";
- container broker {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity mdsal:binding-broker-osgi-registry;
- }
- }
- }
- }
- }
-}
\ No newline at end of file
bindingToNormalized.onGlobalContextUpdated(schemaContext);
dataBroker = new BindingDOMDataBrokerAdapter(cDOMDataBroker, bindingToNormalized);
- final MountPointService mountPointService = mock(MountPointService.class);
- netconfCommands = new NetconfCommandsImpl(dataBroker, mountPointService);
+ netconfCommands = new NetconfCommandsImpl(dataBroker);
}
@Test
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. 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.netconf.console.impl;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.powermock.api.mockito.PowerMockito.when;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.BDDMockito;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.netconf.console.api.NetconfCommands;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(FrameworkUtil.class)
-public class NetconfConsoleProviderTest {
-
- @Test
- public void testProvider() throws Exception {
- final NetconfConsoleProvider netconfConsoleProvider = new NetconfConsoleProvider();
-
- PowerMockito.mockStatic(FrameworkUtil.class);
-
- final BindingAwareBroker.ProviderContext session = mock(BindingAwareBroker.ProviderContext.class);
- final MountPointService mountPointService = mock(MountPointService.class);
- final BundleContext bundleContext = mock(BundleContext.class);
- final DataBroker dataBroker = mock(DataBroker.class);
- final Bundle bundle = mock(Bundle.class);
-
- doReturn(dataBroker).when(session).getSALService(DataBroker.class);
- doReturn(mountPointService).when(session).getSALService(MountPointService.class);
- BDDMockito.given(FrameworkUtil.getBundle(any())).willReturn(bundle);
- when(bundle.getBundleContext()).thenReturn(bundleContext);
-
- netconfConsoleProvider.onSessionInitiated(session);
-
- verify(bundleContext, times(1)).registerService(eq(NetconfCommands.class), any(NetconfCommandsImpl.class), eq(null));
-
- }
-}