[ovs-dev] [PATCH] Show total_ports_on_switch when displaying logical_switch:

amginwal at gmail.com amginwal at gmail.com
Sat Jan 20 05:08:17 UTC 2018


From: aginwala <aginwala at ebay.com>

e.g. when running ovn-nbctl show ls, it's good to have total ports that are
attached to the switch.

Signed-off-by: Aliasgar Ginwala <aginwala at ebay.com>
---
 ovn/utilities/ovn-nbctl.c |  1 +
 tests/ovn-nbctl.at        | 10 ++++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index c9aa2fe..0f1e952 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -682,6 +682,7 @@ print_ls(const struct nbrec_logical_switch *ls, struct ds *s)
             ds_put_format(s, "        router-port: %s\n", router_port);
         }
     }
+    ds_put_format(s, "total_ports_on_switch: %u\n", ls->n_ports);
 }
 
 static void
diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at
index 5ac4a6d..5fbaffd 100644
--- a/tests/ovn-nbctl.at
+++ b/tests/ovn-nbctl.at
@@ -43,15 +43,17 @@ AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl
 q
 AT_CHECK([ovn-nbctl show ls0])
 AT_CHECK([ovn-nbctl ls-add ls0])
-AT_CHECK([ovn-nbctl show ls0 | uuidfilt], [0],
-  [switch <0> (ls0)
+AT_CHECK([ovn-nbctl show ls0 | uuidfilt], [0], [dnl
+switch <0> (ls0)
+total_ports_on_switch: 0
 ])
 AT_CHECK([ovn-nbctl ls-add ls0], [1], [],
   [ovn-nbctl: ls0: a switch with this name already exists
 ])
 AT_CHECK([ovn-nbctl --may-exist ls-add ls0])
-AT_CHECK([ovn-nbctl show ls0 | uuidfilt], [0],
-  [switch <0> (ls0)
+AT_CHECK([ovn-nbctl show ls0 | uuidfilt], [0], [dnl
+switch <0> (ls0)
+total_ports_on_switch: 0
 ])
 AT_CHECK([ovn-nbctl --add-duplicate ls-add ls0])
 AT_CHECK([ovn-nbctl --may-exist --add-duplicate ls-add ls0], [1], [],
-- 
1.9.1



More information about the dev mailing list