Skip to content

Commit 55af809

Browse files
committed
Fallout from node refactoring
* Remove dead file: inventories_parsing.py * Instead of calling _init, call the device init function initialize. They cannot be called init because they're async code. Signed-off-by: Dinesh Dutt <[email protected]>
1 parent ba7956e commit 55af809

File tree

3 files changed

+13
-158
lines changed

3 files changed

+13
-158
lines changed

suzieq/poller/worker/inventory/dir.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class InputDirInventory(Inventory):
1717
create fake nodes returning the content of the input
1818
directory
1919
"""
20+
2021
def __init__(self, add_task_fn, **kwargs) -> None:
2122
self.input_dir = kwargs.pop('input_dir', None)
2223
super().__init__(add_task_fn, **kwargs)
@@ -31,8 +32,7 @@ async def build_inventory(self) -> Dict[str, FileNode]:
3132
"""
3233

3334
node = FileNode()
34-
# pylint: disable=protected-access
35-
await node._init(self.input_dir)
35+
await node.initialize(self.input_dir)
3636
self._nodes = {node.hostname: node}
3737

3838
return self._nodes

suzieq/poller/worker/inventory/inventory.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ async def schedule_nodes_run(self):
104104
for node in self._nodes}
105105
await self.add_task_fn(list(self._node_tasks.values()))
106106

107-
async def _init_nodes(self, inventory_list: List[Dict]) -> Dict[str, Node]:
107+
async def _init_nodes(self, inventory_list:
108+
List[Dict]) -> Dict[str, Node]:
108109
"""Initialize the Node objects given the of credentials of the nodes.
109110
After this function is called, a connection with the nodes in the list
110111
is performed.
@@ -117,23 +118,26 @@ async def _init_nodes(self, inventory_list: List[Dict]) -> Dict[str, Node]:
117118

118119
for host in inventory_list:
119120
new_node = Node()
120-
# pylint: disable=protected-access
121-
init_tasks += [new_node._init(
121+
init_tasks += [new_node.initialize(
122122
**host,
123123
connect_timeout=self.connect_timeout,
124124
ssh_config_file=self.ssh_config_file
125125
)]
126126

127127
for n in asyncio.as_completed(init_tasks):
128128
newnode = await n
129-
if newnode.devtype is None:
129+
if newnode.devtype == "unsupported":
130130
logger.error(
131-
f'Unable to determine device type for '
131+
f'Unsupported device type for '
132132
f'{newnode.address}.{newnode.port}'
133133
)
134+
elif not newnode.devtype:
135+
logger.warning('Unable to determine device type for '
136+
f'{newnode.address}. Will retry')
134137
else:
135-
logger.info(f"Added node {newnode.hostname}:{newnode.port}")
136-
nodes_list.update({self.get_node_key(newnode): newnode})
138+
logger.info(f'Added node {newnode.hostname}:{newnode.port} '
139+
f'of type {newnode.devtype}')
140+
nodes_list.update({self.get_node_key(newnode): newnode})
137141

138142
return nodes_list
139143

suzieq/shared/inventories_parsing.py

Lines changed: 0 additions & 149 deletions
This file was deleted.

0 commit comments

Comments
 (0)