summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2022-07-09 13:11:07 +0100
committerGitHub <noreply@github.com>2022-07-09 13:11:07 +0100
commit9e2fa823901104ff7e3ef7440b3cf164652d49bb (patch)
treeba9296fe954e526406b3156c9b5c33f5443e66cc
parente8ba34e3b2c7a89f2ca9d3a1826946bb4c3dc81d (diff)
parentb2e6934152e94db21ca96525915db70bc6e9f172 (diff)
downloadvyos-1x-9e2fa823901104ff7e3ef7440b3cf164652d49bb.tar.gz
vyos-1x-9e2fa823901104ff7e3ef7440b3cf164652d49bb.zip
Merge pull request #1405 from sever-sever/T4499
nat: T4499: Fix NAT not showing a single flow entry
-rwxr-xr-xsrc/op_mode/show_nat_translations.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/op_mode/show_nat_translations.py b/src/op_mode/show_nat_translations.py
index 25091e9fc..508845e23 100755
--- a/src/op_mode/show_nat_translations.py
+++ b/src/op_mode/show_nat_translations.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2020 VyOS maintainers and contributors
+# Copyright (C) 2020-2022 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -83,11 +83,23 @@ def pipe():
return xml
+def xml_to_dict(xml):
+ """
+ Convert XML to dictionary
+ Return: dictionary
+ """
+ parse = xmltodict.parse(xml)
+ # If only one NAT entry we must change dict T4499
+ if 'meta' in parse['conntrack']['flow']:
+ return dict(conntrack={'flow': [parse['conntrack']['flow']]})
+ return parse
+
+
def process(data, stats, protocol, pipe, verbose, flowtype=''):
if not data:
return
- parsed = xmltodict.parse(data)
+ parsed = xml_to_dict(data)
print(headers(verbose, pipe))