From 403afc35033a51136e0eaa0da855ef827077063d Mon Sep 17 00:00:00 2001 From: Ofer Ben-Yacov Date: Wed, 25 Jan 2017 16:28:24 +0200 Subject: [PATCH] Fix get all devices command --- wan_qos/db/wan_qos_db.py | 19 ++++++++++++------- wan_qos/services/plugin.py | 3 ++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/wan_qos/db/wan_qos_db.py b/wan_qos/db/wan_qos_db.py index 1db8a97..e11aa4c 100644 --- a/wan_qos/db/wan_qos_db.py +++ b/wan_qos/db/wan_qos_db.py @@ -81,13 +81,18 @@ class WanTcDb(object): else: LOG.error('Got heartbeat for non-existing device: %s' % host) - def get_all_devices(self, context): - device_list = context.session.query(models.WanTcDevice).all() - device_list_dict = [] - for device in device_list: - device_list_dict.append(self._device_to_dict(device)) - - return device_list_dict + def get_all_devices(self, context, filters=None, + fields=None, + sorts=None, limit=None, marker=None, + page_reverse=False): + marker_obj = self._get_marker_obj( + context, 'wan_tc_device', limit, marker) + return self._get_collection(context, models.WanTcDevice, + self._device_to_dict, + filters=filters, fields=fields, + sorts=sorts, limit=limit, + marker_obj=marker_obj, + page_reverse=page_reverse) def get_last_class_ext_id(self, context): diff --git a/wan_qos/services/plugin.py b/wan_qos/services/plugin.py index d8d6e9a..9f5779e 100644 --- a/wan_qos/services/plugin.py +++ b/wan_qos/services/plugin.py @@ -84,7 +84,8 @@ class WanQosPlugin(wanqos.WanQosPluginBase, def get_wan_tc_devices(self, context, filters=None, fields=None, sorts=None, limit=None, marker=None, page_reverse=False): - return self.db.get_all_devices(context) + return self.db.get_all_devices(context, filters, fields, sorts, limit, + marker, page_reverse) def get_plugin_type(self): """Get type of the plugin."""