diff mbox

[ovs-dev,2/2] ovn-nbctl: Update show format for addresses.

Message ID 1452787395-2383-2-git-send-email-russell@ovn.org
State Superseded
Headers show

Commit Message

Russell Bryant Jan. 14, 2016, 4:03 p.m. UTC
This patch updates the formatting for the Logical_Port addresses column
in the show command output.  Previously, output would look like:

  addresses: 00:00:00:00:00:01 192.168.1.1 00:00:00:00:00:01 192.168.1.2

Now it looks like:

  addresses: ["00:00:00:00:00:01 192.168.1.1", "00:00:00:00:00:01 192.168.1.2"]

The grouping of addresses is important, so it should be reflected in the
output.

Signed-off-by: Russell Bryant <russell@ovn.org>
---
 ovn/utilities/ovn-nbctl.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Ben Pfaff Jan. 20, 2016, 10:01 p.m. UTC | #1
On Thu, Jan 14, 2016 at 11:03:15AM -0500, Russell Bryant wrote:
> This patch updates the formatting for the Logical_Port addresses column
> in the show command output.  Previously, output would look like:
> 
>   addresses: 00:00:00:00:00:01 192.168.1.1 00:00:00:00:00:01 192.168.1.2
> 
> Now it looks like:
> 
>   addresses: ["00:00:00:00:00:01 192.168.1.1", "00:00:00:00:00:01 192.168.1.2"]
> 
> The grouping of addresses is important, so it should be reflected in the
> output.
> 
> Signed-off-by: Russell Bryant <russell@ovn.org>

Hmm, I think just adding commas would be good enough, but the extra
syntax doesn't hurt I guess.

Acked-by: Ben Pfaff <blp@ovn.org>
diff mbox

Patch

diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index 7c715b9..9e87109 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -407,11 +407,13 @@  print_lswitch(const struct nbrec_logical_switch *lswitch, struct ds *s)
             ds_put_format(s, "            tag: %"PRIu64"\n", lport->tag[0]);
         }
         if (lport->n_addresses) {
-            ds_put_cstr(s, "            addresses:");
+            ds_put_cstr(s, "            addresses: [");
             for (size_t j = 0; j < lport->n_addresses; j++) {
-                ds_put_format(s, " %s", lport->addresses[j]);
+                ds_put_format(s, "%s\"%s\"",
+                        j == 0 ? "" : ", ",
+                        lport->addresses[j]);
             }
-            ds_put_char(s, '\n');
+            ds_put_cstr(s, "]\n");
         }
     }
 }