Device config synchronizer

- initial sketch of Device Config Synchronizer outline (ONOS-6745)

Change-Id: I57c8ab6c3511f12c15e3501aa61498eb18264b27
diff --git a/apps/config/src/main/java/org/onosproject/config/Filter.java b/apps/config/src/main/java/org/onosproject/config/Filter.java
index d37c206..0d332ae 100644
--- a/apps/config/src/main/java/org/onosproject/config/Filter.java
+++ b/apps/config/src/main/java/org/onosproject/config/Filter.java
@@ -84,7 +84,6 @@
      */
     private final int depth;
 
-
     /**
      * Creates a default Filter builder.
      *
diff --git a/apps/configsync-netconf/BUCK b/apps/configsync-netconf/BUCK
new file mode 100644
index 0000000..2fc0e10
--- /dev/null
+++ b/apps/configsync-netconf/BUCK
@@ -0,0 +1,31 @@
+APPS = [
+    'org.onosproject.configsync',
+    'org.onosproject.yang',
+    'org.onosproject.netconf',
+]
+
+COMPILE_DEPS = [
+    '//lib:CORE_DEPS',
+    '//lib:onos-yang-model',
+    '//lib:onos-yang-runtime',
+    '//protocols/netconf/api:onos-protocols-netconf-api',
+    '//apps/config:onos-apps-config',
+    '//apps/configsync:onos-apps-configsync',
+]
+
+TEST_DEPS = [
+    '//lib:TEST_ADAPTERS',
+]
+
+osgi_jar_with_tests (
+    deps = COMPILE_DEPS,
+    test_deps = TEST_DEPS,
+)
+
+onos_app (
+    title = 'Dynamic Configuration Synchronizer for NETCONF',
+    category = 'Utility',
+    url = 'http://onosproject.org',
+    description = 'Application to support the Dynamic configuration service.',
+    required_apps = APPS,
+)
diff --git a/apps/configsync-netconf/pom.xml b/apps/configsync-netconf/pom.xml
new file mode 100644
index 0000000..068d732
--- /dev/null
+++ b/apps/configsync-netconf/pom.xml
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2017 Open Networking Foundation
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<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>onos-apps</artifactId>
+        <groupId>org.onosproject</groupId>
+        <version>1.12.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>onos-apps-configsync-netconf</artifactId>
+    <packaging>bundle</packaging>
+
+    <description>Dynamic Device Config device synchronizer</description>
+    <url>http://onosproject.org</url>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <onos.version>${project.version}</onos.version>
+        <onos.app.origin>ON.Lab</onos.app.origin>
+        <onos.app.requires>org.onosproject.configsync, org.onosproject.yang, org.onosproject.netconf</onos.app.requires>
+        <onos.app.category>Utility</onos.app.category>
+        <onos.app.title>Dynamic Device Config device synchronizer for NETCONF</onos.app.title>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+            </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-yang-model</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-yang-runtime</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-apps-configsync</artifactId>
+            <version>${onos.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-netconf-api</artifactId>
+            <version>${onos.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-cli</artifactId>
+            <version>${onos.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.karaf.shell</groupId>
+            <artifactId>org.apache.karaf.shell.console</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onlab-osgi</artifactId>
+            </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+            <scope>test</scope>
+            <classifier>tests</classifier>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <pluginManagement>
+            <plugins>
+
+                <plugin>
+                    <groupId>org.apache.karaf.tooling</groupId>
+                    <artifactId>karaf-maven-plugin</artifactId>
+                    <version>3.0.5</version>
+                    <extensions>true</extensions>
+                </plugin>
+
+            </plugins>
+        </pluginManagement>
+
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>generate-scr-srcdescriptor</id>
+                        <goals>
+                            <goal>scr</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <supportedProjectTypes>
+                        <supportedProjectType>bundle</supportedProjectType>
+                        <supportedProjectType>war</supportedProjectType>
+                    </supportedProjectTypes>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.onosproject</groupId>
+                <artifactId>onos-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>cfg</id>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>cfg</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>swagger</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>swagger</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>app</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>app</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+
+        </plugins>
+    </build>
+
+</project>
diff --git a/apps/configsync-netconf/src/main/java/org/onosproject/d/config/sync/impl/netconf/NetconfDeviceConfigSynchronizerComponent.java b/apps/configsync-netconf/src/main/java/org/onosproject/d/config/sync/impl/netconf/NetconfDeviceConfigSynchronizerComponent.java
new file mode 100644
index 0000000..ced2b41
--- /dev/null
+++ b/apps/configsync-netconf/src/main/java/org/onosproject/d/config/sync/impl/netconf/NetconfDeviceConfigSynchronizerComponent.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.d.config.sync.impl.netconf;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onosproject.d.config.sync.DeviceConfigSynchronizationProviderRegistry;
+import org.onosproject.d.config.sync.DeviceConfigSynchronizationProviderService;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.provider.ProviderId;
+import org.onosproject.netconf.NetconfController;
+import org.onosproject.yang.model.SchemaContextProvider;
+import org.onosproject.yang.runtime.YangRuntimeService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Main component of Dynamic config synchronizer for NETCONF.
+ * <p>
+ * <ul>
+ * <li> bootstrap Active and Passive synchronization modules
+ * <li> start background anti-entropy mechanism for offline device configuration
+ * </ul>
+ */
+@Component(immediate = true)
+public class NetconfDeviceConfigSynchronizerComponent {
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    /**
+     * NETCONF dynamic config synchronizer provider ID.
+     */
+    public static final ProviderId PID =
+            new ProviderId("netconf", "org.onosproject.d.config.sync.netconf");
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected DeviceConfigSynchronizationProviderRegistry registry;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected NetconfController netconfController;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected YangRuntimeService yangRuntimeService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected SchemaContextProvider schemaContextProvider;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected DeviceService deviceService;
+
+    private NetconfDeviceConfigSynchronizerProvider provider;
+
+    private DeviceConfigSynchronizationProviderService providerService;
+
+
+    @Activate
+    protected void activate() {
+        provider = new NetconfDeviceConfigSynchronizerProvider(PID, new InnerNetconfContext());
+        providerService = registry.register(provider);
+
+        // TODO (Phase 2 or later)
+        //      listen to NETCONF events (new Device appeared, etc.)
+        //      for PASSIVE "state" synchronization upward
+
+        // TODO listen to DeviceEvents (Offline pre-configuration scenario)
+
+        // TODO background anti-entropy mechanism
+
+        log.info("Started");
+    }
+
+    @Deactivate
+    protected void deactivate() {
+        registry.unregister(provider);
+        log.info("Stopped");
+    }
+
+    /**
+     * Context object to provide reference to OSGi services, etc.
+     */
+    @Beta
+    public static interface NetconfContext {
+
+        /**
+         * Returns DeviceConfigSynchronizationProviderService interface.
+         *
+         * @return DeviceConfigSynchronizationProviderService
+         */
+        DeviceConfigSynchronizationProviderService providerService();
+
+        SchemaContextProvider schemaContextProvider();
+
+        YangRuntimeService yangRuntime();
+
+        NetconfController netconfController();
+
+    }
+
+    class InnerNetconfContext implements NetconfContext {
+
+        @Override
+        public NetconfController netconfController() {
+            return netconfController;
+        }
+
+        @Override
+        public YangRuntimeService yangRuntime() {
+            return yangRuntimeService;
+        }
+
+        @Override
+        public SchemaContextProvider schemaContextProvider() {
+            return schemaContextProvider;
+        }
+
+        @Override
+        public DeviceConfigSynchronizationProviderService providerService() {
+            return providerService;
+        }
+    }
+}
diff --git a/apps/configsync-netconf/src/main/java/org/onosproject/d/config/sync/impl/netconf/NetconfDeviceConfigSynchronizerProvider.java b/apps/configsync-netconf/src/main/java/org/onosproject/d/config/sync/impl/netconf/NetconfDeviceConfigSynchronizerProvider.java
new file mode 100644
index 0000000..876cceb
--- /dev/null
+++ b/apps/configsync-netconf/src/main/java/org/onosproject/d/config/sync/impl/netconf/NetconfDeviceConfigSynchronizerProvider.java
@@ -0,0 +1,295 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.d.config.sync.impl.netconf;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.concurrent.CompletableFuture.completedFuture;
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.onlab.util.XmlString;
+import org.onosproject.d.config.ResourceIds;
+import org.onosproject.d.config.sync.DeviceConfigSynchronizationProvider;
+import org.onosproject.d.config.sync.impl.netconf.NetconfDeviceConfigSynchronizerComponent.NetconfContext;
+import org.onosproject.d.config.sync.operation.SetRequest;
+import org.onosproject.d.config.sync.operation.SetRequest.Change;
+import org.onosproject.d.config.sync.operation.SetRequest.Change.Operation;
+import org.onosproject.d.config.sync.operation.SetResponse;
+import org.onosproject.d.config.sync.operation.SetResponse.Code;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.provider.AbstractProvider;
+import org.onosproject.net.provider.ProviderId;
+import org.onosproject.netconf.NetconfDevice;
+import org.onosproject.netconf.NetconfException;
+import org.onosproject.netconf.NetconfSession;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.DefaultResourceData;
+import org.onosproject.yang.model.InnerNode;
+import org.onosproject.yang.model.ResourceData;
+import org.onosproject.yang.model.ResourceId;
+import org.onosproject.yang.runtime.AnnotatedNodeInfo;
+import org.onosproject.yang.runtime.Annotation;
+import org.onosproject.yang.runtime.CompositeStream;
+import org.onosproject.yang.runtime.DefaultAnnotatedNodeInfo;
+import org.onosproject.yang.runtime.DefaultAnnotation;
+import org.onosproject.yang.runtime.DefaultCompositeData;
+import org.onosproject.yang.runtime.DefaultRuntimeContext;
+import org.onosproject.yang.runtime.RuntimeContext;
+import org.slf4j.Logger;
+import com.google.common.io.CharStreams;
+
+/**
+ * Dynamic config synchronizer provider for NETCONF.
+ * <p>
+ * <ul>
+ * <li> Converts POJO YANG into XML.
+ * <li> Adds NETCONF envelope around it.
+ * <li> Send request down to the device over NETCONF
+ * </ul>
+ */
+public class NetconfDeviceConfigSynchronizerProvider
+        extends AbstractProvider
+        implements DeviceConfigSynchronizationProvider {
+
+    private static final Logger log = getLogger(NetconfDeviceConfigSynchronizerProvider.class);
+
+    // TODO this should probably be defined on YRT Serializer side
+    /**
+     * {@link RuntimeContext} parameter Dataformat specifying XML.
+     */
+    private static final String DATAFORMAT_XML = "xml";
+
+    private static final String XMLNS_XC = "xmlns:xc";
+    private static final String NETCONF_1_0_BASE_NAMESPACE =
+                                    "urn:ietf:params:xml:ns:netconf:base:1.0";
+
+    /**
+     * Annotation to add xc namespace declaration.
+     * {@value #XMLNS_XC}={@value #NETCONF_1_0_BASE_NAMESPACE}
+     */
+    private static final DefaultAnnotation XMLNS_XC_ANNOTATION =
+                    new DefaultAnnotation(XMLNS_XC, NETCONF_1_0_BASE_NAMESPACE);
+
+    private static final String XC_OPERATION = "xc:operation";
+
+
+    private NetconfContext context;
+
+    // FIXME remove and let netconf southbound deal with message-id generation
+    private final AtomicInteger messageId = new AtomicInteger(1);
+
+    protected NetconfDeviceConfigSynchronizerProvider(ProviderId id,
+                                                      NetconfContext context) {
+        super(id);
+        this.context = checkNotNull(context);
+    }
+
+    @Override
+    public CompletableFuture<SetResponse> setConfiguration(DeviceId deviceId,
+                                                           SetRequest request) {
+        // sanity check and handle empty change?
+
+        // TODOs:
+        // - Construct convert request object into XML
+        // --  [FutureWork] may need to introduce behaviour for Device specific
+        //     workaround insertion
+
+        StringBuilder rpc = new StringBuilder();
+
+        // - Add NETCONF envelope
+        rpc.append("<rpc xmlns=\"").append(NETCONF_1_0_BASE_NAMESPACE).append("\" ")
+            .append("message-id=\"").append(messageId.getAndIncrement()).append("\">");
+
+        rpc.append("<edit-config>");
+        rpc.append("<target>");
+        // TODO directly writing to running for now
+        rpc.append("<running/>");
+        rpc.append("</target>\n");
+        rpc.append("<config ")
+            .append(XMLNS_XC).append("=\"").append(NETCONF_1_0_BASE_NAMESPACE).append("\">");
+        // TODO netconf SBI should probably be adding these envelopes once
+        // netconf SBI is in better shape
+        // TODO In such case netconf sbi need to define namespace externally visible.
+        // ("xc" in above instance)
+        // to be used to add operations on config tree nodes
+
+
+        // Convert change(s) into a DataNode tree
+        for (Change change : request.changes()) {
+
+            // TODO switch statement can probably be removed
+            switch (change.op()) {
+            case REPLACE:
+            case UPDATE:
+            case DELETE:
+                // convert DataNode -> ResourceData
+                ResourceData data = toResourceData(change);
+
+                // build CompositeData
+                DefaultCompositeData.Builder compositeData =
+                                        DefaultCompositeData.builder();
+
+                // add ResourceData
+                compositeData.resourceData(data);
+
+                // add AnnotatedNodeInfo operation
+                compositeData.addAnnotatedNodeInfo(toAnnotatedNodeInfo(change.op(), change.path()));
+
+                RuntimeContext yrtContext = new DefaultRuntimeContext.Builder()
+                                           .setDataFormat(DATAFORMAT_XML)
+                                           .addAnnotation(XMLNS_XC_ANNOTATION)
+                                           .build();
+                CompositeStream xml = context.yangRuntime().encode(compositeData.build(),
+                                                                   yrtContext);
+                try {
+                    CharStreams.copy(new InputStreamReader(xml.resourceData(), UTF_8), rpc);
+                } catch (IOException e) {
+                    log.error("IOException thrown", e);
+                    // FIXME handle error
+                }
+                break;
+
+            default:
+                log.error("Should never reach here. {}", change);
+                break;
+            }
+        }
+
+        // - close NETCONF envelope
+        // TODO eventually these should be handled by NETCONF SBI side
+        rpc.append('\n');
+        rpc.append("</config>");
+        rpc.append("</edit-config>");
+        rpc.append("</rpc>");
+
+        // - send requests down to the device
+        NetconfSession session = getNetconfSession(deviceId);
+        if (session == null) {
+            log.error("No session available for {}", deviceId);
+            return completedFuture(SetResponse.response(request,
+                                                        Code.FAILED_PRECONDITION,
+                                                        "No session for " + deviceId));
+        }
+        try {
+            // FIXME Netconf async API is currently screwed up, need to fix
+            // NetconfSession, etc.
+            CompletableFuture<String> response = session.request(rpc.toString());
+            log.info("TRACE: request:\n{}", XmlString.prettifyXml(rpc));
+            return response.handle((resp, err) -> {
+                if (err == null) {
+                    log.info("TRACE: reply:\n{}", XmlString.prettifyXml(resp));
+                    // FIXME check response properly
+                    return SetResponse.ok(request);
+                } else {
+                    return SetResponse.response(request, Code.UNKNOWN, err.getMessage());
+                }
+            });
+        } catch (NetconfException e) {
+            // TODO Handle error
+            log.error("NetconfException thrown", e);
+            return completedFuture(SetResponse.response(request, Code.UNKNOWN, e.getMessage()));
+
+        }
+    }
+
+    // overridable for ease of testing
+    /**
+     * Returns a session for the specified deviceId.
+     *
+     * @param deviceId for which we wish to retrieve a session
+     * @return a NetconfSession with the specified node
+     * or null if this node does not have the session to the specified Device.
+     */
+    protected NetconfSession getNetconfSession(DeviceId deviceId) {
+        NetconfDevice device = context.netconfController().getNetconfDevice(deviceId);
+        checkNotNull(device, "The specified deviceId could not be found by the NETCONF controller.");
+        NetconfSession session = device.getSession();
+        checkNotNull(session, "A session could not be retrieved for the specified deviceId.");
+        return session;
+    }
+
+    /**
+     * Creates AnnotatedNodeInfo for {@code node}.
+     *
+     * @param op operation
+     * @param parent resourceId
+     * @param node the node
+     * @return AnnotatedNodeInfo
+     */
+    static AnnotatedNodeInfo annotatedNodeInfo(Operation op,
+                                               ResourceId parent,
+                                               DataNode node) {
+        return DefaultAnnotatedNodeInfo.builder()
+                .resourceId(ResourceIds.resourceId(parent, node))
+                .addAnnotation(toAnnotation(op))
+                .build();
+    }
+
+    /**
+     * Creates AnnotatedNodeInfo for specified resource path.
+     *
+     * @param op operation
+     * @param path resourceId
+     * @return AnnotatedNodeInfo
+     */
+    static AnnotatedNodeInfo toAnnotatedNodeInfo(Operation op,
+                                               ResourceId path) {
+        return DefaultAnnotatedNodeInfo.builder()
+                .resourceId(path)
+                .addAnnotation(toAnnotation(op))
+                .build();
+    }
+
+    /**
+     * Transform DataNode into a ResourceData.
+     *
+     * @param change object
+     * @return ResourceData
+     */
+    static ResourceData toResourceData(Change change) {
+        DefaultResourceData.Builder builder = DefaultResourceData.builder();
+        builder.resourceId(change.path());
+        if (change.op() != Change.Operation.DELETE) {
+            DataNode dataNode = change.val();
+            if (dataNode instanceof InnerNode) {
+                ((InnerNode) dataNode).childNodes().values().forEach(builder::addDataNode);
+            } else {
+                log.error("Unexpected DataNode encountered", change);
+            }
+        }
+
+        return builder.build();
+    }
+
+    static Annotation toAnnotation(Operation op) {
+        switch (op) {
+        case DELETE:
+            return new DefaultAnnotation(XC_OPERATION, "remove");
+        case REPLACE:
+            return new DefaultAnnotation(XC_OPERATION, "replace");
+        case UPDATE:
+            return new DefaultAnnotation(XC_OPERATION, "merge");
+        default:
+            throw new IllegalArgumentException("Unknown operation " + op);
+        }
+    }
+
+}
diff --git a/apps/configsync-netconf/src/main/java/org/onosproject/d/config/sync/impl/netconf/package-info.java b/apps/configsync-netconf/src/main/java/org/onosproject/d/config/sync/impl/netconf/package-info.java
new file mode 100644
index 0000000..bc3c75a
--- /dev/null
+++ b/apps/configsync-netconf/src/main/java/org/onosproject/d/config/sync/impl/netconf/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Implementation of NETCONF dynamic config synchronizer provider.
+ */
+package org.onosproject.d.config.sync.impl.netconf;
diff --git a/apps/configsync-netconf/src/test/java/org/onosproject/d/config/sync/impl/netconf/NetconfDeviceConfigSynchronizerProviderTest.java b/apps/configsync-netconf/src/test/java/org/onosproject/d/config/sync/impl/netconf/NetconfDeviceConfigSynchronizerProviderTest.java
new file mode 100644
index 0000000..1aa3411
--- /dev/null
+++ b/apps/configsync-netconf/src/test/java/org/onosproject/d/config/sync/impl/netconf/NetconfDeviceConfigSynchronizerProviderTest.java
@@ -0,0 +1,379 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.d.config.sync.impl.netconf;
+
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.stringContainsInOrder;
+import static org.junit.Assert.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.function.BiFunction;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.io.input.ReaderInputStream;
+import org.hamcrest.Matchers;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.util.XmlString;
+import org.onosproject.d.config.sync.DeviceConfigSynchronizationProviderService;
+import org.onosproject.d.config.sync.impl.netconf.NetconfDeviceConfigSynchronizerComponent.NetconfContext;
+import org.onosproject.d.config.sync.operation.SetRequest;
+import org.onosproject.d.config.sync.operation.SetResponse;
+import org.onosproject.d.config.sync.operation.SetResponse.Code;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.provider.ProviderId;
+import org.onosproject.netconf.NetconfController;
+import org.onosproject.netconf.NetconfException;
+import org.onosproject.netconf.NetconfSession;
+import org.onosproject.netconf.NetconfSessionAdapter;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.DataNode.Type;
+import org.onosproject.yang.model.InnerNode;
+import org.onosproject.yang.model.LeafNode;
+import org.onosproject.yang.model.ResourceData;
+import org.onosproject.yang.model.ResourceId;
+import org.onosproject.yang.model.SchemaContextProvider;
+import org.onosproject.yang.runtime.AnnotatedNodeInfo;
+import org.onosproject.yang.runtime.CompositeData;
+import org.onosproject.yang.runtime.CompositeStream;
+import org.onosproject.yang.runtime.DefaultAnnotatedNodeInfo;
+import org.onosproject.yang.runtime.DefaultAnnotation;
+import org.onosproject.yang.runtime.DefaultCompositeStream;
+import org.onosproject.yang.runtime.RuntimeContext;
+import org.onosproject.yang.runtime.YangRuntimeService;
+import com.google.common.io.CharSource;
+
+public class NetconfDeviceConfigSynchronizerProviderTest {
+
+    private static final ProviderId PID = new ProviderId("netconf", "test");
+    private static final DeviceId DID = DeviceId.deviceId("netconf:testDevice");
+
+    private static final String XMLNS_XC = "xmlns:xc";
+    private static final String NETCONF_1_0_BASE_NAMESPACE =
+                                    "urn:ietf:params:xml:ns:netconf:base:1.0";
+
+    private static final DefaultAnnotation XC_ANNOTATION =
+            new DefaultAnnotation(XMLNS_XC, NETCONF_1_0_BASE_NAMESPACE);
+
+    private static final DefaultAnnotation AN_XC_REPLACE_OPERATION =
+                        new DefaultAnnotation("xc:operation", "replace");
+
+    private static final DefaultAnnotation AN_XC_REMOVE_OPERATION =
+            new DefaultAnnotation("xc:operation", "remove");
+
+    /**
+     *  Yang namespace for test config data.
+     */
+    private static final String TEST_NS = "testNS";
+
+    private static final ResourceId RID_INTERFACES =
+            ResourceId.builder().addBranchPointSchema("interfaces", TEST_NS).build();
+
+    private NetconfDeviceConfigSynchronizerProvider sut;
+
+    private NetconfContext ncCtx;
+
+
+    // Set following accordingly to suite test scenario
+    NetconfSession testNcSession;
+    YangRuntimeService testYangRuntime;
+
+
+    @Before
+    public void setUp() throws Exception {
+
+        ncCtx = new TestNetconfContext();
+
+        sut = new NetconfDeviceConfigSynchronizerProvider(PID, ncCtx) {
+            // overriding to avoid mocking whole NetconController and all that.
+            @Override
+            protected NetconfSession getNetconfSession(DeviceId deviceId) {
+                assertEquals(DID, deviceId);
+                return testNcSession;
+            }
+        };
+    }
+
+    @Test
+    public void testReplaceOperation() throws Exception {
+        // plug drivers with assertions
+        testYangRuntime = onEncode((data, context) -> {
+            assertEquals("xml", context.getDataFormat());
+            assertThat(context.getProtocolAnnotations(), hasItem(XC_ANNOTATION));
+
+            //  assert CompositeData
+            ResourceData rData = data.resourceData();
+            List<AnnotatedNodeInfo> infos = data.annotatedNodesInfo();
+
+            ResourceId interfacesRid = RID_INTERFACES;
+            AnnotatedNodeInfo intfsAnnot = DefaultAnnotatedNodeInfo.builder()
+                    .resourceId(interfacesRid)
+                    .addAnnotation(AN_XC_REPLACE_OPERATION)
+                    .build();
+            assertThat("interfaces has replace operation", infos, hasItem(intfsAnnot));
+
+            // assertion for ResourceData.
+            assertEquals(RID_INTERFACES, rData.resourceId());
+            assertThat("has 1 child", rData.dataNodes(), hasSize(1));
+            assertThat("which is interface",
+                           rData.dataNodes().get(0).key().schemaId().name(),
+                           is("interface"));
+            // todo: assert the rest of the tree if it make sense.
+
+            // FIXME it's unclear what URI is expected here
+            String id = URI.create("netconf:testDevice").toString();
+
+            String inXml = deviceConfigAsXml("replace");
+
+            return toCompositeStream(id, inXml);
+        });
+        testNcSession = new TestEditNetconfSession();
+
+
+        // building test data
+        ResourceId interfacesId = RID_INTERFACES;
+        DataNode interfaces = deviceConfigNode();
+        SetRequest request = SetRequest.builder()
+                .replace(interfacesId, interfaces)
+                .build();
+
+        // test start
+        CompletableFuture<SetResponse> f = sut.setConfiguration(DID, request);
+        SetResponse response = f.get(5, TimeUnit.MINUTES);
+
+        assertEquals(Code.OK, response.code());
+        assertEquals(request.subjects(), response.subjects());
+    }
+
+
+    @Test
+    public void testDeleteOperation() throws Exception {
+        // plug drivers with assertions
+        testYangRuntime = onEncode((data, context) -> {
+            assertEquals("xml", context.getDataFormat());
+            assertThat(context.getProtocolAnnotations(), hasItem(XC_ANNOTATION));
+
+            //  assert CompositeData
+            ResourceData rData = data.resourceData();
+            List<AnnotatedNodeInfo> infos = data.annotatedNodesInfo();
+
+            ResourceId interfacesRid = RID_INTERFACES;
+            AnnotatedNodeInfo intfsAnnot = DefaultAnnotatedNodeInfo.builder()
+                    .resourceId(interfacesRid)
+                    .addAnnotation(AN_XC_REMOVE_OPERATION)
+                    .build();
+            assertThat("interfaces has replace operation", infos, hasItem(intfsAnnot));
+
+            // assertion for ResourceData.
+            assertEquals(RID_INTERFACES, rData.resourceId());
+            assertThat("has no child", rData.dataNodes(), hasSize(0));
+
+            // FIXME it's unclear what URI is expected here
+            String id = URI.create("netconf:testDevice").toString();
+
+            String inXml = deviceConfigAsXml("remove");
+
+            return toCompositeStream(id, inXml);
+        });
+        testNcSession = new TestEditNetconfSession();
+
+        // building test data
+        ResourceId interfacesId = RID_INTERFACES;
+        SetRequest request = SetRequest.builder()
+                .delete(interfacesId)
+                .build();
+
+        // test start
+        CompletableFuture<SetResponse> f = sut.setConfiguration(DID, request);
+
+        SetResponse response = f.get(5, TimeUnit.MINUTES);
+        assertEquals(Code.OK, response.code());
+        assertEquals(request.subjects(), response.subjects());
+    }
+
+    /**
+     * DataNode for testing.
+     *
+     * <pre>
+     *   +-interfaces
+     *      |
+     *      +- interface{intf-name="en0"}
+     *           |
+     *           +- speed = "10G"
+     *           +- state = "up"
+     *
+     * </pre>
+     * @return DataNode
+     */
+    private DataNode deviceConfigNode() {
+        InnerNode.Builder intfs = InnerNode.builder("interfaces", TEST_NS);
+        intfs.type(Type.SINGLE_INSTANCE_NODE);
+        InnerNode.Builder intf = intfs.createChildBuilder("interface", TEST_NS);
+        intf.type(Type.SINGLE_INSTANCE_LEAF_VALUE_NODE);
+        intf.addKeyLeaf("name", TEST_NS, "Ethernet0/0");
+        LeafNode.Builder speed = intf.createChildBuilder("mtu", TEST_NS, "1500");
+        speed.type(Type.SINGLE_INSTANCE_LEAF_VALUE_NODE);
+
+        intf.addNode(speed.build());
+        intfs.addNode(intf.build());
+        return intfs.build();
+    }
+
+    /**
+     * {@link #deviceConfigNode()} as XML.
+     *
+     * @param operation xc:operation value on {@code interfaces} node
+     * @return XML
+     */
+    private String deviceConfigAsXml(String operation) {
+        return  "<interfaces xmlns=\"http://example.com/schema/1.2/config\""
+                + " xc:operation=\"" + operation + "\">\n" +
+                "  <interface>\n" +
+                "    <name>Ethernet0/0</name>\n" +
+                "    <mtu>1500</mtu>\n" +
+                "  </interface>\n" +
+                "</interfaces>";
+    }
+
+    private String rpcReplyOk(int messageid) {
+        return "<rpc-reply message-id=\"" + messageid + "\"\n" +
+               "      xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+               "   <ok/>\n" +
+               "</rpc-reply>";
+    }
+
+    private int fetchMessageId(String request) {
+        int messageid;
+        Pattern msgId = Pattern.compile("message-id=['\"]([0-9]+)['\"]");
+        Matcher matcher = msgId.matcher(request);
+        if (matcher.find()) {
+            messageid = Integer.parseInt(matcher.group(1));
+        } else {
+            messageid = -1;
+        }
+        return messageid;
+    }
+
+
+    protected CompositeStream toCompositeStream(String id, String inXml) {
+        try {
+            InputStream xml = new ReaderInputStream(
+                         CharSource.wrap(inXml)
+                             .openStream());
+
+            return new DefaultCompositeStream(id, xml);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * Asserts that it received edit-config message and reply Ok.
+     */
+    private class TestEditNetconfSession extends NetconfSessionAdapter {
+        @Override
+        public CompletableFuture<String> request(String request)
+                throws NetconfException {
+            System.out.println("TestEditNetconfSession received:");
+            System.out.println(XmlString.prettifyXml(request));
+
+            // Extremely naive request rpc message check
+            assertThat(request, stringContainsInOrder(Arrays.asList(
+                                  "<rpc",
+                                  "<edit-config",
+                                  "<target",
+                                  "<config",
+
+                                  "</config>",
+                                  "</edit-config>",
+                                  "</rpc>")));
+
+            assertThat("XML namespace decl exists",
+                       request, Matchers.containsString("xmlns:xc"));
+
+            assertThat("netconf operation exists",
+                       request, Matchers.containsString("xc:operation"));
+
+            return CompletableFuture.completedFuture(rpcReplyOk(fetchMessageId(request)));
+        }
+    }
+
+    /**
+     * Creates mock YangRuntimeService.
+     *
+     * @param body to execute when {@link YangRuntimeService#encode(CompositeData, RuntimeContext)} was called.
+     * @return YangRuntimeService instance
+     */
+    TestYangRuntimeService onEncode(BiFunction<CompositeData, RuntimeContext, CompositeStream> body) {
+        return new TestYangRuntimeService() {
+            @Override
+            public CompositeStream encode(CompositeData internal,
+                                          RuntimeContext context) {
+                return body.apply(internal, context);
+            }
+        };
+    }
+
+    private abstract class TestYangRuntimeService implements YangRuntimeService {
+
+        @Override
+        public CompositeStream encode(CompositeData internal,
+                                      RuntimeContext context) {
+            fail("stub not implemented");
+            return null;
+        }
+        @Override
+        public CompositeData decode(CompositeStream external,
+                                    RuntimeContext context) {
+            fail("stub not implemented");
+            return null;
+        }
+    }
+
+    private final class TestNetconfContext implements NetconfContext {
+        @Override
+        public DeviceConfigSynchronizationProviderService providerService() {
+            fail("Add stub driver as necessary");
+            return null;
+        }
+
+        @Override
+        public SchemaContextProvider schemaContextProvider() {
+            fail("Add stub driver as necessary");
+            return null;
+        }
+
+        @Override
+        public YangRuntimeService yangRuntime() {
+            return testYangRuntime;
+        }
+
+        @Override
+        public NetconfController netconfController() {
+            fail("Add stub driver as necessary");
+            return null;
+        }
+    }
+
+}
diff --git a/apps/configsync/BUCK b/apps/configsync/BUCK
new file mode 100644
index 0000000..aa9caf1
--- /dev/null
+++ b/apps/configsync/BUCK
@@ -0,0 +1,22 @@
+APPS = [
+    # dynamic config
+    'org.onosproject.config',
+]
+
+COMPILE_DEPS = [
+    '//lib:CORE_DEPS',
+    '//apps/config:onos-apps-config',
+    '//lib:onos-yang-model',
+]
+
+osgi_jar_with_tests (
+    deps = COMPILE_DEPS,
+)
+
+onos_app (
+    title = 'Dynamic Configuration Synchronizer',
+    category = 'Utility',
+    url = 'http://onosproject.org',
+    description = 'Application to support the Dynamic configuration service.',
+    required_apps = APPS,
+)
diff --git a/apps/configsync/pom.xml b/apps/configsync/pom.xml
new file mode 100644
index 0000000..6d42e95
--- /dev/null
+++ b/apps/configsync/pom.xml
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2017 Open Networking Foundation
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<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>onos-apps</artifactId>
+        <groupId>org.onosproject</groupId>
+        <version>1.12.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>onos-apps-configsync</artifactId>
+    <packaging>bundle</packaging>
+
+    <description>Dynamic Device Config device synchronizer</description>
+    <url>http://onosproject.org</url>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <onos.version>${project.version}</onos.version>
+        <onos.app.origin>ON.Lab</onos.app.origin>
+        <onos.app.requires>org.onosproject.config</onos.app.requires>
+        <onos.app.category>Utility</onos.app.category>
+        <onos.app.title>Dynamic Device Config device synchronizer</onos.app.title>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-yang-model</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-yang-runtime</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-apps-config</artifactId>
+            <version>${onos.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-cli</artifactId>
+            <version>${onos.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.karaf.shell</groupId>
+            <artifactId>org.apache.karaf.shell.console</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onlab-osgi</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+            <scope>test</scope>
+            <classifier>tests</classifier>
+        </dependency>
+
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava-testlib</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <pluginManagement>
+            <plugins>
+
+                <plugin>
+                    <groupId>org.apache.karaf.tooling</groupId>
+                    <artifactId>karaf-maven-plugin</artifactId>
+                    <version>3.0.5</version>
+                    <extensions>true</extensions>
+                </plugin>
+
+            </plugins>
+        </pluginManagement>
+
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>generate-scr-srcdescriptor</id>
+                        <goals>
+                            <goal>scr</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <supportedProjectTypes>
+                        <supportedProjectType>bundle</supportedProjectType>
+                        <supportedProjectType>war</supportedProjectType>
+                    </supportedProjectTypes>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.onosproject</groupId>
+                <artifactId>onos-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>cfg</id>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>cfg</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>swagger</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>swagger</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>app</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>app</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+
+        </plugins>
+    </build>
+
+</project>
diff --git a/apps/configsync/src/main/java/org/onosproject/d/config/sync/DeviceConfigSynchronizationProvider.java b/apps/configsync/src/main/java/org/onosproject/d/config/sync/DeviceConfigSynchronizationProvider.java
new file mode 100644
index 0000000..eed008f
--- /dev/null
+++ b/apps/configsync/src/main/java/org/onosproject/d/config/sync/DeviceConfigSynchronizationProvider.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.d.config.sync;
+
+import java.util.concurrent.CompletableFuture;
+
+import org.onosproject.d.config.sync.operation.SetRequest;
+import org.onosproject.d.config.sync.operation.SetResponse;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.provider.Provider;
+
+import com.google.common.annotations.Beta;
+
+// TODO might want to remove Device~ prefix, class name too long.
+/**
+ * Abstraction of a device config synchronization provider.
+ * <p>
+ * Provides a mean for propagating dynamic config triggered change down to
+ * the device.
+ */
+@Beta
+public interface DeviceConfigSynchronizationProvider extends Provider {
+
+    // TODO API to propagate dynamic config subsystem side change down to the
+    // device
+
+    /**
+     * Requests a device to set configuration as specified.
+     *
+     * @param deviceId target Device identifier
+     * @param request configuration requests
+     * @return result
+     */
+    CompletableFuture<SetResponse> setConfiguration(DeviceId deviceId, SetRequest request);
+
+    // TODO API for Get from Device
+    // CompletableFuture<GetResponse> getConfiguration(DeviceId deviceId, GetRequest request);
+
+}
diff --git a/apps/configsync/src/main/java/org/onosproject/d/config/sync/DeviceConfigSynchronizationProviderRegistry.java b/apps/configsync/src/main/java/org/onosproject/d/config/sync/DeviceConfigSynchronizationProviderRegistry.java
new file mode 100644
index 0000000..edf1eba
--- /dev/null
+++ b/apps/configsync/src/main/java/org/onosproject/d/config/sync/DeviceConfigSynchronizationProviderRegistry.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.d.config.sync;
+
+import org.onosproject.net.provider.ProviderRegistry;
+
+/**
+ * Abstraction of a device config synchronization provider registry.
+ */
+public interface DeviceConfigSynchronizationProviderRegistry
+        extends ProviderRegistry<DeviceConfigSynchronizationProvider,
+                                 DeviceConfigSynchronizationProviderService> {
+
+}
diff --git a/apps/configsync/src/main/java/org/onosproject/d/config/sync/DeviceConfigSynchronizationProviderService.java b/apps/configsync/src/main/java/org/onosproject/d/config/sync/DeviceConfigSynchronizationProviderService.java
new file mode 100644
index 0000000..8fa0ee3
--- /dev/null
+++ b/apps/configsync/src/main/java/org/onosproject/d/config/sync/DeviceConfigSynchronizationProviderService.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.d.config.sync;
+
+import org.onosproject.net.provider.ProviderService;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Service which configuration synchronization provider can interact
+ * with the service.
+ * <p>
+ * Provides a mean to propagate device triggered change event upward to
+ * dynamic config subsystem.
+ */
+@Beta
+public interface DeviceConfigSynchronizationProviderService
+    extends ProviderService<DeviceConfigSynchronizationProvider> {
+
+    // TODO API to propagate device detected change upwards
+    // e.g., in reaction to NETCONF async notification,
+    //       report polling result up to DynConfig subsystem
+}
diff --git a/apps/configsync/src/main/java/org/onosproject/d/config/sync/impl/DynamicDeviceConfigSynchronizer.java b/apps/configsync/src/main/java/org/onosproject/d/config/sync/impl/DynamicDeviceConfigSynchronizer.java
new file mode 100644
index 0000000..e0067d6
--- /dev/null
+++ b/apps/configsync/src/main/java/org/onosproject/d/config/sync/impl/DynamicDeviceConfigSynchronizer.java
@@ -0,0 +1,381 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.d.config.sync.impl;
+
+import static java.util.concurrent.CompletableFuture.completedFuture;
+import static org.onosproject.d.config.DeviceResourceIds.isUnderDeviceRootNode;
+import static org.onosproject.d.config.DeviceResourceIds.toDeviceId;
+import static org.onosproject.d.config.DeviceResourceIds.toResourceId;
+import static org.onosproject.d.config.sync.operation.SetResponse.response;
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.Service;
+import org.onlab.util.Tools;
+import org.onosproject.config.DynamicConfigEvent;
+import org.onosproject.config.DynamicConfigEvent.Type;
+import org.onosproject.config.DynamicConfigListener;
+import org.onosproject.config.DynamicConfigService;
+import org.onosproject.config.Filter;
+import org.onosproject.d.config.DataNodes;
+import org.onosproject.d.config.DeviceResourceIds;
+import org.onosproject.d.config.ResourceIds;
+import org.onosproject.d.config.sync.DeviceConfigSynchronizationProvider;
+import org.onosproject.d.config.sync.DeviceConfigSynchronizationProviderRegistry;
+import org.onosproject.d.config.sync.DeviceConfigSynchronizationProviderService;
+import org.onosproject.d.config.sync.operation.SetRequest;
+import org.onosproject.d.config.sync.operation.SetResponse;
+import org.onosproject.d.config.sync.operation.SetResponse.Code;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.config.NetworkConfigService;
+import org.onosproject.net.provider.AbstractProviderRegistry;
+import org.onosproject.net.provider.AbstractProviderService;
+import org.onosproject.store.primitives.TransactionId;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.ResourceId;
+import org.slf4j.Logger;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Component to bridge Dynamic Config store and the Device configuration state.
+ * <p>
+ * <ul>
+ * <li> Propagate DynamicConfig service change downward to Device side via provider.
+ * <li> Propagate Device triggered change event upward to DyamicConfig service.
+ * </ul>
+ */
+@Beta
+@Component(immediate = true)
+@Service
+public class DynamicDeviceConfigSynchronizer
+    extends AbstractProviderRegistry<DeviceConfigSynchronizationProvider,
+                                     DeviceConfigSynchronizationProviderService>
+    implements DeviceConfigSynchronizationProviderRegistry {
+
+    private static final Logger log = getLogger(DynamicDeviceConfigSynchronizer.class);
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected DynamicConfigService dynConfigService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected NetworkConfigService netcfgService;
+
+    private DynamicConfigListener listener = new InnerDyConListener();
+
+    @Activate
+    public void activate() {
+        // TODO start background task to sync Controller and Device?
+        dynConfigService.addListener(listener);
+        log.info("Started");
+    }
+
+    @Deactivate
+    public void deactivate() {
+        dynConfigService.removeListener(listener);
+        log.info("Stopped");
+    }
+
+
+    @Override
+    protected DeviceConfigSynchronizationProviderService createProviderService(
+                                 DeviceConfigSynchronizationProvider provider) {
+        return new InternalConfigSynchronizationServiceProvider(provider);
+    }
+
+    @Override
+    protected DeviceConfigSynchronizationProvider defaultProvider() {
+        // TODO return provider instance which can deal with "general" provider?
+        return super.defaultProvider();
+    }
+
+    /**
+     * Proxy to relay Device change event for propagating running "state"
+     * information up to dynamic configuration service.
+     */
+    class InternalConfigSynchronizationServiceProvider
+        extends AbstractProviderService<DeviceConfigSynchronizationProvider>
+        implements DeviceConfigSynchronizationProviderService {
+
+        protected InternalConfigSynchronizationServiceProvider(DeviceConfigSynchronizationProvider provider) {
+            super(provider);
+        }
+
+        // TODO API for passive information propagation to be added later on
+    }
+
+    /**
+     * DynamicConfigListener to trigger active synchronization toward the device.
+     */
+    class InnerDyConListener implements DynamicConfigListener {
+
+        @Override
+        public boolean isRelevant(DynamicConfigEvent event) {
+            // TODO NetconfActiveComponent.isRelevant(DynamicConfigEvent)
+            // seems to be doing some filtering
+            // Logic filtering for L3VPN is probably a demo hack,
+            // but is there any portion of it which is really needed?
+            // e.g., listen only for device tree events?
+
+            ResourceId path = event.subject();
+            // TODO only device tree related event is relevant.
+            // 1) path is under device tree
+            // 2) path is root, and DataNode contains element under node
+            // ...
+            return true;
+        }
+
+        @Override
+        public void event(DynamicConfigEvent event) {
+            // Note: removed accumulator in the old code assuming,
+            // event accumulation will happen on Device Config Event level.
+
+            // TODO execute off event dispatch thread
+            processEventNonBatch(event);
+        }
+
+    }
+
+    void processEventNonBatch(DynamicConfigEvent event) {
+        ResourceId path = event.subject();
+        if (isUnderDeviceRootNode(path)) {
+
+            DeviceId deviceId = DeviceResourceIds.toDeviceId(path);
+            ResourceId deviceRootPath = DeviceResourceIds.toResourceId(deviceId);
+
+            ResourceId relPath = ResourceIds.relativize(deviceRootPath, path);
+            // FIXME figure out how to express give me everything Filter
+            Filter giveMeEverything = Filter.builder().build();
+
+            DataNode node = dynConfigService.readNode(path, giveMeEverything);
+            SetRequest request;
+            switch (event.type()) {
+
+            case NODE_ADDED:
+            case NODE_REPLACED:
+                request = SetRequest.builder().replace(relPath, node).build();
+            case NODE_UPDATED:
+                // Event has no pay load, only thing we can do is replace.
+                request = SetRequest.builder().replace(relPath, node).build();
+                break;
+            case NODE_DELETED:
+                request = SetRequest.builder().delete(relPath).build();
+                break;
+            case UNKNOWN_OPRN:
+            default:
+                log.error("Unexpected event {}, aborting", event);
+                return;
+            }
+
+            log.info("Dispatching {} request {}", deviceId, request);
+            CompletableFuture<SetResponse> response = dispatchRequest(deviceId, request);
+            response.whenComplete((resp, e) -> {
+                if (e == null) {
+                    if (resp.code() == Code.OK) {
+                        log.info("{} for {} complete", resp, deviceId);
+                    } else {
+                        log.warn("{} for {} had problem", resp, deviceId);
+                    }
+                } else {
+                    log.error("Request to {} failed {}", deviceId, response, e);
+                }
+            });
+        }
+    }
+
+
+    // was sketch to handle case, where event could contain batch of things...
+    private void processEvent(DynamicConfigEvent event) {
+        // TODO assuming event object will contain batch of (atomic) change event
+
+        // What the new event will contain:
+        Type evtType = event.type();
+
+        // Transaction ID, can be null
+        TransactionId txId = null;
+
+        // TODO this might change into collection of (path, val_before, val_after)
+
+        ResourceId path = event.subject();
+        // data node (can be tree) representing change, it could be incremental update
+        DataNode val = null;
+
+        // build per-Device SetRequest
+        // val could be a tree, containing multiple Device tree,
+        // break them down into per-Device sub-tree
+        Map<DeviceId, SetRequest.Builder> requests = new HashMap<>();
+
+        if (isUnderDeviceRootNode(path)) {
+            // about single device
+            buildDeviceRequest(requests, evtType, path, toDeviceId(path), val);
+
+        } else if (DeviceResourceIds.isRootOrDevicesNode(path)) {
+            //  => potentially contain changes spanning multiple Devices
+            Map<DeviceId, DataNode> perDevices = perDevices(path, val);
+
+            perDevices.forEach((did, dataNode) -> {
+                buildDeviceRequest(requests, evtType, toResourceId(did), did, dataNode);
+            });
+
+            // TODO special care is probably required for delete cases
+            // especially delete all under devices
+
+        } else {
+            log.warn("Event not related to a Device?");
+        }
+
+
+        // TODO assuming event is a batch,
+        // potentially containing changes for multiple devices,
+        // who will process/coordinate the batch event?
+
+
+        // TODO loop through per-Device change set
+        List<CompletableFuture<SetResponse>> responses =
+                requests.entrySet().stream()
+                .map(entry -> dispatchRequest(entry.getKey(), entry.getValue().build()))
+                .collect(Collectors.toList());
+
+        // wait for all responses
+        List<SetResponse> allResults = Tools.allOf(responses).join();
+        // TODO deal with partial failure case (multi-device coordination)
+        log.info("DEBUG: results: {}", allResults);
+    }
+
+    // might make sense to make this public
+    CompletableFuture<SetResponse> dispatchRequest(DeviceId devId, SetRequest req) {
+
+        // determine appropriate provider for this Device
+        DeviceConfigSynchronizationProvider provider = this.getProvider(devId);
+
+        if (provider == null) {
+            // no appropriate provider found
+            // return completed future with failed SetResponse
+            return completedFuture(response(req,
+                                            SetResponse.Code.FAILED_PRECONDITION,
+                                            "no provider found for " + devId));
+        }
+
+        // dispatch request
+        return provider.setConfiguration(devId, req)
+                .handle((resp, err) -> {
+                    if (err == null) {
+                        // set complete
+                        log.info("DEBUG: Req:{}, Resp:{}", req, resp);
+                        return resp;
+                    } else {
+                        // fatal error
+                        log.error("Fatal error on {}", req, err);
+                        return response(req,
+                                        SetResponse.Code.UNKNOWN,
+                                        "Unknown error " + err);
+                    }
+                });
+    }
+
+
+    // may eventually reuse with batch event
+    /**
+     * Build device request about a Device.
+     *
+     * @param requests map containing request builder to populate
+     * @param evtType change request type
+     * @param path to {@code val}
+     * @param did DeviceId which {@code path} is about
+     * @param val changed node to write
+     */
+    private void buildDeviceRequest(Map<DeviceId, SetRequest.Builder> requests,
+                            Type evtType,
+                            ResourceId path,
+                            DeviceId did,
+                            DataNode val) {
+
+        SetRequest.Builder request =
+                requests.computeIfAbsent(did, d -> SetRequest.builder());
+
+        switch (evtType) {
+        case NODE_ADDED:
+        case NODE_REPLACED:
+            request.replace(path, val);
+            break;
+
+        case NODE_UPDATED:
+            // TODO Auto-generated method stub
+            request.update(path, val);
+            break;
+
+        case NODE_DELETED:
+            // TODO Auto-generated method stub
+            request.delete(path);
+            break;
+
+        case UNKNOWN_OPRN:
+        default:
+            log.warn("Ignoring unexpected {}", evtType);
+            break;
+        }
+    }
+
+    /**
+     * Breaks down tree {@code val} into per Device subtree.
+     *
+     * @param path pointing to {@code val}
+     * @param val tree which contains only 1 Device.
+     * @return Device node relative DataNode for each DeviceId
+     * @throws IllegalArgumentException
+     */
+    private static Map<DeviceId, DataNode> perDevices(ResourceId path, DataNode val) {
+        if (DeviceResourceIds.isUnderDeviceRootNode(path)) {
+            // - if path is device root or it's subtree, path alone is sufficient
+            return ImmutableMap.of(DeviceResourceIds.toDeviceId(path), val);
+
+        } else if (DeviceResourceIds.isRootOrDevicesNode(path)) {
+            // - if path is "/" or devices, it might be constructible from val tree
+            final Collection<DataNode> devicesChildren;
+            if (DeviceResourceIds.isRootNode(path)) {
+                // root
+                devicesChildren = DataNodes.childOnlyByName(val, DeviceResourceIds.DEVICES_NAME)
+                            .map(dn -> DataNodes.children(dn))
+                            .orElse(ImmutableList.of());
+            } else {
+                // devices
+                devicesChildren = DataNodes.children(val);
+            }
+
+            return devicesChildren.stream()
+                    // TODO use full schemaId for filtering when ready
+                    .filter(dn -> dn.key().schemaId().name().equals(DeviceResourceIds.DEVICE_NAME))
+                    .collect(Collectors.toMap(dn -> DeviceResourceIds.toDeviceId(dn.key()),
+                                              dn -> dn));
+
+        }
+        throw new IllegalArgumentException(path + " not related to Device");
+    }
+
+}
diff --git a/apps/configsync/src/main/java/org/onosproject/d/config/sync/impl/package-info.java b/apps/configsync/src/main/java/org/onosproject/d/config/sync/impl/package-info.java
new file mode 100644
index 0000000..23fa201
--- /dev/null
+++ b/apps/configsync/src/main/java/org/onosproject/d/config/sync/impl/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Implementation of dynamic config synchronizer.
+ */
+package org.onosproject.d.config.sync.impl;
diff --git a/apps/configsync/src/main/java/org/onosproject/d/config/sync/operation/SetRequest.java b/apps/configsync/src/main/java/org/onosproject/d/config/sync/operation/SetRequest.java
new file mode 100644
index 0000000..d4d3254
--- /dev/null
+++ b/apps/configsync/src/main/java/org/onosproject/d/config/sync/operation/SetRequest.java
@@ -0,0 +1,240 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.d.config.sync.operation;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Objects;
+import java.util.Optional;
+
+import org.apache.commons.lang3.tuple.Pair;
+import org.onosproject.d.config.sync.operation.SetRequest.Change.Operation;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.ResourceId;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableList;
+
+// One SetRequest is expected to be a transaction, all-or-nothing
+/**
+ * Collection of changes about a single Device,
+ * intended to be applied to the Device transactionally.
+ */
+@Beta
+public final class SetRequest {
+
+    private final Collection<Change> changes;
+
+    SetRequest(Collection<Change> changes) {
+        this.changes = ImmutableList.copyOf(changes);
+    }
+
+    public Collection<Change> changes() {
+        return changes;
+    }
+
+    public Collection<Pair<Operation, ResourceId>> subjects() {
+        return changes.stream()
+                    .map(c -> Pair.of(c.op(), c.path()))
+                    .collect(ImmutableList.toImmutableList());
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof SetRequest) {
+            SetRequest that = (SetRequest) obj;
+            return Objects.equals(this.changes, that.changes);
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(changes);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .add("changes", changes)
+                .toString();
+    }
+    public static SetRequest.Builder builder() {
+        return new Builder();
+    }
+
+    public static class Builder {
+        private final List<Change> changes = new ArrayList<>();
+
+        /**
+         * Returns changes contained in this builder.
+         *
+         * @return unmodifiable list view of Changes
+         */
+        public List<Change> changes() {
+            return Collections.unmodifiableList(changes);
+        }
+
+        /**
+         * Adds request to remove specified {@code path}.
+         *
+         * @param path resource path relative to device root node
+         * @return self
+         */
+        public SetRequest.Builder delete(ResourceId path) {
+            changes.add(Change.delete(path));
+            return this;
+        }
+
+        /**
+         * Adds request to replace specified {@code path} with specified {@code val}.
+         *
+         * @param path resource path relative to device root node
+         * @param val  resource value
+         * @return self
+         */
+        public SetRequest.Builder replace(ResourceId path, DataNode val) {
+            changes.add(Change.replace(path, val));
+            return this;
+        }
+
+        /**
+         * Adds request to update/merge specified {@code val} to the {@code path}.
+         *
+         * @param path resource path relative to device root node
+         * @param val  resource value
+         * @return self
+         */
+        public SetRequest.Builder update(ResourceId path, DataNode val) {
+            changes.add(Change.update(path, val));
+            return this;
+        }
+
+        public SetRequest build() {
+            return new SetRequest(changes);
+        }
+    }
+
+    public static final class Change {
+
+        public enum Operation {
+
+            // Note: equivalent to remove in netconf
+            /**
+             * Request to delete specified {@code path}.
+             * If path does not exist, it is silently ignored.
+             */
+            DELETE,
+            // Note: equivalent to replace in netconf
+            /**
+             * Request to replace specified {@code path} with specified {@code val}.
+             */
+            REPLACE,
+            // Note: equivalent to merge in netconf
+            /**
+             * Request to update/merge specified {@code val} to the {@code path}.
+             */
+            UPDATE
+        }
+
+        private final Operation op;
+        private final ResourceId path;
+        private final Optional<DataNode> val;
+
+        public static Change delete(ResourceId path) {
+            return new Change(Operation.DELETE, path, Optional.empty());
+        }
+
+        public static Change replace(ResourceId path, DataNode val) {
+            return new Change(Operation.REPLACE, path, Optional.of(val));
+        }
+
+        public static Change update(ResourceId path, DataNode val) {
+            return new Change(Operation.UPDATE, path, Optional.of(val));
+        }
+
+        Change(Operation op, ResourceId path, Optional<DataNode> val) {
+            this.op = checkNotNull(op);
+            this.path = checkNotNull(path);
+            this.val = checkNotNull(val);
+        }
+
+        /**
+         * Returns type of change operation.
+         *
+         * @return Operation
+         */
+        public Operation op() {
+            return op;
+        }
+
+        /**
+         * Returns resource path to be changed.
+         *
+         * @return resource path relative to device root node
+         */
+        public ResourceId path() {
+            return path;
+        }
+
+        /**
+         * Returns the {@code val} specified.
+         *
+         * @return {@code val}
+         * @throws NoSuchElementException if this object represent {@code DELETE} op.
+         */
+        public DataNode val() {
+            return val.get();
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj instanceof Change) {
+                Change that = (Change) obj;
+                return Objects.equals(this.op, that.op) &&
+                       Objects.equals(this.path, that.path) &&
+                       Objects.equals(this.val, that.val);
+            }
+            return false;
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hash(op, path, val);
+        }
+
+        @Override
+        public String toString() {
+            return MoreObjects.toStringHelper(getClass())
+                    .add("op", op)
+                    .add("path", path)
+                    .add("val", val)
+                    .toString();
+        }
+    }
+}
\ No newline at end of file
diff --git a/apps/configsync/src/main/java/org/onosproject/d/config/sync/operation/SetResponse.java b/apps/configsync/src/main/java/org/onosproject/d/config/sync/operation/SetResponse.java
new file mode 100644
index 0000000..0bc9502
--- /dev/null
+++ b/apps/configsync/src/main/java/org/onosproject/d/config/sync/operation/SetResponse.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.d.config.sync.operation;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Collection;
+import java.util.Objects;
+
+import org.apache.commons.lang3.tuple.Pair;
+import org.onosproject.d.config.sync.operation.SetRequest.Change.Operation;
+import org.onosproject.yang.model.ResourceId;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableList;
+
+
+@Beta
+public final class SetResponse {
+
+    // partially borrowed from io.grpc.Status.Code,
+    // might want to borrow all of them
+    public enum Code {
+        OK,
+        CANCELLED,
+
+        UNKNOWN,
+
+        INVALID_ARGUMENT,
+
+        NOT_FOUND,
+        ALREADY_EXISTS,
+
+        FAILED_PRECONDITION,
+        ABORTED,
+        UNAVAILABLE,
+    }
+
+    private final Collection<Pair<Operation, ResourceId>> subjects;
+
+    private final SetResponse.Code code;
+
+    // human readable error message for logging purpose
+    private final String message;
+
+    SetResponse(Collection<Pair<Operation, ResourceId>> subjects,
+                SetResponse.Code code,
+                String message) {
+        this.subjects = ImmutableList.copyOf(subjects);
+        this.code = checkNotNull(code);
+        this.message = checkNotNull(message);
+    }
+
+    public Collection<Pair<Operation, ResourceId>> subjects() {
+        return subjects;
+    }
+
+    public Code code() {
+        return code;
+    }
+
+    public String message() {
+        return message;
+    }
+
+
+    /**
+     * Creates SetResponse instance from request.
+     *
+     * @param request original request this response corresponds to
+     * @param code response status code
+     * @param message human readable error message for logging purpose.
+     *        can be left empty string on OK response.
+     * @return SetResponse instance
+     */
+    public static SetResponse response(SetRequest request,
+                                       Code code,
+                                       String message) {
+        return new SetResponse(request.subjects(), code, checkNotNull(message));
+    }
+
+    /**
+     * Creates successful SetResponce instance from request.
+     *
+     * @param request original request this response corresponds to
+     * @return SetResponse instance
+     */
+    public static SetResponse ok(SetRequest request) {
+        return new SetResponse(request.subjects(), Code.OK, "");
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(subjects, code, message);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof SetResponse) {
+            SetResponse that = (SetResponse) obj;
+            return Objects.equals(this.subjects, that.subjects) &&
+                    Objects.equals(this.code, that.code) &&
+                    Objects.equals(this.message, that.message);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .add("code", code)
+                .add("subjects", subjects)
+                .add("message", message)
+                .toString();
+    }
+
+
+
+}
\ No newline at end of file
diff --git a/apps/configsync/src/main/java/org/onosproject/d/config/sync/operation/package-info.java b/apps/configsync/src/main/java/org/onosproject/d/config/sync/operation/package-info.java
new file mode 100644
index 0000000..d7612e9
--- /dev/null
+++ b/apps/configsync/src/main/java/org/onosproject/d/config/sync/operation/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Dynamic config synchronizer API related value objects.
+ */
+package org.onosproject.d.config.sync.operation;
diff --git a/apps/configsync/src/main/java/org/onosproject/d/config/sync/package-info.java b/apps/configsync/src/main/java/org/onosproject/d/config/sync/package-info.java
new file mode 100644
index 0000000..8da2769
--- /dev/null
+++ b/apps/configsync/src/main/java/org/onosproject/d/config/sync/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Dynamic config synchronizer API.
+ */
+package org.onosproject.d.config.sync;
diff --git a/apps/configsync/src/test/java/org/onosproject/d/config/sync/impl/DynamicDeviceConfigSynchronizerTest.java b/apps/configsync/src/test/java/org/onosproject/d/config/sync/impl/DynamicDeviceConfigSynchronizerTest.java
new file mode 100644
index 0000000..78812fb
--- /dev/null
+++ b/apps/configsync/src/test/java/org/onosproject/d/config/sync/impl/DynamicDeviceConfigSynchronizerTest.java
@@ -0,0 +1,178 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.d.config.sync.impl;
+
+import static org.junit.Assert.*;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.function.BiFunction;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.config.DynamicConfigEvent;
+import org.onosproject.config.DynamicConfigServiceAdapter;
+import org.onosproject.config.Filter;
+import org.onosproject.d.config.DeviceResourceIds;
+import org.onosproject.d.config.ResourceIds;
+import org.onosproject.d.config.sync.DeviceConfigSynchronizationProvider;
+import org.onosproject.d.config.sync.operation.SetRequest;
+import org.onosproject.d.config.sync.operation.SetRequest.Change;
+import org.onosproject.d.config.sync.operation.SetRequest.Change.Operation;
+import org.onosproject.d.config.sync.operation.SetResponse;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.config.NetworkConfigServiceAdapter;
+import org.onosproject.net.provider.ProviderId;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.InnerNode;
+import org.onosproject.yang.model.LeafNode;
+import org.onosproject.yang.model.ResourceId;
+
+import com.google.common.collect.Iterables;
+
+public class DynamicDeviceConfigSynchronizerTest {
+
+    static final String TEST_NS = "testNS";
+
+    static final ResourceId REL_INTERFACES = ResourceId.builder()
+                .addBranchPointSchema("interfaces", TEST_NS)
+                .build();
+
+    static final DeviceId DID = DeviceId.deviceId("test:device1");
+
+    DynamicDeviceConfigSynchronizer sut;
+
+    TestDynamicConfigService dyConService;
+
+    CountDownLatch providerCalled = new CountDownLatch(1);
+
+    BiFunction<ResourceId, Filter, DataNode> onDcsRead;
+
+    BiFunction<DeviceId, SetRequest, CompletableFuture<SetResponse>> onSetConfiguration;
+
+    @Before
+    public void setUp() throws Exception {
+
+        sut = new DynamicDeviceConfigSynchronizer();
+        dyConService = new TestDynamicConfigService();
+        sut.dynConfigService = dyConService;
+        sut.netcfgService = new NetworkConfigServiceAdapter();
+
+        sut.activate();
+
+        sut.register(new MockDeviceConfigSynchronizerProvider());
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        sut.deactivate();
+    }
+
+    @Test
+    public void testDispatchRequest() throws Exception {
+
+        ResourceId devicePath = DeviceResourceIds.toResourceId(DID);
+        ResourceId cfgPath = REL_INTERFACES;
+        ResourceId absPath = ResourceIds.concat(devicePath, cfgPath);
+        DynamicConfigEvent event = new DynamicConfigEvent(DynamicConfigEvent.Type.NODE_REPLACED, absPath);
+
+        // assertions
+        onDcsRead = (path, filter) -> {
+            assertTrue(filter.isEmptyFilter());
+            assertEquals("DCS get access by absolute RID", absPath, path);
+            return deviceConfigNode();
+        };
+
+        onSetConfiguration = (deviceId, request) -> {
+            assertEquals(DID, deviceId);
+            assertEquals(1, request.changes().size());
+            Change change = Iterables.get(request.changes(), 0);
+            assertEquals("Provider get access by rel RID", REL_INTERFACES, change.path());
+            assertEquals(Operation.REPLACE, change.op());
+            assertEquals("interfaces", change.val().key().schemaId().name());
+            // walk and test children if it adds value
+
+            providerCalled.countDown();
+            return CompletableFuture.completedFuture(SetResponse.ok(request));
+        };
+
+        // start test run
+
+        // imitate event from DCS
+        dyConService.postEvent(event);
+
+        // assert that it reached the provider
+        providerCalled.await(5, TimeUnit.HOURS);
+    }
+
+    /**
+     * DataNode for testing.
+     *
+     * <pre>
+     *   +-interfaces
+     *      |
+     *      +- interface{intf-name="en0"}
+     *           |
+     *           +- speed = "10G"
+     *           +- state = "up"
+     *
+     * </pre>
+     * @return DataNode
+     */
+    private DataNode deviceConfigNode() {
+        InnerNode.Builder intfs = InnerNode.builder("interfaces", TEST_NS);
+        intfs.type(DataNode.Type.SINGLE_INSTANCE_NODE);
+        InnerNode.Builder intf = intfs.createChildBuilder("interface", TEST_NS);
+        intf.type(DataNode.Type.SINGLE_INSTANCE_LEAF_VALUE_NODE);
+        intf.addKeyLeaf("name", TEST_NS, "Ethernet0/0");
+        LeafNode.Builder speed = intf.createChildBuilder("mtu", TEST_NS, "1500");
+        speed.type(DataNode.Type.SINGLE_INSTANCE_LEAF_VALUE_NODE);
+
+        intf.addNode(speed.build());
+        intfs.addNode(intf.build());
+        return intfs.build();
+    }
+
+    private class TestDynamicConfigService extends DynamicConfigServiceAdapter {
+
+        public void postEvent(DynamicConfigEvent event) {
+            listenerRegistry.process(event);
+        }
+
+        @Override
+        public DataNode readNode(ResourceId path, Filter filter) {
+            return onDcsRead.apply(path, filter);
+        }
+    }
+
+    private class MockDeviceConfigSynchronizerProvider
+            implements DeviceConfigSynchronizationProvider {
+
+        @Override
+        public ProviderId id() {
+            return new ProviderId(DID.uri().getScheme(), "test-provider");
+        }
+
+        @Override
+        public CompletableFuture<SetResponse> setConfiguration(DeviceId deviceId,
+                                                               SetRequest request) {
+            return onSetConfiguration.apply(deviceId, request);
+        }
+    }
+
+}
diff --git a/apps/pom.xml b/apps/pom.xml
index e5e50f1..b43c0db 100644
--- a/apps/pom.xml
+++ b/apps/pom.xml
@@ -81,6 +81,8 @@
         <module>tetunnel</module>
         <module>actn-mdsc</module>
         <module>config</module>
+        <module>configsync</module>
+        <module>configsync-netconf</module>
         <module>ofagent</module>
         <module>intentsync</module>
         <module>mappingmanagement</module>