The config system is being removed in Flourine.
Change-Id: I97efbe7263773ddbf5776be51de08502717af39d
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
<type>xml</type>
<classifier>features</classifier>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-config-netconf-connector</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>odl-netconf-all</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>3.0.2</version>
- <relativePath/>
- </parent>
-
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>odl-config-netconf-connector</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <packaging>feature</packaging>
-
- <name>OpenDaylight :: Netconf :: Connector</name>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-artifacts</artifactId>
- <version>0.9.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-config-manager</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-config-netty</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>netconf-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-netconf-notifications-impl</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>config-netconf-connector</artifactId>
- </dependency>
- </dependencies>
-</project>
<type>xml</type>
<classifier>features</classifier>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-config-netconf-connector</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>odl-netconf-netty-util</artifactId>
<classifier>features</classifier>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
<type>xml</type>
<classifier>features</classifier>
</dependency>
- <!-- Netconf server without config connector is just an empty shell -->
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-config-netconf-connector</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
<!-- Netconf will not provide schemas without monitoring -->
<dependency>
<groupId>org.opendaylight.controller</groupId>
<version>${project.version}</version>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
<module>features-netconf</module>
<module>odl-aaa-netconf-plugin</module>
<module>odl-aaa-netconf-plugin-no-cluster</module>
- <module>odl-config-netconf-connector</module>
<module>odl-netconf-all</module>
<module>odl-netconf-api</module>
<module>odl-netconf-client</module>
+++ /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.5.0-SNAPSHOT</version>
- <relativePath>../netconf-parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>config-netconf-connector</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <name>${project.artifactId}</name>
- <packaging>bundle</packaging>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-artifacts</artifactId>
- <version>0.9.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <dependencies>
- <!-- compile dependencies -->
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-manager-facade-xml</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-util</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-mapping-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-notifications-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</groupId>
- <artifactId>mdsal-binding-generator-impl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- </dependency>
- <dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-manager</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-manager</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-test-util</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-util</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-test</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-Activator>org.opendaylight.netconf.confignetconfconnector.osgi.Activator</Bundle-Activator>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
+++ /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.confignetconfconnector.operations;
-
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
-
-public abstract class AbstractConfigNetconfOperation extends AbstractLastNetconfOperation {
-
- private final ConfigSubsystemFacade configSubsystemFacade;
-
- protected AbstractConfigNetconfOperation(ConfigSubsystemFacade configSubsystemFacade,
- String netconfSessionIdForReporting) {
- super(netconfSessionIdForReporting);
- this.configSubsystemFacade = configSubsystemFacade;
- }
-
- public ConfigSubsystemFacade getConfigSubsystemFacade() {
- return configSubsystemFacade;
- }
-}
+++ /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.confignetconfconnector.operations;
-
-import com.google.common.base.Optional;
-import org.opendaylight.controller.config.api.ConflictingVersionException;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.facade.xml.Datastore;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class Commit extends AbstractConfigNetconfOperation {
-
- private static final Logger LOG = LoggerFactory.getLogger(Commit.class);
-
- public Commit(final ConfigSubsystemFacade configSubsystemFacade, final String netconfSessionIdForReporting) {
- super(configSubsystemFacade, netconfSessionIdForReporting);
- }
-
- private static void checkXml(XmlElement xml) throws DocumentedException {
- xml.checkName(XmlNetconfConstants.COMMIT);
- xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
- }
-
- @Override
- protected String getOperationName() {
- return XmlNetconfConstants.COMMIT;
- }
-
- @Override
- protected Element handleWithNoSubsequentOperations(Document document, XmlElement xml) throws DocumentedException {
-
- checkXml(xml);
- CommitStatus status;
- try {
- status = getConfigSubsystemFacade().commitTransaction();
- LOG.trace("Datastore {} committed successfully: {}", Datastore.candidate, status);
- } catch (ConflictingVersionException | ValidationException e) {
- throw DocumentedException.wrap(e);
- }
- LOG.trace("Datastore {} committed successfully: {}", Datastore.candidate, status);
-
- return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
- }
-
-}
+++ /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.confignetconfconnector.operations;
-
-import com.google.common.base.Optional;
-import java.util.HashMap;
-import java.util.Map;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.facade.xml.Datastore;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-
-public class DiscardChanges extends AbstractConfigNetconfOperation {
-
- public static final String DISCARD = "discard-changes";
-
- private static final Logger LOG = LoggerFactory.getLogger(DiscardChanges.class);
-
- public DiscardChanges(final ConfigSubsystemFacade configSubsystemFacade,
- final String netconfSessionIdForReporting) {
- super(configSubsystemFacade, netconfSessionIdForReporting);
- }
-
- private static void fromXml(final XmlElement xml) throws DocumentedException {
- xml.checkName(DISCARD);
- xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
- }
-
- @Override
- protected String getOperationName() {
- return DISCARD;
- }
-
- @SuppressWarnings("checkstyle:IllegalCatch")
- @Override
- protected Element handleWithNoSubsequentOperations(final Document document,
- final XmlElement xml) throws DocumentedException {
- fromXml(xml);
- try {
- getConfigSubsystemFacade().abortConfiguration();
- } catch (final RuntimeException e) {
- LOG.warn("Abort failed: ", e);
- final Map<String, String> errorInfo = new HashMap<>();
- errorInfo
- .put(ErrorTag.OPERATION_FAILED.name(),
- "Abort failed.");
- throw new DocumentedException(e.getMessage(), e, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED,
- ErrorSeverity.ERROR, errorInfo);
- }
- LOG.trace("Changes discarded successfully from datastore {}", Datastore.candidate);
-
-
- return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
- }
-}
+++ /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.confignetconfconnector.operations;
-
-import com.google.common.base.Optional;
-import org.opendaylight.controller.config.facade.xml.Datastore;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * Simple Lock implementation that pretends to lock candidate datastore.
- * Candidate datastore is allocated per session and is private so no real locking is needed
- * (JMX is the only possible interference)
- */
-public class Lock extends AbstractLastNetconfOperation {
-
- private static final Logger LOG = LoggerFactory.getLogger(Lock.class);
-
- private static final String LOCK = "lock";
- private static final String TARGET_KEY = "target";
-
- public Lock(final String netconfSessionIdForReporting) {
- super(netconfSessionIdForReporting);
- }
-
- @Override
- protected Element handleWithNoSubsequentOperations(final Document document,
- final XmlElement operationElement) throws DocumentedException {
- final Datastore targetDatastore = extractTargetParameter(operationElement);
- if (targetDatastore == Datastore.candidate) {
- // Since candidate datastore instances are allocated per session and not accessible anywhere else,
- // no need to lock
- LOG.debug("Locking {} datastore on session: {}", targetDatastore, getNetconfSessionIdForReporting());
- // TODO should this fail if we are already locked ?
- return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
- }
-
- // Not supported running lock
- throw new DocumentedException("Unable to lock " + Datastore.running + " datastore",
- DocumentedException.ErrorType.APPLICATION,
- DocumentedException.ErrorTag.OPERATION_NOT_SUPPORTED, DocumentedException.ErrorSeverity.ERROR);
- }
-
- static Datastore extractTargetParameter(final XmlElement operationElement) throws DocumentedException {
- final XmlElement targetElement = operationElement.getOnlyChildElementWithSameNamespace(TARGET_KEY);
- final XmlElement targetChildNode = targetElement.getOnlyChildElementWithSameNamespace();
-
- return Datastore.valueOf(targetChildNode.getName());
- }
-
- @Override
- protected String getOperationName() {
- return LOCK;
- }
-}
+++ /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.confignetconfconnector.operations;
-
-import com.google.common.base.Optional;
-import org.opendaylight.controller.config.facade.xml.Datastore;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * Simple unlock implementation that pretends to unlock candidate datastore.
- * Candidate datastore is allocated per session and is private so no real locking is needed
- * (JMX is the only possible interference)
- */
-public class UnLock extends AbstractLastNetconfOperation {
-
- private static final Logger LOG = LoggerFactory.getLogger(UnLock.class);
-
- private static final String UNLOCK = "unlock";
-
- public UnLock(final String netconfSessionIdForReporting) {
- super(netconfSessionIdForReporting);
- }
-
- @Override
- protected Element handleWithNoSubsequentOperations(final Document document,
- final XmlElement operationElement) throws DocumentedException {
- final Datastore targetDatastore = Lock.extractTargetParameter(operationElement);
- if (targetDatastore == Datastore.candidate) {
- // Since candidate datastore instances are allocated per session and not accessible anywhere else,
- // no need to lock
- LOG.debug("Unlocking {} datastore on session: {}", targetDatastore, getNetconfSessionIdForReporting());
- // TODO this should fail if we are not locked
- return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
- }
-
- // Not supported running lock
- throw new DocumentedException("Unable to unlock " + Datastore.running + " datastore",
- DocumentedException.ErrorType.APPLICATION,
- DocumentedException.ErrorTag.OPERATION_NOT_SUPPORTED, DocumentedException.ErrorSeverity.ERROR);
- }
-
- @Override
- protected String getOperationName() {
- return UNLOCK;
- }
-}
+++ /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.confignetconfconnector.operations;
-
-import com.google.common.base.Optional;
-import java.util.HashMap;
-import java.util.Map;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.facade.xml.Datastore;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class Validate extends AbstractConfigNetconfOperation {
-
- public static final String VALIDATE = "validate";
-
- private static final Logger LOG = LoggerFactory.getLogger(Validate.class);
-
- public Validate(final ConfigSubsystemFacade configSubsystemFacade, final String netconfSessionIdForReporting) {
- super(configSubsystemFacade, netconfSessionIdForReporting);
- }
-
- private void checkXml(final XmlElement xml) throws DocumentedException {
- xml.checkName(VALIDATE);
- xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
-
- final XmlElement sourceElement = xml.getOnlyChildElement(XmlNetconfConstants.SOURCE_KEY,
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
- final XmlElement sourceChildNode = sourceElement.getOnlyChildElement();
-
- sourceChildNode.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
- final String datastoreValue = sourceChildNode.getName();
- final Datastore sourceDatastore = Datastore.valueOf(datastoreValue);
-
- if (sourceDatastore != Datastore.candidate) {
- throw new DocumentedException("Only " + Datastore.candidate
- + " is supported as source for " + VALIDATE + " but was " + datastoreValue, ErrorType.APPLICATION,
- ErrorTag.DATA_MISSING, ErrorSeverity.ERROR);
- }
- }
-
- @Override
- protected String getOperationName() {
- return VALIDATE;
- }
-
- @Override
- protected Element handleWithNoSubsequentOperations(final Document document,
- final XmlElement xml) throws DocumentedException {
- checkXml(xml);
- try {
- getConfigSubsystemFacade().validateConfiguration();
- } catch (final ValidationException e) {
- LOG.warn("Validation failed", e);
- throw DocumentedException.wrap(e);
- } catch (final IllegalStateException e) {
- LOG.warn("Validation failed", e);
- final Map<String, String> errorInfo = new HashMap<>();
- errorInfo
- .put(ErrorTag.OPERATION_FAILED.name(),
- "Datastore is not present. "
- + "Use 'get-config' or 'edit-config' before triggering 'operations' operation");
- throw new DocumentedException(e.getMessage(), e, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED,
- ErrorSeverity.ERROR, errorInfo);
-
- }
-
- LOG.trace("Datastore {} validated successfully", Datastore.candidate);
-
- return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
- }
-}
+++ /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.confignetconfconnector.operations.editconfig;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
-import java.util.HashMap;
-import java.util.Map;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.facade.xml.ConfigExecution;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.facade.xml.mapping.config.Config;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
-import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class EditConfig extends AbstractConfigNetconfOperation {
-
- private static final Logger LOG = LoggerFactory.getLogger(EditConfig.class);
-
- private final EditConfigXmlParser editConfigXmlParser;
-
- public EditConfig(final ConfigSubsystemFacade configSubsystemFacade, final String netconfSessionIdForReporting) {
- super(configSubsystemFacade, netconfSessionIdForReporting);
- this.editConfigXmlParser = new EditConfigXmlParser();
- }
-
- @VisibleForTesting
- Element getResponseInternal(final Document document,
- final ConfigExecution configExecution) throws DocumentedException {
-
- try {
- getConfigSubsystemFacade().executeConfigExecution(configExecution);
- } catch (final ValidationException e) {
- LOG.warn("Test phase for {} failed", EditConfigXmlParser.EDIT_CONFIG, e);
- final Map<String, String> errorInfo = new HashMap<>();
- errorInfo.put(ErrorTag.OPERATION_FAILED.name(), e.getMessage());
- throw new DocumentedException("Test phase: " + e.getMessage(), e, ErrorType.APPLICATION,
- ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR, errorInfo);
- }
-
- LOG.trace("Operation {} successful", EditConfigXmlParser.EDIT_CONFIG);
-
- return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
- }
-
- @Override
- protected String getOperationName() {
- return EditConfigXmlParser.EDIT_CONFIG;
- }
-
- @Override
- protected Element handleWithNoSubsequentOperations(final Document document,
- final XmlElement xml) throws DocumentedException {
- // FIXME config mapping getter works on dynamic yang store service
- // and so does later executeConfigExecution method
- // They might have different view of current yangs in ODL and might cause race conditions
- final Config cfg = getConfigSubsystemFacade().getConfigMapping();
- final ConfigExecution configExecution = editConfigXmlParser.fromXml(xml, cfg);
-
- return getResponseInternal(document, configExecution);
- }
-
-}
+++ /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.confignetconfconnector.operations.editconfig;
-
-import com.google.common.base.Optional;
-import org.opendaylight.controller.config.facade.xml.ConfigExecution;
-import org.opendaylight.controller.config.facade.xml.Datastore;
-import org.opendaylight.controller.config.facade.xml.TestOption;
-import org.opendaylight.controller.config.facade.xml.mapping.config.Config;
-import org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class EditConfigXmlParser {
-
- private static final Logger LOG = LoggerFactory.getLogger(EditConfigXmlParser.class);
-
- public static final String EDIT_CONFIG = "edit-config";
- public static final String DEFAULT_OPERATION_KEY = "default-operation";
- static final String ERROR_OPTION_KEY = "error-option";
- static final String DEFAULT_ERROR_OPTION = "stop-on-error";
- static final String TARGET_KEY = "target";
- static final String TEST_OPTION_KEY = "test-option";
-
- public EditConfigXmlParser() {
- }
-
- ConfigExecution fromXml(final XmlElement xml, final Config cfgMapping)
- throws DocumentedException {
-
- //TODO remove transactionProvider and CfgRegistry from parameters, accept only service ref store
-
- EditStrategyType editStrategyType = EditStrategyType.getDefaultStrategy();
-
- xml.checkName(EditConfigXmlParser.EDIT_CONFIG);
- xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
-
-
- XmlElement targetElement;
- XmlElement targetChildNode;
- targetElement = xml.getOnlyChildElementWithSameNamespace(EditConfigXmlParser.TARGET_KEY);
- targetChildNode = targetElement.getOnlyChildElementWithSameNamespace();
-
- final String datastoreValue = targetChildNode.getName();
- final Datastore targetDatastore = Datastore.valueOf(datastoreValue);
- LOG.debug("Setting {} to '{}'", EditConfigXmlParser.TARGET_KEY, targetDatastore);
-
- // check target
- if (targetDatastore != Datastore.candidate) {
- throw new DocumentedException(String.format(
- "Only %s datastore supported for edit config but was: %s",
- Datastore.candidate,
- targetDatastore),
- DocumentedException.ErrorType.APPLICATION,
- DocumentedException.ErrorTag.INVALID_VALUE,
- DocumentedException.ErrorSeverity.ERROR);
- }
-
- // Test option
- final TestOption testOption;
- final Optional<XmlElement> testOptionElementOpt = xml
- .getOnlyChildElementWithSameNamespaceOptionally(EditConfigXmlParser.TEST_OPTION_KEY);
- if (testOptionElementOpt.isPresent()) {
- final String testOptionValue = testOptionElementOpt.get().getTextContent();
- testOption = TestOption.getFromXmlName(testOptionValue);
- } else {
- testOption = TestOption.getDefault();
- }
- LOG.debug("Setting {} to '{}'", EditConfigXmlParser.TEST_OPTION_KEY, testOption);
-
- // Error option
- final Optional<XmlElement> errorOptionElement = xml
- .getOnlyChildElementWithSameNamespaceOptionally(EditConfigXmlParser.ERROR_OPTION_KEY);
- if (errorOptionElement.isPresent()) {
- final String errorOptionParsed = errorOptionElement.get().getTextContent();
- if (!errorOptionParsed.equals(EditConfigXmlParser.DEFAULT_ERROR_OPTION)) {
- throw new UnsupportedOperationException("Only " + EditConfigXmlParser.DEFAULT_ERROR_OPTION
- + " supported for " + EditConfigXmlParser.ERROR_OPTION_KEY + ", was " + errorOptionParsed);
- }
- }
-
- // Default op
- final Optional<XmlElement> defaultContent = xml
- .getOnlyChildElementWithSameNamespaceOptionally(EditConfigXmlParser.DEFAULT_OPERATION_KEY);
- if (defaultContent.isPresent()) {
- final String mergeStrategyString = defaultContent.get().getTextContent();
- LOG.trace("Setting merge strategy to {}", mergeStrategyString);
- editStrategyType = EditStrategyType.valueOf(mergeStrategyString);
- }
-
- XmlElement configElement;
- configElement = xml.getOnlyChildElementWithSameNamespace(XmlNetconfConstants.CONFIG_KEY);
-
- return new ConfigExecution(cfgMapping, configElement, testOption, editStrategyType);
- }
-}
+++ /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.confignetconfconnector.operations.get;
-
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class Get extends AbstractConfigNetconfOperation {
-
- private static final Logger LOG = LoggerFactory.getLogger(Get.class);
-
- public Get(final ConfigSubsystemFacade configSubsystemFacade, final String netconfSessionIdForReporting) {
- super(configSubsystemFacade, netconfSessionIdForReporting);
- }
-
- private static void checkXml(XmlElement xml) throws DocumentedException {
- xml.checkName(XmlNetconfConstants.GET);
- xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
-
- // Filter option: ignore for now, TODO only load modules specified by the filter
- }
-
- @Override
- protected String getOperationName() {
- return XmlNetconfConstants.GET;
- }
-
- @Override
- protected Element handleWithNoSubsequentOperations(Document document, XmlElement xml) throws DocumentedException {
- checkXml(xml);
- final Element element = getConfigSubsystemFacade().get(document);
- LOG.trace("{} operation successful", XmlNetconfConstants.GET);
- return element;
- }
-}
+++ /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.confignetconfconnector.operations.getconfig;
-
-import com.google.common.base.Optional;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.facade.xml.Datastore;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class GetConfig extends AbstractConfigNetconfOperation {
-
- public static final String GET_CONFIG = "get-config";
-
- private final Optional<String> maybeNamespace;
-
- private static final Logger LOG = LoggerFactory.getLogger(GetConfig.class);
-
- public GetConfig(final ConfigSubsystemFacade configSubsystemFacade, final Optional<String> maybeNamespace,
- final String netconfSessionIdForReporting) {
- super(configSubsystemFacade, netconfSessionIdForReporting);
- this.maybeNamespace = maybeNamespace;
- }
-
- public static Datastore fromXml(XmlElement xml) throws DocumentedException {
-
- xml.checkName(GET_CONFIG);
- xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
-
- XmlElement sourceElement = xml.getOnlyChildElement(XmlNetconfConstants.SOURCE_KEY,
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
- XmlElement sourceNode = sourceElement.getOnlyChildElement();
- String sourceParsed = sourceNode.getName();
- LOG.debug("Setting source datastore to '{}'", sourceParsed);
-
- // Filter option: ignore for now, TODO only load modules specified by the filter
-
- return Datastore.valueOf(sourceParsed);
-
- }
-
- @Override
- protected String getOperationName() {
- return GET_CONFIG;
- }
-
- @Override
- public Element handleWithNoSubsequentOperations(Document document, XmlElement xml) throws DocumentedException {
- return getConfigSubsystemFacade().getConfiguration(document, fromXml(xml), maybeNamespace);
- }
-}
+++ /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.confignetconfconnector.operations.runtimerpc;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.facade.xml.RpcFacade;
-import org.opendaylight.controller.config.facade.xml.rpc.InstanceRuntimeRpc;
-import org.opendaylight.controller.config.facade.xml.rpc.ModuleRpcs;
-import org.opendaylight.controller.config.facade.xml.rpc.Rpcs;
-import org.opendaylight.controller.config.facade.xml.rpc.RuntimeRpcElementResolved;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
-import org.opendaylight.netconf.mapping.api.HandlingPriority;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class RuntimeRpc extends AbstractConfigNetconfOperation {
-
- private static final Logger LOG = LoggerFactory.getLogger(RuntimeRpc.class);
-
- public RuntimeRpc(final ConfigSubsystemFacade configSubsystemFacade, final String netconfSessionIdForReporting) {
- super(configSubsystemFacade, netconfSessionIdForReporting);
- }
-
-
- @Override
- public HandlingPriority canHandle(Document message) throws DocumentedException {
- XmlElement requestElement = getRequestElementWithCheck(message);
-
- XmlElement operationElement = requestElement.getOnlyChildElement();
- final String netconfOperationName = operationElement.getName();
- final String netconfOperationNamespace;
- try {
- netconfOperationNamespace = operationElement.getNamespace();
- } catch (DocumentedException e) {
- LOG.debug("Cannot retrieve netconf operation namespace from message due to ", e);
- return HandlingPriority.CANNOT_HANDLE;
- }
-
- final Optional<XmlElement> contextInstanceElement = operationElement
- .getOnlyChildElementOptionally(RpcFacade.CONTEXT_INSTANCE);
-
- if (!contextInstanceElement.isPresent()) {
- return HandlingPriority.CANNOT_HANDLE;
- }
-
- final RuntimeRpcElementResolved id = RuntimeRpcElementResolved.fromXpath(contextInstanceElement.get()
- .getTextContent(), netconfOperationName, netconfOperationNamespace);
-
- // TODO reuse rpcs instance in fromXml method
- final Rpcs rpcs = getConfigSubsystemFacade().getRpcFacade().mapRpcs();
-
- try {
- final ModuleRpcs rpcMapping = rpcs.getRpcMapping(id);
- final InstanceRuntimeRpc instanceRuntimeRpc = rpcMapping.getRpc(id.getRuntimeBeanName(),
- netconfOperationName);
- Preconditions.checkState(instanceRuntimeRpc != null, "No rpc found for %s:%s", netconfOperationNamespace,
- netconfOperationName);
- } catch (IllegalStateException e) {
- LOG.debug("Cannot handle runtime operation {}:{}", netconfOperationNamespace, netconfOperationName, e);
- return HandlingPriority.CANNOT_HANDLE;
- }
-
- return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY;
- }
-
- @Override
- protected HandlingPriority canHandle(String netconfOperationName, String namespace) {
- throw new UnsupportedOperationException(
- "This should not be used since it is not possible to provide check with these attributes");
- }
-
- @Override
- protected String getOperationName() {
- throw new UnsupportedOperationException("Runtime rpc does not have a stable name");
- }
-
- @Override
- protected Element handleWithNoSubsequentOperations(Document document, XmlElement xml) throws DocumentedException {
- // TODO check for namespaces and unknown elements
- final RpcFacade.OperationExecution execution = getConfigSubsystemFacade().getRpcFacade().fromXml(xml);
-
- LOG.debug("Invoking operation {} on {} with arguments {}", execution.getOperationName(), execution.getOn(),
- execution.getAttributes());
- final Object result = getConfigSubsystemFacade().getRpcFacade().executeOperation(execution);
-
- LOG.trace("Operation {} called successfully on {} with arguments {} with result {}",
- execution.getOperationName(), execution.getOn(), execution.getAttributes(), result);
-
- if (execution.isVoid()) {
- return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
- } else {
- return getConfigSubsystemFacade().getRpcFacade().toXml(document, result, execution);
- }
- }
-
-}
+++ /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.confignetconfconnector.osgi;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacadeFactory;
-import org.opendaylight.netconf.api.util.NetconfConstants;
-import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class Activator implements BundleActivator {
-
- private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
-
- private ServiceRegistration<?> osgiRegistration;
-
- @Override
- public void start(final BundleContext context) throws Exception {
- ServiceTrackerCustomizer<ConfigSubsystemFacadeFactory,
- ConfigSubsystemFacadeFactory> schemaServiceTrackerCustomizer =
- new ServiceTrackerCustomizer<ConfigSubsystemFacadeFactory, ConfigSubsystemFacadeFactory>() {
-
- @Override
- public ConfigSubsystemFacadeFactory addingService(
- ServiceReference<ConfigSubsystemFacadeFactory> reference) {
- LOG.debug("Got addingService(SchemaContextProvider) event");
- // Yang store service should not be registered multiple times
- ConfigSubsystemFacadeFactory configSubsystemFacade =
- reference.getBundle().getBundleContext().getService(reference);
- osgiRegistration = startNetconfServiceFactory(configSubsystemFacade, context);
- return configSubsystemFacade;
- }
-
- @Override
- public void modifiedService(ServiceReference<ConfigSubsystemFacadeFactory> reference,
- ConfigSubsystemFacadeFactory service) {
- LOG.warn("Config manager facade was modified unexpectedly");
- }
-
- @Override
- public void removedService(ServiceReference<ConfigSubsystemFacadeFactory> reference,
- ConfigSubsystemFacadeFactory service) {
- LOG.warn("Config manager facade was removed unexpectedly");
- }
- };
-
- ServiceTracker<ConfigSubsystemFacadeFactory, ConfigSubsystemFacadeFactory> schemaContextProviderServiceTracker =
- new ServiceTracker<>(context, ConfigSubsystemFacadeFactory.class, schemaServiceTrackerCustomizer);
- schemaContextProviderServiceTracker.open();
- }
-
- @Override
- public void stop(final BundleContext bundleContext) throws Exception {
- if (osgiRegistration != null) {
- osgiRegistration.unregister();
- }
- }
-
- private ServiceRegistration<NetconfOperationServiceFactory> startNetconfServiceFactory(
- final ConfigSubsystemFacadeFactory configSubsystemFacade, final BundleContext context) {
- final NetconfOperationServiceFactoryImpl netconfOperationServiceFactory =
- new NetconfOperationServiceFactoryImpl(configSubsystemFacade);
- // Add properties to autowire with netconf-impl instance for cfg subsystem
- final Dictionary<String, String> properties = new Hashtable<>();
- properties.put(NetconfConstants.SERVICE_NAME, NetconfConstants.CONFIG_NETCONF_CONNECTOR);
- return context.registerService(NetconfOperationServiceFactory.class,
- netconfOperationServiceFactory, properties);
- }
-
-}
+++ /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.confignetconfconnector.osgi;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.Sets;
-import java.util.Set;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.netconf.confignetconfconnector.operations.Commit;
-import org.opendaylight.netconf.confignetconfconnector.operations.DiscardChanges;
-import org.opendaylight.netconf.confignetconfconnector.operations.Lock;
-import org.opendaylight.netconf.confignetconfconnector.operations.UnLock;
-import org.opendaylight.netconf.confignetconfconnector.operations.Validate;
-import org.opendaylight.netconf.confignetconfconnector.operations.editconfig.EditConfig;
-import org.opendaylight.netconf.confignetconfconnector.operations.get.Get;
-import org.opendaylight.netconf.confignetconfconnector.operations.getconfig.GetConfig;
-import org.opendaylight.netconf.confignetconfconnector.operations.runtimerpc.RuntimeRpc;
-import org.opendaylight.netconf.mapping.api.NetconfOperation;
-
-final class NetconfOperationProvider {
- private final Set<NetconfOperation> operations;
-
- NetconfOperationProvider(final ConfigSubsystemFacade configSubsystemFacade,
- final String netconfSessionIdForReporting) {
-
- operations = setUpOperations(configSubsystemFacade, netconfSessionIdForReporting);
- }
-
- Set<NetconfOperation> getOperations() {
- return operations;
- }
-
- private static Set<NetconfOperation> setUpOperations(final ConfigSubsystemFacade configSubsystemFacade,
- String netconfSessionIdForReporting) {
- Set<NetconfOperation> ops = Sets.newHashSet();
-
- GetConfig getConfigOp = new GetConfig(configSubsystemFacade, Optional.absent(), netconfSessionIdForReporting);
-
- ops.add(getConfigOp);
- ops.add(new EditConfig(configSubsystemFacade, netconfSessionIdForReporting));
- ops.add(new Commit(configSubsystemFacade, netconfSessionIdForReporting));
- ops.add(new Lock(netconfSessionIdForReporting));
- ops.add(new UnLock(netconfSessionIdForReporting));
- ops.add(new Get(configSubsystemFacade, netconfSessionIdForReporting));
- ops.add(new DiscardChanges(configSubsystemFacade, netconfSessionIdForReporting));
- ops.add(new Validate(configSubsystemFacade, netconfSessionIdForReporting));
- ops.add(new RuntimeRpc(configSubsystemFacade, netconfSessionIdForReporting));
-
- return ops;
- }
-
-}
+++ /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.confignetconfconnector.osgi;
-
-import java.util.Set;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacadeFactory;
-import org.opendaylight.controller.config.util.capability.Capability;
-import org.opendaylight.netconf.api.monitoring.CapabilityListener;
-import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
-
-public class NetconfOperationServiceFactoryImpl implements NetconfOperationServiceFactory {
-
- private final ConfigSubsystemFacadeFactory configFacadeFactory;
-
- public NetconfOperationServiceFactoryImpl(ConfigSubsystemFacadeFactory configFacadeFactory) {
- this.configFacadeFactory = configFacadeFactory;
- }
-
- @Override
- public NetconfOperationServiceImpl createService(String netconfSessionIdForReporting) {
- return new NetconfOperationServiceImpl(configFacadeFactory.createFacade(netconfSessionIdForReporting),
- netconfSessionIdForReporting);
- }
-
- @Override
- public Set<Capability> getCapabilities() {
- return configFacadeFactory.getCurrentCapabilities();
- }
-
- @Override
- public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
- return configFacadeFactory.getYangStoreService().registerModuleListener(listener::onCapabilitiesChanged);
- }
-}
+++ /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.confignetconfconnector.osgi;
-
-import java.util.Set;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.netconf.mapping.api.NetconfOperation;
-import org.opendaylight.netconf.mapping.api.NetconfOperationService;
-
-public class NetconfOperationServiceImpl implements NetconfOperationService {
-
- private final NetconfOperationProvider operationProvider;
- private final ConfigSubsystemFacade configSubsystemFacade;
-
- public NetconfOperationServiceImpl(final ConfigSubsystemFacade configSubsystemFacade,
- final String netconfSessionIdForReporting) {
- this.configSubsystemFacade = configSubsystemFacade;
- this.operationProvider = new NetconfOperationProvider(configSubsystemFacade, netconfSessionIdForReporting);
- }
-
- @Override
- public Set<NetconfOperation> getNetconfOperations() {
- return operationProvider.getOperations();
- }
-
- @Override
- public void close() {
- configSubsystemFacade.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.confignetconfconnector;
-
-import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.not;
-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.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.opendaylight.controller.config.util.xml.XmlUtil.readXmlToElement;
-import static org.opendaylight.netconf.util.test.XmlUnitUtil.assertContainsElement;
-import static org.opendaylight.netconf.util.test.XmlUnitUtil.assertContainsElementWithText;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import io.netty.channel.Channel;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.net.URISyntaxException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.ObjectName;
-import javax.xml.parsers.ParserConfigurationException;
-import org.custommonkey.xmlunit.AbstractNodeTester;
-import org.custommonkey.xmlunit.NodeTest;
-import org.custommonkey.xmlunit.NodeTestException;
-import org.custommonkey.xmlunit.NodeTester;
-import org.custommonkey.xmlunit.XMLAssert;
-import org.custommonkey.xmlunit.XMLUnit;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.api.ConflictingVersionException;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
-import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.facade.xml.osgi.EnumResolver;
-import org.opendaylight.controller.config.facade.xml.osgi.YangStoreService;
-import org.opendaylight.controller.config.facade.xml.transactions.TransactionProvider;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlMappingConstants;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.controller.config.yang.test.impl.ComplexDtoBInner;
-import org.opendaylight.controller.config.yang.test.impl.ComplexList;
-import org.opendaylight.controller.config.yang.test.impl.Deep;
-import org.opendaylight.controller.config.yang.test.impl.DepTestImplModuleFactory;
-import org.opendaylight.controller.config.yang.test.impl.DtoAInner;
-import org.opendaylight.controller.config.yang.test.impl.DtoAInnerInner;
-import org.opendaylight.controller.config.yang.test.impl.DtoC;
-import org.opendaylight.controller.config.yang.test.impl.DtoD;
-import org.opendaylight.controller.config.yang.test.impl.IdentityTestModuleFactory;
-import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleFactory;
-import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleMXBean;
-import org.opendaylight.controller.config.yang.test.impl.Peers;
-import org.opendaylight.controller.config.yang.test.impl.TestImplModuleFactory;
-import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
-import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
-import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
-import org.opendaylight.netconf.confignetconfconnector.operations.Commit;
-import org.opendaylight.netconf.confignetconfconnector.operations.DiscardChanges;
-import org.opendaylight.netconf.confignetconfconnector.operations.Lock;
-import org.opendaylight.netconf.confignetconfconnector.operations.UnLock;
-import org.opendaylight.netconf.confignetconfconnector.operations.editconfig.EditConfig;
-import org.opendaylight.netconf.confignetconfconnector.operations.get.Get;
-import org.opendaylight.netconf.confignetconfconnector.operations.getconfig.GetConfig;
-import org.opendaylight.netconf.confignetconfconnector.operations.runtimerpc.RuntimeRpc;
-import org.opendaylight.netconf.impl.NetconfServerSession;
-import org.opendaylight.netconf.impl.NetconfServerSessionListener;
-import org.opendaylight.netconf.impl.mapping.operations.DefaultCloseSession;
-import org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory;
-import org.opendaylight.netconf.impl.osgi.NetconfOperationRouter;
-import org.opendaylight.netconf.mapping.api.HandlingPriority;
-import org.opendaylight.netconf.mapping.api.NetconfOperation;
-import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
-import org.opendaylight.netconf.util.messages.NetconfMessageUtil;
-import org.opendaylight.netconf.util.test.XmlFileLoader;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity2;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
-import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-import org.osgi.framework.Filter;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.w3c.dom.traversal.DocumentTraversal;
-import org.xml.sax.SAXException;
-
-
-public class NetconfMappingTest extends AbstractConfigTest {
- private static final Logger LOG = LoggerFactory.getLogger(NetconfMappingTest.class);
-
- private static final String INSTANCE_NAME = "instance-from-code";
- private static final String NETCONF_SESSION_ID = "foo";
- private static final String TEST_NAMESPACE = "urn:opendaylight:params:xml:ns:yang:controller:test:impl";
- private NetconfTestImplModuleFactory factory;
- private DepTestImplModuleFactory factory2;
- private IdentityTestModuleFactory factory3;
- private TestImplModuleFactory factory4;
-
- @Mock
- YangStoreService yangStoreSnapshot;
- @Mock
- NetconfOperationRouter netconfOperationRouter;
- @Mock
- AggregatedNetconfOperationServiceFactory netconfOperationServiceSnapshot;
- @Mock
- private AutoCloseable sessionCloseable;
-
- private TransactionProvider transactionProvider;
-
- private ConfigSubsystemFacade configSubsystemFacade;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
-
- final Filter filter = mock(Filter.class);
- doReturn(filter).when(mockedContext).createFilter(anyString());
- doNothing().when(mockedContext).addServiceListener(any(ServiceListener.class), anyString());
- doReturn(new ServiceReference<?>[]{}).when(mockedContext).getServiceReferences(anyString(), anyString());
-
- doReturn(yangStoreSnapshot).when(yangStoreSnapshot).getCurrentSnapshot();
- doReturn(getMbes()).when(this.yangStoreSnapshot).getModuleMXBeanEntryMap();
- doReturn(getModules()).when(this.yangStoreSnapshot).getModules();
- doReturn(new EnumResolver() {
- @Override
- public String fromYang(final String enumType, final String enumYangValue) {
- return Preconditions.checkNotNull(getEnumMapping().get(enumYangValue),
- "Unable to resolve enum value %s, for enum %s with mappings %s",
- enumYangValue, enumType, getEnumMapping());
- }
-
- @Override
- public String toYang(final String enumType, final String enumYangValue) {
- return Preconditions.checkNotNull(getEnumMapping().inverse().get(enumYangValue),
- "Unable to resolve enum value %s, for enum %s with mappings %s",
- enumYangValue, enumType, getEnumMapping().inverse());
- }
- }).when(this.yangStoreSnapshot).getEnumResolver();
-
- this.factory = new NetconfTestImplModuleFactory();
- this.factory2 = new DepTestImplModuleFactory();
- this.factory3 = new IdentityTestModuleFactory();
- factory4 = new TestImplModuleFactory();
- doNothing().when(sessionCloseable).close();
-
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, this.factory,
- this.factory2, this.factory3, factory4));
-
- transactionProvider = new TransactionProvider(this.configRegistryClient, NETCONF_SESSION_ID);
-
- configSubsystemFacade = new ConfigSubsystemFacade(configRegistryClient, configRegistryClient, yangStoreSnapshot,
- "mapping-test");
- }
-
- private ObjectName createModule(final String instanceName) throws InstanceAlreadyExistsException,
- InstanceNotFoundException, URISyntaxException, ValidationException, ConflictingVersionException {
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-
- final ObjectName on = transaction.createModule(this.factory.getImplementationName(), instanceName);
- final NetconfTestImplModuleMXBean mxBean = transaction.newMXBeanProxy(on, NetconfTestImplModuleMXBean.class);
- setModule(mxBean, transaction, instanceName + "_dep");
-
- int index = 1;
- for (final Class<? extends AbstractServiceInterface> serviceInterface :
- factory.getImplementedServiceIntefaces()) {
- final ServiceInterfaceAnnotation annotation =
- serviceInterface.getAnnotation(ServiceInterfaceAnnotation.class);
- transaction.saveServiceReference(
- transaction.getServiceInterfaceName(annotation.namespace(), annotation.localName()),
- "ref_from_code_to_" + instanceName + "_" + index++, on);
-
- }
- transaction.commit();
- return on;
- }
-
- @Test
- public void testIdentityRefs() throws Exception {
- edit("netconfMessages/editConfig_identities.xml");
-
- commit();
- Document configRunning = getConfigRunning();
- String asString = XmlUtil.toString(configRunning);
- assertThat(asString, containsString("test-identity2"));
- assertThat(asString, containsString("test-identity1"));
- assertEquals(2, countSubstringOccurence(asString, "</identities>"));
-
- edit("netconfMessages/editConfig_identities_inner_replace.xml");
- commit();
- configRunning = getConfigRunning();
- asString = XmlUtil.toString(configRunning);
- // test-identity1 was removed by replace
- assertThat(asString, not(containsString("test-identity2")));
- // now only 1 identities entry is present
- assertEquals(1, countSubstringOccurence(asString, "</identities>"));
- }
-
- private static int countSubstringOccurence(final String string, final String substring) {
- final Matcher matches = Pattern.compile(substring).matcher(string);
- int count = 0;
- while (matches.find()) {
- count++;
- }
- return count;
- }
-
- @Override
- protected BindingRuntimeContext getBindingRuntimeContext() {
- final BindingRuntimeContext ret = super.getBindingRuntimeContext();
- doReturn(TestIdentity1.class).when(ret).getIdentityClass(TestIdentity1.QNAME);
- doReturn(TestIdentity2.class).when(ret).getIdentityClass(TestIdentity2.QNAME);
- doReturn(getSchemaContext()).when(ret).getSchemaContext();
- return ret;
- }
-
- @Test
- public void testServicePersistance() throws Exception {
- createModule(INSTANCE_NAME);
-
- edit("netconfMessages/editConfig.xml");
- Document config = getConfigCandidate();
- assertCorrectServiceNames(config, Sets.newHashSet("user_to_instance_from_code", "ref_dep_user",
- "ref_dep_user_two", "ref_from_code_to_instance-from-code_dep_1",
- "ref_from_code_to_instance-from-code_1"));
-
-
- edit("netconfMessages/editConfig_addServiceName.xml");
- config = getConfigCandidate();
- assertCorrectServiceNames(config, Sets.newHashSet("user_to_instance_from_code", "ref_dep_user",
- "ref_dep_user_two", "ref_from_code_to_instance-from-code_dep_1",
- "ref_from_code_to_instance-from-code_1", "ref_dep_user_another"));
-
- edit("netconfMessages/editConfig_addServiceNameOnTest.xml");
- config = getConfigCandidate();
- assertCorrectServiceNames(config, Sets.newHashSet("user_to_instance_from_code", "ref_dep_user",
- "ref_dep_user_two", "ref_from_code_to_instance-from-code_dep_1",
- "ref_from_code_to_instance-from-code_1", "ref_dep_user_another"));
-
- commit();
- config = getConfigRunning();
- assertCorrectRefNamesForDependencies(config);
- assertCorrectServiceNames(config, Sets.newHashSet("user_to_instance_from_code", "ref_dep_user",
- "ref_dep_user_two", "ref_from_code_to_instance-from-code_dep_1",
- "ref_from_code_to_instance-from-code_1", "ref_dep_user_another"));
-
- edit("netconfMessages/editConfig_removeServiceNameOnTest.xml");
- config = getConfigCandidate();
- assertCorrectServiceNames(config, Sets.newHashSet("user_to_instance_from_code", "ref_dep_user",
- "ref_dep_user_two", "ref_from_code_to_instance-from-code_dep_1",
- "ref_from_code_to_instance-from-code_1"));
-
- try {
- edit("netconfMessages/editConfig_removeServiceNameOnTest.xml");
- fail("Should've failed, non-existing service instance");
- } catch (final DocumentedException e) {
- assertEquals(e.getErrorSeverity(), DocumentedException.ErrorSeverity.ERROR);
- assertEquals(e.getErrorTag(), DocumentedException.ErrorTag.OPERATION_FAILED);
- assertEquals(e.getErrorType(), DocumentedException.ErrorType.APPLICATION);
- }
-
- edit("netconfMessages/editConfig_replace_default.xml");
- config = getConfigCandidate();
- assertCorrectServiceNames(config, Collections.<String>emptySet());
-
- edit("netconfMessages/editConfig_remove.xml");
- config = getConfigCandidate();
- assertCorrectServiceNames(config, Collections.<String>emptySet());
-
- commit();
- config = getConfigCandidate();
- assertCorrectServiceNames(config, Collections.<String>emptySet());
-
- }
-
- @Test
- public void testUnLock() throws Exception {
- assertTrue(NetconfMessageUtil.isOKMessage(lockCandidate()));
- assertTrue(NetconfMessageUtil.isOKMessage(unlockCandidate()));
- }
-
- private static void assertCorrectRefNamesForDependencies(final Document config) throws NodeTestException {
- final NodeList modulesList = config.getElementsByTagName("modules");
- assertEquals(1, modulesList.getLength());
-
- final NodeTest nt = new NodeTest((DocumentTraversal) config, modulesList.item(0));
- final NodeTester tester = new AbstractNodeTester() {
- private int defaultRefNameCount = 0;
- private int userRefNameCount = 0;
-
- @Override
- public void testText(final Text text) throws NodeTestException {
- if (text.getData().equals("ref_dep2")) {
- defaultRefNameCount++;
- } else if (text.getData().equals("ref_dep_user_two")) {
- userRefNameCount++;
- }
- }
-
- @Override
- public void noMoreNodes(final NodeTest forTest) throws NodeTestException {
- assertEquals(0, defaultRefNameCount);
- assertEquals(2, userRefNameCount);
- }
- };
- nt.performTest(tester, Node.TEXT_NODE);
- }
-
- private static void assertCorrectServiceNames(final Document configCandidate,
- final Set<String> refNames) throws NodeTestException {
- final Set<String> refNames2 = new HashSet<>(refNames);
- final NodeList servicesNodes = configCandidate.getElementsByTagName("services");
- assertEquals(1, servicesNodes.getLength());
-
- final NodeTest nt = new NodeTest((DocumentTraversal) configCandidate, servicesNodes.item(0));
- final NodeTester tester = new AbstractNodeTester() {
-
- @Override
- public void testElement(final Element element) throws NodeTestException {
- if (element.getNodeName() != null) {
- if (element.getNodeName().equals("name")) {
- final String elmText = element.getTextContent();
- if (refNames2.contains(elmText)) {
- refNames2.remove(elmText);
- } else {
- throw new NodeTestException("Unexpected services defined: " + elmText);
- }
- }
- }
- }
-
- @Override
- public void noMoreNodes(final NodeTest forTest) throws NodeTestException {
- assertEquals(Collections.<String>emptySet(), refNames2);
- assertTrue(refNames2.toString(), refNames2.isEmpty());
- }
- };
- nt.performTest(tester, Node.ELEMENT_NODE);
- }
-
- @Test
- public void testConfigNetconfUnionTypes() throws Exception {
-
- createModule(INSTANCE_NAME);
-
- edit("netconfMessages/editConfig.xml");
- commit();
- Document response = getConfigRunning();
- final Element ipElement = readXmlToElement(
- "<ip xmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">0:0:0:0:0:0:0:1</ip>");
- assertContainsElement(response, readXmlToElement(
- "<ip xmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">0:0:0:0:0:0:0:1</ip>"));
-
- assertContainsElement(response, readXmlToElement("<union-test-attr xmlns="
- + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">456</union-test-attr>"));
-
-
- edit("netconfMessages/editConfig_setUnions.xml");
- commit();
- response = getConfigRunning();
- assertContainsElement(response, readXmlToElement(
- "<ip xmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">127.1.2.3</ip>"));
- assertContainsElement(response, readXmlToElement("<union-test-attr xmlns="
- + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">"
- + "randomStringForUnion</union-test-attr>"));
-
- }
-
- @Test
- public void testConfigNetconf() throws Exception {
-
- createModule(INSTANCE_NAME);
-
- edit("netconfMessages/editConfig.xml");
- final Document configCandidate = getConfigCandidate();
- checkBinaryLeafEdited(configCandidate);
-
-
- // default-operation:none, should not affect binary leaf
- edit("netconfMessages/editConfig_none.xml");
- checkBinaryLeafEdited(getConfigCandidate());
-
- // check after edit
- commit();
- final Document response = getConfigRunning();
-
- checkBinaryLeafEdited(response);
- checkTypeConfigAttribute(response);
- checkTypedefs(response);
- checkTestingDeps(response);
- checkEnum(response);
- checkBigDecimal(response);
-
- edit("netconfMessages/editConfig_remove.xml");
-
- commit();
- assertXMLEqual(getConfigCandidate(), getConfigRunning());
-
- final Document expectedResult =
- XmlFileLoader.xmlFileToDocument("netconfMessages/editConfig_expectedResult.xml");
- XMLUnit.setIgnoreWhitespace(true);
- assertXMLEqual(expectedResult, getConfigRunning());
- assertXMLEqual(expectedResult, getConfigCandidate());
-
- edit("netconfMessages/editConfig_none.xml");
- closeSession();
- verify(sessionCloseable).close();
- verifyNoMoreInteractions(netconfOperationRouter);
- verifyNoMoreInteractions(netconfOperationServiceSnapshot);
- }
-
- private static void checkBigDecimal(final Document response) throws NodeTestException, SAXException, IOException {
- assertContainsElement(response, readXmlToElement("<sleep-factor xmlns="
- + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">2.58</sleep-factor>"));
- // Default
- assertContainsElement(response, readXmlToElement("<sleep-factor xmlns="
- + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">2.00</sleep-factor>"));
- }
-
- private void closeSession() throws ParserConfigurationException, SAXException,
- IOException, DocumentedException {
- final Channel channel = mock(Channel.class);
- doReturn("channel").when(channel).toString();
- final NetconfServerSessionListener listener = mock(NetconfServerSessionListener.class);
- final NetconfServerSession session =
- new NetconfServerSession(listener, channel, 1L,
- NetconfHelloMessageAdditionalHeader.fromString("[netconf;10.12.0.102:48528;ssh;;;;;;]"));
- final DefaultCloseSession closeOp = new DefaultCloseSession(NETCONF_SESSION_ID, sessionCloseable);
- closeOp.setNetconfSession(session);
- executeOp(closeOp, "netconfMessages/closeSession.xml");
- }
-
- private void edit(final String resource) throws ParserConfigurationException, SAXException, IOException,
- DocumentedException {
- final EditConfig editOp = new EditConfig(configSubsystemFacade, NETCONF_SESSION_ID);
- executeOp(editOp, resource);
- }
-
- private void commit() throws ParserConfigurationException, SAXException, IOException, DocumentedException {
- final Commit commitOp = new Commit(configSubsystemFacade, NETCONF_SESSION_ID);
- executeOp(commitOp, "netconfMessages/commit.xml");
- }
-
- private static Document lockCandidate() throws ParserConfigurationException, SAXException, IOException,
- DocumentedException {
- final Lock commitOp = new Lock(NETCONF_SESSION_ID);
- return executeOp(commitOp, "netconfMessages/lock.xml");
- }
-
- private static Document unlockCandidate() throws ParserConfigurationException, SAXException, IOException,
- DocumentedException {
- final UnLock commitOp = new UnLock(NETCONF_SESSION_ID);
- return executeOp(commitOp, "netconfMessages/unlock.xml");
- }
-
- private Document getConfigCandidate() throws ParserConfigurationException, SAXException, IOException,
- DocumentedException {
- final GetConfig getConfigOp = new GetConfig(configSubsystemFacade, Optional.<String>absent(),
- NETCONF_SESSION_ID);
- return executeOp(getConfigOp, "netconfMessages/getConfig_candidate.xml");
- }
-
- private Document getConfigRunning() throws ParserConfigurationException, SAXException, IOException,
- DocumentedException {
- final GetConfig getConfigOp = new GetConfig(configSubsystemFacade, Optional.<String>absent(),
- NETCONF_SESSION_ID);
- return executeOp(getConfigOp, "netconfMessages/getConfig.xml");
- }
-
- @Ignore("second edit message corrupted")
- @Test(expected = DocumentedException.class)
- public void testConfigNetconfReplaceDefaultEx() throws Exception {
-
- createModule(INSTANCE_NAME);
-
- edit("netconfMessages/editConfig.xml");
- edit("netconfMessages/editConfig_replace_default_ex.xml");
- }
-
- @Test
- public void testConfigNetconfReplaceDefault() throws Exception {
-
- createModule(INSTANCE_NAME);
-
- edit("netconfMessages/editConfig.xml");
- commit();
- Document response = getConfigRunning();
- final int allInstances = response.getElementsByTagName("module").getLength();
-
- edit("netconfMessages/editConfig_replace_default.xml");
-
- commit();
- response = getConfigRunning();
-
- final int afterReplace = response.getElementsByTagName("module").getLength();
- assertEquals(4, allInstances);
- assertEquals(2, afterReplace);
- }
-
- @Test
- public void testSameAttrDifferentNamespaces() throws Exception {
- try {
- edit("netconfMessages/namespaces/editConfig_sameAttrDifferentNamespaces.xml");
- fail();
- } catch (final DocumentedException e) {
- final String message = e.getMessage();
- assertContainsString(message, "Element simpleInt present multiple times with different namespaces");
- assertContainsString(message, TEST_NAMESPACE);
- assertContainsString(message, XmlMappingConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG);
- }
- }
-
- @Test
- public void testDifferentNamespaceInTO() throws Exception {
- try {
- edit("netconfMessages/namespaces/editConfig_differentNamespaceTO.xml");
- fail();
- } catch (final DocumentedException e) {
- final String message = e.getMessage();
- assertContainsString(message, "Unrecognised elements");
- assertContainsString(message, "simple-int2");
- assertContainsString(message, "dto_d");
- }
- }
-
- @Test
- public void testSameAttrDifferentNamespacesList() throws Exception {
- try {
- edit("netconfMessages/namespaces/editConfig_sameAttrDifferentNamespacesList.xml");
- fail();
- } catch (final DocumentedException e) {
- final String message = e.getMessage();
- assertContainsString(message, "Element allow-user present multiple times with different namespaces");
- assertContainsString(message, TEST_NAMESPACE);
- assertContainsString(message, XmlMappingConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG);
- }
- }
-
- @Test
- public void testTypeNameConfigAttributeMatching() throws Exception {
- edit("netconfMessages/editConfig.xml");
- commit();
- edit("netconfMessages/namespaces/editConfig_typeNameConfigAttributeMatching.xml");
- commit();
-
- final Document response = getConfigRunning();
- checkTypeConfigAttribute(response);
- }
-
- // TODO add <modules operation="replace"> functionality
- @Test(expected = DocumentedException.class)
- public void testConfigNetconfReplaceModuleEx() throws Exception {
-
- createModule(INSTANCE_NAME);
-
- edit("netconfMessages/editConfig.xml");
- edit("netconfMessages/editConfig_replace_module_ex.xml");
- }
-
- @Test
- public void testUnrecognisedConfigElements() throws Exception {
-
- final String format = "netconfMessages/unrecognised/editConfig_unrecognised%d.xml";
- final int testsCount = 8;
-
- for (int i = 0; i < testsCount; i++) {
- final String file = String.format(format, i + 1);
- LOG.info("Reading {}", file);
- try {
- edit(file);
- } catch (final DocumentedException e) {
- assertContainsString(e.getMessage(), "Unrecognised elements");
- assertContainsString(e.getMessage(), "unknownAttribute");
- continue;
- }
- fail("Unrecognised test should throw exception " + file);
- }
- }
-
- @Test
- @Ignore
- // FIXME
- public void testConfigNetconfReplaceModule() throws Exception {
-
- createModule(INSTANCE_NAME);
-
- edit("netconfMessages/editConfig.xml");
- commit();
- Document response = getConfigRunning();
- final int allInstances = response.getElementsByTagName("instance").getLength();
-
- edit("netconfMessages/editConfig_replace_module.xml");
-
- commit();
- response = getConfigRunning();
- final int afterReplace = response.getElementsByTagName("instance").getLength();
-
- assertEquals(4 + 4 /* Instances from services */, allInstances);
- assertEquals(3 + 3, afterReplace);
- }
-
- @Test
- public void testEx2() throws Exception {
- //check abort before tx creation
- assertContainsElement(discard(), readXmlToElement("<ok xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>"));
-
- //check abort after tx creation
- edit("netconfMessages/editConfig.xml");
- assertContainsElement(discard(), readXmlToElement("<ok xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>"));
- }
-
- @Test
- public void testFailedDiscardChangesAbort() throws Exception {
- final ConfigSubsystemFacade facade = mock(ConfigSubsystemFacade.class);
- doThrow(new RuntimeException("Mocked runtime exception, Abort has to fail")).when(facade).abortConfiguration();
-
- final DiscardChanges discardOp = new DiscardChanges(facade, NETCONF_SESSION_ID);
-
- try {
- executeOp(discardOp, "netconfMessages/discardChanges.xml");
- fail("Should've failed, abort on mocked is supposed to throw RuntimeException");
- } catch (final DocumentedException e) {
- assertTrue(e.getErrorTag() == DocumentedException.ErrorTag.OPERATION_FAILED);
- assertTrue(e.getErrorSeverity() == DocumentedException.ErrorSeverity.ERROR);
- assertTrue(e.getErrorType() == DocumentedException.ErrorType.APPLICATION);
- }
- }
-
- private Document discard() throws ParserConfigurationException, SAXException, IOException, DocumentedException {
- final DiscardChanges discardOp = new DiscardChanges(configSubsystemFacade, NETCONF_SESSION_ID);
- return executeOp(discardOp, "netconfMessages/discardChanges.xml");
- }
-
- private static void checkBinaryLeafEdited(final Document response)
- throws NodeTestException, SAXException, IOException {
- assertContainsElement(response, readXmlToElement("<binaryLeaf xmlns="
- + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">YmluYXJ5</binaryLeaf>"));
- assertContainsElement(response, readXmlToElement("<binaryLeaf xmlns="
- + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">ZGVmYXVsdEJpbg==</binaryLeaf>"));
- }
-
- private static void checkTypedefs(final Document response) throws NodeTestException, SAXException, IOException {
-
- assertContainsElement(response, readXmlToElement(
- "<extended xmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">10</extended>"));
- // Default
- assertContainsElement(response, readXmlToElement(
- "<extended xmlns=\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">1</extended>"));
-
- assertContainsElement(response, readXmlToElement("<extended-twice xmlns="
- + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">20</extended-twice>"));
- // Default
- assertContainsElement(response, readXmlToElement("<extended-twice xmlns="
- + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">2</extended-twice>"));
-
- assertContainsElement(response, readXmlToElement("<extended-enum xmlns="
- + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">two</extended-enum>"));
- // Default
- assertContainsElement(response, readXmlToElement("<extended-enum xmlns="
- + "\"urn:opendaylight:params:xml:ns:yang:controller:test:impl\">one</extended-enum>"));
- }
-
- private static void assertContainsString(final String string, final String substring) {
- assertThat(string, containsString(substring));
- }
-
- private static void checkEnum(final Document response) throws Exception {
-
- final String expectedEnumContent = "two";
-
- XMLAssert.assertXpathEvaluatesTo(expectedEnumContent,
- getXpathForNetconfImplSubnode(INSTANCE_NAME, "extended-enum"),
- response);
- }
-
- private static void checkTestingDeps(final Document response) {
- final int testingDepsSize = response.getElementsByTagName("testing-deps").getLength();
- assertEquals(2, testingDepsSize);
- }
-
- private static String getXpathForNetconfImplSubnode(final String instanceName, final String subnode) {
- return "/urn:ietf:params:xml:ns:netconf:base:1.0:rpc-reply"
- + "/urn:ietf:params:xml:ns:netconf:base:1.0:data"
- + "/urn:opendaylight:params:xml:ns:yang:controller:config:modules"
- + "/urn:opendaylight:params:xml:ns:yang:controller:config:module"
- + "[urn:opendaylight:params:xml:ns:yang:controller:config:name='" + instanceName + "']"
- + "/urn:opendaylight:params:xml:ns:yang:controller:test:impl:impl-netconf"
- + "/urn:opendaylight:params:xml:ns:yang:controller:test:impl:" + subnode;
- }
-
- private static void checkTypeConfigAttribute(final Document response) throws Exception {
-
- final Map<String, String> namesToTypeValues = ImmutableMap.of("instance-from-code", "configAttributeType",
- "test2", "default-string");
- for (final Entry<String, String> nameToExpectedValue : namesToTypeValues.entrySet()) {
- XMLAssert.assertXpathEvaluatesTo(nameToExpectedValue.getValue(),
- getXpathForNetconfImplSubnode(nameToExpectedValue.getKey(), "type"),
- response);
- }
- }
-
- private static Map<String, Map<String, ModuleMXBeanEntry>> getMbes() {
-
- final SchemaContext schemaContext = getSchemaContext();
- final YangStoreService yangStoreService = new YangStoreService(() -> schemaContext,
- mock(SchemaSourceProvider.class));
- final BindingRuntimeContext bindingRuntimeContext = mock(BindingRuntimeContext.class);
- doReturn(schemaContext).when(bindingRuntimeContext).getSchemaContext();
- doReturn(getEnumMapping()).when(bindingRuntimeContext).getEnumMapping(any(Class.class));
- yangStoreService.refresh(bindingRuntimeContext);
- final Map<String, Map<String, ModuleMXBeanEntry>> mBeanEntries = new HashMap<>();
- mBeanEntries.putAll(yangStoreService.getModuleMXBeanEntryMap());
-
- return mBeanEntries;
- }
-
- private static BiMap<String, String> getEnumMapping() {
- final HashBiMap<String, String> enumBiMap = HashBiMap.create();
- // Enum constants mapping from yang -> Java and back
- enumBiMap.put("one", "One");
- enumBiMap.put("two", "Two");
- enumBiMap.put("version1", "Version1");
- enumBiMap.put("version2", "Version2");
- return enumBiMap;
- }
-
- private static Set<org.opendaylight.yangtools.yang.model.api.Module> getModules() {
- return getSchemaContext().getModules();
- }
-
- @Test
- public void testConfigNetconfRuntime() throws Exception {
-
- createModule(INSTANCE_NAME);
-
- edit("netconfMessages/editConfig.xml");
- checkBinaryLeafEdited(getConfigCandidate());
-
- // check after edit
- commit();
- Document response = get();
-
- assertEquals(2/*With runtime beans*/ + 2 /*Without runtime beans*/, getElementsSize(response, "module"));
- // data from state
- assertEquals(2, getElementsSize(response, "asdf"));
- // data from running config
- assertEquals(2, getElementsSize(response, "simple-short"));
-
- assertEquals(8, getElementsSize(response, "inner-running-data"));
- assertEquals(8, getElementsSize(response, "deep2"));
- assertEquals(8 * 4, getElementsSize(response, "inner-inner-running-data"));
- assertEquals(8 * 4, getElementsSize(response, "deep3"));
- assertEquals(8 * 4 * 2, getElementsSize(response, "list-of-strings"));
- assertEquals(8, getElementsSize(response, "inner-running-data-additional",
- "urn:opendaylight:params:xml:ns:yang:controller:test:impl"));
- assertEquals(8, getElementsSize(response, "deep4"));
- // TODO assert keys
-
- final RuntimeRpc netconf = new RuntimeRpc(configSubsystemFacade, NETCONF_SESSION_ID);
-
- response = executeOp(netconf, "netconfMessages/rpc.xml");
- assertContainsElementWithText(response, "testarg1");
-
- response = executeOp(netconf, "netconfMessages/rpcInner.xml");
- final Document expectedReplyOk = XmlFileLoader.xmlFileToDocument("netconfMessages/rpc-reply_ok.xml");
- XMLUnit.setIgnoreWhitespace(true);
- XMLAssert.assertXMLEqual(expectedReplyOk, response);
-
- response = executeOp(netconf, "netconfMessages/rpcInnerInner.xml");
- assertContainsElementWithText(response, "true");
-
- response = executeOp(netconf, "netconfMessages/rpcInnerInner_complex_output.xml");
- assertContainsElementWithText(response, "1");
- assertContainsElementWithText(response, "2");
- }
-
- private Document get() throws ParserConfigurationException, SAXException, IOException, DocumentedException {
- final Get getOp = new Get(configSubsystemFacade, NETCONF_SESSION_ID);
- return executeOp(getOp, "netconfMessages/get.xml");
- }
-
- private static int getElementsSize(final Document response, final String elementName) {
- return response.getElementsByTagName(elementName).getLength();
- }
-
- private static int getElementsSize(final Document response, final String elementName, final String namespace) {
- return response.getElementsByTagNameNS(namespace, elementName).getLength();
- }
-
- private static Document executeOp(final NetconfOperation op,
- final String filename) throws ParserConfigurationException,
- SAXException, IOException, DocumentedException {
-
- final Document request = XmlFileLoader.xmlFileToDocument(filename);
-
- LOG.debug("Executing netconf operation\n{}", XmlUtil.toString(request));
- final HandlingPriority priority = op.canHandle(request);
-
- Preconditions.checkState(priority != HandlingPriority.CANNOT_HANDLE);
-
- final Document response = op.handle(request, NetconfOperationChainedExecution.EXECUTION_TERMINATION_POINT);
- LOG.debug("Got response\n{}", XmlUtil.toString(response));
- return response;
- }
-
- private static SchemaContext getSchemaContext() {
- return YangParserTestUtils.parseYangResources(NetconfMappingTest.class,
- "/META-INF/yang/config@2013-04-05.yang", "/META-INF/yang/rpc-context@2013-06-17.yang",
- "/META-INF/yang/config-test@2013-06-13.yang", "/META-INF/yang/config-test-impl@2013-04-03.yang",
- "/META-INF/yang/test-types@2013-11-27.yang", "/META-INF/yang/test-groups@2014-12-08.yang",
- "/META-INF/yang/ietf-inet-types@2013-07-15.yang");
- }
-
- private void setModule(final NetconfTestImplModuleMXBean mxBean, final ConfigTransactionJMXClient transaction,
- final String depName)
- throws InstanceAlreadyExistsException, InstanceNotFoundException {
- mxBean.setSimpleInt((long) 44);
- mxBean.setBinaryLeaf(new byte[]{8, 7, 9});
- final DtoD dtob = getDtoD();
- mxBean.setDtoD(dtob);
- //
- final DtoC dtoa = getDtoC();
- mxBean.setDtoC(dtoa);
- mxBean.setSimpleBoolean(false);
- //
- final Peers p1 = new Peers();
- p1.setCoreSize(44L);
- p1.setPort("port1");
- p1.setSimpleInt3(456);
- final Peers p2 = new Peers();
- p2.setCoreSize(44L);
- p2.setPort("port23");
- p2.setSimpleInt3(456);
- mxBean.setPeers(Lists.<Peers>newArrayList(p1, p2));
- // //
- mxBean.setSimpleLong(454545L);
- mxBean.setSimpleLong2(44L);
- mxBean.setSimpleBigInteger(BigInteger.valueOf(999L));
- mxBean.setSimpleByte(new Byte((byte) 4));
- mxBean.setSimpleShort(new Short((short) 4));
- mxBean.setSimpleTest(545);
-
- mxBean.setComplexList(Lists.<ComplexList>newArrayList());
- mxBean.setSimpleList(Lists.<Integer>newArrayList());
-
- final ObjectName testingDepOn = transaction.createModule(this.factory2.getImplementationName(), depName);
- int index = 1;
- for (final Class<? extends AbstractServiceInterface> serviceInterface :
- factory2.getImplementedServiceIntefaces()) {
- final ServiceInterfaceAnnotation annotation =
- serviceInterface.getAnnotation(ServiceInterfaceAnnotation.class);
- transaction.saveServiceReference(
- transaction.getServiceInterfaceName(annotation.namespace(), annotation.localName()),
- "ref_from_code_to_" + depName + "_" + index++, testingDepOn);
-
- }
- mxBean.setTestingDep(testingDepOn);
- }
-
- private static DtoD getDtoD() {
- final DtoD dtob = new DtoD();
- dtob.setSimpleInt1((long) 444);
- dtob.setSimpleInt2((long) 4444);
- dtob.setSimpleInt3(454);
- final ComplexDtoBInner dtobInner = new ComplexDtoBInner();
- final Deep deep = new Deep();
- deep.setSimpleInt3(4);
- dtobInner.setDeep(deep);
- dtobInner.setSimpleInt3(44);
- dtobInner.setSimpleList(Lists.newArrayList(4));
- dtob.setComplexDtoBInner(Lists.newArrayList(dtobInner));
- dtob.setSimpleList(Lists.newArrayList(4));
- return dtob;
- }
-
- private static DtoC getDtoC() {
- final DtoC dtoa = new DtoC();
- // dtoa.setSimpleArg((long) 55);
- final DtoAInner dtoAInner = new DtoAInner();
- final DtoAInnerInner dtoAInnerInner = new DtoAInnerInner();
- dtoAInnerInner.setSimpleArg(456L);
- dtoAInner.setDtoAInnerInner(dtoAInnerInner);
- dtoAInner.setSimpleArg(44L);
- dtoa.setDtoAInner(dtoAInner);
- return dtoa;
- }
-
-}
+++ /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.confignetconfconnector;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-import org.opendaylight.controller.config.facade.xml.mapping.config.Services;
-import org.opendaylight.controller.config.facade.xml.mapping.config.Services.ServiceInstance;
-
-public class ServiceTrackerTest {
-
- @Test
- public void test() {
- Services.ServiceInstance serviceInstance = new ServiceInstance("module", "serviceInstance");
-
- String string = serviceInstance.toString();
-
- Services.ServiceInstance serviceInstance2 = Services.ServiceInstance.fromString(string);
-
- assertEquals(serviceInstance, serviceInstance2);
- }
-
-}
+++ /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.confignetconfconnector.operations;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-
-import org.junit.Test;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.w3c.dom.Element;
-
-public class ValidateTest {
-
- public static final String NETCONF_SESSION_ID_FOR_REPORTING = "foo";
-
- @Test(expected = DocumentedException.class)
- public void test() throws Exception {
- final XmlElement xml = XmlElement.fromString("<abc></abc>");
- final Validate validate = new Validate(null, NETCONF_SESSION_ID_FOR_REPORTING);
- validate.handleWithNoSubsequentOperations(null, xml);
- }
-
- @Test(expected = DocumentedException.class)
- public void testNoSource() throws Exception {
- final XmlElement xml = XmlElement.fromString("<validate xmlns=\""
- + XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0 + "\"/>");
- final Validate validate = new Validate(null, NETCONF_SESSION_ID_FOR_REPORTING);
- validate.handleWithNoSubsequentOperations(null, xml);
- }
-
- @Test(expected = DocumentedException.class)
- public void testNoNamespace() throws Exception {
- final XmlElement xml = XmlElement.fromString("<validate/>");
- final Validate validate = new Validate(null, NETCONF_SESSION_ID_FOR_REPORTING);
- validate.handleWithNoSubsequentOperations(null, xml);
- }
-
- @Test(expected = DocumentedException.class)
- public void testRunningSource() throws Exception {
-
- final XmlElement xml = XmlElement.fromString("<validate xmlns=\""
- + XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0
- + "\"><source><running></running></source></validate>");
- final Validate validate = new Validate(null, NETCONF_SESSION_ID_FOR_REPORTING);
- validate.handleWithNoSubsequentOperations(null, xml);
- }
-
- @Test(expected = DocumentedException.class)
- public void testNoTransaction() throws Exception {
- final XmlElement xml = XmlElement.fromString("<validate xmlns=\""
- + XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0
- + "\"><source><candidate/></source></validate>");
- final ConfigSubsystemFacade facade = mock(ConfigSubsystemFacade.class);
- doThrow(IllegalStateException.class).when(facade).validateConfiguration();
- final Validate validate = new Validate(facade, NETCONF_SESSION_ID_FOR_REPORTING);
- validate.handleWithNoSubsequentOperations(null, xml);
- }
-
- @Test(expected = DocumentedException.class)
- public void testValidationException() throws Exception {
- final XmlElement xml = XmlElement.fromString("<validate xmlns=\""
- + XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0
- + "\">><source><candidate/></source></validate>");
- final ConfigSubsystemFacade facade = mock(ConfigSubsystemFacade.class);
- doThrow(ValidationException.class).when(facade).validateConfiguration();
- final Validate validate = new Validate(facade, NETCONF_SESSION_ID_FOR_REPORTING);
- validate.handleWithNoSubsequentOperations(null, xml);
- }
-
- @Test
- public void testValidation() throws Exception {
- final XmlElement xml = XmlElement.fromString("<validate xmlns=\""
- + XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0
- + "\"><source><candidate/></source></validate>");
- final Element okElement = XmlUtil.readXmlToElement("<ok/>");
- final ConfigSubsystemFacade facade = mock(ConfigSubsystemFacade.class);
- doNothing().when(facade).validateConfiguration();
- final Validate validate = new Validate(facade, NETCONF_SESSION_ID_FOR_REPORTING);
- Element ok = validate.handleWithNoSubsequentOperations(XmlUtil.newDocument(), xml);
- assertEquals(XmlUtil.toString(okElement), XmlUtil.toString(ok));
- }
-
-}
+++ /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.confignetconfconnector.operations.editconfig;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyMapOf;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doNothing;
-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 com.google.common.base.Optional;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Multimap;
-import java.util.Collections;
-import java.util.Map;
-import javax.management.ObjectName;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.api.ServiceReferenceReadableRegistry;
-import org.opendaylight.controller.config.facade.xml.ConfigExecution;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement;
-import org.opendaylight.controller.config.facade.xml.mapping.config.InstanceConfigElementResolved;
-import org.opendaylight.controller.config.facade.xml.mapping.config.ModuleElementDefinition;
-import org.opendaylight.controller.config.facade.xml.mapping.config.ModuleElementResolved;
-import org.opendaylight.controller.config.facade.xml.mapping.config.ServiceRegistryWrapper;
-import org.opendaylight.controller.config.facade.xml.mapping.config.Services;
-import org.opendaylight.controller.config.facade.xml.osgi.YangStoreService;
-import org.opendaylight.controller.config.facade.xml.strategy.EditConfigStrategy;
-import org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType;
-import org.opendaylight.controller.config.facade.xml.transactions.TransactionProvider;
-import org.opendaylight.controller.config.util.ConfigRegistryClient;
-import org.opendaylight.controller.config.util.ConfigTransactionClient;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.confignetconfconnector.operations.ValidateTest;
-
-public class EditConfigTest {
-
- @Mock
- private YangStoreService yangStoreSnapshot;
- @Mock
- private TransactionProvider provider;
- @Mock
- private ConfigRegistryClient configRegistry;
- @Mock
- private ConfigTransactionClient configTransactionClient;
- @Mock
- private ObjectName mockOn;
-
- private ConfigSubsystemFacade cfgFacade;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
- doReturn("mockON").when(mockOn).toString();
- doReturn(mockOn).when(provider).getTestTransaction();
- doNothing().when(provider).validateTestTransaction(any(ObjectName.class));
-
- doReturn(mockOn).when(provider).getTestTransaction();
- doNothing().when(provider).abortTestTransaction(any(ObjectName.class));
- doReturn(mockOn).when(provider).getOrCreateTransaction();
-
- doNothing().when(provider).wipeTestTransaction(any(ObjectName.class));
-
- doReturn(configTransactionClient).when(configRegistry).getConfigTransactionClient(any(ObjectName.class));
- doReturn("mockConfigTransactionClient").when(configTransactionClient).toString();
-
- doReturn(mockOn).when(configTransactionClient).lookupConfigBean(anyString(), anyString());
-
- cfgFacade = new ConfigSubsystemFacade(configRegistry, configRegistry, yangStoreSnapshot, provider);
- }
-
- @Test
- public void test() throws Exception {
- EditConfig edit = new EditConfig(cfgFacade, ValidateTest.NETCONF_SESSION_ID_FOR_REPORTING);
- EditConfigStrategy editStrat = mock(EditConfigStrategy.class);
-
- doNothing().when(editStrat).executeConfiguration(anyString(), anyString(), anyMapOf(String.class,
- AttributeConfigElement.class),
- any(ConfigTransactionClient.class), any(ServiceRegistryWrapper.class));
-
- ConfigExecution editConfigExecution = mockExecution(editStrat);
-
- edit.getResponseInternal(XmlUtil.newDocument(), editConfigExecution);
-
- verify(provider).getTestTransaction();
- verify(provider).validateTestTransaction(mockOn);
- verify(provider).abortTestTransaction(mockOn);
-
- verify(provider).getOrCreateTransaction();
-
- // For every instance execute strat
- verify(editStrat, times(2/* Test */ + 2/* Set */ + 2/*Handle missing instance Test*/
- + 2 /*Handle missing instance Set*/)).executeConfiguration(anyString(),
- anyString(), anyMapOf(String.class, AttributeConfigElement.class),
- any(ConfigTransactionClient.class), any(ServiceRegistryWrapper.class));
- }
-
- private ConfigExecution mockExecution(EditConfigStrategy editStrat) throws Exception {
- ConfigExecution mock = mock(ConfigExecution.class);
- doReturn(getMapping(editStrat)).when(mock).getResolvedXmlElements(any(ConfigTransactionClient.class));
- doReturn(getMappingDefinition(editStrat)).when(mock).getModulesDefinition(any(ConfigTransactionClient.class));
- doReturn(EditStrategyType.merge).when(mock).getDefaultStrategy();
- doReturn(true).when(mock).shouldSet();
- doReturn(true).when(mock).shouldTest();
- doReturn(mockServices()).when(mock).getServiceRegistryWrapper(any(ConfigTransactionClient.class));
- doReturn(new Services()).when(mock).getServices();
- doReturn(XmlElement.fromDomElement(XmlUtil.readXmlToElement("<abc/>"))).when(mock).getConfigElement();
- return mock;
- }
-
- private Object getMappingDefinition(EditConfigStrategy editStrat) {
- final Map<String, Multimap<String, ModuleElementDefinition>> result = Maps.newHashMap();
-
- Multimap<String, ModuleElementDefinition> innerMultimap = HashMultimap.create();
- Map<String, AttributeConfigElement> attributes = getSimpleAttributes();
-
- ModuleElementDefinition mockedDefinition = mock(ModuleElementDefinition.class);
- doReturn(editStrat).when(mockedDefinition).getEditStrategy();
- doReturn("i1").when(mockedDefinition).getInstanceName();
- innerMultimap.put("m1", mockedDefinition);
-
- ModuleElementDefinition mockedDefinition2 = mock(ModuleElementDefinition.class);
- doReturn(editStrat).when(mockedDefinition2).getEditStrategy();
- doReturn("i2").when(mockedDefinition2).getInstanceName();
- innerMultimap.put("m1", mockedDefinition2);
-
- result.put("n1", innerMultimap);
-
- return result;
- }
-
- private static ServiceReferenceReadableRegistry mockServiceRegistry() {
- ServiceReferenceReadableRegistry mock = mock(ServiceReferenceReadableRegistry.class);
- doReturn(
- Collections.emptyMap())
- .when(mock).getServiceMapping();
- doReturn("mockedServiceReg").when(mock).toString();
-
- return mock;
- }
-
- static ServiceRegistryWrapper mockServices() {
- return new ServiceRegistryWrapper(mockServiceRegistry());
- }
-
- private Map<String, Multimap<String, ModuleElementResolved>> getMapping(EditConfigStrategy editStrat) {
- final Map<String, Multimap<String, ModuleElementResolved>> result = Maps.newHashMap();
-
- Multimap<String, ModuleElementResolved> innerMultimap = HashMultimap.create();
- Map<String, AttributeConfigElement> attributes = getSimpleAttributes();
-
- InstanceConfigElementResolved ice1 = mock(InstanceConfigElementResolved.class);
- doReturn(attributes).when(ice1).getConfiguration();
- doReturn(editStrat).when(ice1).getEditStrategy();
- innerMultimap.put("m1", new ModuleElementResolved("i1", ice1));
-
- InstanceConfigElementResolved ice2 = mock(InstanceConfigElementResolved.class);
- doReturn(attributes).when(ice2).getConfiguration();
- doReturn(editStrat).when(ice2).getEditStrategy();
- innerMultimap.put("m1", new ModuleElementResolved("i2", ice2));
-
- result.put("n1", innerMultimap);
-
- return result;
- }
-
- static Map<String, AttributeConfigElement> getSimpleAttributes() {
- final Map<String, AttributeConfigElement> attributes = Maps.newHashMap();
- AttributeConfigElement ace1 = mock(AttributeConfigElement.class);
- doReturn("abcd").when(ace1).getResolvedDefaultValue();
- doReturn(Optional.<String>of("abc")).when(ace1).getResolvedValue();
- doReturn("mockedAce1").when(ace1).toString();
- doReturn("jmxNameAce1").when(ace1).getJmxName();
- attributes.put("a1", ace1);
- return attributes;
- }
-
-}
+++ /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.confignetconfconnector.operations.editconfig;
-
-import static java.util.Arrays.asList;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.opendaylight.controller.config.api.jmx.ObjectNameUtil.createReadOnlyModuleON;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
-import java.util.List;
-import java.util.Map;
-import javax.management.ObjectName;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement;
-import org.opendaylight.controller.config.facade.xml.mapping.config.ServiceRegistryWrapper;
-import org.opendaylight.controller.config.facade.xml.strategy.MergeEditConfigStrategy;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.yang.test.impl.MultipleDependenciesModule;
-import org.opendaylight.controller.config.yang.test.impl.MultipleDependenciesModuleFactory;
-import org.opendaylight.controller.config.yang.test.impl.MultipleDependenciesModuleMXBean;
-
-public class MergeEditConfigStrategyTest extends AbstractConfigTest {
- private static final MultipleDependenciesModuleFactory FACTORY = new MultipleDependenciesModuleFactory();
- private static final String FACTORY_NAME = FACTORY.getImplementationName();
- public static final String PARENT = "parent";
- public static final String D1 = "d1";
- public static final String D2 = "d2";
- public static final String D3 = "d3";
-
- @Before
- public void setUp() throws Exception {
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, FACTORY));
-
- ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- ObjectName d1 = transaction.createModule(FACTORY_NAME, D1);
- ObjectName d2 = transaction.createModule(FACTORY_NAME, D2);
- ObjectName parent = transaction.createModule(FACTORY_NAME, PARENT);
- MultipleDependenciesModuleMXBean multipleDependenciesModuleMXBean = transaction.newMXBeanProxy(parent,
- MultipleDependenciesModuleMXBean.class);
- multipleDependenciesModuleMXBean.setTestingDeps(asList(d1, d2));
- transaction.createModule(FACTORY_NAME, D3);
- transaction.commit();
- }
-
- @Test
- public void testMergingOfObjectNames() throws Exception {
- final MergeEditConfigStrategy strategy = new MergeEditConfigStrategy();
- final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
-
- // add D3
-
- AttributeConfigElement attributeConfigElement = mock(AttributeConfigElement.class);
- doReturn(Optional.of(new ObjectName[] {createReadOnlyModuleON(FACTORY_NAME, D3)}))
- .when(attributeConfigElement).getResolvedValue();
- doReturn("mocked").when(attributeConfigElement).toString();
- String attributeName = MultipleDependenciesModule.testingDepsJmxAttribute.getAttributeName();
- doReturn(attributeName).when(attributeConfigElement).getJmxName();
- Map<String, AttributeConfigElement> configuration = ImmutableMap.of(
- attributeName,
- attributeConfigElement);
-
- strategy.executeConfiguration(FACTORY_NAME, PARENT, configuration, transaction,
- mock(ServiceRegistryWrapper.class));
- transaction.commit();
-
- // parent's attribute should contain d1,d2,d3
- MultipleDependenciesModuleMXBean proxy = configRegistryClient.newMXBeanProxy(
- createReadOnlyModuleON(FACTORY_NAME, PARENT),
- MultipleDependenciesModuleMXBean.class);
- List<ObjectName> testingDeps = proxy.getTestingDeps();
- List<ObjectName> expected = asList(createReadOnlyModuleON(FACTORY_NAME, D1),
- createReadOnlyModuleON(FACTORY_NAME, D2),
- createReadOnlyModuleON(FACTORY_NAME, D3));
- assertEquals(expected, testingDeps);
- }
-}
+++ /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.confignetconfconnector.operations.editconfig;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-import com.google.common.collect.Sets;
-import java.util.Map;
-import javax.management.Attribute;
-import javax.management.ObjectName;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement;
-import org.opendaylight.controller.config.facade.xml.strategy.ReplaceEditConfigStrategy;
-import org.opendaylight.controller.config.util.ConfigTransactionClient;
-
-public class ReplaceEditConfigStrategyTest {
-
- @Mock
- private ConfigTransactionClient ta;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- doNothing().when(ta).destroyModule(anyString(), anyString());
- doReturn(mockON()).when(ta).lookupConfigBean(anyString(), anyString());
- doNothing().when(ta).setAttribute(any(ObjectName.class), anyString(), any(Attribute.class));
- }
-
- @Test
- public void test() throws Exception {
- ReplaceEditConfigStrategy strat = new ReplaceEditConfigStrategy();
-
- Map<String, AttributeConfigElement> map = EditConfigTest.getSimpleAttributes();
-
- doReturn(Sets.newHashSet(mockON(), mockON())).when(ta).lookupConfigBeans();
-
- strat.executeConfiguration("m1", "i1", map, ta, EditConfigTest.mockServices());
-
- verify(ta).lookupConfigBean(anyString(), anyString());
- verify(ta).setAttribute(any(ObjectName.class), anyString(), any(Attribute.class));
- }
-
- ObjectName mockON() {
- ObjectName mock = mock(ObjectName.class);
- doReturn("mockON").when(mock).toString();
- return mock;
- }
-
-}
+++ /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.confignetconfconnector.osgi;
-
-import static junit.framework.TestCase.assertTrue;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.Set;
-import org.junit.Test;
-import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
-import org.opendaylight.netconf.confignetconfconnector.operations.Commit;
-import org.opendaylight.netconf.confignetconfconnector.operations.DiscardChanges;
-import org.opendaylight.netconf.confignetconfconnector.operations.Lock;
-import org.opendaylight.netconf.confignetconfconnector.operations.UnLock;
-import org.opendaylight.netconf.confignetconfconnector.operations.Validate;
-import org.opendaylight.netconf.confignetconfconnector.operations.editconfig.EditConfig;
-import org.opendaylight.netconf.confignetconfconnector.operations.get.Get;
-import org.opendaylight.netconf.confignetconfconnector.operations.getconfig.GetConfig;
-import org.opendaylight.netconf.confignetconfconnector.operations.runtimerpc.RuntimeRpc;
-import org.opendaylight.netconf.mapping.api.NetconfOperation;
-import org.opendaylight.netconf.mapping.api.NetconfOperationService;
-
-public class NetconfOperationServiceImplTest {
-
- @Test
- public void testOperationService() {
- final ConfigSubsystemFacade configSubsystemFacade = mock(ConfigSubsystemFacade.class);
- final NetconfOperationService netconfOperationService =
- new NetconfOperationServiceImpl(configSubsystemFacade, "reportingID");
-
- // testing operations in Set from NetconfOperationProvider
-
- Set<NetconfOperation> operations = netconfOperationService.getNetconfOperations();
-
- assertTrue(containInstance(operations, GetConfig.class));
- assertTrue(containInstance(operations, EditConfig.class));
- assertTrue(containInstance(operations, Commit.class));
- assertTrue(containInstance(operations, Lock.class));
- assertTrue(containInstance(operations, UnLock.class));
- assertTrue(containInstance(operations, Get.class));
- assertTrue(containInstance(operations, DiscardChanges.class));
- assertTrue(containInstance(operations, Validate.class));
- assertTrue(containInstance(operations, RuntimeRpc.class));
-
- // verify closing service
-
- doNothing().when(configSubsystemFacade).close();
- netconfOperationService.close();
-
- verify(configSubsystemFacade, times(1)).close();
- }
-
- private boolean containInstance(final Set<NetconfOperation> operations, final Class<?> cls) {
- return operations.stream().filter(cls::isInstance).findFirst().isPresent();
- }
-}
<artifactId>aaa-authn-odl-plugin</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>config-netconf-connector</artifactId>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netconf-api</artifactId>
<type>xml</type>
<classifier>features</classifier>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-config-netconf-connector</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>odl-netconf-all</artifactId>
<module>netconf-api</module>
<module>netconf-config</module>
<module>netconf-impl</module>
- <module>config-netconf-connector</module>
<module>mdsal-netconf-ssh</module>
<module>mdsal-netconf-tcp</module>
<module>mdsal-netconf-connector</module>
<groupId>${project.groupId}</groupId>
<artifactId>netconf-auth</artifactId>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>config-netconf-connector</artifactId>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>sal-netconf-connector</artifactId>
import org.opendaylight.controller.config.util.xml.XmlElement;
import org.opendaylight.controller.config.util.xml.XmlUtil;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
+import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-public class SimulatedCommit extends AbstractConfigNetconfOperation {
+public class SimulatedCommit extends AbstractLastNetconfOperation {
public SimulatedCommit(final String netconfSessionIdForReporting) {
- super(null, netconfSessionIdForReporting);
+ super(netconfSessionIdForReporting);
}
@Override
import org.opendaylight.controller.config.util.xml.XmlElement;
import org.opendaylight.controller.config.util.xml.XmlUtil;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
+import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-public class SimulatedDiscardChanges extends AbstractConfigNetconfOperation {
+public class SimulatedDiscardChanges extends AbstractLastNetconfOperation {
public SimulatedDiscardChanges(final String netconfSessionIdForReporting) {
- super(null, netconfSessionIdForReporting);
+ super(netconfSessionIdForReporting);
}
@Override
import org.opendaylight.controller.config.util.xml.XmlElement;
import org.opendaylight.controller.config.util.xml.XmlUtil;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
-import org.opendaylight.netconf.confignetconfconnector.operations.editconfig.EditConfigXmlParser;
+import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-public class SimulatedEditConfig extends AbstractConfigNetconfOperation {
+public class SimulatedEditConfig extends AbstractLastNetconfOperation {
private static final String DELETE_EDIT_CONFIG = "delete";
private static final String OPERATION = "operation";
private static final String REMOVE_EDIT_CONFIG = "remove";
private final DataList storage;
public SimulatedEditConfig(final String netconfSessionIdForReporting, final DataList storage) {
- super(null, netconfSessionIdForReporting);
+ super(netconfSessionIdForReporting);
this.storage = storage;
}
@Override
protected String getOperationName() {
- return EditConfigXmlParser.EDIT_CONFIG;
+ return "edit-config";
}
private boolean containsDelete(final XmlElement element) {
import org.opendaylight.controller.config.util.xml.XmlElement;
import org.opendaylight.controller.config.util.xml.XmlUtil;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
+import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-public class SimulatedGet extends AbstractConfigNetconfOperation {
+public class SimulatedGet extends AbstractLastNetconfOperation {
private final DataList storage;
public SimulatedGet(final String netconfSessionIdForReporting, final DataList storage) {
- super(null, netconfSessionIdForReporting);
+ super(netconfSessionIdForReporting);
this.storage = storage;
}
import org.opendaylight.controller.config.util.xml.XmlElement;
import org.opendaylight.controller.config.util.xml.XmlUtil;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
+import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
-public class SimulatedGetConfig extends AbstractConfigNetconfOperation {
+public class SimulatedGetConfig extends AbstractLastNetconfOperation {
private final DataList storage;
private static final Logger LOG = LoggerFactory
public SimulatedGetConfig(final String netconfSessionIdForReporting, final DataList storage,
final Optional<File> initialConfigXMLFile) {
- super(null, netconfSessionIdForReporting);
+ super(netconfSessionIdForReporting);
if (initialConfigXMLFile.isPresent()) {
LOG.info("File is present: {}", initialConfigXMLFile.get()
import org.opendaylight.controller.config.util.xml.XmlElement;
import org.opendaylight.controller.config.util.xml.XmlUtil;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
+import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-public class SimulatedLock extends AbstractConfigNetconfOperation {
+public class SimulatedLock extends AbstractLastNetconfOperation {
public SimulatedLock(final String netconfSessionIdForReporting) {
- super(null, netconfSessionIdForReporting);
+ super(netconfSessionIdForReporting);
}
@Override
import org.opendaylight.controller.config.util.xml.XmlElement;
import org.opendaylight.controller.config.util.xml.XmlUtil;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
+import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-public class SimulatedUnLock extends AbstractConfigNetconfOperation {
+public class SimulatedUnLock extends AbstractLastNetconfOperation {
public SimulatedUnLock(final String netconfSessionIdForReporting) {
- super(null, netconfSessionIdForReporting);
+ super(netconfSessionIdForReporting);
}
@Override