<artifactId>config-persister-api</artifactId>
<version>${config.version}</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-file-adapter</artifactId>
- <version>${config.version}</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-persister-file-xml-adapter</artifactId>
<version>${config.version}</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-directory-adapter</artifactId>
- <version>${config.version}</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-persister-directory-xml-adapter</artifactId>
<version>${config.version}</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-directory-autodetect-adapter</artifactId>
- <version>${config.version}</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<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>
- <artifactId>config-subsystem</artifactId>
- <groupId>org.opendaylight.controller</groupId>
- <version>0.2.5-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>config-persister-directory-adapter</artifactId>
- <name>${project.artifactId}</name>
- <packaging>bundle</packaging>
-
- <dependencies>
- <!-- compile dependencies -->
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>config-persister-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
-
- <!-- test dependencies -->
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>mockito-configuration</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>config-persister-api</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <!-- workaround for creating version according to OSGi specification (major.minor.micro[.qualifier] -->
- <plugin>
- <groupId>org.codehaus.groovy.maven</groupId>
- <artifactId>gmaven-plugin</artifactId>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <goals>
- <goal>execute</goal>
- </goals>
- <configuration>
- <source>
- System.setProperty("osgiversion", "${project.version}".replace('-', '.'))
- </source>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Fragment-Host>${project.groupId}.config-persister-impl;bundle-version=${osgiversion}
- </Fragment-Host>
- <Provide-Capability>org.opendaylight.controller.config.persister.storage.adapter
- </Provide-Capability>
- <Import-Package>
- com.google.common.base,
- com.google.common.io,
- org.apache.commons.io,
- org.opendaylight.controller.config.persist.api,
- org.slf4j
- </Import-Package>
- </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.controller.config.persist.storage.directory;
-
-import com.google.common.base.Charsets;
-import com.google.common.io.Files;
-import org.apache.commons.io.IOUtils;
-import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
-import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolderImpl;
-import org.opendaylight.controller.config.persist.api.Persister;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkState;
-
-public class DirectoryPersister implements Persister {
- private static final Logger logger = LoggerFactory.getLogger(DirectoryPersister.class);
- private static final Charset ENCODING = Charsets.UTF_8;
-
- public static final String MODULES_START = "//MODULES START";
- static final String SERVICES_START = "//SERVICES START";
- static final String CAPABILITIES_START = "//CAPABILITIES START";
-
-
- private final File storage;
- private static final String header, middle, footer;
-
- static {
- header = readResource("header.txt");
- middle = readResource("middle.txt");
- footer = readResource("footer.txt");
- }
-
- public DirectoryPersister(File storage) {
- checkArgument(storage.exists() && storage.isDirectory(), "Storage directory does not exist: " + storage);
- this.storage = storage;
- }
-
- private static String readResource(String resource) {
- try {
- return IOUtils.toString(DirectoryPersister.class.getResourceAsStream("/" + resource));
- } catch (IOException e) {
- throw new IllegalStateException("Cannot load " + resource, e);
- }
- }
-
- @Override
- public void persistConfig(ConfigSnapshotHolder holder) throws IOException {
- throw new UnsupportedOperationException("This adapter is read only. Please set readonly=true on " + getClass());
- }
-
- @Override
- public List<ConfigSnapshotHolder> loadLastConfigs() throws IOException {
- File[] filesArray = storage.listFiles();
- if (filesArray == null || filesArray.length == 0) {
- return Collections.emptyList();
- }
- List<File> sortedFiles = new ArrayList<>(Arrays.asList(filesArray));
- Collections.sort(sortedFiles);
- // combine all found files
- logger.debug("Reading files in following order: {}", sortedFiles);
-
- List<ConfigSnapshotHolder> result = new ArrayList<>();
- for (File file : sortedFiles) {
- logger.trace("Adding file '{}' to combined result", file);
-
- ConfigSnapshotHolder configSnapshotHolder = loadLastConfig(file);
- result.add(configSnapshotHolder);
- }
- return result;
- }
-
- public static ConfigSnapshotHolder loadLastConfig(File file) throws IOException {
- final MyLineProcessor lineProcessor = new MyLineProcessor(file.getAbsolutePath());
- Files.readLines(file, ENCODING, lineProcessor);
- return lineProcessor.getConfigSnapshotHolder(header, middle, footer);
- }
-
-
- @Override
- public void close() {
-
- }
-
- @Override
- public String toString() {
- return "FileStorageAdapter [storage=" + storage + "]";
- }
-}
-
-class MyLineProcessor implements com.google.common.io.LineProcessor<String> {
- private final String fileNameForReporting;
-
- private boolean inModules, inServices, inCapabilities;
- private final StringBuffer modulesBuffer = new StringBuffer(), servicesBuilder = new StringBuffer();
- private final SortedSet<String> caps = new TreeSet<>();
-
- MyLineProcessor(String fileNameForReporting) {
- this.fileNameForReporting = fileNameForReporting;
- }
-
- @Override
- public String getResult() {
- return null;
- }
-
- @Override
- public boolean processLine(String line) throws IOException {
-
- String lineWithNewLine = line + System.lineSeparator();
- if (line.equals(DirectoryPersister.MODULES_START)) {
- checkState(inModules == false && inServices == false && inCapabilities == false);
- inModules = true;
- } else if (line.equals(DirectoryPersister.SERVICES_START)) {
- checkState(inModules == true && inServices == false && inCapabilities == false);
- inModules = false;
- inServices = true;
- } else if (line.equals(DirectoryPersister.CAPABILITIES_START)) {
- checkState(inModules == false && inServices == true && inCapabilities == false);
- inServices = false;
- inCapabilities = true;
- } else if (inModules) {
- modulesBuffer.append(lineWithNewLine);
- } else if (inServices) {
- servicesBuilder.append(lineWithNewLine);
- } else {
- caps.add(line);
- }
- return true;
- }
-
- private void checkFileConsistency(){
- checkState(inCapabilities, "File %s is missing delimiters in this order: %s", fileNameForReporting,
- Arrays.asList(DirectoryPersister.MODULES_START,
- DirectoryPersister.SERVICES_START,
- DirectoryPersister.CAPABILITIES_START));
- }
-
- String getModules() {
- checkFileConsistency();
- return modulesBuffer.toString();
- }
-
- String getServices() {
- checkFileConsistency();
- return servicesBuilder.toString();
- }
-
- SortedSet<String> getCapabilities() {
- checkFileConsistency();
- return caps;
- }
-
- ConfigSnapshotHolder getConfigSnapshotHolder(String header, String middle, String footer) {
- String combinedSnapshot = header + getModules() + middle + getServices() + footer;
- ConfigSnapshotHolder result = new ConfigSnapshotHolderImpl(combinedSnapshot, getCapabilities(), fileNameForReporting);
- return result;
- }
-
-}
-
+++ /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.controller.config.persist.storage.directory;
-
-import com.google.common.base.Preconditions;
-import org.opendaylight.controller.config.persist.api.Persister;
-import org.opendaylight.controller.config.persist.api.PropertiesProvider;
-import org.opendaylight.controller.config.persist.api.StorageAdapter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-
-/**
- * StorageAdapter that retrieves initial configuration from a directory. If multiple files are present, snapshot and
- * required capabilities will be merged together. Writing to this persister is not supported.
- */
-public class DirectoryStorageAdapter implements StorageAdapter {
- private static final Logger logger = LoggerFactory.getLogger(DirectoryStorageAdapter.class);
-
- public static final String DIRECTORY_STORAGE_PROP = "directoryStorage";
-
-
- @Override
- public Persister instantiate(PropertiesProvider propertiesProvider) {
- String fileStorageProperty = propertiesProvider.getProperty(DIRECTORY_STORAGE_PROP);
- Preconditions.checkNotNull(fileStorageProperty, "Unable to find " + propertiesProvider.getFullKeyForReporting(DIRECTORY_STORAGE_PROP));
- File storage = new File(fileStorageProperty);
- logger.debug("Using {}", storage);
- return new DirectoryPersister(storage);
- }
-
-}
+++ /dev/null
- </services>
-</data>
+++ /dev/null
-<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+++ /dev/null
- </modules>
- <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+++ /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.controller.config.persist.storage.directory;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import org.apache.commons.io.IOUtils;
-import org.junit.Test;
-import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
-import org.opendaylight.controller.config.persist.api.Persister;
-import org.opendaylight.controller.config.persist.test.PropertiesProviderTest;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-public class DirectoryStorageAdapterTest {
- Persister tested;
-
- private Persister instantiatePersisterFromAdapter(File file){
- PropertiesProviderTest pp = new PropertiesProviderTest();
- pp.addProperty("directoryStorage",file.getPath());
- DirectoryStorageAdapter dsa = new DirectoryStorageAdapter();
- return dsa.instantiate(pp);
- }
- @Test
- public void testEmptyDirectory() throws Exception {
- File folder = new File("target/emptyFolder");
- folder.mkdir();
-
- tested = instantiatePersisterFromAdapter(folder);
- assertEquals(Collections.<ConfigSnapshotHolder>emptyList(), tested.loadLastConfigs());
-
- try {
- tested.persistConfig(new ConfigSnapshotHolder() {
- @Override
- public String getConfigSnapshot() {
- throw new RuntimeException();
- }
-
- @Override
- public SortedSet<String> getCapabilities() {
- throw new RuntimeException();
- }
- });
- fail();
- } catch (UnsupportedOperationException e) {
-
- }
- }
-
- private File getFolder(String folderName) {
- File result = new File(("src/test/resources/" +
- folderName).replace("/", File.separator));
- assertTrue(result + " is not a directory", result.isDirectory());
- return result;
- }
-
- @Test
- public void testOneFile() throws Exception {
- File folder = getFolder("oneFile");
-
- tested = instantiatePersisterFromAdapter(folder);
-
- List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
- assertEquals(1, results.size());
- ConfigSnapshotHolder result = results.get(0);
- assertSnapshot(result, "oneFileExpected");
- }
-
-
- @Test
- public void testTwoFiles() throws Exception {
- File folder = getFolder("twoFiles");
- tested = instantiatePersisterFromAdapter(folder);
-
- List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
- assertEquals(2, results.size());
- assertSnapshot(results.get(0), "twoFilesExpected1");
- assertSnapshot(results.get(1), "twoFilesExpected2");
- }
-
- private void assertSnapshot(ConfigSnapshotHolder result, String directory) throws Exception {
- SortedSet<String> expectedCapabilities = new TreeSet<>(IOUtils.readLines(getClass().getResourceAsStream("/" + directory + "/expectedCapabilities.txt")));
- String expectedSnapshot = IOUtils.toString(getClass().getResourceAsStream("/" + directory + "/expectedSnapshot.xml"));
- expectedSnapshot = expectedSnapshot.replaceAll("\r","");
- String _snapshot = result.getConfigSnapshot();
- _snapshot = _snapshot.replaceAll("\r","");
- assertEquals(expectedCapabilities, result.getCapabilities());
- assertEquals(expectedSnapshot, _snapshot);
- }
-
-}
+++ /dev/null
-//MODULES START
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:schema-service-singleton</type>
- <name>yang-schema-service</name>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:hash-map-data-store</type>
- <name>hash-map-data-store</name>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-broker-impl</type>
- <name>dom-broker</name>
- <data-store xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
- <name>ref_hash-map-data-store</name>
- </data-store>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-broker-impl</type>
- <name>binding-broker-impl</name>
- <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
- <name>ref_binding-notification-broker</name>
- </notification-service>
- <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
- <name>ref_binding-data-broker</name>
- </data-broker>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:runtime-generated-mapping</type>
- <name>runtime-mapping-singleton</name>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-notification-broker</type>
- <name>binding-notification-broker</name>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-data-broker</type>
- <name>binding-data-broker</name>
- <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
- <name>ref_dom-broker</name>
- </dom-broker>
- <mapping-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
- <name>ref_runtime-mapping-singleton</name>
- </mapping-service>
- </module>
-//SERVICES START
- <service>
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
- <instance>
- <name>ref_yang-schema-service</name>
- <provider>/config/modules/module[name='schema-service-singleton']/instance[name='yang-schema-service']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
- <instance>
- <name>ref_binding-notification-broker</name>
- <provider>/config/modules/module[name='binding-notification-broker']/instance[name='binding-notification-broker']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
- <instance>
- <name>ref_hash-map-data-store</name>
- <provider>/config/modules/module[name='hash-map-data-store']/instance[name='hash-map-data-store']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
- <instance>
- <name>ref_binding-broker-impl</name>
- <provider>/config/modules/module[name='binding-broker-impl']/instance[name='binding-broker-impl']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding-impl:binding-dom-mapping-service</type>
- <instance>
- <name>ref_runtime-mapping-singleton</name>
- <provider>/config/modules/module[name='runtime-generated-mapping']/instance[name='runtime-mapping-singleton']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
- <instance>
- <name>ref_dom-broker</name>
- <provider>/config/modules/module[name='dom-broker-impl']/instance[name='dom-broker']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
- <instance>
- <name>ref_binding-data-broker</name>
- <provider>/config/modules/module[name='binding-data-broker']/instance[name='binding-data-broker']</provider>
- </instance>
- </service>
-//CAPABILITIES START
-urn:opendaylight:l2:types?module=opendaylight-l2-types&revision=2013-08-27
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:threadpool?module=threadpool&revision=2013-04-09
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:config?module=config&revision=2013-04-05
-urn:ietf:params:netconf:capability:candidate:1.0
-urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring?module=ietf-netconf-monitoring&revision=2010-10-04
-urn:opendaylight:params:xml:ns:yang:controller:netty:eventexecutor?module=netty-event-executor&revision=2013-11-12
-urn:ietf:params:xml:ns:yang:rpc-context?module=rpc-context&revision=2013-06-17
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28
-urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2010-09-24
-urn:ietf:params:netconf:capability:rollback-on-error:1.0
-urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&revision=2010-09-24
-urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl?module=threadpool-impl&revision=2013-04-05
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:logback:config?module=config-logging&revision=2013-07-16
-urn:opendaylight:yang:extension:yang-ext?module=yang-ext&revision=2013-07-09
-urn:opendaylight:params:xml:ns:yang:iana?module=iana&revision=2013-08-16
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:ieee754?module=ieee754&revision=2013-08-19
+++ /dev/null
-urn:opendaylight:l2:types?module=opendaylight-l2-types&revision=2013-08-27
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:threadpool?module=threadpool&revision=2013-04-09
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:config?module=config&revision=2013-04-05
-urn:ietf:params:netconf:capability:candidate:1.0
-urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring?module=ietf-netconf-monitoring&revision=2010-10-04
-urn:opendaylight:params:xml:ns:yang:controller:netty:eventexecutor?module=netty-event-executor&revision=2013-11-12
-urn:ietf:params:xml:ns:yang:rpc-context?module=rpc-context&revision=2013-06-17
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28
-urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2010-09-24
-urn:ietf:params:netconf:capability:rollback-on-error:1.0
-urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&revision=2010-09-24
-urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl?module=threadpool-impl&revision=2013-04-05
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:logback:config?module=config-logging&revision=2013-07-16
-urn:opendaylight:yang:extension:yang-ext?module=yang-ext&revision=2013-07-09
-urn:opendaylight:params:xml:ns:yang:iana?module=iana&revision=2013-08-16
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:ieee754?module=ieee754&revision=2013-08-19
+++ /dev/null
-<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:schema-service-singleton</type>
- <name>yang-schema-service</name>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:hash-map-data-store</type>
- <name>hash-map-data-store</name>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-broker-impl</type>
- <name>dom-broker</name>
- <data-store xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
- <name>ref_hash-map-data-store</name>
- </data-store>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-broker-impl</type>
- <name>binding-broker-impl</name>
- <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
- <name>ref_binding-notification-broker</name>
- </notification-service>
- <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
- <name>ref_binding-data-broker</name>
- </data-broker>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:runtime-generated-mapping</type>
- <name>runtime-mapping-singleton</name>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-notification-broker</type>
- <name>binding-notification-broker</name>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-data-broker</type>
- <name>binding-data-broker</name>
- <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
- <name>ref_dom-broker</name>
- </dom-broker>
- <mapping-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
- <name>ref_runtime-mapping-singleton</name>
- </mapping-service>
- </module>
- </modules>
- <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
- <service>
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
- <instance>
- <name>ref_yang-schema-service</name>
- <provider>/config/modules/module[name='schema-service-singleton']/instance[name='yang-schema-service']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
- <instance>
- <name>ref_binding-notification-broker</name>
- <provider>/config/modules/module[name='binding-notification-broker']/instance[name='binding-notification-broker']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
- <instance>
- <name>ref_hash-map-data-store</name>
- <provider>/config/modules/module[name='hash-map-data-store']/instance[name='hash-map-data-store']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
- <instance>
- <name>ref_binding-broker-impl</name>
- <provider>/config/modules/module[name='binding-broker-impl']/instance[name='binding-broker-impl']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding-impl:binding-dom-mapping-service</type>
- <instance>
- <name>ref_runtime-mapping-singleton</name>
- <provider>/config/modules/module[name='runtime-generated-mapping']/instance[name='runtime-mapping-singleton']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
- <instance>
- <name>ref_dom-broker</name>
- <provider>/config/modules/module[name='dom-broker-impl']/instance[name='dom-broker']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
- <instance>
- <name>ref_binding-data-broker</name>
- <provider>/config/modules/module[name='binding-data-broker']/instance[name='binding-data-broker']</provider>
- </instance>
- </service>
- </services>
-</data>
+++ /dev/null
-//MODULES START
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:schema-service-singleton</type>
- <name>yang-schema-service</name>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:hash-map-data-store</type>
- <name>hash-map-data-store</name>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-broker-impl</type>
- <name>dom-broker</name>
- <data-store xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
- <name>ref_hash-map-data-store</name>
- </data-store>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-broker-impl</type>
- <name>binding-broker-impl</name>
- <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
- <name>ref_binding-notification-broker</name>
- </notification-service>
- <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
- <name>ref_binding-data-broker</name>
- </data-broker>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:runtime-generated-mapping</type>
- <name>runtime-mapping-singleton</name>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-notification-broker</type>
- <name>binding-notification-broker</name>
- </module>
-//SERVICES START
- <service>
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
- <instance>
- <name>ref_yang-schema-service</name>
- <provider>/config/modules/module[name='schema-service-singleton']/instance[name='yang-schema-service']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
- <instance>
- <name>ref_binding-notification-broker</name>
- <provider>/config/modules/module[name='binding-notification-broker']/instance[name='binding-notification-broker']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
- <instance>
- <name>ref_hash-map-data-store</name>
- <provider>/config/modules/module[name='hash-map-data-store']/instance[name='hash-map-data-store']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
- <instance>
- <name>ref_binding-broker-impl</name>
- <provider>/config/modules/module[name='binding-broker-impl']/instance[name='binding-broker-impl']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding-impl:binding-dom-mapping-service</type>
- <instance>
- <name>ref_runtime-mapping-singleton</name>
- <provider>/config/modules/module[name='runtime-generated-mapping']/instance[name='runtime-mapping-singleton']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
- <instance>
- <name>ref_dom-broker</name>
- <provider>/config/modules/module[name='dom-broker-impl']/instance[name='dom-broker']</provider>
- </instance>
- </service>
-//CAPABILITIES START
-urn:opendaylight:l2:types?module=opendaylight-l2-types&revision=2013-08-27
+++ /dev/null
-//MODULES START
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-data-broker</type>
- <name>binding-data-broker</name>
- <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
- <name>ref_dom-broker</name>
- </dom-broker>
- <mapping-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
- <name>ref_runtime-mapping-singleton</name>
- </mapping-service>
- </module>
-//SERVICES START
- <service>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
- <instance>
- <name>ref_binding-data-broker</name>
- <provider>/config/modules/module[name='binding-data-broker']/instance[name='binding-data-broker']</provider>
- </instance>
- </service>
-//CAPABILITIES START
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:threadpool?module=threadpool&revision=2013-04-09
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:config?module=config&revision=2013-04-05
-urn:ietf:params:netconf:capability:candidate:1.0
-urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring?module=ietf-netconf-monitoring&revision=2010-10-04
-urn:opendaylight:params:xml:ns:yang:controller:netty:eventexecutor?module=netty-event-executor&revision=2013-11-12
-urn:ietf:params:xml:ns:yang:rpc-context?module=rpc-context&revision=2013-06-17
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28
-urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2010-09-24
-urn:ietf:params:netconf:capability:rollback-on-error:1.0
-urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&revision=2010-09-24
-urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl?module=threadpool-impl&revision=2013-04-05
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:logback:config?module=config-logging&revision=2013-07-16
-urn:opendaylight:yang:extension:yang-ext?module=yang-ext&revision=2013-07-09
-urn:opendaylight:params:xml:ns:yang:iana?module=iana&revision=2013-08-16
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:ieee754?module=ieee754&revision=2013-08-19
+++ /dev/null
-urn:opendaylight:l2:types?module=opendaylight-l2-types&revision=2013-08-27
+++ /dev/null
-<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:schema-service-singleton</type>
- <name>yang-schema-service</name>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:hash-map-data-store</type>
- <name>hash-map-data-store</name>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-broker-impl</type>
- <name>dom-broker</name>
- <data-store xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
- <name>ref_hash-map-data-store</name>
- </data-store>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-broker-impl</type>
- <name>binding-broker-impl</name>
- <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
- <name>ref_binding-notification-broker</name>
- </notification-service>
- <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
- <name>ref_binding-data-broker</name>
- </data-broker>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:runtime-generated-mapping</type>
- <name>runtime-mapping-singleton</name>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-notification-broker</type>
- <name>binding-notification-broker</name>
- </module>
- </modules>
- <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
- <service>
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
- <instance>
- <name>ref_yang-schema-service</name>
- <provider>/config/modules/module[name='schema-service-singleton']/instance[name='yang-schema-service']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
- <instance>
- <name>ref_binding-notification-broker</name>
- <provider>/config/modules/module[name='binding-notification-broker']/instance[name='binding-notification-broker']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
- <instance>
- <name>ref_hash-map-data-store</name>
- <provider>/config/modules/module[name='hash-map-data-store']/instance[name='hash-map-data-store']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
- <instance>
- <name>ref_binding-broker-impl</name>
- <provider>/config/modules/module[name='binding-broker-impl']/instance[name='binding-broker-impl']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding-impl:binding-dom-mapping-service</type>
- <instance>
- <name>ref_runtime-mapping-singleton</name>
- <provider>/config/modules/module[name='runtime-generated-mapping']/instance[name='runtime-mapping-singleton']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
- <instance>
- <name>ref_dom-broker</name>
- <provider>/config/modules/module[name='dom-broker-impl']/instance[name='dom-broker']</provider>
- </instance>
- </service>
- </services>
-</data>
+++ /dev/null
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:threadpool?module=threadpool&revision=2013-04-09
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:config?module=config&revision=2013-04-05
-urn:ietf:params:netconf:capability:candidate:1.0
-urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring?module=ietf-netconf-monitoring&revision=2010-10-04
-urn:opendaylight:params:xml:ns:yang:controller:netty:eventexecutor?module=netty-event-executor&revision=2013-11-12
-urn:ietf:params:xml:ns:yang:rpc-context?module=rpc-context&revision=2013-06-17
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28
-urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2010-09-24
-urn:ietf:params:netconf:capability:rollback-on-error:1.0
-urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&revision=2010-09-24
-urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl?module=threadpool-impl&revision=2013-04-05
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:logback:config?module=config-logging&revision=2013-07-16
-urn:opendaylight:yang:extension:yang-ext?module=yang-ext&revision=2013-07-09
-urn:opendaylight:params:xml:ns:yang:iana?module=iana&revision=2013-08-16
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:ieee754?module=ieee754&revision=2013-08-19
+++ /dev/null
-<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-data-broker</type>
- <name>binding-data-broker</name>
- <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
- <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
- <name>ref_dom-broker</name>
- </dom-broker>
- <mapping-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
- <name>ref_runtime-mapping-singleton</name>
- </mapping-service>
- </module>
- </modules>
- <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
- <service>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
- <instance>
- <name>ref_binding-data-broker</name>
- <provider>/config/modules/module[name='binding-data-broker']/instance[name='binding-data-broker']</provider>
- </instance>
- </service>
- </services>
-</data>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<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>
- <artifactId>config-subsystem</artifactId>
- <groupId>org.opendaylight.controller</groupId>
- <version>0.2.5-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>config-persister-directory-autodetect-adapter</artifactId>
- <name>${project.artifactId}</name>
- <packaging>bundle</packaging>
-
- <dependencies>
- <!-- compile dependencies -->
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>config-persister-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-directory-adapter</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-directory-xml-adapter</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
-
- <!-- test dependencies -->
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>mockito-configuration</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>config-persister-api</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <!-- workaround for creating version according to OSGi specification (major.minor.micro[.qualifier] -->
- <plugin>
- <groupId>org.codehaus.groovy.maven</groupId>
- <artifactId>gmaven-plugin</artifactId>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <goals>
- <goal>execute</goal>
- </goals>
- <configuration>
- <source>
- System.setProperty("osgiversion", "${project.version}".replace('-', '.'))
- </source>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Fragment-Host>${project.groupId}.config-persister-impl;bundle-version=${osgiversion}
- </Fragment-Host>
- <Provide-Capability>org.opendaylight.controller.config.persister.storage.adapter
- </Provide-Capability>
- <Import-Package>
- com.google.common.base,
- com.google.common.io,
- org.apache.commons.io,
- org.opendaylight.controller.config.persist.api,
- org.slf4j,
- com.google.common.collect,
- javax.xml.bind,
- javax.xml.bind.annotation,
- javax.xml.transform,
- javax.xml.transform.stream,
- org.eclipse.persistence.jaxb,
- org.apache.commons.lang3
- </Import-Package>
- <Private-Package>
- org.opendaylight.controller.config.persist.storage.file.xml.model,
- org.opendaylight.controller.config.persist.storage.directory,
- org.opendaylight.controller.config.persist.storage.directory.xml,
- </Private-Package>
- </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.controller.config.persist.storage.directory.autodetect;
-
-import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
-import org.opendaylight.controller.config.persist.api.Persister;
-import org.opendaylight.controller.config.persist.storage.directory.DirectoryPersister;
-import org.opendaylight.controller.config.persist.storage.directory.xml.XmlDirectoryPersister;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.xml.bind.JAXBException;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-public class AutodetectDirectoryPersister implements Persister {
- private static final Logger logger = LoggerFactory.getLogger(AutodetectDirectoryPersister.class);
-
- private final File storage;
-
- public AutodetectDirectoryPersister(File storage) {
- checkArgument(storage.exists() && storage.isDirectory(), "Storage directory does not exist: " + storage);
- this.storage = storage;
- }
-
- @Override
- public void persistConfig(ConfigSnapshotHolder holder) throws IOException {
- throw new UnsupportedOperationException("This adapter is read only. Please set readonly=true on " + getClass());
- }
-
- @Override
- public List<ConfigSnapshotHolder> loadLastConfigs() throws IOException {
- File[] filesArray = storage.listFiles();
- if (filesArray == null || filesArray.length == 0) {
- return Collections.emptyList();
- }
- List<File> sortedFiles = new ArrayList<>(Arrays.asList(filesArray));
- Collections.sort(sortedFiles);
-
- // combine all found files
- logger.debug("Reading files in following order: {}", sortedFiles);
-
- List<ConfigSnapshotHolder> result = new ArrayList<>();
- for (File file : sortedFiles) {
- logger.trace("Adding file '{}' to combined result", file);
-
- FileType fileType = FileType.getFileType(file);
- logger.trace("File '{}' detected as {} storage", file, fileType);
-
- ConfigSnapshotHolder snapshot = loadLastConfig(file, fileType);
- result.add(snapshot);
- }
- return result;
- }
-
- private ConfigSnapshotHolder loadLastConfig(File file, FileType fileType) throws IOException {
- switch (fileType) {
- case plaintext:
- logger.warn("Plaintext configuration files are deprecated, and will not be supported in future versions. " +
- "Use xml files instead");
- return DirectoryPersister.loadLastConfig(file);
- case xml:
- try {
- return XmlDirectoryPersister.loadLastConfig(file);
- } catch (JAXBException e) {
- logger.warn("Unable to restore configuration snapshot from {}", file, e);
- throw new IllegalStateException("Unable to restore configuration snapshot from " + file, e);
- }
- default:
- throw new IllegalStateException("Unknown storage type " + fileType);
- }
- }
-
- @Override
- public void close() {
-
- }
-
- @Override
- public String toString() {
- final StringBuffer sb = new StringBuffer("AutodetectDirectoryPersister{");
- sb.append("storage=").append(storage);
- sb.append('}');
- return sb.toString();
- }
-}
+++ /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.controller.config.persist.storage.directory.autodetect;
-
-import com.google.common.base.Preconditions;
-import org.opendaylight.controller.config.persist.api.Persister;
-import org.opendaylight.controller.config.persist.api.PropertiesProvider;
-import org.opendaylight.controller.config.persist.api.StorageAdapter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-
-/**
- * StorageAdapter that retrieves initial configuration from a directory. If multiple files are present, snapshot and
- * required capabilities will be merged together. Writing to this persister is not supported.
- */
-public class AutodetectDirectoryStorageAdapter implements StorageAdapter {
- private static final Logger logger = LoggerFactory.getLogger(AutodetectDirectoryStorageAdapter.class);
-
- public static final String DIRECTORY_STORAGE_PROP = "directoryStorage";
-
-
- @Override
- public Persister instantiate(PropertiesProvider propertiesProvider) {
- String fileStorageProperty = propertiesProvider.getProperty(DIRECTORY_STORAGE_PROP);
- Preconditions.checkNotNull(fileStorageProperty, "Unable to find " + propertiesProvider.getFullKeyForReporting(DIRECTORY_STORAGE_PROP));
- File storage = new File(fileStorageProperty);
- logger.debug("Using {}", storage);
- return new AutodetectDirectoryPersister(storage);
- }
-
-}
+++ /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.controller.config.persist.storage.directory.autodetect;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
-import com.google.common.io.Files;
-import org.apache.commons.lang3.StringUtils;
-import org.opendaylight.controller.config.persist.storage.directory.DirectoryPersister;
-import org.opendaylight.controller.config.persist.storage.file.xml.model.ConfigSnapshot;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-
-enum FileType {
-
- plaintext, xml;
-
- public static final String XML_STORAGE_FIRST_LINE = "<" + ConfigSnapshot.SNAPSHOT_ROOT_ELEMENT_NAME + ">";
- private static final String XML_FILE_DEFINITION_LINE = "<?xml";
-
- static FileType getFileType(File file) {
- String firstLine = readFirstLine(file);
- if(isPlaintextStorage(firstLine)) {
- return plaintext;
- } else if(isXmlStorage(firstLine))
- return xml;
-
- throw new IllegalArgumentException("File " + file + " is not of permitted storage type: " + Arrays.toString(FileType.values()));
- }
-
- private static boolean isXmlStorage(String firstLine) {
- boolean isXml = false;
- isXml |= firstLine.startsWith(XML_STORAGE_FIRST_LINE);
- isXml |= firstLine.startsWith(XML_FILE_DEFINITION_LINE);
- return isXml;
- }
-
- private static boolean isPlaintextStorage(String firstLine) {
- return firstLine.startsWith(DirectoryPersister.MODULES_START);
-
- }
-
- @VisibleForTesting
- static String readFirstLine(File file) {
- FirstLineReadingProcessor callback = new FirstLineReadingProcessor();
- try {
- return Files.readLines(file, Charsets.UTF_8, callback);
- } catch (IOException e) {
- throw new IllegalArgumentException("Unable to detect file type of file " + file, e);
- }
- }
-
-
- private static class FirstLineReadingProcessor implements com.google.common.io.LineProcessor<String> {
- private String firstNonBlankLine;
-
- @Override
- public boolean processLine(String line) throws IOException {
- if(isEmptyLine(line)) {
- return true;
- } else {
- firstNonBlankLine = line.trim();
- return false;
- }
- }
-
- private boolean isEmptyLine(String line) {
- return StringUtils.isBlank(line);
- }
-
- @Override
- public String getResult() {
- return firstNonBlankLine;
- }
- }
-}
+++ /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.controller.config.persist.storage.directory.autodetect;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import junit.framework.Assert;
-import org.junit.Test;
-import org.junit.matchers.JUnitMatchers;
-import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
-import org.opendaylight.controller.config.persist.test.PropertiesProviderTest;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-
-public class AutodetectDirectoryPersisterTest {
-
- @Test
- public void testCombined() throws Exception {
- File resourcePath = FileTypeTest.getResourceAsFile("/combined/1controller.txt.config");
- File parentFile = resourcePath.getParentFile();
-
- AutodetectDirectoryStorageAdapter adapter = new AutodetectDirectoryStorageAdapter();
-
- PropertiesProviderTest pp = new PropertiesProviderTest();
- pp.addProperty("directoryStorage",parentFile.getPath());
- AutodetectDirectoryPersister persister = (AutodetectDirectoryPersister) adapter.instantiate(pp);
- List<ConfigSnapshotHolder> configs = persister.loadLastConfigs();
-
- Assert.assertEquals(2, configs.size());
- String snapFromTxt = configs.get(0).getConfigSnapshot();
- org.junit.Assert.assertThat(snapFromTxt, JUnitMatchers.containsString("<config>txt</config>"));
- org.junit.Assert.assertThat(snapFromTxt, JUnitMatchers.containsString("<service>txt</service>"));
-
- String snapFromXml = configs.get(1).getConfigSnapshot();
- org.junit.Assert.assertThat(snapFromXml, JUnitMatchers.containsString("<config>xml</config>"));
-
- Assert.assertEquals(configs.get(0).getCapabilities(), configs.get(1).getCapabilities());
- }
-
- @Test
- public void testInvalidXml() throws Exception {
- File resourcePath = FileTypeTest.getResourceAsFile("/bad_controller.xml.config");
- File parentFile = resourcePath.getParentFile();
-
- AutodetectDirectoryStorageAdapter adapter = new AutodetectDirectoryStorageAdapter();
-
- PropertiesProviderTest pp = new PropertiesProviderTest();
- pp.addProperty("directoryStorage",parentFile.getPath());
- AutodetectDirectoryPersister persister = (AutodetectDirectoryPersister) adapter.instantiate(pp);
- try {
- List<ConfigSnapshotHolder> configs = persister.loadLastConfigs();
- fail("An exception of type " + IllegalStateException.class + " was expected");
- } catch (IllegalStateException ise){
- String message = ise.getMessage();
- assertThat(message, JUnitMatchers.containsString("Unable to restore configuration snapshot from "));
- }
-
- }
-
- @Test
- public void testPersistConfig() throws Exception {
- File resourcePath = FileTypeTest.getResourceAsFile("/combined/1controller.txt.config");
- File parentFile = resourcePath.getParentFile();
-
- AutodetectDirectoryStorageAdapter adapter = new AutodetectDirectoryStorageAdapter();
-
- PropertiesProviderTest pp = new PropertiesProviderTest();
- pp.addProperty("directoryStorage",parentFile.getPath());
- AutodetectDirectoryPersister persister = (AutodetectDirectoryPersister) adapter.instantiate(pp);
- List<ConfigSnapshotHolder> configs = null;
- try {
- configs = persister.loadLastConfigs();
- } catch (IOException e) {
- fail("An exception of type " + UnsupportedOperationException.class + " was expected");
- }
- Assert.assertEquals(2, configs.size());
- try {
- persister.persistConfig(configs.get(0));
- } catch (UnsupportedOperationException uoe){
- String message = uoe.getMessage();
- assertThat(message,JUnitMatchers.containsString("This adapter is read only. Please set readonly=true on class"));
- }
- }
-
-}
+++ /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.controller.config.persist.storage.directory.autodetect;
-
-import junit.framework.Assert;
-import org.junit.Test;
-import org.junit.matchers.JUnitMatchers;
-
-import java.io.File;
-
-public class FileTypeTest {
-
- @Test
- public void testPlaintext() throws Exception {
- File file = getResourceAsFile("/test.txt.config");
-
- FileType type = FileType.getFileType(file);
- Assert.assertEquals(FileType.plaintext, type);
-
- }
-
- @Test
- public void testXml() throws Exception {
- File file = getResourceAsFile("/test.xml.config");
-
- FileType type = FileType.getFileType(file);
- Assert.assertEquals(FileType.xml, type);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testUnknown() throws Exception {
- File file = getResourceAsFile("/unknown.config");
-
- try {
- FileType.getFileType(file);
- } catch (IllegalArgumentException e) {
- org.junit.Assert.assertThat(e.getMessage(), JUnitMatchers.containsString("File " + file + " is not of permitted storage type"));
- throw e;
- }
- }
-
- static File getResourceAsFile(String resource) {
- String f = FileTypeTest.class.getResource(resource).getFile();
- return new File(f);
- }
-
-}
+++ /dev/null
-<snapshot>
- <required-capabilities>
- <capability
- <capability>cap2</capability>
- <capability>capa a</capability>
- </required-capabilities>
- <configuration>
- <config>xml</config>
- </configuration>
-</snapshot>
\ No newline at end of file
+++ /dev/null
-//MODULES START
- <config>txt</config>
-//SERVICES START
- <service>txt</service>
-//CAPABILITIES START
-cap1&rev
-cap2
-capa a
\ No newline at end of file
+++ /dev/null
-<snapshot>
- <required-capabilities>
- <capability>cap1&rev</capability>
- <capability>cap2</capability>
- <capability>capa a</capability>
- </required-capabilities>
- <configuration>
- <config>xml</config>
- </configuration>
-</snapshot>
\ No newline at end of file
+++ /dev/null
-//MODULES START
-configuration
\ No newline at end of file
+++ /dev/null
-
-<snapshot>
\ No newline at end of file
+++ /dev/null
-unknown
-file type
\ No newline at end of file
*/
package org.opendaylight.controller.config.persist.storage.directory.xml;
+import com.google.common.base.Optional;
+import com.google.common.io.Files;
import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
import org.opendaylight.controller.config.persist.api.Persister;
import org.opendaylight.controller.config.persist.storage.file.xml.model.ConfigSnapshot;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.File;
+import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.Set;
import java.util.SortedSet;
import static com.google.common.base.Preconditions.checkArgument;
private static final Logger logger = LoggerFactory.getLogger(XmlDirectoryPersister.class);
private final File storage;
+ private final Optional<FilenameFilter> extensionsFilter;
+ /**
+ * Creates XmlDirectoryPersister that picks up all files in specified folder
+ */
public XmlDirectoryPersister(File storage) {
+ this(storage, Optional.<FilenameFilter>absent());
+ }
+
+ /**
+ * Creates XmlDirectoryPersister that picks up files only with specified file extension
+ */
+ public XmlDirectoryPersister(File storage, Set<String> fileExtensions) {
+ this(storage, Optional.of(getFilter(fileExtensions)));
+ }
+
+ private XmlDirectoryPersister(File storage, Optional<FilenameFilter> extensionsFilter) {
checkArgument(storage.exists() && storage.isDirectory(), "Storage directory does not exist: " + storage);
this.storage = storage;
+ this.extensionsFilter = extensionsFilter;
}
@Override
@Override
public List<ConfigSnapshotHolder> loadLastConfigs() throws IOException {
- File[] filesArray = storage.listFiles();
+ File[] filesArray = extensionsFilter.isPresent() ? storage.listFiles(extensionsFilter.get()) : storage.listFiles();
if (filesArray == null || filesArray.length == 0) {
return Collections.emptyList();
}
List<ConfigSnapshotHolder> result = new ArrayList<>();
for (File file : sortedFiles) {
logger.trace("Adding file '{}' to combined result", file);
- ConfigSnapshotHolder h = fromXmlSnapshot(file);
- result.add(h);
+ Optional<ConfigSnapshotHolder> h = fromXmlSnapshot(file);
+ // Ignore non valid snapshot
+ if(h.isPresent() == false) {
+ continue;
+ }
+
+ result.add(h.get());
}
return result;
}
- private ConfigSnapshotHolder fromXmlSnapshot(File file) {
+ private Optional<ConfigSnapshotHolder> fromXmlSnapshot(File file) {
try {
- return loadLastConfig(file);
+ return Optional.of(loadLastConfig(file));
} catch (JAXBException e) {
- logger.warn("Unable to restore configuration snapshot from {}", file, e);
- throw new IllegalStateException("Unable to restore configuration snapshot from " + file, e);
+ // In case of parse error, issue a warning, ignore and continue
+ logger.warn(
+ "Unable to parse configuration snapshot from {}. Initial config from {} will be IGNORED in this run. " +
+ "Note that subsequent config files may fail due to this problem. " +
+ "Xml markup in this file needs to be fixed, for detailed information see enclosed exception.",
+ file, file, e);
}
+
+ return Optional.absent();
}
public static ConfigSnapshotHolder loadLastConfig(File file) throws JAXBException {
};
}
+ private static FilenameFilter getFilter(final Set<String>fileExtensions) {
+ checkArgument(fileExtensions.isEmpty() == false, "No file extension provided", fileExtensions);
+
+ return new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ String ext = Files.getFileExtension(name);
+ return fileExtensions.contains(ext);
+ }
+ };
+ }
@Override
public void close() {
package org.opendaylight.controller.config.persist.storage.directory.xml;
import com.google.common.base.Preconditions;
+import com.google.common.base.Splitter;
+import com.google.common.collect.Sets;
import org.opendaylight.controller.config.persist.api.Persister;
import org.opendaylight.controller.config.persist.api.PropertiesProvider;
import org.opendaylight.controller.config.persist.api.StorageAdapter;
import org.slf4j.LoggerFactory;
import java.io.File;
+import java.util.Set;
/**
* StorageAdapter that retrieves initial configuration from a directory. If multiple files are present, snapshot and
private static final Logger logger = LoggerFactory.getLogger(XmlDirectoryStorageAdapter.class);
public static final String DIRECTORY_STORAGE_PROP = "directoryStorage";
+ public static final String INCLUDE_EXT_PROP = "includeExtensions";
+ private static final char EXTENSIONS_SEPARATOR = ',';
@Override
String fileStorageProperty = propertiesProvider.getProperty(DIRECTORY_STORAGE_PROP);
Preconditions.checkNotNull(fileStorageProperty, "Unable to find " + propertiesProvider.getFullKeyForReporting(DIRECTORY_STORAGE_PROP));
File storage = new File(fileStorageProperty);
- logger.debug("Using {}", storage);
- return new XmlDirectoryPersister(storage);
+ String fileExtensions = propertiesProvider.getProperty(INCLUDE_EXT_PROP);
+
+ logger.debug("Using storage: {}", storage);
+
+ if(fileExtensions != null) {
+ logger.debug("Using extensions: {}", fileExtensions);
+ return new XmlDirectoryPersister(storage, splitExtensions(fileExtensions));
+ } else {
+ return new XmlDirectoryPersister(storage);
+ }
+ }
+
+ private Set<String> splitExtensions(String fileExtensions) {
+ return Sets.newHashSet(Splitter.on(EXTENSIONS_SEPARATOR).trimResults().omitEmptyStrings()
+ .split(fileExtensions));
}
}
import java.util.Collections;
import java.util.List;
import java.util.SortedSet;
+
+import com.google.common.base.Optional;
import org.junit.Test;
import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
import org.opendaylight.controller.config.persist.api.Persister;
Persister tested;
Logger logger = LoggerFactory.getLogger(DirectoryStorageAdapterTest.class.toString());
- private Persister instantiatePersisterFromAdapter(File file){
+ private Persister instantiatePersisterFromAdapter(File file, Optional<String> extensions){
PropertiesProviderTest pp = new PropertiesProviderTest();
- pp.addProperty("directoryStorage",file.getPath());
+ pp.addProperty(XmlDirectoryStorageAdapter.DIRECTORY_STORAGE_PROP,file.getPath());
+ if(extensions.isPresent()) {
+ pp.addProperty(XmlDirectoryStorageAdapter.INCLUDE_EXT_PROP, extensions.get());
+ }
+
XmlDirectoryStorageAdapter dsa = new XmlDirectoryStorageAdapter();
return dsa.instantiate(pp);
}
+ private Persister instantiatePersisterFromAdapter(File file){
+ return instantiatePersisterFromAdapter(file, Optional.<String>absent());
+ }
+
@Test
public void testEmptyDirectory() throws Exception {
File folder = new File("target/emptyFolder");
@Test
public void testOneFile() throws Exception {
File folder = getFolder("oneFile");
- tested = instantiatePersisterFromAdapter(folder);
+ tested = instantiatePersisterFromAdapter(folder, Optional.of("xml"));
- logger.info("Testing : "+tested.toString());
+ logger.info("Testing : " + tested.toString());
List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
assertEquals(1, results.size());
ConfigSnapshotHolder result = results.get(0);
assertResult(result, "<config>1</config>", "cap1&rev", "cap2", "capa a");
}
+ @Test
+ public void testOneFileWrongExtension() throws Exception {
+ File folder = getFolder("oneFile");
+ tested = instantiatePersisterFromAdapter(folder, Optional.of("aa, bb"));
+ logger.info("Testing : " + tested.toString());
+ }
+
private void assertResult(ConfigSnapshotHolder result, String s, String... caps) {
assertEquals(s, result.getConfigSnapshot().replaceAll("\\s", ""));
int i = 0;
}
@Test
- public void testTwoFiles() throws Exception {
+ public void testTwoFilesAllExtensions() throws Exception {
File folder = getFolder("twoFiles");
tested = instantiatePersisterFromAdapter(folder);
- logger.info("Testing : "+tested.toString());
+ logger.info("Testing : " + tested.toString());
List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
assertEquals(2, results.size());
assertResult(results.get(0), "<config>1</config>", "cap1-a", "cap2-a", "capa a-a");
assertResult(results.get(1), "<config>2</config>", "cap1-b", "cap2-b", "capa a-b");
+ }
+
+ @Test
+ public void testTwoFilesTwoExtensions() throws Exception {
+ File folder = getFolder("twoFiles");
+ tested = instantiatePersisterFromAdapter(folder, Optional.of("xml, xml2"));
+ logger.info("Testing : " + tested.toString());
+ assertEquals(2, tested.loadLastConfigs().size());
+ }
+
+ @Test
+ public void testTwoFilesOnlyOneExtension() throws Exception {
+ File folder = getFolder("twoFiles");
+ tested = instantiatePersisterFromAdapter(folder, Optional.of("xml"));
+ logger.info("Testing : " + tested.toString());
+ List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
+ assertEquals(1, results.size());
+ assertResult(results.get(0), "<config>1</config>", "cap1-a", "cap2-a", "capa a-a");
+ }
+
+ @Test
+ public void testTwoFilesOneInvalid() throws Exception {
+ File folder = getFolder("twoFiles_corrupt");
+ tested = instantiatePersisterFromAdapter(folder, Optional.of("xml"));
+ logger.info("Testing : " + tested.toString());
+ List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
+ assertEquals(1, results.size());
+
+ assertResult(results.get(0), "<config>1</config>", "cap1-a", "cap2-a", "capa a-a");
}
}
--- /dev/null
+<snapshot>
+ <required-capabilities>
+ <capability>cap1-a</capability>
+ <capability>cap2-a</capability>
+ <capability>capa a-a</capability>
+ </required-capabilities>
+ <configuration>
+ <config>1</config>
+ </configuration>
+</snapshot>
\ No newline at end of file
--- /dev/null
+<snapshotInvalid>
+ <required-capabilities>
+ <capability>cap1-b</capability>
+ <capability>cap2-b</capability>
+ <capability>capa a-b</capability>
+ </required-capabilities>
+ <configuration>
+ <config>2</config>
+ </configuration>
+</snapshotInvalid>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<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>
- <artifactId>config-subsystem</artifactId>
- <groupId>org.opendaylight.controller</groupId>
- <version>0.2.5-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>config-persister-file-adapter</artifactId>
- <name>${project.artifactId}</name>
- <packaging>bundle</packaging>
-
- <dependencies>
- <!-- compile dependencies -->
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>config-persister-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
-
- <!-- test dependencies -->
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>mockito-configuration</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>config-persister-api</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <!-- workaround for creating version according to OSGi specification (major.minor.micro[.qualifier] -->
- <plugin>
- <groupId>org.codehaus.groovy.maven</groupId>
- <artifactId>gmaven-plugin</artifactId>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <goals>
- <goal>execute</goal>
- </goals>
- <configuration>
- <source>
- System.setProperty("osgiversion", "${project.version}".replace('-', '.'))
- </source>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Fragment-Host>${project.groupId}.config-persister-impl;bundle-version=${osgiversion}
- </Fragment-Host>
- <Provide-Capability>org.opendaylight.controller.config.persister.storage.adapter
- </Provide-Capability>
- </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.controller.config.persist.storage.file;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.io.Files;
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import org.apache.commons.lang3.StringUtils;
-import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
-import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolderImpl;
-import org.opendaylight.controller.config.persist.api.Persister;
-import org.opendaylight.controller.config.persist.api.PropertiesProvider;
-import org.opendaylight.controller.config.persist.api.StorageAdapter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * StorageAdapter that stores configuration in a plain file.
- */
-public class FileStorageAdapter implements StorageAdapter, Persister {
- private static final Logger logger = LoggerFactory.getLogger(FileStorageAdapter.class);
-
-
- private static final Charset ENCODING = Charsets.UTF_8;
-
- public static final String FILE_STORAGE_PROP = "fileStorage";
- public static final String NUMBER_OF_BACKUPS = "numberOfBackups";
-
-
- private static final String SEPARATOR_E_PURE = "//END OF CONFIG";
- private static final String SEPARATOR_E = newLine(SEPARATOR_E_PURE);
-
- private static final String SEPARATOR_M_PURE = "//END OF SNAPSHOT";
- private static final String SEPARATOR_M = newLine(SEPARATOR_M_PURE);
-
- private static final String SEPARATOR_S = newLine("//START OF CONFIG");
-
- private static final String SEPARATOR_SL_PURE = "//START OF CONFIG-LAST";
- private static final String SEPARATOR_SL = newLine(SEPARATOR_SL_PURE);
-
- private static Integer numberOfStoredBackups;
- private File storage;
-
- @Override
- public Persister instantiate(PropertiesProvider propertiesProvider) {
- File storage = extractStorageFileFromProperties(propertiesProvider);
- logger.debug("Using file {}", storage.getAbsolutePath());
- // Create file if it does not exist
- File parentFile = storage.getAbsoluteFile().getParentFile();
- if (parentFile.exists() == false) {
- logger.debug("Creating parent folders {}", parentFile);
- parentFile.mkdirs();
- }
- if (storage.exists() == false) {
- logger.debug("Storage file does not exist, creating empty file");
- try {
- boolean result = storage.createNewFile();
- if (result == false)
- throw new RuntimeException("Unable to create storage file " + storage);
- } catch (IOException e) {
- throw new RuntimeException("Unable to create storage file " + storage, e);
- }
- }
- if (numberOfStoredBackups == 0) {
- throw new RuntimeException(NUMBER_OF_BACKUPS
- + " property should be either set to positive value, or ommited. Can not be set to 0.");
- }
- setFileStorage(storage);
- return this;
- }
-
- @VisibleForTesting
- void setFileStorage(File storage) {
- this.storage = storage;
- }
-
- @VisibleForTesting
- void setNumberOfBackups(Integer numberOfBackups) {
- numberOfStoredBackups = numberOfBackups;
- }
-
- private static File extractStorageFileFromProperties(PropertiesProvider propertiesProvider) {
- String fileStorageProperty = propertiesProvider.getProperty(FILE_STORAGE_PROP);
- Preconditions.checkNotNull(fileStorageProperty, "Unable to find " + propertiesProvider.getFullKeyForReporting(FILE_STORAGE_PROP));
- File result = new File(fileStorageProperty);
- String numberOfBAckupsAsString = propertiesProvider.getProperty(NUMBER_OF_BACKUPS);
- if (numberOfBAckupsAsString != null) {
- numberOfStoredBackups = Integer.valueOf(numberOfBAckupsAsString);
- } else {
- numberOfStoredBackups = Integer.MAX_VALUE;
- }
- logger.trace("Property {} set to {}", NUMBER_OF_BACKUPS, numberOfStoredBackups);
- return result;
- }
-
- private static String newLine(String string) {
- return string + "\n";
- }
-
- @Override
- public void persistConfig(ConfigSnapshotHolder holder) throws IOException {
- Preconditions.checkNotNull(storage, "Storage file is null");
-
- String content = Files.toString(storage, ENCODING);
- if (numberOfStoredBackups == Integer.MAX_VALUE) {
- resetLastConfig(content);
- persistLastConfig(holder);
- } else {
- if (numberOfStoredBackups == 1) {
- Files.write("", storage, ENCODING);
- persistLastConfig(holder);
- } else {
- int count = StringUtils.countMatches(content, SEPARATOR_S);
- if ((count + 1) < numberOfStoredBackups) {
- resetLastConfig(content);
- persistLastConfig(holder);
- } else {
- String contentSubString = StringUtils.substringBefore(content, SEPARATOR_E);
- contentSubString = contentSubString.concat(SEPARATOR_E_PURE);
- content = StringUtils.substringAfter(content, contentSubString);
- resetLastConfig(content);
- persistLastConfig(holder);
- }
- }
- }
- }
-
- private void resetLastConfig(String content) throws IOException {
- content = content.replaceFirst(SEPARATOR_SL, SEPARATOR_S);
- Files.write(content, storage, ENCODING);
- }
-
- private void persistLastConfig(ConfigSnapshotHolder holder) throws IOException {
- Files.append(SEPARATOR_SL, storage, ENCODING);
- String snapshotAsString = holder.getConfigSnapshot();
- Files.append(newLine(snapshotAsString), storage, ENCODING);
- Files.append(SEPARATOR_M, storage, ENCODING);
- Files.append(toStringCaps(holder.getCapabilities()), storage, ENCODING);
- Files.append(SEPARATOR_E, storage, ENCODING);
- }
-
- private CharSequence toStringCaps(Set<String> capabilities) {
- StringBuilder b = new StringBuilder();
- for (String capability : capabilities) {
- b.append(newLine(capability));
- }
- return b.toString();
- }
-
- @Override
- public List<ConfigSnapshotHolder> loadLastConfigs() throws IOException {
- Preconditions.checkNotNull(storage, "Storage file is null");
-
- if (!storage.exists()) {
- return Collections.emptyList();
- }
-
- final LineProcessor lineProcessor = new LineProcessor();
- Files.readLines(storage, ENCODING, lineProcessor);
-
- if (lineProcessor.getConfigSnapshot().isPresent() == false) {
- return Collections.emptyList();
- } else {
- return Arrays.<ConfigSnapshotHolder>asList(new ConfigSnapshotHolderImpl(lineProcessor.getConfigSnapshot().get(),
- lineProcessor.getCapabilities(), storage.getAbsolutePath()));
- }
-
- }
-
- private static final class LineProcessor implements com.google.common.io.LineProcessor<String> {
-
- private boolean inLastConfig, inLastSnapshot;
- private final StringBuffer snapshotBuffer = new StringBuffer();
- private final SortedSet<String> caps = new TreeSet<>();
-
- @Override
- public String getResult() {
- return null;
- }
-
- @Override
- public boolean processLine(String line) throws IOException {
- if (inLastConfig && line.equals(SEPARATOR_E_PURE)) {
- inLastConfig = false;
- return false;
- }
-
- if (inLastConfig && line.equals(SEPARATOR_M_PURE)) {
- inLastSnapshot = false;
- return true;
- }
-
- if (inLastConfig) {
- if (inLastSnapshot) {
- snapshotBuffer.append(line);
- snapshotBuffer.append(System.lineSeparator());
- } else {
- caps.add(line);
- }
- }
-
- if (line.equals(SEPARATOR_SL_PURE)) {
- inLastConfig = true;
- inLastSnapshot = true;
- }
-
- return true;
- }
-
- Optional<String> getConfigSnapshot() {
- final String xmlContent = snapshotBuffer.toString();
- if (xmlContent.equals("")) {
- return Optional.absent();
- } else {
- return Optional.of(xmlContent);
- }
- }
-
- SortedSet<String> getCapabilities() {
- return caps;
- }
-
- }
-
- @Override
- public void close() {
-
- }
-
- @Override
- public String toString() {
- return "FileStorageAdapter [storage=" + storage + "]";
- }
-
-}
+++ /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.controller.config.persist.storage.file;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Collections2;
-import java.io.File;
-import java.nio.file.Files;
-import java.util.Collection;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
-import org.opendaylight.controller.config.persist.api.Persister;
-import org.opendaylight.controller.config.persist.test.PropertiesProviderTest;
-import static junit.framework.Assert.assertFalse;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
-public class FileStorageAdapterTest {
-
- private static int i;
- private File file;
-
- @Before
- public void setUp() throws Exception {
- file = Files.createTempFile("testFilePersist", ".txt").toFile();
- if (!file.exists())
- return;
- com.google.common.io.Files.write("", file, Charsets.UTF_8);
- i = 1;
- }
-
-
- @Test
- public void testFileAdapterAsPersister() throws Exception {
- FileStorageAdapter storage = new FileStorageAdapter();
- PropertiesProviderTest pp = new PropertiesProviderTest();
- pp.addProperty("fileStorage",file.getPath());
- pp.addProperty("numberOfBackups",Integer.toString(Integer.MAX_VALUE));
-
- Persister configPersister = storage.instantiate(pp);
- final ConfigSnapshotHolder holder = new ConfigSnapshotHolder() {
- @Override
- public String getConfigSnapshot() {
- return createConfig();
- }
-
- @Override
- public SortedSet<String> getCapabilities() {
- return createCaps();
- }
- };
- configPersister.persistConfig(holder);
-
- configPersister.persistConfig(holder);
-
- Collection<String> readLines = Collections2.filter(com.google.common.io.Files.readLines(file, Charsets.UTF_8),
- new Predicate<String>() {
-
- @Override
- public boolean apply(String input) {
- if (input.equals(""))
- return false;
- return true;
- }
- });
- assertEquals(14, readLines.size());
-
- List<ConfigSnapshotHolder> lastConf = storage.loadLastConfigs();
- assertEquals(1, lastConf.size());
- ConfigSnapshotHolder configSnapshotHolder = lastConf.get(0);
- assertEquals("<config>2</config>",
- configSnapshotHolder.getConfigSnapshot().replaceAll("\\s", ""));
- assertEquals(createCaps(), configSnapshotHolder.getCapabilities());
- }
- @Test
- public void testFileAdapter() throws Exception {
- FileStorageAdapter storage = new FileStorageAdapter();
- storage.setFileStorage(file);
- storage.setNumberOfBackups(Integer.MAX_VALUE);
- final ConfigSnapshotHolder holder = new ConfigSnapshotHolder() {
- @Override
- public String getConfigSnapshot() {
- return createConfig();
- }
-
- @Override
- public SortedSet<String> getCapabilities() {
- return createCaps();
- }
- };
- storage.persistConfig(holder);
-
- storage.persistConfig(holder);
-
- Collection<String> readLines = Collections2.filter(com.google.common.io.Files.readLines(file, Charsets.UTF_8),
- new Predicate<String>() {
-
- @Override
- public boolean apply(String input) {
- if (input.equals(""))
- return false;
- return true;
- }
- });
- assertEquals(14, readLines.size());
-
- List<ConfigSnapshotHolder> lastConf = storage.loadLastConfigs();
- assertEquals(1, lastConf.size());
- ConfigSnapshotHolder configSnapshotHolder = lastConf.get(0);
- assertEquals("<config>2</config>",
- configSnapshotHolder.getConfigSnapshot().replaceAll("\\s", ""));
- assertEquals(createCaps(), configSnapshotHolder.getCapabilities());
- }
-
- private SortedSet<String> createCaps() {
- SortedSet<String> caps = new TreeSet<>();
-
- caps.add("cap1");
- caps.add("cap2");
- caps.add("capaaaa as dasfasdf s2");
- return caps;
- }
-
- @Test
- public void testFileAdapterOneBackup() throws Exception {
- FileStorageAdapter storage = new FileStorageAdapter();
- storage.setFileStorage(file);
- storage.setNumberOfBackups(1);
- final ConfigSnapshotHolder holder = new ConfigSnapshotHolder() {
- @Override
- public String getConfigSnapshot() {
- return createConfig();
- }
-
- @Override
- public SortedSet<String> getCapabilities() {
- return createCaps();
- }
- };
- storage.persistConfig(holder);
-
- storage.persistConfig(holder);
-
- Collection<String> readLines = Collections2.filter(com.google.common.io.Files.readLines(file, Charsets.UTF_8),
- new Predicate<String>() {
-
- @Override
- public boolean apply(String input) {
- if (input.equals(""))
- return false;
- return true;
- }
- });
- assertEquals(7, readLines.size());
-
- List<ConfigSnapshotHolder> lastConf = storage.loadLastConfigs();
- assertEquals(1, lastConf.size());
- ConfigSnapshotHolder configSnapshotHolder = lastConf.get(0);
- assertEquals("<config>2</config>",
- configSnapshotHolder.getConfigSnapshot().replaceAll("\\s", ""));
- }
-
- @Test
- public void testFileAdapterOnlyTwoBackups() throws Exception {
- FileStorageAdapter storage = new FileStorageAdapter();
- storage.setFileStorage(file);
- storage.setNumberOfBackups(2);
- final ConfigSnapshotHolder holder = new ConfigSnapshotHolder() {
- @Override
- public String getConfigSnapshot() {
- return createConfig();
- }
-
- @Override
- public SortedSet<String> getCapabilities() {
- return createCaps();
- }
- };
- storage.persistConfig(holder);
-
- storage.persistConfig(holder);
- storage.persistConfig(holder);
-
- Collection<String> readLines = Collections2.filter(com.google.common.io.Files.readLines(file, Charsets.UTF_8),
- new Predicate<String>() {
-
- @Override
- public boolean apply(String input) {
- if (input.equals(""))
- return false;
- return true;
- }
- });
-
- assertEquals(14, readLines.size());
-
- List<ConfigSnapshotHolder> lastConf = storage.loadLastConfigs();
- assertEquals(1, lastConf.size());
- ConfigSnapshotHolder configSnapshotHolder = lastConf.get(0);
- assertEquals("<config>3</config>",
- configSnapshotHolder.getConfigSnapshot().replaceAll("\\s", ""));
- assertFalse(readLines.contains(holder.getConfigSnapshot()));
- }
-
- @Test
- public void testNoLastConfig() throws Exception {
- File file = Files.createTempFile("testFilePersist", ".txt").toFile();
- if (!file.exists())
- return;
- FileStorageAdapter storage = new FileStorageAdapter();
- storage.setFileStorage(file);
-
- List<ConfigSnapshotHolder> elementOptional = storage.loadLastConfigs();
- assertThat(elementOptional.size(), is(0));
- }
-
- @Test(expected = NullPointerException.class)
- public void testNoProperties() throws Exception {
- FileStorageAdapter storage = new FileStorageAdapter();
- storage.loadLastConfigs();
- }
-
- @Test(expected = NullPointerException.class)
- public void testNoProperties2() throws Exception {
- FileStorageAdapter storage = new FileStorageAdapter();
- storage.persistConfig(new ConfigSnapshotHolder() {
- @Override
- public String getConfigSnapshot() {
- return Mockito.mock(String.class);
- }
-
- @Override
- public SortedSet<String> getCapabilities() {
- return new TreeSet<>();
- }
- } );
- }
-
- static String createConfig() {
- return "<config>" + i++ + "</config>";
- }
-
-}
<module>config-plugin-parent</module>
<module>config-util</module>
<module>config-persister-api</module>
- <module>config-persister-file-adapter</module>
<module>config-persister-file-xml-adapter</module>
<module>yang-jmx-generator</module>
<module>yang-jmx-generator-plugin</module>
<module>netty-threadgroup-config</module>
<module>netty-event-executor-config</module>
<module>netty-timer-config</module>
- <module>config-persister-directory-adapter</module>
<module>config-persister-directory-xml-adapter</module>
- <module>config-persister-directory-autodetect-adapter</module>
<module>yang-test-plugin</module>
<module>shutdown-api</module>
<module>shutdown-impl</module>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-persister-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-file-adapter</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-persister-file-xml-adapter</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-directory-adapter</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-persister-directory-xml-adapter</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-directory-autodetect-adapter</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
netconf.config.persister.active=1,2
# read startup configuration
-#netconf.config.persister.1.storageAdapterClass=org.opendaylight.controller.config.persist.storage.directory.DirectoryStorageAdapter
-#netconf.config.persister.1.properties.directoryStorage=configuration/initial/
-#netconf.config.persister.1.readonly=true
-
-netconf.config.persister.1.storageAdapterClass=org.opendaylight.controller.config.persist.storage.directory.autodetect.AutodetectDirectoryStorageAdapter
+netconf.config.persister.1.storageAdapterClass=org.opendaylight.controller.config.persist.storage.directory.xml.XmlDirectoryStorageAdapter
netconf.config.persister.1.properties.directoryStorage=configuration/initial/
+# include only xml files, files with other extensions will be skipped, multiple extensions are permitted e.g. netconf.config.persister.1.properties.includeExtensions=xml,cfg,config
+netconf.config.persister.1.properties.includeExtensions=xml
netconf.config.persister.1.readonly=true
-#netconf.config.persister.3.storageAdapterClass=org.opendaylight.controller.config.persist.storage.directory.xml.XmlDirectoryStorageAdapter
-#netconf.config.persister.3.properties.directoryStorage=configuration/initialXml/
-#netconf.config.persister.3.readonly=true
-
-#netconf.config.persister.4.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.FileStorageAdapter
-#netconf.config.persister.4.properties.fileStorage=configuration/current/controller.currentconfig.txt
-#netconf.config.persister.4.properties.numberOfBackups=1
-
netconf.config.persister.2.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.xml.XmlFileStorageAdapter
netconf.config.persister.2.properties.fileStorage=configuration/current/controller.currentconfig.xml
netconf.config.persister.2.properties.numberOfBackups=1
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-file-adapter</artifactId>
+ <artifactId>config-persister-file-xml-adapter</artifactId>
<version>${config.version}</version>
</dependency>
<dependency>
<artifactId>config-persister-impl</artifactId>
<version>${config.version}</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-file-adapter</artifactId>
- <version>${config.version}</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>netconf-impl</artifactId>
class ChangeListenerNotifyTask implements Runnable {
private static final Logger LOG = LoggerFactory.getLogger(ChangeListenerNotifyTask.class);
- private final Iterable<DataChangeListenerRegistration<?>> listeners;
+ private final Iterable<? extends DataChangeListenerRegistration<?>> listeners;
private final AsyncDataChangeEvent<InstanceIdentifier, NormalizedNode<?, ?>> event;
- public ChangeListenerNotifyTask(final Iterable<DataChangeListenerRegistration<?>> listeners,
+ public ChangeListenerNotifyTask(final Iterable<? extends DataChangeListenerRegistration<?>> listeners,
final AsyncDataChangeEvent<InstanceIdentifier, NormalizedNode<?, ?>> event) {
this.listeners = listeners;
this.event = event;
subtree.merge(resolveSubtreeChangeEvent(childPath, childListen, childMod, childBefore.get(),
childAfter.get()));
break;
+ case UNMODIFIED:
+ // no-op
+ break;
}
}
DOMImmutableDataChangeEvent oneChangeEvent = one.build();
import static com.google.common.base.Preconditions.checkState;
import static org.opendaylight.controller.md.sal.dom.store.impl.StoreUtils.increase;
+import java.util.Collections;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicReference;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerRegistrationNode;
+import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerRegistrationNode.DataChangeListenerRegistration;
import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType;
import org.opendaylight.controller.md.sal.dom.store.impl.tree.NodeModification;
import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreMetadataNode;
import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedLong;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
private final ListeningExecutorService executor;
private final String name;
private final AtomicLong txCounter = new AtomicLong(0);
-
- private DataAndMetadataSnapshot snapshot;
- private ModificationApplyOperation operationTree;
private final ListenerRegistrationNode listenerTree;
+ private final AtomicReference<DataAndMetadataSnapshot> snapshot;
-
+ private ModificationApplyOperation operationTree;
private SchemaContext schemaContext;
public InMemoryDOMDataStore(final String name, final ListeningExecutorService executor) {
- this.executor = executor;
- this.name = name;
- this.operationTree = new AllwaysFailOperation();
- this.snapshot = DataAndMetadataSnapshot.createEmpty();
+ this.name = Preconditions.checkNotNull(name);
+ this.executor = Preconditions.checkNotNull(executor);
this.listenerTree = ListenerRegistrationNode.createRoot();
+ this.snapshot = new AtomicReference<DataAndMetadataSnapshot>(DataAndMetadataSnapshot.createEmpty());
+ this.operationTree = new AlwaysFailOperation();
}
@Override
- public String getIdentifier() {
+ public final String getIdentifier() {
return name;
}
@Override
public DOMStoreReadTransaction newReadOnlyTransaction() {
- return new SnapshotBackedReadTransaction(nextIdentifier(), snapshot);
+ return new SnapshotBackedReadTransaction(nextIdentifier(), snapshot.get());
}
@Override
public DOMStoreReadWriteTransaction newReadWriteTransaction() {
- return new SnapshotBackedReadWriteTransaction(nextIdentifier(), snapshot, this, operationTree);
+ return new SnapshotBackedReadWriteTransaction(nextIdentifier(), snapshot.get(), this, operationTree);
}
@Override
public DOMStoreWriteTransaction newWriteOnlyTransaction() {
- return new SnaphostBackedWriteTransaction(nextIdentifier(), snapshot, this, operationTree);
+ return new SnaphostBackedWriteTransaction(nextIdentifier(), snapshot.get(), this, operationTree);
}
@Override
final InstanceIdentifier path, final L listener, final DataChangeScope scope) {
LOG.debug("{}: Registering data change listener {} for {}",name,listener,path);
ListenerRegistrationNode listenerNode = listenerTree;
- for(PathArgument arg :path.getPath()) {
+ for(PathArgument arg : path.getPath()) {
listenerNode = listenerNode.ensureChild(arg);
}
- synchronized (listener) {
- notifyInitialState(path, listener);
- }
- return listenerNode.registerDataChangeListener(path,listener, scope);
- }
- private void notifyInitialState(final InstanceIdentifier path,
- final AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>> listener) {
- Optional<StoreMetadataNode> currentState = snapshot.read(path);
- try {
+ /*
+ * Make sure commit is not occurring right now. Listener has to be registered and its
+ * state capture enqueued at a consistent point.
+ *
+ * FIXME: improve this to read-write lock, such that multiple listener registrations
+ * can occur simultaneously
+ */
+ final DataChangeListenerRegistration<L> reg;
+ synchronized (this) {
+ reg = listenerNode.registerDataChangeListener(path, listener, scope);
+
+ Optional<StoreMetadataNode> currentState = snapshot.get().read(path);
if (currentState.isPresent()) {
- NormalizedNode<?, ?> data = currentState.get().getData();
- listener.onDataChanged(DOMImmutableDataChangeEvent.builder() //
+ final NormalizedNode<?, ?> data = currentState.get().getData();
+
+ final DOMImmutableDataChangeEvent event = DOMImmutableDataChangeEvent.builder() //
.setAfter(data) //
.addCreated(path, data) //
- .build() //
- );
+ .build();
+ executor.submit(new ChangeListenerNotifyTask(Collections.singletonList(reg), event));
}
- } catch (Exception e) {
- LOG.error("Unhandled exception encountered when invoking listener {}", listener, e);
}
+ return reg;
}
private synchronized DOMStoreThreePhaseCommitCohort submit(
return name + "-" + txCounter.getAndIncrement();
}
- private synchronized void commit(final DataAndMetadataSnapshot currentSnapshot,
+ private void commit(final DataAndMetadataSnapshot currentSnapshot,
final StoreMetadataNode newDataTree, final Iterable<ChangeListenerNotifyTask> listenerTasks) {
LOG.debug("Updating Store snaphot version: {} with version:{}",currentSnapshot.getMetadataTree().getSubtreeVersion(),newDataTree.getSubtreeVersion());
if(LOG.isTraceEnabled()) {
LOG.trace("Data Tree is {}",StoreUtils.toStringTree(newDataTree));
}
- checkState(snapshot == currentSnapshot, "Store snapshot and transaction snapshot differs");
- snapshot = DataAndMetadataSnapshot.builder() //
+
+ final DataAndMetadataSnapshot newSnapshot = DataAndMetadataSnapshot.builder() //
.setMetadataTree(newDataTree) //
.setSchemaContext(schemaContext) //
.build();
- for(ChangeListenerNotifyTask task : listenerTasks) {
- executor.submit(task);
- }
+ /*
+ * The commit has to occur atomically with regard to listener registrations.
+ */
+ synchronized (this) {
+ final boolean success = snapshot.compareAndSet(currentSnapshot, newSnapshot);
+ checkState(success, "Store snapshot and transaction snapshot differ. This should never happen.");
+ for (ChangeListenerNotifyTask task : listenerTasks) {
+ executor.submit(task);
+ }
+ }
}
private static class SnapshotBackedReadTransaction implements DOMStoreReadTransaction {
@Override
public ListenableFuture<Boolean> canCommit() {
- final DataAndMetadataSnapshot snapshotCapture = snapshot;
+ final DataAndMetadataSnapshot snapshotCapture = snapshot.get();
final ModificationApplyOperation snapshotOperation = operationTree;
return executor.submit(new Callable<Boolean>() {
@Override
public ListenableFuture<Void> preCommit() {
- storeSnapshot = snapshot;
+ storeSnapshot = snapshot.get();
if(modification.getModificationType() == ModificationType.UNMODIFIED) {
return Futures.immediateFuture(null);
}
}
- private class AllwaysFailOperation implements ModificationApplyOperation {
+ private static final class AlwaysFailOperation implements ModificationApplyOperation {
@Override
public Optional<StoreMetadataNode> apply(final NodeModification modification,
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
public class ListenerRegistrationNode implements StoreTreeNode<ListenerRegistrationNode>, Identifiable<PathArgument> {
- private final Logger LOG = LoggerFactory.getLogger(ListenerRegistrationNode.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ListenerRegistrationNode.class);
private final ListenerRegistrationNode parent;
private final Map<PathArgument, ListenerRegistrationNode> children;
@SuppressWarnings({ "rawtypes", "unchecked" })
public Collection<org.opendaylight.controller.md.sal.dom.store.impl.DataChangeListenerRegistration<?>> getListeners() {
+ // FIXME: this is not thread-safe and races with listener (un)registration!
return (Collection) listeners;
}
* @param scope Scope of triggering event.
* @return
*/
- public <L extends AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>>> ListenerRegistration<L> registerDataChangeListener(final InstanceIdentifier path,
+ public <L extends AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>>> DataChangeListenerRegistration<L> registerDataChangeListener(final InstanceIdentifier path,
final L listener, final DataChangeScope scope) {
DataChangeListenerRegistration<L> listenerReg = new DataChangeListenerRegistration<L>(path,listener, scope, this);
</plugins>
<pluginManagement>
<plugins>
- <!--This plugin's configuration is used to store Eclipse
+ <!--This plugin's configuration is used to store Eclipse
m2e settings only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-api</artifactId>
</dependency>
- <!--dependency> <groupId>org.opendaylight.yangtools</groupId> <artifactId>yang-data-impl</artifactId>
+ <!--dependency> <groupId>org.opendaylight.yangtools</groupId> <artifactId>yang-data-impl</artifactId>
<version>${yangtools.version}</version> </dependency -->
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-file-adapter</artifactId>
+ <artifactId>config-persister-file-xml-adapter</artifactId>
<version>${config.version}</version>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam</artifactId>
<version>${exam.version}</version>
- <!-- Compile scope here is intentional, it is used in TestHelper
- class which could be downloaded via nexus and reused in other integration
+ <!-- Compile scope here is intentional, it is used in TestHelper
+ class which could be downloaded via nexus and reused in other integration
tests. -->
<scope>compile</scope>
</dependency>
return callRpc(rpc, null)
}
- def resolveIdentifierInInvokeRpc(String identifier) {
+ private def resolveIdentifierInInvokeRpc(String identifier) {
if (identifier.indexOf("/") === -1) {
val identifierDecoded = identifier.urlPathArgDecode
val rpc = identifierDecoded.rpcDefinition
}
throw new ResponseException(NOT_FOUND, "RPC does not exist.");
}
- val slashErrorMsg = String.format("Identifier %n%s%ncan't contain slash character (/). +
- If slash is part of identifier name then use %2F placeholder.",identifier)
+ val slashErrorMsg = String.format(
+ "Identifier %n%s%ncan't contain slash character (/).%nIf slash is part of identifier name then use %%2F placeholder.", identifier)
throw new ResponseException(NOT_FOUND, slashErrorMsg);
}
*/
package org.opendaylight.controller.sal.restconf.impl.test;
+import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.opendaylight.controller.sal.core.api.mount.MountInstance;
import org.opendaylight.controller.sal.core.api.mount.MountService;
import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
import org.opendaylight.controller.sal.restconf.impl.RestconfImpl;
import org.opendaylight.controller.sal.restconf.impl.SimpleNodeWrapper;
+import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.Node;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import static junit.framework.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
public class RestGetOperationTest extends JerseyTest {
assertEquals(200, get(uri, MediaType.APPLICATION_XML));
}
+ /**
+ * MountPoint test. URI represents mount point.
+ *
+ * Slashes in URI behind mount point. lst1 element with key
+ * GigabitEthernet0%2F0%2F0%2F0 (GigabitEthernet0/0/0/0) is requested via
+ * GET HTTP operation. It is tested whether %2F character is replaced with
+ * simple / in InstanceIdentifier parameter in method
+ * {@link BrokerFacade#readConfigurationDataBehindMountPoint(MountInstance, InstanceIdentifier)}
+ * which is called in method {@link RestconfImpl#readConfigurationData}
+ *
+ *
+ * @throws ParseException
+ */
+ @Test
+ public void getDataWithSlashesBehindMountPoint() throws UnsupportedEncodingException, URISyntaxException,
+ ParseException {
+ InstanceIdentifier awaitedInstanceIdentifier = prepareInstanceIdentifierForList();
+ when(
+ brokerFacade.readConfigurationDataBehindMountPoint(any(MountInstance.class),
+ eq(awaitedInstanceIdentifier))).thenReturn(prepareCnDataForMountPointTest());
+ MountInstance mountInstance = mock(MountInstance.class);
+ when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule);
+ MountService mockMountService = mock(MountService.class);
+ when(mockMountService.getMountPoint(any(InstanceIdentifier.class))).thenReturn(mountInstance);
+
+ ControllerContext.getInstance().setMountService(mockMountService);
+
+ String uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont/lst1/GigabitEthernet0%2F0%2F0%2F0";
+ assertEquals(200, get(uri, MediaType.APPLICATION_XML));
+ }
+
+ private InstanceIdentifier prepareInstanceIdentifierForList() throws URISyntaxException, ParseException {
+ List<PathArgument> parameters = new ArrayList<>();
+
+ Date revision = new SimpleDateFormat("yyyy-MM-dd").parse("2014-01-09");
+ URI uri = new URI("test:module");
+ QName qNameCont = QName.create(uri, revision, "cont");
+ QName qNameList = QName.create(uri, revision, "lst1");
+ QName qNameKeyList = QName.create(uri, revision, "lf11");
+
+ parameters.add(new InstanceIdentifier.NodeIdentifier(qNameCont));
+ parameters.add(new InstanceIdentifier.NodeIdentifierWithPredicates(qNameList, qNameKeyList,
+ "GigabitEthernet0/0/0/0"));
+ return new InstanceIdentifier(parameters);
+ }
+
@Test
public void getDataMountPointIntoHighestElement() throws UnsupportedEncodingException, URISyntaxException {
when(
response = target(uri).request("application/yang.api+xml").get();
validateModulesResponseXml(response);
}
+
// /streams/
@Test
public void getStreamsTest() throws UnsupportedEncodingException, FileNotFoundException {
assertTrue("Module2 in xml wasn't found", prepareXmlRegex("module2", "2014-01-02", "module:2", responseBody)
.find());
String[] split = responseBody.split("<module");
- assertEquals("<module element is returned more then once",2,split.length);
+ assertEquals("<module element is returned more then once", 2, split.length);
response = target(uri).request("application/yang.api+json").get();
assertEquals(200, response.getStatus());
assertTrue("Module2 in json wasn't found", prepareJsonRegex("module2", "2014-01-02", "module:2", responseBody)
.find());
split = responseBody.split("\"module\"");
- assertEquals("\"module\" element is returned more then once",2,split.length);
+ assertEquals("\"module\" element is returned more then once", 2, split.length);
}
prepareJsonRegex("module1-behind-mount-point", "2014-02-03", "module:1:behind:mount:point",
responseBody).find());
String[] split = responseBody.split("\"module\"");
- assertEquals("\"module\" element is returned more then once",2,split.length);
-
+ assertEquals("\"module\" element is returned more then once", 2, split.length);
response = target(uri).request("application/yang.api+xml").get();
assertEquals(200, response.getStatus());
prepareXmlRegex("module1-behind-mount-point", "2014-02-03", "module:1:behind:mount:point", responseBody)
.find());
split = responseBody.split("<module");
- assertEquals("<module element is returned more then once",2,split.length);
-
-
-
+ assertEquals("<module element is returned more then once", 2, split.length);
}
type string;
}
}
- }
+ list lst1 {
+ key "lf11";
+ leaf lf11 {
+ type string;
+ }
+ }
+ }
rpc rpc-test {
</plugins>
<pluginManagement>
<plugins>
- <!--This plugin's configuration is used to store Eclipse
+ <!--This plugin's configuration is used to store Eclipse
m2e settings only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>jersey-core</artifactId>
<version>${jersey.version}</version>
</dependency>
- <!-- <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-servlet</artifactId>
+ <!-- <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-servlet</artifactId>
<version>${jersey.version}</version> </dependency> -->
<dependency>
<groupId>com.sun.jersey</groupId>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-file-adapter</artifactId>
+ <artifactId>config-persister-file-xml-adapter</artifactId>
<version>${config.version}</version>
</dependency>
<dependency>
InstanceIdentifier path = InstanceIdentifier.builder(InventoryUtils.INVENTORY_PATH)
.nodeWithKey(InventoryUtils.INVENTORY_NODE, InventoryUtils.INVENTORY_ID, "foo").toInstance();
-
+
InstanceIdentifier mountPointPath = path;
-
+
/** We retrive a mountpoint **/
MountProvisionInstance mountPoint = mountService.getMountPoint(mountPointPath);
CompositeNode data = mountPoint.readOperationalData(InstanceIdentifier.builder().node(CONFIG_MODULES)
mavenBundle(ODL, "yang-jmx-generator").versionAsInProject(),
mavenBundle(ODL, "logback-config").versionAsInProject(),
mavenBundle(ODL, "config-persister-api").versionAsInProject(),
- // mavenBundle(ODL,"config-persister-file-adapter").versionAsInProject(),
+ // mavenBundle(ODL,"config-persister-file-xml-adapter").versionAsInProject(),
mavenBundle(ODL, "protocol-framework").versionAsInProject(),
mavenBundle(ODL, "netconf-api").versionAsInProject(),
mavenBundle(ODL, "netconf-impl").versionAsInProject(),
netconf.config.persister.1.storageAdapterClass=org.opendaylight.controller.config.persist.storage.directory.xml.XmlDirectoryStorageAdapter
netconf.config.persister.1.properties.fileStorage=configuration/initial/
- netconf.config.persister.2.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.FileStorageAdapter
+ netconf.config.persister.2.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.xml.XmlFileStorageAdapter
netconf.config.persister.2.readonly=true
- netconf.config.persister.2.properties.fileStorage=configuration/current/controller.config.1.txt
+ netconf.config.persister.2.properties.fileStorage=configuration/current/controller.config.1.xml
- netconf.config.persister.3.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.FileStorageAdapter
- netconf.config.persister.3.properties.fileStorage=configuration/current/controller.config.2.txt
+ netconf.config.persister.3.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.xml.XmlFileStorageAdapter
+ netconf.config.persister.3.properties.fileStorage=configuration/current/controller.config.2.xml
netconf.config.persister.3.properties.numberOfBackups=3
</pre>
<artifactId>config-persister-api</artifactId>
<version>${config.version}</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-file-adapter</artifactId>
- <version>${config.version}</version>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netconf-client</artifactId>
/*
- * Copyright IBM Corporation, 2013. All rights reserved.
+ * Copyright IBM Corporation and others, 2013. 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,
@XmlElement (name="tenant_id")
String tenantID;
+ @XmlElement (name="ipv6_address_mode", nillable=true)
+ String ipV6AddressMode;
+
+ @XmlElement (name="ipv6_ra_mode", nillable=true)
+ String ipV6RaMode;
+
/* stores the OpenStackPorts associated with an instance
* used to determine if that instance can be deleted.
*/
this.tenantID = tenantID;
}
+ public String getIpV6AddressMode() { return ipV6AddressMode; }
+
+ public void setIpV6AddressMode(String ipV6AddressMode) { this.ipV6AddressMode = ipV6AddressMode; }
+
+ public String getIpV6RaMode() { return ipV6RaMode; }
+
+ public void setIpV6RaMode(String ipV6RaMode) { this.ipV6RaMode = ipV6RaMode; }
+
/**
* This method copies selected fields from the object and returns them
* as a new object, suitable for marshaling.
if (s.equals("tenant_id")) {
ans.setTenantID(this.getTenantID());
}
+ if (s.equals("ipv6_address_mode")) {
+ ans.setIpV6AddressMode(this.getIpV6AddressMode());
+ }
+ if (s.equals("ipv6_ra_mode")) {
+ ans.setIpV6RaMode(this.getIpV6RaMode());
+ }
}
return ans;
}
+ ", ipVersion=" + ipVersion + ", cidr=" + cidr + ", gatewayIP=" + gatewayIP + ", dnsNameservers="
+ dnsNameservers + ", allocationPools=" + allocationPools + ", hostRoutes=" + hostRoutes
+ ", enableDHCP=" + enableDHCP + ", tenantID=" + tenantID + ", myPorts=" + myPorts
- + ", gatewayIPAssigned=" + gatewayIPAssigned + "]";
+ + ", gatewayIPAssigned=" + gatewayIPAssigned + ", ipv6AddressMode=" + ipV6AddressMode
+ + ", ipv6RaMode=" + ipV6RaMode + "]";
}
}
/*
- * Copyright IBM Corporation, 2013. All rights reserved.
+ * Copyright IBM Corporation and others, 2013. 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,
@QueryParam("gateway_ip") String queryGatewayIP,
@QueryParam("enable_dhcp") String queryEnableDHCP,
@QueryParam("tenant_id") String queryTenantID,
+ @QueryParam("ipv6_address_mode") String queryIpV6AddressMode,
+ @QueryParam("ipv6_ra_mode") String queryIpV6RaMode,
// pagination
@QueryParam("limit") String limit,
@QueryParam("marker") String marker,
(queryCIDR == null || queryCIDR.equals(oSS.getCidr())) &&
(queryGatewayIP == null || queryGatewayIP.equals(oSS.getGatewayIP())) &&
(queryEnableDHCP == null || queryEnableDHCP.equals(oSS.getEnableDHCP())) &&
- (queryTenantID == null || queryTenantID.equals(oSS.getTenantID()))) {
+ (queryTenantID == null || queryTenantID.equals(oSS.getTenantID())) &&
+ (queryIpV6AddressMode == null || queryIpV6AddressMode.equals(oSS.getIpV6AddressMode())) &&
+ (queryIpV6RaMode == null || queryIpV6RaMode.equals(oSS.getIpV6RaMode()))){
if (fields.size() > 0) {
ans.add(extractFields(oSS,fields));
} else {
if (!src.getType().equals(NodeConnector.NodeConnectorIDType.PRODUCTION)) {
if (type == UpdateType.ADDED) {
edgeMap.put(dst, edge);
- } else {
+ } else if (type == UpdateType.REMOVED) {
edgeMap.remove(dst);
}
} else {
*/
if (type == UpdateType.ADDED) {
prodMap.put(dst, edge);
- } else {
+ } else if (type == UpdateType.REMOVED) {
prodMap.remove(dst);
}
}