diff --git a/xos/synchronizer/steps/helpers.py b/xos/synchronizer/steps/helpers.py
new file mode 100644
index 0000000..914279e
--- /dev/null
+++ b/xos/synchronizer/steps/helpers.py
@@ -0,0 +1,43 @@
+# 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.
+
+class Helpers():
+    @staticmethod
+    def format_url(url):
+        if 'http' in url:
+            return url
+        else:
+            return 'http://%s' % url
+
+    @staticmethod
+    def get_voltha_info(olt_service):
+        return {
+            'url': Helpers.format_url(olt_service.voltha_url),
+            'user': olt_service.voltha_user,
+            'pass': olt_service.voltha_pass
+        }
+
+    @staticmethod
+    def get_p_onos_info(olt_service):
+        return {
+            'url': Helpers.format_url(olt_service.p_onos_url),
+            'user': olt_service.p_onos_user,
+            'pass': olt_service.p_onos_pass
+        }
+
+    @staticmethod
+    def datapath_id_to_hex(id):
+        if isinstance(id, basestring):
+            id = int(id)
+        return "{0:0{1}x}".format(id, 16)
\ No newline at end of file
diff --git a/xos/synchronizer/steps/sync_olt_device.py b/xos/synchronizer/steps/sync_olt_device.py
index 74da3b0..2845721 100644
--- a/xos/synchronizer/steps/sync_olt_device.py
+++ b/xos/synchronizer/steps/sync_olt_device.py
@@ -21,6 +21,7 @@
 from time import sleep
 import requests
 from requests.auth import HTTPBasicAuth
+from helpers import Helpers
 
 log = create_logger(Config().get('logging'))
 
@@ -30,31 +31,8 @@
     observes = OLTDevice
 
     @staticmethod
-    def format_url(url):
-        if 'http' in url:
-            return url
-        else:
-            return 'http://%s' % url
-
-    @staticmethod
-    def get_voltha_info(o):
-        return {
-            'url': SyncOLTDevice.format_url(o.volt_service.voltha_url),
-            'user': o.volt_service.voltha_user,
-            'pass': o.volt_service.voltha_pass
-        }
-
-    @staticmethod
-    def get_p_onos_info(o):
-        return {
-            'url': SyncOLTDevice.format_url(o.volt_service.p_onos_url),
-            'user': o.volt_service.p_onos_user,
-            'pass': o.volt_service.p_onos_pass
-        }
-
-    @staticmethod
-    def get_of_id_from_device(o):
-        voltha_url = SyncOLTDevice.get_voltha_info(o)['url']
+    def get_ids_from_logical_device(o):
+        voltha_url = Helpers.get_voltha_info(o.volt_service)['url']
 
         r = requests.get(voltha_url + "/api/v1/logical_devices")
 
@@ -65,7 +43,10 @@
 
         for ld in res["items"]:
             if ld["root_device_id"] == o.device_id:
-                return ld["id"]
+                o.of_id = ld["id"]
+                o.dp_id = "of:" + Helpers.datapath_id_to_hex(ld["datapath_id"]) # convert to hex
+                return o
+
         raise Exception("Can't find a logical device for device id: %s" % o.device_id)
 
 
@@ -75,7 +56,7 @@
         # If the device has feedback_state is already present in voltha
         if not o.device_id and not o.admin_state and not o.oper_status and not o.of_id:
             log.info("Pushing device to VOLTHA", object=str(o), **o.tologdict())
