diff options
author | John Estabrook <jestabro@vyos.io> | 2023-03-28 13:50:10 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2023-03-28 13:50:10 -0500 |
commit | 3d4e0e070e84581d4eb28cb623c019c30daf85f4 (patch) | |
tree | fda6cafa1bd69c53da5ba54d79ec990e9e9c3756 /python/vyos/ifconfig | |
parent | b5d940d9f279a8391c8d8c56cc86f4855c9d38b5 (diff) | |
download | vyos-1x-3d4e0e070e84581d4eb28cb623c019c30daf85f4.tar.gz vyos-1x-3d4e0e070e84581d4eb28cb623c019c30daf85f4.zip |
interfaces: T4885: fix Perl to Python rewrite of clear/reset_counters
Diffstat (limited to 'python/vyos/ifconfig')
-rw-r--r-- | python/vyos/ifconfig/operational.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/python/vyos/ifconfig/operational.py b/python/vyos/ifconfig/operational.py index 33e8614f0..dc2742123 100644 --- a/python/vyos/ifconfig/operational.py +++ b/python/vyos/ifconfig/operational.py @@ -143,15 +143,17 @@ class Operational(Control): except IOError: return no_stats - def clear_counters(self, counters=None): - clear = self._stats_all if counters is None else [] - stats = self.load_counters() + def clear_counters(self): + stats = self.get_stats() for counter, value in stats.items(): - stats[counter] = 0 if counter in clear else value + stats[counter] = value self.save_counters(stats) def reset_counters(self): - os.remove(self.cachefile(self.ifname)) + try: + os.remove(self.cachefile(self.ifname)) + except FileNotFoundError: + pass def get_stats(self): """ return a dict() with the value for each interface counter """ |