diff mbox

[ovs-dev,v3] ovn: use name instead of uuid as key of logical router ports

Message ID 1448407612-23276-1-git-send-email-zhouhan@gmail.com
State Accepted
Headers show

Commit Message

Han Zhou Nov. 24, 2015, 11:26 p.m. UTC
Before this patch, logical switch ports were using name as key but
logical router ports using uuid, which confuses user when trouble-
shooting, and names of patch ports unreadable. This patch unifies
it by using "name" field also for logical router ports.

Signed-off-by: Han Zhou <zhouhan@gmail.com>
---

Notes:
    v1->v2: update test case
    v2->v3: update documentation in ovn-nb.xml

 ovn/northd/ovn-northd.c | 14 ++++----------
 ovn/ovn-nb.ovsschema    |  5 +++--
 ovn/ovn-nb.xml          | 27 +++++++++++++++++----------
 tests/ovn.at            |  2 +-
 4 files changed, 25 insertions(+), 23 deletions(-)

Comments

Ben Pfaff Nov. 30, 2015, 12:38 a.m. UTC | #1
On Tue, Nov 24, 2015 at 03:26:52PM -0800, Han Zhou wrote:
> Before this patch, logical switch ports were using name as key but
> logical router ports using uuid, which confuses user when trouble-
> shooting, and names of patch ports unreadable. This patch unifies
> it by using "name" field also for logical router ports.
> 
> Signed-off-by: Han Zhou <zhouhan@gmail.com>
> ---
> 
> Notes:
>     v1->v2: update test case
>     v2->v3: update documentation in ovn-nb.xml

Thanks!  Applied to master.
diff mbox

Patch

diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index 8fe0c2c..2bd31ee 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -594,23 +594,20 @@  join_logical_ports(struct northd_context *ctx,
                     continue;
                 }
 
-                char name[UUID_LEN + 1];
-                snprintf(name, sizeof name, UUID_FMT,
-                         UUID_ARGS(&nbr->header_.uuid));
-                struct ovn_port *op = ovn_port_find(ports, name);
+                struct ovn_port *op = ovn_port_find(ports, nbr->name);
                 if (op) {
                     if (op->nbs || op->nbr) {
                         static struct vlog_rate_limit rl
                             = VLOG_RATE_LIMIT_INIT(5, 1);
                         VLOG_WARN_RL(&rl, "duplicate logical router port %s",
-                                     name);
+                                     nbr->name);
                         continue;
                     }
                     op->nbr = nbr;
                     list_remove(&op->list);
                     list_push_back(both, &op->list);
                 } else {
-                    op = ovn_port_create(ports, name, NULL, nbr, NULL);
+                    op = ovn_port_create(ports, nbr->name, NULL, nbr, NULL);
                     list_push_back(nb_only, &op->list);
                 }
 
@@ -647,10 +644,7 @@  join_logical_ports(struct northd_context *ctx,
                 sizeof *op->od->router_ports * (op->od->n_router_ports + 1));
             op->od->router_ports[op->od->n_router_ports++] = op;
         } else if (op->nbr && op->nbr->peer) {
-            char peer_name[UUID_LEN + 1];
-            snprintf(peer_name, sizeof peer_name, UUID_FMT,
-                     UUID_ARGS(&op->nbr->peer->header_.uuid));
-            op->peer = ovn_port_find(ports, peer_name);
+            op->peer = ovn_port_find(ports, op->nbr->name);
         }
     }
 }
diff --git a/ovn/ovn-nb.ovsschema b/ovn/ovn-nb.ovsschema
index b338c3f..9fb8cd1 100644
--- a/ovn/ovn-nb.ovsschema
+++ b/ovn/ovn-nb.ovsschema
@@ -1,7 +1,7 @@ 
 {
     "name": "OVN_Northbound",
-    "version": "2.0.0",
-    "cksum": "3515938918 4583",
+    "version": "2.0.1",
+    "cksum": "660370796 4618",
     "tables": {
         "Logical_Switch": {
             "columns": {
@@ -89,6 +89,7 @@ 
                 "external_ids": {
                     "type": {"key": "string", "value": "string",
                              "min": 0, "max": "unlimited"}}},
+            "indexes": [["name"]],
             "isRoot": false}
     }
 }
diff --git a/ovn/ovn-nb.xml b/ovn/ovn-nb.xml
index b6eef03..a1fa0ee 100644
--- a/ovn/ovn-nb.xml
+++ b/ovn/ovn-nb.xml
@@ -148,9 +148,10 @@ 
           subnets).
         </p>
 
-        <column name="options" key="router-port" type='{"type": "uuid"}'>
-          Required.  The UUID of the <ref table="Logical_Router_Port"/> to
-          which this logical switch port is connected.
+        <column name="options" key="router-port">
+          Required.  The <ref column="name"/> of the <ref
+          table="Logical_Router_Port"/> to which this logical switch port is
+          connected.
         </column>
       </group>
 
@@ -468,10 +469,14 @@ 
 
     <column name="name">
       <p>
-        A name for the logical router port.  This name has no special meaning or purpose
-        other than to provide convenience for human interaction with the ovn-nb
-        database.  There is no requirement for the name to be unique.  The
-        logical router port's UUID should be used as the unique identifier.
+        A name for the logical router port.
+      </p>
+
+      <p>
+        In addition to provide convenience for human interaction with the
+        ovn-nb database, this column is used as reference by its patch port in
+        <ref table="Logical_Port"/> or another logical router port in <ref
+        table="Logical_Router_Port"/>.
       </p>
     </column>
 
@@ -502,8 +507,10 @@ 
         <li>
           To attach a logical switch to a logical router.  A logical router
           port of this type is referenced by exactly one <ref
-          table="Logical_Port"/> of type <code>router</code>.  The <ref
-          column="peer"/> column is empty.
+          table="Logical_Port"/> of type <code>router</code>.  The value of
+          <ref column="name"/> is set as <code>router-port</code> in column
+          <ref column="options"/> of <ref table="Logical_Port"/>.
+          In this case <ref column="peer"/> column is empty.
         </li>
 
         <li>
@@ -518,7 +525,7 @@ 
       <column name="peer">
         <p>
           For a router port used to connect two logical routers, this
-          identifies the other router port in the pair.
+          identifies the other router port in the pair by <ref column="name"/>.
         </p>
 
         <p>
diff --git a/tests/ovn.at b/tests/ovn.at
index 68fcc9a..75933c3 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -878,7 +878,7 @@  for i in 1 2 3; do
 	    -- lport-add ls$i lrp$i$j-attachment`
 	ovn-nbctl \
 	    set Logical_Port lrp$i$j-attachment type=router \
-                             options:router-port=$lrp_uuid \
+                             options:router-port=lrp$i$j \
                              addresses='"00:00:00:00:ff:'$i$j'"'
     done
 done