-            voltha_url = self.get_voltha_info(o)['url']
+            voltha_url = Helpers.get_voltha_info(o.volt_service)['url']
 
             data = {
                 "type": o.device_type,
@@ -123,7 +104,7 @@
             o.oper_status = r['oper_status']
 
             # find of_id of device
-            o.of_id = self.get_of_id_from_device(o)
+            o = self.get_ids_from_logical_device(o)
             o.save()
         else:
             log.info("Device already exists in VOLTHA", object=str(o), **o.tologdict())
@@ -136,7 +117,7 @@
         # add device info to P-ONOS
         data = {
           "devices": {
-            o.of_id: {
+            o.dp_id: {
               "basic": {
                 "driver": o.driver
               },
@@ -148,7 +129,7 @@
           }
         }
 
-        onos= self.get_p_onos_info(o)
+        onos= Helpers.get_p_onos_info(o.volt_service)
 
         r = requests.post(onos['url'] + '/onos/v1/network/configuration/', data=json.dumps(data), auth=HTTPBasicAuth(onos['user'], onos['pass']))
 
@@ -163,8 +144,8 @@
 
     def delete_record(self, o):
 
-        voltha_url = self.get_voltha_info(o)['url']
-        onos = self.get_p_onos_info(o)
+        voltha_url = Helpers.get_voltha_info(o.volt_service)['url']
+        onos = Helpers.get_p_onos_info(o.volt_service)
         if not o.device_id:
             log.error("Device %s has no device_id" % o.name)
 
diff --git a/xos/synchronizer/steps/sync_volt_service_instance.py b/xos/synchronizer/steps/sync_volt_service_instance.py
new file mode 100644
index 0000000..dccac6a
--- /dev/null
+++ b/xos/synchronizer/steps/sync_volt_service_instance.py
@@ -0,0 +1,68 @@
+# 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.
+
+from synchronizers.new_base.syncstep import SyncStep, DeferredException
+from synchronizers.new_base.modelaccessor import model_accessor
+from synchronizers.new_base.modelaccessor import VOLTService, VOLTServiceInstance, ServiceInstance, OLTDevice
+
+from xosconfig import Config
+from multistructlog import create_logger
+import requests
+from requests.auth import HTTPBasicAuth
+from helpers import Helpers
+
+log = create_logger(Config().get("logging"))
+
+class SyncVOLTServiceInstance(SyncStep):
+    provides = [VOLTServiceInstance]
+
+    observes = VOLTServiceInstance
+
+    def sync_record(self, o):
+
+        volt_service = VOLTService.objects.get(id=o.owner_id)
+
+        si = ServiceInstance.objects.get(id=o.id)
+
+        log.info("sync'ing OLTServiceInstance", object=str(o), **o.tologdict())
+
+        c_tag = si.get_westbound_service_instance_properties("c_tag")
+        uni_port_id = si.get_westbound_service_instance_properties("uni_port_id")
+
+        olt_device_name = si.get_westbound_service_instance_properties("olt_device")
+
+        olt_device = OLTDevice.objects.get(name=olt_device_name)
+
+        if not olt_device.dp_id:
+            raise DeferredException("Waiting for OLTDevice %s to be synchronized" % olt_device.name)
+
+        log.debug("Adding subscriber with info",
+                 c_tag=c_tag,
+                 uni_port_id=uni_port_id,
+                 dp_id=olt_device.dp_id)
+
+        # sending request to ONOS
+
+        onos = Helpers.get_p_onos_info(volt_service)
+
+        url = onos['url'] + "/onos/olt/oltapp/%s/%s/%s" % (olt_device.dp_id, uni_port_id, c_tag)
+
+        log.info("sending request to P_ONOS", url=url)
+
+        r = requests.post(url,auth=HTTPBasicAuth(onos['user'], onos['pass']))
+
+        if r.status_code != 200:
+            raise Exception("Failed to add subscriber in P_ONOS: %s" % r.text)
+
+        log.info("P_ONOS response", res=r.text)
\ No newline at end of file
diff --git a/xos/synchronizer/steps/test_helpers.py b/xos/synchronizer/steps/test_helpers.py
new file mode 100644
index 0000000..2820d9e
--- /dev/null
+++ b/xos/synchronizer/steps/test_helpers.py
@@ -0,0 +1,61 @@
+# 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.
+
+import unittest
+from mock import patch, call, Mock, PropertyMock
+from helpers import Helpers
+
+class TestHelpers(unittest.TestCase):
+
+    def setUp(self):
+        # create a mock service instance
+        o = Mock()
+        o.voltha_url = "voltha_url"
+        o.voltha_user = "voltha_user"
+        o.voltha_pass = "voltha_pass"
+        o.p_onos_url = "p_onos_url"
+        o.p_onos_user = "p_onos_user"
+        o.p_onos_pass = "p_onos_pass"
+
+        self.o = o
+
+    def test_format_url(self):
+        url = Helpers.format_url("onf.com")
+        self.assertEqual(url, "http://onf.com")
+        url = Helpers.format_url("http://onf.com")
+        self.assertEqual(url, "http://onf.com")
+
+    def test_get_voltha_info(self):
+        voltha_dict = Helpers.get_voltha_info(self.o)
+
+        self.assertEqual(voltha_dict["url"], "http://voltha_url")
+        self.assertEqual(voltha_dict["user"], "voltha_user")
+        self.assertEqual(voltha_dict["pass"], "voltha_pass")
+
+    def test_get_onos_info(self):
+        p_onos_dict = Helpers.get_p_onos_info(self.o)
+
+        self.assertEqual(p_onos_dict["url"], "http://p_onos_url")
+        self.assertEqual(p_onos_dict["user"], "p_onos_user")
+        self.assertEqual(p_onos_dict["pass"], "p_onos_pass")
+
+    def test_datapath_id_to_hex(self):
+        hex = Helpers.datapath_id_to_hex(55334486016)
+        self.assertEqual(hex, "0000000ce2314000")
+
+        hex = Helpers.datapath_id_to_hex("55334486016")
+        self.assertEqual(hex, "0000000ce2314000")
+
+if __name__ == "__main__":
+    unittest.main()
\ No newline at end of file
diff --git a/xos/synchronizer/steps/test_sync_olt_device.py b/xos/synchronizer/steps/test_sync_olt_device.py
index cd4906f..8143ef8 100644
--- a/xos/synchronizer/steps/test_sync_olt_device.py
+++ b/xos/synchronizer/steps/test_sync_olt_device.py
@@ -42,12 +42,12 @@
 
 def match_onos_req(req):
     r = req.json()['devices']
-    if not r['abc']:
+    if not r['of:0000000ce2314000']:
         return False
     else:
-        if not r['abc']['basic']['driver'] == 'pmc-olt':
+        if not r['of:0000000ce2314000']['basic']['driver'] == 'pmc-olt':
             return False
-        if not r['abc']['accessDevice']['vlan'] == "s_tag" or not r['abc']['accessDevice']['uplink'] == "129":
+        if not r['of:0000000ce2314000']['accessDevice']['vlan'] == "s_tag" or not r['of:0000000ce2314000']['accessDevice']['uplink'] == "129":
             return False
     return True
 
@@ -109,42 +109,25 @@
         self.o = None
         sys.path = self.sys_path_save
 
-    def test_format_url(self):
-        url = self.sync_step.format_url("onf.com")
-        self.assertEqual(url, "http://onf.com")
-        url = self.sync_step.format_url("http://onf.com")
-        self.assertEqual(url, "http://onf.com")
 
-    def test_get_voltha_info(self):
-        voltha_dict = self.sync_step.get_voltha_info(self.o)
-
-        self.assertEqual(voltha_dict["url"], "http://voltha_url")
-        self.assertEqual(voltha_dict["user"], "voltha_user")
-        self.assertEqual(voltha_dict["pass"], "voltha_pass")
-
-    def test_get_onos_info(self):
-        p_onos_dict = self.sync_step.get_p_onos_info(self.o)
-
-        self.assertEqual(p_onos_dict["url"], "http://p_onos_url")
-        self.assertEqual(p_onos_dict["user"], "p_onos_user")
-        self.assertEqual(p_onos_dict["pass"], "p_onos_pass")
 
     @requests_mock.Mocker()
     def test_get_of_id_from_device(self, m):
         logical_devices = {
             "items": [
-                {"root_device_id": "123", "id": "abc"},
+                {"root_device_id": "123", "id": "0001000ce2314000", "datapath_id": "55334486016"},
                 {"root_device_id": "0001cc4974a62b87", "id": "0001000000000001"}
             ]
         }
         m.get("http://voltha_url/api/v1/logical_devices", status_code=200, json=logical_devices)
         self.o.device_id = "123"
-        of_id = self.sync_step.get_of_id_from_device(self.o)
-        self.assertEqual(of_id, "abc")
+        self.o = self.sync_step.get_ids_from_logical_device(self.o)
+        self.assertEqual(self.o.of_id, "0001000ce2314000")
+        self.assertEqual(self.o.dp_id, "of:0000000ce2314000")
 
         with self.assertRaises(Exception) as e:
             self.o.device_id = "idonotexist"
-            self.sync_step.get_of_id_from_device(self.o)
+            self.sync_step.get_ids_from_logical_device(self.o)
         self.assertEqual(e.exception.message, "Can't find a logical device for device id: idonotexist")
 
     @requests_mock.Mocker()
@@ -191,7 +174,7 @@
         m.get("http://voltha_url/api/v1/devices/123", json={"oper_status": "ENABLED", "admin_state": "ACTIVE"})
         logical_devices = {
             "items": [
-                {"root_device_id": "123", "id": "abc"},
+                {"root_device_id": "123", "id": "0001000ce2314000", "datapath_id": "55334486016"},
                 {"root_device_id": "0001cc4974a62b87", "id": "0001000000000001"}
             ]
         }
@@ -202,7 +185,8 @@
         self.sync_step().sync_record(self.o)
         self.assertEqual(self.o.admin_state, "ACTIVE")
         self.assertEqual(self.o.oper_status, "ENABLED")
-        self.assertEqual(self.o.of_id, "abc")
+        self.assertEqual(self.o.of_id, "0001000ce2314000")
+        # self.assertEqual(self.o.dp_id, "of:0000000ce2314000")
         self.o.save.assert_called_once()
 
     @requests_mock.Mocker()
@@ -212,7 +196,7 @@
         self.o.device_id = "123"
         self.o.admin_state = "ACTIVE"
         self.o.oper_status = "ENABLED"
-        self.o.of_id = "abc"
+        self.o.dp_id = "of:0000000ce2314000"
 
         m.post("http://p_onos_url/onos/v1/network/configuration/", status_code=200, additional_matcher=match_onos_req, json={})
 
@@ -222,10 +206,10 @@
 
     @requests_mock.Mocker()
     def test_delete_record(self, m):
-        self.o.of_id = "abc"
+        self.o.of_id = "0001000ce2314000"
         self.o.device_id = "123"
 
-        m.delete("http://p_onos_url/onos/v1/network/configuration/devices/abc", status_code=200)
+        m.delete("http://p_onos_url/onos/v1/network/configuration/devices/0001000ce2314000", status_code=200)
         m.post("http://voltha_url/api/v1/devices/123/disable", status_code=200)
         m.delete("http://voltha_url/api/v1/devices/123/delete", status_code=200)
 
diff --git a/xos/synchronizer/steps/test_sync_volt_service_instance.py b/xos/synchronizer/steps/test_sync_volt_service_instance.py
new file mode 100644
index 0000000..dfab503
--- /dev/null
+++ b/xos/synchronizer/steps/test_sync_volt_service_instance.py
@@ -0,0 +1,158 @@
+# 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.
+
+import unittest
+from mock import patch, call, Mock, PropertyMock
+import requests_mock
+
+import os, sys
+
+# Hack to load synchronizer framework
+test_path=os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
+xos_dir=os.path.join(test_path, "../../..")
+if not os.path.exists(os.path.join(test_path, "new_base")):
+    xos_dir=os.path.join(test_path, "../../../../../../orchestration/xos/xos")
+    services_dir = os.path.join(xos_dir, "../../xos_services")
+sys.path.append(xos_dir)
+sys.path.append(os.path.join(xos_dir, 'synchronizers', 'new_base'))
+# END Hack to load synchronizer framework
+
+# generate model from xproto
+def get_models_fn(service_name, xproto_name):
+    name = os.path.join(service_name, "xos", xproto_name)
+    if os.path.exists(os.path.join(services_dir, name)):
+        return name
+    else:
+        name = os.path.join(service_name, "xos", "synchronizer", "models", xproto_name)
+        if os.path.exists(os.path.join(services_dir, name)):
+            return name
+    raise Exception("Unable to find service=%s xproto=%s" % (service_name, xproto_name))
+# END generate model from xproto
+
+def mock_get_westbound_service_instance_properties(prop):
+    return prop
+
+class TestSyncOLTDevice(unittest.TestCase):
+
+    def setUp(self):
+        global DeferredException
+
+        self.sys_path_save = sys.path
+        sys.path.append(xos_dir)
+        sys.path.append(os.path.join(xos_dir, 'synchronizers', 'new_base'))
+
+        # Setting up the config module
+        from xosconfig import Config
+        config = os.path.join(test_path, "../model_policies/test_config.yaml")
+        Config.clear()
+        Config.init(config, "synchronizer-config-schema.yaml")
+        # END Setting up the config module
+
+        from synchronizers.new_base.syncstep import DeferredException
+        from synchronizers.new_base.mock_modelaccessor_build import build_mock_modelaccessor
+        build_mock_modelaccessor(xos_dir, services_dir, [get_models_fn("olt-service", "volt.xproto")])
+        import synchronizers.new_base.modelaccessor
+        from sync_volt_service_instance import SyncVOLTServiceInstance, model_accessor
+
+        # import all class names to globals
+        for (k, v) in model_accessor.all_model_classes.items():
+            globals()[k] = v
+
+        self.sync_step = SyncVOLTServiceInstance
+
+        # create a mock service instance
+        o = Mock()
+        o.id = 1
+        o.owner_id = "volt_service"
+        o.tologdict.return_value = {}
+
+        volt_service = Mock()
+        volt_service.p_onos_url = "p_onos_url"
+        volt_service.p_onos_user = "p_onos_user"
+        volt_service.p_onos_pass = "p_onos_pass"
+
+        si = Mock()
+        si.get_westbound_service_instance_properties = mock_get_westbound_service_instance_properties
+
+        olt_device = Mock()
+        olt_device.name = "Test OLT Device"
+
+        self.o = o
+        self.si = si
+        self.olt_device = olt_device
+        self.volt_service = volt_service
+
+    def tearDown(self):
+        self.o = None
+        sys.path = self.sys_path_save
+
+
+
+    @requests_mock.Mocker()
+    def test_do_not_sync(self, m):
+
+        self.olt_device.dp_id = None
+
+        with patch.object(ServiceInstance.objects, "get") as service_instance_mock, \
+                patch.object(OLTDevice.objects, "get") as olt_device_mock, \
+                patch.object(VOLTService.objects, "get") as olt_service_mock:
+            service_instance_mock.return_value = self.si
+            olt_device_mock.return_value = self.olt_device
+            olt_service_mock.return_value = self.volt_service
+
+            with self.assertRaises(DeferredException) as e:
+                self.sync_step().sync_record(self.o)
+
+            self.assertFalse(m.called)
+            self.assertEqual(e.exception.message, "Waiting for OLTDevice Test OLT Device to be synchronized")
+
+    @requests_mock.Mocker()
+    def test_do_sync(self, m):
+
+        m.post("http://p_onos_url/onos/olt/oltapp/of:dp_id/uni_port_id/c_tag", status_code=200, json={})
+
+        self.olt_device.dp_id = "of:dp_id"
+
+        with patch.object(ServiceInstance.objects, "get") as service_instance_mock, \
+                patch.object(OLTDevice.objects, "get") as olt_device_mock, \
+                patch.object(VOLTService.objects, "get") as olt_service_mock:
+            service_instance_mock.return_value = self.si
+            olt_device_mock.return_value = self.olt_device
+            olt_service_mock.return_value = self.volt_service
+
+            self.sync_step().sync_record(self.o)
+            self.assertTrue(m.called)
+
+    @requests_mock.Mocker()
+    def test_do_sync_fail(self, m):
+        m.post("http://p_onos_url/onos/olt/oltapp/of:dp_id/uni_port_id/c_tag", status_code=500, text="Mock Error")
+
+        self.olt_device.dp_id = "of:dp_id"
+
+        with patch.object(ServiceInstance.objects, "get") as service_instance_mock, \
+                patch.object(OLTDevice.objects, "get") as olt_device_mock, \
+                patch.object(VOLTService.objects, "get") as olt_service_mock:
+            service_instance_mock.return_value = self.si
+            olt_device_mock.return_value = self.olt_device
+            olt_service_mock.return_value = self.volt_service
+
+            with self.assertRaises(Exception) as e:
+                self.sync_step().sync_record(self.o)
+
+            self.assertTrue(m.called)
+            self.assertEqual(e.exception.message, "Failed to add subscriber in P_ONOS: Mock Error")
+
+
+if __name__ == "__main__":
+    unittest.main()
\ No newline at end of file
