<type>xml</type>
<classifier>features</classifier>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-netconf-monitoring</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>odl-netconf-netty-util</artifactId>
<type>xml</type>
<classifier>features</classifier>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-netconf-monitoring</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
</dependencies>
</project>
<type>xml</type>
<classifier>features</classifier>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-netconf-monitoring</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>odl-netconf-notifications-impl</artifactId>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2017 Red Hat, Inc. and others.
-
- 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
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>single-feature-parent</artifactId>
- <version>4.0.7</version>
- <relativePath/>
- </parent>
-
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>odl-netconf-monitoring</artifactId>
- <version>1.6.0-SNAPSHOT</version>
- <packaging>feature</packaging>
-
- <name>OpenDaylight :: Netconf :: Monitoring</name>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-netconf-util</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-monitoring</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-</project>
<module>odl-netconf-impl</module>
<module>odl-netconf-mapping-api</module>
<module>odl-netconf-mdsal</module>
- <module>odl-netconf-monitoring</module>
<module>odl-netconf-netty-util</module>
<module>odl-netconf-notifications-api</module>
<module>odl-netconf-notifications-impl</module>
<groupId>${project.groupId}</groupId>
<artifactId>netconf-mapping-api</artifactId>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-monitoring</artifactId>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netconf-util</artifactId>
* 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.monitoring;
+
+package org.opendaylight.controller.config.yang.netconf.mdsal.monitoring;
import java.util.HashMap;
import java.util.Map;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-public class GetSchema extends AbstractSingletonNetconfOperation {
- public static final String GET_SCHEMA = "get-schema";
- public static final String IDENTIFIER = "identifier";
- public static final String VERSION = "version";
+public final class GetSchema extends AbstractSingletonNetconfOperation {
+ private static final String GET_SCHEMA = "get-schema";
+ private static final String IDENTIFIER = "identifier";
+ private static final String VERSION = "version";
private static final Logger LOG = LoggerFactory.getLogger(GetSchema.class);
private final NetconfMonitoringService cap;
- public GetSchema(final NetconfMonitoringService cap) {
- super(MonitoringConstants.MODULE_NAME);
+ public GetSchema(final String netconfSessionIdForReporting, final NetconfMonitoringService cap) {
+ super(netconfSessionIdForReporting);
this.cap = cap;
}
getSchemaElement.checkName(GET_SCHEMA);
getSchemaElement.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_YANG_IETF_NETCONF_MONITORING);
- XmlElement identifierElement = null;
+ final XmlElement identifierElement;
try {
identifierElement = getSchemaElement.getOnlyChildElementWithSameNamespace(IDENTIFIER);
} catch (final DocumentedException e) {
import org.opendaylight.netconf.mapping.api.NetconfOperationService;
import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener;
-import org.opendaylight.netconf.monitoring.GetSchema;
public class MdsalMonitoringMapperFactory implements NetconfOperationServiceFactory, AutoCloseable {
- private final NetconfOperationService operationService;
private final MonitoringToMdsalWriter monitoringToMdsalWriter;
private final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener;
+ private final NetconfMonitoringService netconfMonitoringService;
private static final Set<Capability> CAPABILITIES = Collections.emptySet();
final MonitoringToMdsalWriter monitoringToMdsalWriter) {
this.netconfOperationServiceFactoryListener = netconfOperationServiceFactoryListener;
+ this.netconfMonitoringService = netconfMonitoringService;
this.monitoringToMdsalWriter = monitoringToMdsalWriter;
+ this.netconfOperationServiceFactoryListener.onAddNetconfOperationServiceFactory(this);
+ }
- this.operationService = new NetconfOperationService() {
+ @Override
+ public NetconfOperationService createService(final String netconfSessionIdForReporting) {
+ return new NetconfOperationService() {
@Override
public Set<NetconfOperation> getNetconfOperations() {
- return Collections.singleton(new GetSchema(netconfMonitoringService));
+ return Collections.singleton(new GetSchema(netconfSessionIdForReporting, netconfMonitoringService));
}
@Override
// NOOP
}
};
-
- this.netconfOperationServiceFactoryListener.onAddNetconfOperationServiceFactory(this);
- }
-
- @Override
- public NetconfOperationService createService(final String netconfSessionIdForReporting) {
- return operationService;
}
@Override
public Set<Capability> getCapabilities() {
- // TODO No capabilities exposed to prevent clashes with schemas from mdsal-netconf-connector (it exposes
- // all the schemas). If the schemas exposed by mdsal-netconf-connector are filtered, this class would expose
- // monitoring related models.
+ // TODO No capabilities exposed to prevent clashes with schemas from mdsal-netconf-connector (it exposes all the
+ // schemas). If the schemas exposed by mdsal-netconf-connector are filtered, this class would expose monitoring
+ // related models.
return CAPABILITIES;
}
<artifactId>netconf-mapping-api</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-monitoring</artifactId>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mdsal-netconf-monitoring</artifactId>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-parent</artifactId>
- <version>1.6.0-SNAPSHOT</version>
- <relativePath>../netconf-parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-monitoring</artifactId>
- <version>1.6.0-SNAPSHOT</version>
- <name>${project.artifactId}</name>
- <packaging>bundle</packaging>
-
- <dependencies>
- <!-- compile dependencies -->
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-mapping-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-util</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>mockito-configuration</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
- <artifactId>rfc6991-ietf-inet-types</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-core</artifactId>
- <!-- FIXME: remove version once odlparent declares it -->
- <version>2.2.11</version>
- </dependency>
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
- <!-- FIXME: remove version once odlparent declares it -->
- <version>2.2.11</version>
- </dependency>
- <dependency>
- <groupId>javax.activation</groupId>
- <artifactId>activation</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-Activator>org.opendaylight.netconf.monitoring.osgi.NetconfMonitoringActivator</Bundle-Activator>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
-/*
- * Copyright (c) 2013 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.monitoring;
-
-import java.util.Collections;
-import org.opendaylight.netconf.api.DocumentedException;
-import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
-import org.opendaylight.netconf.api.xml.XmlElement;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.mapping.api.HandlingPriority;
-import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
-import org.opendaylight.netconf.monitoring.xml.JaxBSerializer;
-import org.opendaylight.netconf.monitoring.xml.model.NetconfState;
-import org.opendaylight.netconf.util.mapping.AbstractNetconfOperation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class Get extends AbstractNetconfOperation {
-
- private static final Logger LOG = LoggerFactory.getLogger(Get.class);
- private final NetconfMonitoringService netconfMonitor;
-
- public Get(final NetconfMonitoringService netconfMonitor) {
- super(MonitoringConstants.MODULE_NAME);
- this.netconfMonitor = netconfMonitor;
- }
-
- private static Element getPlaceholder(final Document innerResult) throws DocumentedException {
- final XmlElement rootElement = XmlElement.fromDomElementWithExpected(
- innerResult.getDocumentElement(), XmlNetconfConstants.RPC_REPLY_KEY,
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
- return rootElement.getOnlyChildElement(XmlNetconfConstants.DATA_KEY).getDomElement();
- }
-
- @Override
- protected String getOperationName() {
- return XmlNetconfConstants.GET;
- }
-
- @Override
- protected HandlingPriority getHandlingPriority() {
- return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.increasePriority(1);
- }
-
- @SuppressWarnings("checkstyle:IllegalCatch")
- @Override
- public Document handle(final Document requestMessage, final NetconfOperationChainedExecution subsequentOperation)
- throws DocumentedException {
- if (subsequentOperation.isExecutionTermination()) {
- throw new DocumentedException(String.format("Subsequent netconf operation expected by %s", this),
- DocumentedException.ErrorType.APPLICATION,
- DocumentedException.ErrorTag.OPERATION_FAILED,
- DocumentedException.ErrorSeverity.ERROR);
- }
-
- try {
- final Document innerResult = subsequentOperation.execute(requestMessage);
-
- final NetconfState netconfMonitoring = new NetconfState(netconfMonitor);
- Element monitoringXmlElement = new JaxBSerializer().toXml(netconfMonitoring);
-
- monitoringXmlElement = (Element) innerResult.importNode(monitoringXmlElement, true);
- final Element monitoringXmlElementPlaceholder = getPlaceholder(innerResult);
- monitoringXmlElementPlaceholder.appendChild(monitoringXmlElement);
-
- return innerResult;
- } catch (final RuntimeException e) {
- final String errorMessage = "Get operation for netconf-state subtree failed";
- LOG.warn(errorMessage, e);
-
- throw new DocumentedException(errorMessage, e, DocumentedException.ErrorType.APPLICATION,
- DocumentedException.ErrorTag.OPERATION_FAILED,
- DocumentedException.ErrorSeverity.ERROR,
- Collections.singletonMap(DocumentedException.ErrorSeverity.ERROR.toString(), e.getMessage()));
- }
- }
-
- @Override
- protected Element handle(final Document document, final XmlElement message,
- final NetconfOperationChainedExecution subsequentOperation) {
- throw new UnsupportedOperationException("Never gets called");
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 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.monitoring.osgi;
-
-import java.util.Collections;
-import java.util.Set;
-import org.opendaylight.netconf.api.capability.Capability;
-import org.opendaylight.netconf.api.monitoring.CapabilityListener;
-import org.opendaylight.netconf.mapping.api.NetconfOperationService;
-import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NetconfMonitoringActivator implements BundleActivator {
-
- private static final Logger LOG = LoggerFactory.getLogger(NetconfMonitoringActivator.class);
-
- private NetconfMonitoringServiceTracker monitor;
-
- @Override
- public void start(final BundleContext context) {
- monitor = new NetconfMonitoringServiceTracker(context);
- monitor.open();
- }
-
- @SuppressWarnings("checkstyle:IllegalCatch")
- @Override
- public void stop(final BundleContext context) {
- if (monitor != null) {
- try {
- monitor.close();
- } catch (final Exception e) {
- LOG.warn("Ignoring exception while closing {}", monitor, e);
- }
- }
- }
-
- public static class NetconfMonitoringOperationServiceFactory implements NetconfOperationServiceFactory,
- AutoCloseable {
-
- private final NetconfMonitoringOperationService operationService;
-
- private static final AutoCloseable AUTO_CLOSEABLE = () -> {
- // NOOP
- };
-
- public NetconfMonitoringOperationServiceFactory(final NetconfMonitoringOperationService operationService) {
- this.operationService = operationService;
- }
-
- @Override
- public NetconfOperationService createService(final String netconfSessionIdForReporting) {
- return operationService;
- }
-
- @Override
- public Set<Capability> getCapabilities() {
- return Collections.emptySet();
- }
-
- @Override
- public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
- return AUTO_CLOSEABLE;
- }
-
- @Override
- public void close() {}
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 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.monitoring.osgi;
-
-import com.google.common.base.Preconditions;
-import java.util.Dictionary;
-import java.util.Hashtable;
-import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
-import org.opendaylight.netconf.api.util.NetconfConstants;
-import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.util.tracker.ServiceTracker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NetconfMonitoringServiceTracker extends ServiceTracker<NetconfMonitoringService,
- NetconfMonitoringService> {
-
- private static final Logger LOG = LoggerFactory.getLogger(NetconfMonitoringServiceTracker.class);
-
- private ServiceRegistration<NetconfOperationServiceFactory> reg;
- private NetconfMonitoringActivator.NetconfMonitoringOperationServiceFactory factory;
-
- NetconfMonitoringServiceTracker(final BundleContext context) {
- super(context, NetconfMonitoringService.class, null);
- }
-
- @Override
- public NetconfMonitoringService addingService(final ServiceReference<NetconfMonitoringService> reference) {
- Preconditions.checkState(reg == null, "Monitoring service was already added");
-
- final NetconfMonitoringService netconfMonitoringService = super.addingService(reference);
-
- final NetconfMonitoringOperationService operationService = new NetconfMonitoringOperationService(
- netconfMonitoringService);
- factory = new NetconfMonitoringActivator.NetconfMonitoringOperationServiceFactory(
- operationService);
-
- Dictionary<String, String> properties = new Hashtable<>();
- properties.put(NetconfConstants.SERVICE_NAME, NetconfConstants.NETCONF_MONITORING);
- reg = context.registerService(NetconfOperationServiceFactory.class, factory, properties);
-
- return netconfMonitoringService;
- }
-
- @SuppressWarnings("checkstyle:IllegalCatch")
- @Override
- public void removedService(final ServiceReference<NetconfMonitoringService> reference,
- final NetconfMonitoringService netconfMonitoringService) {
- if (reg != null) {
- try {
- reg.unregister();
- } catch (final Exception e) {
- LOG.warn("Ignoring exception while unregistering {}", reg, e);
- }
- }
- if (factory != null) {
- factory.close();
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 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
- */
-@XmlSchema(
- elementFormDefault = XmlNsForm.QUALIFIED,
- xmlns = {
- @XmlNs(namespaceURI = MonitoringConstants.EXTENSION_NAMESPACE, prefix =
- MonitoringConstants.EXTENSION_NAMESPACE_PREFIX),
- @XmlNs(namespaceURI = MonitoringConstants.NAMESPACE, prefix = "")
- },
- namespace = MonitoringConstants.NAMESPACE
-)
-package org.opendaylight.netconf.monitoring.xml.model;
-
-import javax.xml.bind.annotation.XmlNs;
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlSchema;
-import org.opendaylight.netconf.monitoring.MonitoringConstants;
\ No newline at end of file
-/*
- * Copyright (c) 2015 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.monitoring;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-
-import java.util.Optional;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.netconf.api.DocumentedException;
-import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
-import org.opendaylight.netconf.api.xml.XmlElement;
-import org.opendaylight.netconf.api.xml.XmlUtil;
-import org.w3c.dom.Document;
-
-public class GetSchemaTest {
-
-
- private NetconfMonitoringService cap;
- private Document doc;
- private String getSchema;
-
- @Before
- public void setUp() throws Exception {
- cap = mock(NetconfMonitoringService.class);
- doc = XmlUtil.newDocument();
- getSchema = "<get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">\n"
- + " <identifier>threadpool-api</identifier>\n"
- + " <version>2010-09-24</version>\n"
- + " <format\n"
- + " xmlns:ncm=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">ncm:yang\n"
- + " </format>\n"
- + " </get-schema>";
- }
-
- @Test(expected = DocumentedException.class)
- public void testDefaultGetSchema() throws Exception {
- GetSchema schema = new GetSchema(cap);
- doThrow(IllegalStateException.class).when(cap).getSchemaForCapability(anyString(), any(Optional.class));
- schema.handleWithNoSubsequentOperations(doc, XmlElement.fromDomElement(XmlUtil.readXmlToElement(getSchema)));
- }
-
- @Test
- public void handleWithNoSubsequentOperations() throws Exception {
- GetSchema schema = new GetSchema(cap);
- doReturn("").when(cap).getSchemaForCapability(anyString(), any(Optional.class));
- assertNotNull(schema.handleWithNoSubsequentOperations(doc,
- XmlElement.fromDomElement(XmlUtil.readXmlToElement(getSchema))));
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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.monitoring;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-
-import java.util.Collections;
-import org.hamcrest.CoreMatchers;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.netconf.api.DocumentedException;
-import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
-import org.opendaylight.netconf.api.xml.XmlUtil;
-import org.opendaylight.netconf.mapping.api.HandlingPriority;
-import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.SchemasBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.SessionsBuilder;
-import org.w3c.dom.Document;
-
-public class GetTest {
-
- @Mock
- private NetconfMonitoringService monitor;
- @Mock
- private Document request;
- @Mock
- private NetconfOperationChainedExecution subsequentOperation;
- private Document incorrectSubsequentResult;
- private Document correctSubsequentResult;
-
- private Get get;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
- incorrectSubsequentResult = XmlUtil.readXmlToDocument("<rpc-reply "
- + "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>");
- correctSubsequentResult = XmlUtil.readXmlToDocument("<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:"
- + "1.0\"><data></data></rpc-reply>");
-
- doReturn(new SessionsBuilder().setSession(Collections.emptyList()).build()).when(monitor)
- .getSessions();
- doReturn(new SchemasBuilder().setSchema(Collections.emptyList()).build()).when(monitor).getSchemas();
- doReturn(false).when(subsequentOperation).isExecutionTermination();
-
- get = new Get(monitor);
- }
-
- @Test
- public void testHandleNoSubsequent() throws Exception {
- try {
- get.handle(null, NetconfOperationChainedExecution.EXECUTION_TERMINATION_POINT);
- } catch (final DocumentedException e) {
- assertNetconfDocumentedEx(e, DocumentedException.ErrorSeverity.ERROR,
- DocumentedException.ErrorTag.OPERATION_FAILED, DocumentedException.ErrorType.APPLICATION);
- return;
- }
-
- fail("Get should fail without subsequent operation");
- }
-
- @Test
- public void testHandleWrongPlaceholder() throws Exception {
- doReturn(incorrectSubsequentResult).when(subsequentOperation).execute(request);
- try {
- get.handle(request, subsequentOperation);
- } catch (final DocumentedException e) {
- assertNetconfDocumentedEx(e, DocumentedException.ErrorSeverity.ERROR,
- DocumentedException.ErrorTag.INVALID_VALUE, DocumentedException.ErrorType.APPLICATION);
- return;
- }
-
- fail("Get should fail with wrong xml");
- }
-
- @Test
- public void testHandleRuntimeEx() throws Exception {
- doThrow(RuntimeException.class).when(subsequentOperation).execute(request);
- try {
- get.handle(request, subsequentOperation);
- } catch (final DocumentedException e) {
- assertNetconfDocumentedEx(e, DocumentedException.ErrorSeverity.ERROR,
- DocumentedException.ErrorTag.OPERATION_FAILED, DocumentedException.ErrorType.APPLICATION);
- assertEquals(1, e.getErrorInfo().size());
- return;
- }
-
- fail("Get should fail with wrong xml");
- }
-
- @Test
- public void testSuccessHandle() throws Exception {
- doReturn(correctSubsequentResult).when(subsequentOperation).execute(request);
- assertTrue(get.getHandlingPriority().getPriority().get()
- > HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.getPriority().get());
- final Document result = get.handle(request, subsequentOperation);
- assertThat(XmlUtil.toString(result), CoreMatchers.containsString("sessions"));
- assertThat(XmlUtil.toString(result), CoreMatchers.containsString("schemas"));
-
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void testHandle() throws Exception {
- get.handle(null, null, null);
-
- }
-
- private void assertNetconfDocumentedEx(final DocumentedException exception, final DocumentedException.ErrorSeverity
- severity, final DocumentedException.ErrorTag errorTag, final DocumentedException.ErrorType type) {
- assertEquals(severity, exception.getErrorSeverity());
- assertEquals(errorTag, exception.getErrorTag());
- assertEquals(type, exception.getErrorType());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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.monitoring.osgi;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.Arrays;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-
-public class NetconfMonitoringActivatorTest {
-
- @Mock
- BundleContext context;
- @Mock
- Filter filter;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- doReturn(filter).when(context).createFilter(anyString());
- doNothing().when(context).addServiceListener(any(ServiceListener.class), anyString());
- ServiceReference<?>[] refs = new ServiceReference[2];
- doReturn(Arrays.asList(refs)).when(context).getServiceReferences(any(Class.class), anyString());
- doReturn(refs).when(context).getServiceReferences(anyString(), any());
- doNothing().when(context).removeServiceListener(any(ServiceListener.class));
- }
-
- @Test
- public void testNetconfMonitoringActivator() throws Exception {
- NetconfMonitoringActivator activator = new NetconfMonitoringActivator();
- activator.start(context);
- verify(context, times(1)).addServiceListener(any(ServiceListener.class), anyString());
-
- activator.stop(context);
- verify(context, times(1)).removeServiceListener(any(ServiceListener.class));
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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.monitoring.osgi;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-
-import org.junit.Test;
-import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
-
-public class NetconfMonitoringOperationServiceTest {
- @Test
- public void testGetters() throws Exception {
- NetconfMonitoringService monitor = mock(NetconfMonitoringService.class);
- NetconfMonitoringOperationService service = new NetconfMonitoringOperationService(monitor);
- NetconfMonitoringActivator.NetconfMonitoringOperationServiceFactory serviceFactory =
- new NetconfMonitoringActivator.NetconfMonitoringOperationServiceFactory(service);
-
- assertEquals(2, service.getNetconfOperations().size());
-
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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.monitoring.osgi;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.anyString;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.Hashtable;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
-import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-
-public class NetconfMonitoringServiceTrackerTest {
-
- @Mock
- private ServiceReference<NetconfMonitoringService> reference;
- @Mock
- private BundleContext context;
- @Mock
- private ServiceRegistration<?> serviceRegistration;
- @Mock
- private Filter filter;
- @Mock
- private NetconfMonitoringService monitoringService;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- doReturn(serviceRegistration).when(context).registerService(any(Class.class),
- any(NetconfOperationServiceFactory.class), any(Hashtable.class));
- doNothing().when(serviceRegistration).unregister();
- doReturn(filter).when(context).createFilter(anyString());
- doReturn("").when(reference).toString();
- doReturn(monitoringService).when(context).getService(any(ServiceReference.class));
- }
-
- @Test
- public void testAddingService() throws Exception {
- NetconfMonitoringServiceTracker tracker = new NetconfMonitoringServiceTracker(context);
- tracker.addingService(reference);
- verify(context, times(1)).registerService(any(Class.class), any(NetconfOperationServiceFactory.class),
- any(Hashtable.class));
- tracker.removedService(reference, null);
- verify(serviceRegistration, times(1)).unregister();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 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.monitoring.xml;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
-import com.google.common.collect.Lists;
-import org.hamcrest.CoreMatchers;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
-import org.opendaylight.netconf.api.xml.XmlUtil;
-import org.opendaylight.netconf.monitoring.xml.model.NetconfState;
-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.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.extension.rev131210.NetconfTcp;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.extension.rev131210.Session1;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfSsh;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.Transport;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.Yang;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.SchemasBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.SessionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.Schema;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.SchemaKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.ZeroBasedCounter32;
-
-public class JaxBSerializerTest {
-
- private static final String IPV4 = "192.168.1.1";
- private static final String IPV6 = "FE80:0000:0000:0000:0202:B3FF:FE1E:8329";
- private static final String SESSION_XML = "<session>"
- + "<session-id>1</session-id>"
- + "<in-bad-rpcs>0</in-bad-rpcs>"
- + "<in-rpcs>0</in-rpcs>"
- + "<login-time>2010-10-10T12:32:32Z</login-time>"
- + "<out-notifications>0</out-notifications>"
- + "<out-rpc-errors>0</out-rpc-errors>"
- + "<ncme:session-identifier>client</ncme:session-identifier>"
- + "<source-host>%s</source-host>"
- + "<transport>ncme:netconf-tcp</transport>"
- + "<username>username</username>"
- + "</session>";
-
- @Mock
- private NetconfMonitoringService monitoringService;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- doReturn(new SessionsBuilder().setSession(Lists.newArrayList(
- getMockIPv4Session(NetconfTcp.class),
- getMockIPv4Session(NetconfSsh.class),
- getMockIPv6Session(NetconfTcp.class),
- getMockIPv6Session(NetconfSsh.class)
- )).build())
- .when(monitoringService).getSessions();
- doReturn(new SchemasBuilder().setSchema(Lists.newArrayList(getMockSchema("id", "v1", Yang.class),
- getMockSchema("id2", "", Yang.class))).build()).when(monitoringService).getSchemas();
- }
-
- @Test
- public void testSerialization() throws Exception {
-
- final NetconfState model = new NetconfState(monitoringService);
- final String xml = XmlUtil.toString(new JaxBSerializer().toXml(model)).replaceAll("\\s", "");
- assertThat(xml, CoreMatchers.containsString(
- "<schema>"
- + "<format>yang</format>"
- + "<identifier>id</identifier>"
- + "<location>NETCONF</location>"
- + "<namespace>localhost</namespace>"
- + "<version>v1</version>"
- + "</schema>"));
-
- assertThat(xml, CoreMatchers.containsString(
- String.format(SESSION_XML, IPV4)));
- assertThat(xml, CoreMatchers.containsString(
- String.format(SESSION_XML, IPV6)));
- }
-
- private static Schema getMockSchema(final String id, final String version, final Class<Yang> format) {
- final Schema mock = mock(Schema.class);
-
- doReturn(format).when(mock).getFormat();
- doReturn(id).when(mock).getIdentifier();
- doReturn(new Uri("localhost")).when(mock).getNamespace();
- doReturn(version).when(mock).getVersion();
- doReturn(Lists.newArrayList(new Schema.Location(Schema.Location.Enumeration.NETCONF))).when(mock).getLocation();
- doReturn(new SchemaKey(format, id, version)).when(mock).key();
- return mock;
- }
-
- private static Session getMockIPv4Session(final Class<? extends Transport> transportType) {
- final Session mocked = getMockSession(transportType);
- doReturn(new Host(new IpAddress(new Ipv4Address(IPV4)))).when(mocked).getSourceHost();
- return mocked;
- }
-
- private static Session getMockIPv6Session(final Class<? extends Transport> transportType) {
- final Session mocked = getMockSession(transportType);
- doReturn(new Host(new IpAddress(new Ipv6Address(IPV6)))).when(mocked).getSourceHost();
- return mocked;
- }
-
- private static Session getMockSession(final Class<? extends Transport> transportType) {
- final Session mocked = mock(Session.class);
- final Session1 mockedSession1 = mock(Session1.class);
- doReturn("client").when(mockedSession1).getSessionIdentifier();
- doReturn(1L).when(mocked).getSessionId();
- doReturn(new DateAndTime("2010-10-10T12:32:32Z")).when(mocked).getLoginTime();
- doReturn(new ZeroBasedCounter32(0L)).when(mocked).getInBadRpcs();
- doReturn(new ZeroBasedCounter32(0L)).when(mocked).getInRpcs();
- doReturn(new ZeroBasedCounter32(0L)).when(mocked).getOutNotifications();
- doReturn(new ZeroBasedCounter32(0L)).when(mocked).getOutRpcErrors();
- doReturn(transportType).when(mocked).getTransport();
- doReturn("username").when(mocked).getUsername();
- doReturn(mockedSession1).when(mocked).augmentation(Session1.class);
- return mocked;
- }
-}
<module>netconf-client</module>
<module>netconf-ssh</module>
<module>netconf-tcp</module>
- <module>netconf-monitoring</module>
<module>netconf-auth</module>
<module>aaa-authn-odl-plugin</module>
<module>netconf-notifications-impl</module>
<artifactId>netconf-mapping-api</artifactId>
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-monitoring</artifactId>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>mdsal-netconf-monitoring</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
import org.opendaylight.netconf.impl.SessionIdProvider;
import org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory;
import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
-import org.opendaylight.netconf.monitoring.osgi.NetconfMonitoringActivator;
-import org.opendaylight.netconf.monitoring.osgi.NetconfMonitoringOperationService;
import org.opendaylight.netconf.ssh.SshProxyServer;
import org.opendaylight.netconf.ssh.SshProxyServerConfiguration;
import org.opendaylight.netconf.ssh.SshProxyServerConfigurationBuilder;
import org.opendaylight.netconf.test.tool.config.Configuration;
import org.opendaylight.netconf.test.tool.customrpc.SettableOperationProvider;
+import org.opendaylight.netconf.test.tool.monitoring.NetconfMonitoringOperationService;
+import org.opendaylight.netconf.test.tool.monitoring.NetconfMonitoringOperationServiceFactory;
import org.opendaylight.netconf.test.tool.operations.DefaultOperationsCreator;
import org.opendaylight.netconf.test.tool.operations.OperationsProvider;
import org.opendaylight.netconf.test.tool.rpchandler.SettableOperationRpcProvider;
}
- final NetconfMonitoringActivator.NetconfMonitoringOperationServiceFactory monitoringService =
- new NetconfMonitoringActivator.NetconfMonitoringOperationServiceFactory(
+ final NetconfMonitoringOperationServiceFactory monitoringService =
+ new NetconfMonitoringOperationServiceFactory(
new NetconfMonitoringOperationService(monitoringService1));
aggregatedNetconfOperationServiceFactory.onAddNetconfOperationServiceFactory(operationProvider);
aggregatedNetconfOperationServiceFactory.onAddNetconfOperationServiceFactory(monitoringService);
final AsynchronousChannelGroup group;
try {
group = AsynchronousChannelGroup.withThreadPool(nioExecutor);
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new IllegalStateException("Failed to create group", e);
}
}
configuration.getDefaultYangResources().forEach(r -> {
- SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create(r.getModuleName(),
+ final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create(r.getModuleName(),
Revision.ofNullable(r.getRevision()));
registerSource(consumer, r.getResourcePath(), sourceIdentifier);
});
consumer.getSchemaSource(moduleSourceIdentifier, YangTextSchemaSource.class).get().read());
capabilities.add(new YangModuleCapability(module, moduleContent));
//IOException would be thrown in creating SchemaContext already
- } catch (ExecutionException | InterruptedException | IOException e) {
+ } catch (final ExecutionException | InterruptedException | IOException e) {
throw new RuntimeException("Cannot retrieve schema source for module "
+ moduleSourceIdentifier.toString() + " from schema repository", e);
}
for (final SshProxyServer sshWrapper : sshWrappers) {
try {
sshWrapper.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
LOG.debug("Wrapper {} failed to close", sshWrapper, e);
}
}
--- /dev/null
+/*
+ * Copyright (c) 2013 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.test.tool.monitoring;
+
+import java.util.Collections;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
+import org.opendaylight.netconf.api.xml.XmlElement;
+import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.mapping.api.HandlingPriority;
+import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
+import org.opendaylight.netconf.util.mapping.AbstractNetconfOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class Get extends AbstractNetconfOperation {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Get.class);
+ private final NetconfMonitoringService netconfMonitor;
+
+ public Get(final NetconfMonitoringService netconfMonitor) {
+ super(MonitoringConstants.MODULE_NAME);
+ this.netconfMonitor = netconfMonitor;
+ }
+
+ private Element getPlaceholder(final Document innerResult)
+ throws DocumentedException {
+ final XmlElement rootElement = XmlElement.fromDomElementWithExpected(
+ innerResult.getDocumentElement(), XmlNetconfConstants.RPC_REPLY_KEY,
+ XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
+ return rootElement.getOnlyChildElement(XmlNetconfConstants.DATA_KEY).getDomElement();
+ }
+
+ @Override
+ protected String getOperationName() {
+ return XmlNetconfConstants.GET;
+ }
+
+ @Override
+ protected HandlingPriority getHandlingPriority() {
+ return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.increasePriority(1);
+ }
+
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @Override
+ public Document handle(final Document requestMessage, final NetconfOperationChainedExecution subsequentOperation)
+ throws DocumentedException {
+ if (subsequentOperation.isExecutionTermination()) {
+ throw new DocumentedException(String.format("Subsequent netconf operation expected by %s", this),
+ DocumentedException.ErrorType.APPLICATION,
+ DocumentedException.ErrorTag.OPERATION_FAILED,
+ DocumentedException.ErrorSeverity.ERROR);
+ }
+
+ try {
+ final Document innerResult = subsequentOperation.execute(requestMessage);
+
+ final NetconfState netconfMonitoring = new NetconfState(netconfMonitor);
+ Element monitoringXmlElement = new JaxBSerializer().toXml(netconfMonitoring);
+
+ monitoringXmlElement = (Element) innerResult.importNode(monitoringXmlElement, true);
+ final Element monitoringXmlElementPlaceholder = getPlaceholder(innerResult);
+ monitoringXmlElementPlaceholder.appendChild(monitoringXmlElement);
+
+ return innerResult;
+ } catch (final RuntimeException e) {
+ final String errorMessage = "Get operation for netconf-state subtree failed";
+ LOG.warn(errorMessage, e);
+
+ throw new DocumentedException(errorMessage, e, DocumentedException.ErrorType.APPLICATION,
+ DocumentedException.ErrorTag.OPERATION_FAILED,
+ DocumentedException.ErrorSeverity.ERROR,
+ Collections.singletonMap(DocumentedException.ErrorSeverity.ERROR.toString(), e.getMessage()));
+ }
+ }
+
+ @Override
+ protected Element handle(final Document document, final XmlElement message,
+ final NetconfOperationChainedExecution subsequentOperation) {
+ throw new UnsupportedOperationException("Never gets called");
+ }
+}
* 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.monitoring.xml;
+package org.opendaylight.netconf.test.tool.monitoring;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.transform.dom.DOMResult;
-import org.opendaylight.netconf.monitoring.xml.model.NetconfState;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
static {
try {
JAXB_CONTEXT = JAXBContext.newInstance(NetconfState.class);
- } catch (JAXBException e) {
+ } catch (final JAXBException e) {
throw new ExceptionInInitializerError(e);
}
}
* 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.monitoring;
+package org.opendaylight.netconf.test.tool.monitoring;
public final class MonitoringConstants {
public static final String URI = String.format("%s?module=%s&revision=%s", NAMESPACE, MODULE_NAME, MODULE_REVISION);
public static final String NETCONF_MONITORING_XML_ROOT_ELEMENT = "netconf-state";
-}
+}
\ No newline at end of file
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.netconf.monitoring.xml.model;
+package org.opendaylight.netconf.test.tool.monitoring;
import com.google.common.base.Preconditions;
import com.google.common.collect.Collections2;
schema.getFormat());
return "yang";
}
-}
+}
\ No newline at end of file
* 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.monitoring.xml.model;
+package org.opendaylight.netconf.test.tool.monitoring;
import com.google.common.base.Joiner;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
-import org.opendaylight.netconf.monitoring.MonitoringConstants;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.extension.rev131210.Session1;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session;
@XmlElement(name = "transport")
public String getTransport() {
try {
- QName qualifiedName = (QName) managementSession.getTransport().getField("QNAME").get(null);
+ final QName qualifiedName = (QName) managementSession.getTransport().getField("QNAME").get(null);
// Add extension prefix if transport type is from extension yang module
if (qualifiedName.getNamespace().toString().equals(MonitoringConstants.EXTENSION_NAMESPACE)) {
return Joiner.on(':').join(MonitoringConstants.EXTENSION_NAMESPACE_PREFIX,
} else {
return qualifiedName.getLocalName();
}
- } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
+ } catch (final NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
throw new IllegalArgumentException("Unknown transport type " + managementSession.getTransport(), e);
}
}
public String getUsername() {
return managementSession.getUsername();
}
-}
+}
\ No newline at end of file
* 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.monitoring.osgi;
-import com.google.common.collect.ImmutableSet;
+package org.opendaylight.netconf.test.tool.monitoring;
+
+import com.google.common.collect.Sets;
import java.util.Set;
+import org.opendaylight.controller.config.yang.netconf.mdsal.monitoring.GetSchema;
import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
import org.opendaylight.netconf.mapping.api.NetconfOperation;
import org.opendaylight.netconf.mapping.api.NetconfOperationService;
-import org.opendaylight.netconf.monitoring.Get;
-import org.opendaylight.netconf.monitoring.GetSchema;
public class NetconfMonitoringOperationService implements NetconfOperationService {
- private final ImmutableSet<NetconfOperation> netconfOperations;
+ private static final String TESTTOOL_SESSION = "testtool-session";
+
+ private final NetconfMonitoringService monitor;
public NetconfMonitoringOperationService(final NetconfMonitoringService monitor) {
- netconfOperations = ImmutableSet.of(new Get(monitor), new GetSchema(monitor));
+ this.monitor = monitor;
}
@Override
public Set<NetconfOperation> getNetconfOperations() {
- return netconfOperations;
+ return Sets.newHashSet(new Get(monitor), new GetSchema(TESTTOOL_SESSION, monitor));
}
@Override
--- /dev/null
+/*
+ * Copyright (c) 2013 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.test.tool.monitoring;
+
+import java.util.Collections;
+import java.util.Set;
+import org.opendaylight.netconf.api.capability.Capability;
+import org.opendaylight.netconf.api.monitoring.CapabilityListener;
+import org.opendaylight.netconf.mapping.api.NetconfOperationService;
+import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
+
+public class NetconfMonitoringOperationServiceFactory implements NetconfOperationServiceFactory,
+ AutoCloseable {
+
+ private final NetconfMonitoringOperationService operationService;
+
+ private static final AutoCloseable AUTO_CLOSEABLE = () -> {
+ // NOOP
+ };
+
+ public NetconfMonitoringOperationServiceFactory(final NetconfMonitoringOperationService operationService) {
+ this.operationService = operationService;
+ }
+
+ @Override
+ public NetconfOperationService createService(final String netconfSessionIdForReporting) {
+ return operationService;
+ }
+
+ @Override
+ public Set<Capability> getCapabilities() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
+ return AUTO_CLOSEABLE;
+ }
+
+ @Override
+ public void close() {
+ }
+}
+
* 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.monitoring.xml.model;
+package org.opendaylight.netconf.test.tool.monitoring;
import com.google.common.collect.Collections2;
import java.util.Collection;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
-import org.opendaylight.netconf.monitoring.MonitoringConstants;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Schemas;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Sessions;