diff --git a/xos/synchronizer/models/volt.xproto b/xos/synchronizer/models/volt.xproto
index aa2518d..380c835 100644
--- a/xos/synchronizer/models/volt.xproto
+++ b/xos/synchronizer/models/volt.xproto
@@ -29,9 +29,9 @@
 
     required manytoone volt_service->VOLTService:volt_devices = 1 [db_index = True, null = False, blank = False];
     required string name = 2 [help_text = "name of device", max_length = 254, null = False, db_index = False, blank = False];
-    required string device_type = 3 [help_text = "Device Type", default = "asfvolt16_olt", max_length = 254, null = False, db_index = False, blank = False];
-    required string host = 4 [help_text = "Host", max_length = 254, null = False, db_index = False, blank = False];
-    required int32 port = 5 [help_text = "Fabric port", null = False, db_index = False, blank = False];
+    required string device_type = 3 [help_text = "Device Type", default = "asfvolt16_olt", max_length = 254, null = False, db_index = False, blank = False, tosca_key=True];
+    required string host = 4 [help_text = "Host", max_length = 254, null = False, db_index = False, blank = False, tosca_key=True];
+    required int32 port = 5 [help_text = "Fabric port", null = False, db_index = False, blank = False, tosca_key=True];
 
     optional string device_id = 10 [help_text = "Device ID", null = True, db_index = False, blank = False, feedback_state = True];
     optional string admin_state = 11 [help_text = "admin_state", null = True, db_index = False, blank = False, feedback_state = True];
diff --git a/xos/synchronizer/pull_steps/pull_olts.py b/xos/synchronizer/pull_steps/pull_olts.py
index 3ab76e0..e377f1b 100644
--- a/xos/synchronizer/pull_steps/pull_olts.py
+++ b/xos/synchronizer/pull_steps/pull_olts.py
@@ -13,16 +13,151 @@
 # limitations under the License.
 
 from synchronizers.new_base.pullstep import PullStep
-from synchronizers.new_base.modelaccessor import OLTDevice
+from synchronizers.new_base.modelaccessor import model_accessor, OLTDevice, VOLTService
 
 from xosconfig import Config
 from multistructlog import create_logger
 
+import requests
+from requests import ConnectionError
+from requests.models import InvalidURL
+
 log = create_logger(Config().get('logging'))
 
 class OLTDevicePullStep(PullStep):
     def __init__(self):
         super(OLTDevicePullStep, self).__init__(observed_model=OLTDevice)
 
+    # NOTE move helpers where they can be loaded by multiple modules?
+    @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': OLTDevicePullStep.format_url(olt_service.voltha_url),
+            'user': olt_service.voltha_user,
+            'pass': olt_service.voltha_pass
+        }
+
+    @staticmethod
+    def datapath_id_to_hex(id):
+        if isinstance(id, basestring):
+            id = int(id)
+        return "{0:0{1}x}".format(id, 16)
+
+    @staticmethod
+    def get_ids_from_logical_device(o):
+        voltha_url = OLTDevicePullStep.get_voltha_info(o.volt_service)['url']
+
+        r = requests.get(voltha_url + "/api/v1/logical_devices")
+
+        if r.status_code != 200:
+            raise Exception("Failed to retrieve logical devices from VOLTHA: %s" % r.text)
+
+        res = r.json()
+
+        for ld in res["items"]:
+            if ld["root_device_id"] == o.device_id:
+                o.of_id = ld["id"]
+                o.dp_id = "of:" + OLTDevicePullStep.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)
+    # end note
+
     def pull_records(self):
         log.info("pulling OLT devices from VOLTHA")
