Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(result_manager): Support JSON output and save option (#113)
* feat(result_manager): Support JSON output and save option * doc: Fix typo check-devices script
- Loading branch information
Showing
4 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/python | ||
# coding: utf-8 -*- | ||
|
||
""" | ||
Toolkit for ANTA. | ||
""" | ||
|
||
import logging | ||
from typing import Union, Any | ||
from .inventory.models import InventoryDevices | ||
from .result_manager.models import ListResult | ||
|
||
# pylint: disable=W1309 | ||
|
||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.DEBUG) | ||
|
||
|
||
def pydantic_to_dict(pydantic_list: Union[InventoryDevices, ListResult]) -> Any: | ||
""" | ||
Convert Pydantic object into a dict | ||
Mimic .dict() option from pydantic but overwrite IPv4Address nodes | ||
Args: | ||
pydantic_list: Iterable pydantic object | ||
Returns: | ||
dict: dictionary object | ||
""" | ||
result = [] | ||
for device in pydantic_list: | ||
dev_dict = {k: str(v) for k, v in device} | ||
result.append(dev_dict) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters