Skip to content

Commit ba7956e

Browse files
committed
Node refactoring
* Add a base class with abstract methods that every device has to implement * Rename init_node to _detect_device_type() because that is what it is * Renamed init_boot_time to init_dev_data because it captures better what we're trying to do. * Add _init_rest to test connectivity/auth * Have all derived Device classes implement init_dev_data() rather than having half of them do init_node, and the others do init_boot_time. * Rename all internal functions to start with _. Only run, post_commands and initialize ought to be called from outside the class. * Got rid of the _status field because its only purpose was to determine if a device's type was unknown and so we needed to continue to run the automatic device type determination logic. * Added substantial commentary at the start of the device class to explain the workings of this class, its assumptions and its weaknesses. * Get rid of sigend, which was used to catch and terminate the Node runner when the user hit Ctrl-C. Ctrl-C driven termination is handled elsewhere now. * Add docstrings to all public class methods. Signed-off-by: Dinesh Dutt <[email protected]>
1 parent 5f9d879 commit ba7956e

File tree

2 files changed

+801
-644
lines changed

2 files changed

+801
-644
lines changed

suzieq/poller/worker/nodes/files.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ class FileNode:
1616
'''Class using run-once=gather snapshot output as mock device input'''
1717

1818
# pylint: disable=attribute-defined-outside-init
19-
async def _init(self, datadir: str):
20-
19+
async def initialize(self, datadir: str):
20+
'''Load the data to be read from files'''
2121
self.logger = logging.getLogger(__name__)
2222
self.data = {} # The dict of command to output entries
2323
self.hostname = '_filedata' # Need this for the services
24-
self.sigend = False
2524

2625
self._service_queue = asyncio.Queue()
2726

@@ -121,9 +120,6 @@ async def run(self):
121120
'''Main workhorse routine, serving data from files based on command'''
122121

123122
while True:
124-
if self.sigend:
125-
return
126-
127123
request = await self._service_queue.get()
128124
# request consists of callback fn, service_defn string, cb_token
129125
if request:

0 commit comments

Comments
 (0)