Fixing OLTDevice pull step
Change-Id: I2b7d0b68f0db61d3b1da93fdf7c582c3240b8a77
diff --git a/xos/synchronizer/pull_steps/pull_olts.py b/xos/synchronizer/pull_steps/pull_olts.py
index e377f1b..0fc5e2d 100644
--- a/xos/synchronizer/pull_steps/pull_olts.py
+++ b/xos/synchronizer/pull_steps/pull_olts.py
@@ -40,6 +40,7 @@
def get_voltha_info(olt_service):
return {
'url': OLTDevicePullStep.format_url(olt_service.voltha_url),
+ 'port': olt_service.voltha_port,
'user': olt_service.voltha_user,
'pass': olt_service.voltha_pass
}
@@ -53,8 +54,9 @@
@staticmethod
def get_ids_from_logical_device(o):
voltha_url = OLTDevicePullStep.get_voltha_info(o.volt_service)['url']
+ voltha_port = OLTDevicePullStep.get_voltha_info(o.volt_service)['port']
- r = requests.get(voltha_url + "/api/v1/logical_devices")
+ r = requests.get("%s:%s/api/v1/logical_devices" % (voltha_url, voltha_port))
if r.status_code != 200:
raise Exception("Failed to retrieve logical devices from VOLTHA: %s" % r.text)
@@ -80,10 +82,10 @@
return
voltha_url = OLTDevicePullStep.get_voltha_info(self.volt_service)['url']
+ voltha_port = OLTDevicePullStep.get_voltha_info(self.volt_service)['port']
try:
- devices = []
- r = requests.get(voltha_url + "/api/v1/devices")
+ r = requests.get("%s:%s/api/v1/devices" % (voltha_url, voltha_port))
if r.status_code != 200:
log.info("It was not possible to fetch devices from VOLTHA")
@@ -94,11 +96,7 @@
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
+ # [ ] delete OLTS as OLTDevice.objects.all() - updated OLTs
if r.status_code != 200:
log.info("It was not possible to fetch devices from VOLTHA")
diff --git a/xos/synchronizer/pull_steps/test_pull_olts.py b/xos/synchronizer/pull_steps/test_pull_olts.py
index f377f8c..a0ef017 100644
--- a/xos/synchronizer/pull_steps/test_pull_olts.py
+++ b/xos/synchronizer/pull_steps/test_pull_olts.py
@@ -57,7 +57,13 @@
# 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")])
+ # build_mock_modelaccessor(xos_dir, services_dir, [get_models_fn("olt-service", "volt.xproto")])
+
+ # FIXME this is to get jenkins to pass the tests, somehow it is running tests in a different order
+ # and apparently it is not overriding the generated model accessor
+ build_mock_modelaccessor(xos_dir, services_dir, [get_models_fn("olt-service", "volt.xproto"),
+ get_models_fn("vsg", "vsg.xproto"),
+ get_models_fn("../profiles/rcord", "rcord.xproto")])
import synchronizers.new_base.modelaccessor
from pull_olts import OLTDevicePullStep, model_accessor
@@ -73,6 +79,7 @@
self.volt_service.voltha_url = "voltha_url"
self.volt_service.voltha_user = "voltha_user"
self.volt_service.voltha_pass = "voltha_pass"
+ self.volt_service.voltha_port = 1234
# mock voltha responses
self.devices = {
@@ -111,8 +118,8 @@
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)
+ m.get("http://voltha_url:1234/api/v1/devices", status_code=200, json=self.devices)
+ m.get("http://voltha_url:1234/api/v1/logical_devices", status_code=200, json=self.logical_devices)
self.sync_step().pull_records()
@@ -139,8 +146,8 @@
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)
+ m.get("http://voltha_url:1234/api/v1/devices", status_code=200, json=self.devices)
+ m.get("http://voltha_url:1234/api/v1/logical_devices", status_code=200, json=self.logical_devices)
self.sync_step().pull_records()
@@ -165,8 +172,8 @@
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)
+ m.get("http://voltha_url:1234/api/v1/devices", status_code=200, json=self.devices)
+ m.get("http://voltha_url:1234/api/v1/logical_devices", status_code=200, json=self.logical_devices)
self.sync_step().pull_records()