From cb9e0184dc9f2023b278111d9019797b587b0912 Mon Sep 17 00:00:00 2001 From: Solvik Date: Tue, 6 Aug 2019 17:44:55 +0200 Subject: [PATCH 1/3] Update README.md Mention of caching problem with last netbox version --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 474ec21..ba269b6 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ The goal is to generate an existing infrastructure on Netbox and have the abilit * The project is only compatible with Linux. Since it uses `ethtool` and parses `/sys/` directory, it's not compatible with *BSD distributions. +* Netbox `>=2.6.0,<=2.6.2` has a caching problem ; if the cache lifetime is too high, the script can get stale data after modification. # Configuration -- 2.47.2 From a22b648b8a1e3e21968bedd6da6061c11f1e6aa1 Mon Sep 17 00:00:00 2001 From: Solvik Blum Date: Tue, 6 Aug 2019 18:15:08 +0200 Subject: [PATCH 2/3] be python3.5 compatible --- netbox_agent/ethtool.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/netbox_agent/ethtool.py b/netbox_agent/ethtool.py index 91522c9..36f10f4 100644 --- a/netbox_agent/ethtool.py +++ b/netbox_agent/ethtool.py @@ -19,6 +19,12 @@ field_map = { } +def merge_two_dicts(x, y): + z = x.copy() + z.update(y) + return z + + class Ethtool(): """ This class aims to parse ethtool output @@ -67,7 +73,8 @@ class Ethtool(): def parse(self): if which('ethtool') is None: return None - return { - **self._parse_ethtool_output(), - **self._parse_ethtool_module_output(), - } + # TODO >= py35: return {**a, **b} + return merge_two_dicts( + self._parse_ethtool_output(), + self._parse_ethtool_module_output() + ) -- 2.47.2 From 896a0111739c4d8d9b43912efe2267c6607f93b9 Mon Sep 17 00:00:00 2001 From: Solvik Blum Date: Thu, 8 Aug 2019 10:42:43 +0200 Subject: [PATCH 3/3] simpler way to be python3.4 compatibble --- netbox_agent/ethtool.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/netbox_agent/ethtool.py b/netbox_agent/ethtool.py index 36f10f4..3ce3fbc 100644 --- a/netbox_agent/ethtool.py +++ b/netbox_agent/ethtool.py @@ -73,8 +73,6 @@ class Ethtool(): def parse(self): if which('ethtool') is None: return None - # TODO >= py35: return {**a, **b} - return merge_two_dicts( - self._parse_ethtool_output(), - self._parse_ethtool_module_output() - ) + output = self._parse_ethtool_output() + output.update(self._parse_ethtool_module_output()) + return output -- 2.47.2