diff mbox

[ovs-dev,v5,5/8] ovn-northd: Copy name in logical datapath southbound representations.

Message ID 1471213462-22329-6-git-send-email-blp@ovn.org
State Accepted
Headers show

Commit Message

Ben Pfaff Aug. 14, 2016, 10:24 p.m. UTC
This makes it easier to debug based on the southbound database without
looking at the northbound representation.  This commit adds the name
to "ovn-sbctl dump-flows" output and it will be even more useful in
an upcoming commit.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Ryan Moats <rmoats@us.ibm.com>
---
 ovn/northd/ovn-northd.c   | 16 ++++++++++++++--
 ovn/ovn-sb.xml            |  7 +++++++
 ovn/utilities/ovn-sbctl.c | 10 +++++++---
 3 files changed, 28 insertions(+), 5 deletions(-)

Comments

Justin Pettit Aug. 16, 2016, 12:23 a.m. UTC | #1
> On Aug 14, 2016, at 3:24 PM, Ben Pfaff <blp@ovn.org> wrote:
> 
> This makes it easier to debug based on the southbound database without
> looking at the northbound representation.  This commit adds the name
> to "ovn-sbctl dump-flows" output and it will be even more useful in
> an upcoming commit.
> 
> Signed-off-by: Ben Pfaff <blp@ovn.org>
> Acked-by: Ryan Moats <rmoats@us.ibm.com>

Looks helpful.

Acked-by: Justin Pettit <jpettit@ovn.org>

--Justin
Ben Pfaff Aug. 16, 2016, 2:34 a.m. UTC | #2
On Mon, Aug 15, 2016 at 05:23:21PM -0700, Justin Pettit wrote:
> 
> > On Aug 14, 2016, at 3:24 PM, Ben Pfaff <blp@ovn.org> wrote:
> > 
> > This makes it easier to debug based on the southbound database without
> > looking at the northbound representation.  This commit adds the name
> > to "ovn-sbctl dump-flows" output and it will be even more useful in
> > an upcoming commit.
> > 
> > Signed-off-by: Ben Pfaff <blp@ovn.org>
> > Acked-by: Ryan Moats <rmoats@us.ibm.com>
> 
> Looks helpful.
> 
> Acked-by: Justin Pettit <jpettit@ovn.org>

Thanks, applied.
diff mbox

Patch

diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index 1bb0430..ede92ab 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -518,11 +518,23 @@  build_datapaths(struct northd_context *ctx, struct hmap *datapaths)
 
             od->sb = sbrec_datapath_binding_insert(ctx->ovnsb_txn);
 
+            /* Get the logical-switch or logical-router UUID to set in
+             * external-ids. */
             char uuid_s[UUID_LEN + 1];
             sprintf(uuid_s, UUID_FMT, UUID_ARGS(&od->key));
             const char *key = od->nbs ? "logical-switch" : "logical-router";
-            const struct smap id = SMAP_CONST1(&id, key, uuid_s);
-            sbrec_datapath_binding_set_external_ids(od->sb, &id);
+
+            /* Get name to set in external-ids. */
+            const char *name = od->nbs ? od->nbs->name : od->nbr->name;
+
+            /* Set external-ids. */
+            struct smap ids = SMAP_INITIALIZER(&ids);
+            smap_add(&ids, key, uuid_s);
+            if (*name) {
+                smap_add(&ids, "name", name);
+            }
+            sbrec_datapath_binding_set_external_ids(od->sb, &ids);
+            smap_destroy(&ids);
 
             sbrec_datapath_binding_set_tunnel_key(od->sb, tunnel_key);
         }
diff --git a/ovn/ovn-sb.xml b/ovn/ovn-sb.xml
index 0829cbc..1da309c 100644
--- a/ovn/ovn-sb.xml
+++ b/ovn/ovn-sb.xml
@@ -1524,6 +1524,13 @@  tcp.flags = RST;
         corresponding <ref table="Logical_Router" db="OVN_Northbound"/> row in
         the <ref db="OVN_Northbound"/> database.
       </column>
+
+      <column name="external_ids" key="name">
+        <code>ovn-northd</code> copies this from the <ref
+        table="Logical_Router" db="OVN_Northbound"/> or <ref
+        table="Logical_Switch" db="OVN_Northbound"/> table in the <ref
+        db="OVN_Northbound"/> database, when that column is nonempty.
+      </column>
     </group>
 
     <group title="Common Columns">
diff --git a/ovn/utilities/ovn-sbctl.c b/ovn/utilities/ovn-sbctl.c
index fb340fb..b894b8b 100644
--- a/ovn/utilities/ovn-sbctl.c
+++ b/ovn/utilities/ovn-sbctl.c
@@ -489,6 +489,8 @@  pre_get_info(struct ctl_context *ctx)
     ovsdb_idl_add_column(ctx->idl, &sbrec_logical_flow_col_table_id);
     ovsdb_idl_add_column(ctx->idl, &sbrec_logical_flow_col_match);
     ovsdb_idl_add_column(ctx->idl, &sbrec_logical_flow_col_external_ids);
+
+    ovsdb_idl_add_column(ctx->idl, &sbrec_datapath_binding_col_external_ids);
 }
 
 static struct cmd_show_table cmd_show_tables[] = {
@@ -719,9 +721,11 @@  cmd_lflow_list(struct ctl_context *ctx)
             continue;
         }
         if (strcmp(cur_pipeline, lflow->pipeline)) {
-            printf("Datapath: " UUID_FMT "  Pipeline: %s\n",
-                    UUID_ARGS(&lflow->logical_datapath->header_.uuid),
-                    lflow->pipeline);
+            printf("Datapath: \"%s\" ("UUID_FMT")  Pipeline: %s\n",
+                   smap_get_def(&lflow->logical_datapath->external_ids,
+                                "name", ""),
+                   UUID_ARGS(&lflow->logical_datapath->header_.uuid),
+                   lflow->pipeline);
             cur_pipeline = lflow->pipeline;
         }