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

Ben Pfaff blp at ovn.org
Sat Aug 13 16:30:27 UTC 2016


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 at ovn.org>
Acked-by: Ryan Moats <rmoats at 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(-)

diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index 7224adb..3bcbed4 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 a190c6b..b48b541 100644
--- a/ovn/ovn-sb.xml
+++ b/ovn/ovn-sb.xml
@@ -1441,6 +1441,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 11d4c52..a971b42 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[] = {
@@ -717,9 +719,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;
         }
 
-- 
2.1.3




More information about the dev mailing list