+
+        try:
+            self.volt_service = VOLTService.objects.all()[0]
+        except IndexError:
+            log.warn('VOLTService not found')
+            return
+
+        voltha_url = OLTDevicePullStep.get_voltha_info(self.volt_service)['url']
+
+        try:
+            devices = []
+            r = requests.get(voltha_url + "/api/v1/devices")
+
+            if r.status_code != 200:
+                log.info("It was not possible to fetch devices from VOLTHA")
+
+            # keeping only OLTs
+            devices = [d for d in r.json()["items"] if "olt" in d["type"]]
+
+            log.debug("received devices", olts=devices)
+
+            # TODO
+            # [X] for each device
+            # [X] check if exists, if not save it
+            # [X] if exists and enacted > updated it has already been sync'ed
+            # [X] keep track of the updated OLTs
+            # delete OLTS as OLTDevice.objects.all() - updated OLTs
+
+            if r.status_code != 200:
+                log.info("It was not possible to fetch devices from VOLTHA")
+
+            olts_in_voltha = self.create_or_update_olts(devices)
+
+        except ConnectionError, e:
+            log.warn("It was not possible to connect to VOLTHA", reason=e)
+            return
+        except InvalidURL, e:
+            log.warn("VOLTHA url is invalid, is it configured in the VOLTService?", reason=e)
+            return
+
+    def create_or_update_olts(self, olts):
+
+        updated_olts = []
+
+        for olt in olts:
+            try:
+                if olt["type"] == "simulated_olt":
+                    [host, port] = ["172.17.0.1", "50060"]
+                else:
+                    [host, port] = olt["host_and_port"].split(":")
+                model = OLTDevice.objects.filter(device_type=olt["type"], host=host, port=port)[0]
+                log.debug("OLTDevice already exists, updating it", device_type=olt["type"], host=host, port=port)
+
+                if model.enacted < model.updated:
+                    log.info("Skipping pull on OLTDevice %s as enacted < updated" % model.name, name=model.name, id=model.id, enacted=model.enacted, updated=model.updated)
+                    return
+
+            except IndexError:
+                model = OLTDevice()
+                model.device_type = olt["type"]
+
+                if olt["type"] == "simulated_olt":
+                    model.host = "172.17.0.1"
+                    model.port = 50060
+
+                log.debug("OLTDevice is new, creating it", device_type=olt["type"], host=host, port=port)
+
+            # Adding feedback state to the device
+            model.device_id = olt["id"]
+            model.admin_state = olt["admin_state"]
+            model.oper_status = olt["oper_status"]
+
+            model.volt_service = self.volt_service
+            model.volt_service_id = self.volt_service.id
+
+            # get logical device
+            OLTDevicePullStep.get_ids_from_logical_device(model)
+
+            model.save()
+
+            updated_olts.append(model)
+
+        return updated_olts
+
+
+
+
+
+
diff --git a/xos/synchronizer/pull_steps/test_pull_olts.py b/xos/synchronizer/pull_steps/test_pull_olts.py
new file mode 100644
index 0000000..f377f8c
--- /dev/null
+++ b/xos/synchronizer/pull_steps/test_pull_olts.py
@@ -0,0 +1,176 @@
+# 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
+
+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.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 pull_olts import OLTDevicePullStep, model_accessor
+
+        # import all class names to globals
+        for (k, v) in model_accessor.all_model_classes.items():
+            globals()[k] = v
+
+        self.sync_step = OLTDevicePullStep
+
+        # mock volt service
+        self.volt_service = Mock()
+        self.volt_service.id = "volt_service_id"
+        self.volt_service.voltha_url = "voltha_url"
+        self.volt_service.voltha_user = "voltha_user"
+        self.volt_service.voltha_pass = "voltha_pass"
+
+        # mock voltha responses
+        self.devices = {
+            "items": [
+                {
+                    "id": "test_id",
+                    "type": "simulated_olt",
+                    "host_and_port": "172.17.0.1:50060",
+                    "admin_state": "ENABLED",
+                    "oper_status": "ACTIVE"
+                }
+            ]
+        }
+
+        self.logical_devices = {
+            "items": [
+                {
+                    "root_device_id": "test_id",
+                    "id": "of_id",
+                    "datapath_id": "55334486016"
+                }
+            ]
+        }
+
+    def tearDown(self):
+        sys.path = self.sys_path_save
+
+    @requests_mock.Mocker()
+    def test_missing_volt_service(self, m):
+            self.assertFalse(m.called)
+
+    @requests_mock.Mocker()
+    def test_pull(self, m):
+
+        with patch.object(VOLTService.objects, "all") as olt_service_mock, \
+                patch.object(OLTDevice, "save") as mock_save:
+            olt_service_mock.return_value = [self.volt_service]
+
+            m.get("http://voltha_url/api/v1/devices", status_code=200, json=self.devices)
+            m.get("http://voltha_url/api/v1/logical_devices", status_code=200, json=self.logical_devices)
+
+            self.sync_step().pull_records()
+
+            # TODO how to asster this?
+            # self.assertEqual(existing_olt.admin_state, "ENABLED")
+            # self.assertEqual(existing_olt.oper_status, "ACTIVE")
+            # self.assertEqual(existing_olt.volt_service_id, "volt_service_id")
+            # self.assertEqual(existing_olt.device_id, "test_id")
+            # self.assertEqual(existing_olt.of_id, "of_id")
+            # self.assertEqual(existing_olt.dp_id, "of:0000000ce2314000")
+
+            mock_save.assert_called()
+
+    @requests_mock.Mocker()
+    def test_pull_existing(self, m):
+
+        existing_olt = Mock()
+        existing_olt.enacted = 2
+        existing_olt.updated = 1
+
+        with patch.object(VOLTService.objects, "all") as olt_service_mock, \
+        patch.object(OLTDevice.objects, "filter") as mock_get, \
+        patch.object(existing_olt, "save") as  mock_save:
+            olt_service_mock.return_value = [self.volt_service]
+            mock_get.return_value = [existing_olt]
+
+            m.get("http://voltha_url/api/v1/devices", status_code=200, json=self.devices)
+            m.get("http://voltha_url/api/v1/logical_devices", status_code=200, json=self.logical_devices)
+
+            self.sync_step().pull_records()
+
+            self.assertEqual(existing_olt.admin_state, "ENABLED")
+            self.assertEqual(existing_olt.oper_status, "ACTIVE")
+            self.assertEqual(existing_olt.volt_service_id, "volt_service_id")
+            self.assertEqual(existing_olt.device_id, "test_id")
+            self.assertEqual(existing_olt.of_id, "of_id")
+            self.assertEqual(existing_olt.dp_id, "of:0000000ce2314000")
+
+            mock_save.assert_called()
+
+    @requests_mock.Mocker()
+    def test_pull_existing_do_not_sync(self, m):
+        existing_olt = Mock()
+        existing_olt.enacted = 1
+        existing_olt.updated = 2
+
+        with patch.object(VOLTService.objects, "all") as olt_service_mock, \
+                patch.object(OLTDevice.objects, "get") as mock_get, \
+                patch.object(existing_olt, "save") as  mock_save:
+            olt_service_mock.return_value = [self.volt_service]
+            mock_get.return_value = existing_olt
+
+            m.get("http://voltha_url/api/v1/devices", status_code=200, json=self.devices)
+            m.get("http://voltha_url/api/v1/logical_devices", status_code=200, json=self.logical_devices)
+
+            self.sync_step().pull_records()
+
+            mock_save.assert_not_called()
+
+if __name__ == "__main__":
+    unittest.main()
\ No newline at end of file
diff --git a/xos/unittest.cfg b/xos/unittest.cfg
index 71be7ca..44c6ea4 100644
--- a/xos/unittest.cfg
+++ b/xos/unittest.cfg
@@ -3,3 +3,4 @@
 code-directories=synchronizer
                  model_policies
                  steps
+                 pull_steps
