[ovs-dev] [PATCH 3/8] ovn-nbctl: Update logical router port commands.

Justin Pettit jpettit at ovn.org
Thu Jun 9 07:12:37 UTC 2016


A few minor changes related to logical router port commands:

    - Use "lrp" instead of "lrport" to be more consistent with later
      changes.
    - Use commands where possible in ovn unit tests.
    - Move documentation to group router commands together.
    - Adds mac/network/peer to lrp-add command.  The existing command
      doesn't require creating a mac or network address, which shouldn't
      be possible.
    - Drops lrport-[get|set]-mac-addresses commands in favor of
      initializing them in lrp-add command.
    - Update references from "lrport" to "lrp" (code) or "port" (user).

Signed-off-by: Justin Pettit <jpettit at ovn.org>
---
 ovn/utilities/ovn-nbctl.8.xml | 111 ++++-----
 ovn/utilities/ovn-nbctl.c     | 537 ++++++++++++++++++++----------------------
 tests/ovn-nbctl.at            |  65 ++---
 tests/ovn.at                  | 206 ++++++----------
 4 files changed, 394 insertions(+), 525 deletions(-)

diff --git a/ovn/utilities/ovn-nbctl.8.xml b/ovn/utilities/ovn-nbctl.8.xml
index 6f42a75..c085274 100644
--- a/ovn/utilities/ovn-nbctl.8.xml
+++ b/ovn/utilities/ovn-nbctl.8.xml
@@ -94,68 +94,6 @@
       </dd>
     </dl>
 
-    <h1>Logical Router Port Commands</h1>
-
-    <dl>
-      <dt>[<code>--may-exist</code>] <code>lrport-add</code> <var>router</var> <var>lrport</var></dt>
-      <dd>
-        <p>
-          Creates on <var>router</var> a new logical router port named
-          <var>lrport</var>.
-        </p>
-
-        <p>
-          It is an error if a logical router port named <var>lrport</var>
-          already exists, unless <code>--may-exist</code> is specified.
-          Regardless of <code>--may-exist</code>, it is an error if the
-          existing router port is in some logical router other than
-          <var>router</var>.
-        </p>
-      </dd>
-
-      <dt>[<code>--if-exists</code>] <code>lrport-del</code> <var>lrport</var></dt>
-      <dd>
-        Deletes <var>lrport</var>.  It is an error if <var>lrport</var> does
-        not exist, unless <code>--if-exists</code> is specified.
-      </dd>
-
-      <dt><code>lrport-list</code> <var>router</var></dt>
-      <dd>
-        Lists all the logical router ports within <var>router</var> on
-        standard output, one per line.
-      </dd>
-
-      <dt><code>lrport-set-mac-address</code> <var>lrport</var>
-                <var>address</var>...</dt>
-      <dd>
-        Sets the address associated with <var>lrport</var> to
-        <var>address</var>.  <var>address</var> should be either an
-        Ethernet address or an Ethernet address followed by an IP address
-        (separated by a space and quoted to form a single command-line
-        argument).  The special form <code>unknown</code> is also valid.
-      </dd>
-
-      <dt><code>lrport-get-mac-address</code> <var>lrport</var></dt>
-      <dd>
-        Lists the mac address associated with <var>lrport</var> on standard
-        output.
-      </dd>
-
-      <dt><code>lrport-set-enabled</code> <var>lrport</var> <var>state</var></dt>
-      <dd>
-        Set the administrative state of <var>lrport</var>,
-        either <code>enabled</code> or <code>disabled</code>.
-        When a port is disabled, no traffic is allowed into
-        or out of the port.
-      </dd>
-
-      <dt><code>lrport-get-enabled</code> <var>lrport</var></dt>
-      <dd>
-        Prints the administrative state of <var>lrport</var>,
-        either <code>enabled</code> or <code>disabled</code>.
-      </dd>
-
-    </dl>
     <h1>Logical Port Commands</h1>
     <dl>
       <dt>[<code>--may-exist</code>] <code>lport-add</code> <var>lswitch</var> <var>lport</var></dt>
@@ -345,6 +283,55 @@
       </dd>
     </dl>
 
+    <h1>Logical Router Port Commands</h1>
+
+    <dl>
+      <dt>[<code>--may-exist</code>] <code>lrp-add</code> <var>router</var> <var>port</var> <var>mac</var> <var>network</var> [<var>peer</var>]</dt>
+      <dd>
+        <p>
+          Creates on <var>router</var> a new logical router port named
+          <var>port</var> with Ethernet address <var>mac</var> and IP
+          address/netmask <var>network</var>.  If <var>peer</var> is
+          specified, it identifies a logical router port that connects
+          to this one.
+        </p>
+
+        <p>
+          It is an error if a logical router port named <var>port</var>
+          already exists, unless <code>--may-exist</code> is specified.
+          Regardless of <code>--may-exist</code>, it is an error if the
+          existing router port is in some logical router other than
+          <var>router</var>.
+        </p>
+      </dd>
+
+      <dt>[<code>--if-exists</code>] <code>lrp-del</code> <var>port</var></dt>
+      <dd>
+        Deletes <var>port</var>.  It is an error if <var>port</var> does
+        not exist, unless <code>--if-exists</code> is specified.
+      </dd>
+
+      <dt><code>lrp-list</code> <var>router</var></dt>
+      <dd>
+        Lists all the logical router ports within <var>router</var> on
+        standard output, one per line.
+      </dd>
+
+      <dt><code>lrp-set-enabled</code> <var>port</var> <var>state</var></dt>
+      <dd>
+        Set the administrative state of <var>port</var>, either
+        <code>enabled</code> or <code>disabled</code>.  When a port is
+        disabled, no traffic is allowed into or out of the port.
+      </dd>
+
+      <dt><code>lrp-get-enabled</code> <var>port</var></dt>
+      <dd>
+        Prints the administrative state of <var>port</var>, either
+        <code>enabled</code> or <code>disabled</code>.
+      </dd>
+
+    </dl>
+
     <h1>Database Commands</h1>
     <p>These commands query and modify the contents of <code>ovsdb</code> tables.
     They are a slight abstraction of the <code>ovsdb</code> interface and
diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index 4e49a77..493f1e8 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -307,19 +307,6 @@ ACL commands:\n\
                             remove ACLs from LSWITCH\n\
   acl-list LSWITCH          print ACLs for LSWITCH\n\
 \n\
-Logical router port commands:\n\
-  lrport-add ROUTER LRPORT  add logical router port LRPORT to ROUTER\n\
-  lrport-del LRPORT         delete LRPORT from its attached router\n\
-  lrport-list ROUTER        print the names of all logical ports on ROUTER\n\
-  lrport-set-mac-address LRPORT [ADDRESS]\n\
-                            set MAC address for LRPORT.\n\
-  lrport-get-mac-address LRPORT      get MAC addresses on LRPORT\n\
-  lrport-set-enabled LRPORT STATE\n\
-                            set administrative state LRPORT\n\
-                            ('enabled' or 'disabled')\n\
-  lrport-get-enabled LRPORT   get administrative state LRPORT\n\
-                            ('enabled' or 'disabled')\n\
-\n\
 Logical port commands:\n\
   lport-add LSWITCH LPORT   add logical port LPORT on LSWITCH\n\
   lport-add LSWITCH LPORT PARENT TAG\n\
@@ -352,6 +339,17 @@ Logical router commands:\n\
   lr-del ROUTER             delete ROUTER and all its ports\n\
   lr-list                   print the names of all logical routers\n\
 \n\
+Logical router port commands:\n\
+  lrp-add ROUTER PORT MAC NETWORK [PEER]\n\
+                            add logical port PORT on ROUTER\n\
+  lrp-del PORT              delete PORT from its attached router\n\
+  lrp-list ROUTER           print the names of all ports on ROUTER\n\
+  lrp-set-enabled PORT STATE\n\
+                            set administrative state PORT\n\
+                            ('enabled' or 'disabled')\n\
+  lrp-get-enabled PORT      get administrative state PORT\n\
+                            ('enabled' or 'disabled')\n\
+\n\
 %s\
 \n\
 Options:\n\
@@ -451,11 +449,11 @@ print_lr(const struct nbrec_logical_router *lr, struct ds *s)
                   UUID_ARGS(&lr->header_.uuid), lr->name);
 
     for (size_t i = 0; i < lr->n_ports; i++) {
-        const struct nbrec_logical_router_port *lrport = lr->ports[i];
-        ds_put_format(s, "        lrport %s\n", lrport->name);
-        if (lrport->mac) {
+        const struct nbrec_logical_router_port *lrp = lr->ports[i];
+        ds_put_format(s, "        port %s\n", lrp->name);
+        if (lrp->mac) {
             ds_put_cstr(s, "            mac: ");
-            ds_put_format(s, "\"%s\"", lrport->mac);
+            ds_put_format(s, "\"%s\"", lrp->mac);
         }
         ds_put_format(s, "\n");
     }
@@ -590,37 +588,6 @@ nbctl_lswitch_list(struct ctl_context *ctx)
     free(nodes);
 }
 
-/* Find the lrport given its id. */
-static const struct nbrec_logical_router_port *
-lrport_by_name_or_uuid(struct ctl_context *ctx, const char *id,
-                       bool must_exist)
-{
-    const struct nbrec_logical_router_port *lrport = NULL;
-    bool is_uuid = false;
-    struct uuid lrport_uuid;
-
-    if (uuid_from_string(&lrport_uuid, id)) {
-        is_uuid = true;
-        lrport = nbrec_logical_router_port_get_for_uuid(ctx->idl,
-                                                        &lrport_uuid);
-    }
-
-    if (!lrport) {
-        NBREC_LOGICAL_ROUTER_PORT_FOR_EACH(lrport, ctx->idl) {
-            if (!strcmp(lrport->name, id)) {
-                break;
-            }
-        }
-    }
-
-    if (!lrport && must_exist) {
-        ctl_fatal("%s: lrport with this %s not found",
-                  id, is_uuid ? "name" : "UUID");
-    }
-
-    return lrport;
-}
-
 static const struct nbrec_logical_port *
 lport_by_name_or_uuid(struct ctl_context *ctx, const char *id,
                       bool must_exist)
@@ -667,25 +634,6 @@ lport_to_lswitch(const struct ovsdb_idl *idl,
               lport->name);
 }
 
-/* Returns the logical router that contains 'lport'. */
-static const struct nbrec_logical_router *
-lrport_to_lr(const struct ovsdb_idl *idl,
-             const struct nbrec_logical_router_port *lrport)
-{
-    const struct nbrec_logical_router *lr;
-    NBREC_LOGICAL_ROUTER_FOR_EACH (lr, idl) {
-        for (size_t i = 0; i < lr->n_ports; i++) {
-            if (lr->ports[i] == lrport) {
-                return lr;
-            }
-        }
-    }
-
-    /* Can't happen because of the database schema */
-    ctl_fatal("logical port %s is not part of any logical router",
-              lrport->name);
-}
-
 static const char *
 lswitch_get_name(const struct nbrec_logical_switch *lswitch,
                  char uuid_s[UUID_LEN + 1], size_t uuid_s_size)
@@ -697,17 +645,6 @@ lswitch_get_name(const struct nbrec_logical_switch *lswitch,
     return uuid_s;
 }
 
-static const char *
-lr_get_name(const struct nbrec_logical_router *lr,
-            char uuid_s[UUID_LEN + 1], size_t uuid_s_size)
-{
-    if (lr->name[0]) {
-        return lr->name;
-    }
-    snprintf(uuid_s, uuid_s_size, UUID_FMT, UUID_ARGS(&lr->header_.uuid));
-    return uuid_s;
-}
-
 static void
 nbctl_lport_add(struct ctl_context *ctx)
 {
@@ -794,26 +731,6 @@ nbctl_lport_add(struct ctl_context *ctx)
     free(new_ports);
 }
 
-/* Removes lrport 'lr->ports[idx]' from logical router. */
-static void
-remove_lrport(const struct nbrec_logical_router *lr, size_t idx)
-{
-    const struct nbrec_logical_router_port *lrport = lr->ports[idx];
-
-    /* First remove 'lrport' from the array of ports.  This is what will
-     * actually cause the logical port to be deleted when the transaction is
-     * sent to the database server (due to garbage collection). */
-    struct nbrec_logical_router_port **new_ports
-        = xmemdup(lr->ports, sizeof *new_ports * lr->n_ports);
-    new_ports[idx] = new_ports[lr->n_ports - 1];
-    nbrec_logical_router_verify_ports(lr);
-    nbrec_logical_router_set_ports(lr, new_ports, lr->n_ports - 1);
-    free(new_ports);
-
-    /* Delete 'lrport' from the IDL. */
-    nbrec_logical_router_port_delete(lrport);
-}
-
 /* Removes lport 'lswitch->ports[idx]'. */
 static void
 remove_lport(const struct nbrec_logical_switch *lswitch, size_t idx)
@@ -910,26 +827,6 @@ nbctl_lport_get_tag(struct ctl_context *ctx)
     }
 }
 
-/* Set the MAC address of lrport. */
-static void
-nbctl_lrport_set_mac(struct ctl_context *ctx)
-{
-    struct eth_addr ea;
-    const char *id = ctx->argv[1];
-    const struct nbrec_logical_router_port *lrport;
-
-    lrport = lrport_by_name_or_uuid(ctx, id, true);
-
-    const char *mac = ctx->argc > 2 ? ctx->argv[2] : "";
-    if (mac[0] && !ovs_scan(ctx->argv[2], ETH_ADDR_SCAN_FMT,
-                            ETH_ADDR_SCAN_ARGS(ea))) {
-        ctl_fatal("%s: invalid MAC address format", mac);
-        return;
-    }
-
-    nbrec_logical_router_port_set_mac(lrport, mac);
-}
-
 static void
 nbctl_lport_set_addresses(struct ctl_context *ctx)
 {
@@ -956,20 +853,6 @@ nbctl_lport_set_addresses(struct ctl_context *ctx)
             (const char **) ctx->argv + 2, ctx->argc - 2);
 }
 
-/* Following function prints the mac address of the lrport. */
-static void
-nbctl_lrport_get_mac(struct ctl_context *ctx)
-{
-    const char *id = ctx->argv[1];
-    const struct nbrec_logical_router_port *lrport;
-
-    lrport = lrport_by_name_or_uuid(ctx, id, true);
-    if (!lrport) {
-        return;
-    }
-    ds_put_format(&ctx->output, "%s\n", lrport->mac);
-}
-
 static void
 nbctl_lport_get_addresses(struct ctl_context *ctx)
 {
@@ -1047,23 +930,6 @@ parse_enabled(const char *state)
     }
 }
 
-/* Set the lrport admin-enabled state. */
-static void
-nbctl_lrport_set_enabled(struct ctl_context *ctx)
-{
-    const char *id = ctx->argv[1];
-    const char *state = ctx->argv[2];
-    const struct nbrec_logical_router_port *lrport;
-
-    lrport = lrport_by_name_or_uuid(ctx, id, true);
-    if (!lrport) {
-        return;
-    }
-
-    bool enabled = parse_enabled(state);
-    nbrec_logical_router_port_set_enabled(lrport, &enabled, 1);
-}
-
 static void
 nbctl_lport_set_enabled(struct ctl_context *ctx)
 {
@@ -1076,23 +942,6 @@ nbctl_lport_set_enabled(struct ctl_context *ctx)
     nbrec_logical_port_set_enabled(lport, &enabled, 1);
 }
 
-/* Print admin-enabled state for lrport. */
-static void
-nbctl_lrport_get_enabled(struct ctl_context *ctx)
-{
-    const char *id = ctx->argv[1];
-    const struct nbrec_logical_router_port *lrport;
-
-    lrport = lrport_by_name_or_uuid(ctx, id, true);
-    if (!lrport) {
-        return;
-    }
-
-    ds_put_format(&ctx->output, "%s\n",
-                  !lrport->enabled ||
-                  *lrport->enabled ? "enabled" : "disabled");
-}
-
 static void
 nbctl_lport_get_enabled(struct ctl_context *ctx)
 {
@@ -1420,6 +1269,238 @@ nbctl_lr_list(struct ctl_context *ctx)
     free(nodes);
 }
 
+static const struct nbrec_logical_router_port *
+lrp_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist)
+{
+    const struct nbrec_logical_router_port *lrp = NULL;
+
+    struct uuid lrp_uuid;
+    bool is_uuid = uuid_from_string(&lrp_uuid, id);
+    if (is_uuid) {
+        lrp = nbrec_logical_router_port_get_for_uuid(ctx->idl, &lrp_uuid);
+    }
+
+    if (!lrp) {
+        NBREC_LOGICAL_ROUTER_PORT_FOR_EACH(lrp, ctx->idl) {
+            if (!strcmp(lrp->name, id)) {
+                break;
+            }
+        }
+    }
+
+    if (!lrp && must_exist) {
+        ctl_fatal("%s: port %s not found", id, is_uuid ? "UUID" : "name");
+    }
+
+    return lrp;
+}
+
+/* Returns the logical router that contains 'lrp'. */
+static const struct nbrec_logical_router *
+lrp_to_lr(const struct ovsdb_idl *idl,
+               const struct nbrec_logical_router_port *lrp)
+{
+    const struct nbrec_logical_router *lr;
+    NBREC_LOGICAL_ROUTER_FOR_EACH (lr, idl) {
+        for (size_t i = 0; i < lr->n_ports; i++) {
+            if (lr->ports[i] == lrp) {
+                return lr;
+            }
+        }
+    }
+
+    /* Can't happen because of the database schema */
+    ctl_fatal("port %s is not part of any logical router",
+              lrp->name);
+}
+
+static const char *
+lr_get_name(const struct nbrec_logical_router *lr, char uuid_s[UUID_LEN + 1],
+            size_t uuid_s_size)
+{
+    if (lr->name[0]) {
+        return lr->name;
+    }
+    snprintf(uuid_s, uuid_s_size, UUID_FMT, UUID_ARGS(&lr->header_.uuid));
+    return uuid_s;
+}
+
+static void
+nbctl_lrp_add(struct ctl_context *ctx)
+{
+    bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL;
+
+    const struct nbrec_logical_router *lr;
+    lr = lr_by_name_or_uuid(ctx, ctx->argv[1], true);
+
+    const char *lrp_name = ctx->argv[2];
+    const struct nbrec_logical_router_port *lrp;
+    lrp = lrp_by_name_or_uuid(ctx, lrp_name, false);
+    if (lrp) {
+        if (!may_exist) {
+            ctl_fatal("%s: a port with this name already exists",
+                      lrp_name);
+        }
+
+        const struct nbrec_logical_router *bound_lr;
+        bound_lr = lrp_to_lr(ctx->idl, lrp);
+        if (bound_lr != lr) {
+            char uuid_s[UUID_LEN + 1];
+            ctl_fatal("%s: port already exists but in router %s", lrp_name,
+                      lr_get_name(bound_lr, uuid_s, sizeof uuid_s));
+        }
+
+        return;
+    }
+
+    struct eth_addr ea;
+    if (!ovs_scan(ctx->argv[3], ETH_ADDR_SCAN_FMT, ETH_ADDR_SCAN_ARGS(ea))) {
+        ctl_fatal("%s: invalid mac address.", ctx->argv[3]);
+    }
+
+    ovs_be32 ip;
+    unsigned int plen;
+    char *error = ip_parse_cidr(ctx->argv[4], &ip, &plen);
+    if (error) {
+        free(error);
+        struct in6_addr ipv6;
+        error = ipv6_parse_cidr(ctx->argv[4], &ipv6, &plen);
+        if (error) {
+            free(error);
+            ctl_fatal("%s: invalid network address.", ctx->argv[4]);
+        }
+    }
+
+    /* Create the logical port. */
+    lrp = nbrec_logical_router_port_insert(ctx->txn);
+    nbrec_logical_router_port_set_name(lrp, lrp_name);
+    nbrec_logical_router_port_set_mac(lrp, ctx->argv[3]);
+    nbrec_logical_router_port_set_network(lrp, ctx->argv[4]);
+    if (ctx->argc == 6) {
+        nbrec_logical_router_port_set_peer(lrp, ctx->argv[5]);
+    }
+
+    /* Insert the logical port into the logical router. */
+    nbrec_logical_router_verify_ports(lr);
+    struct nbrec_logical_router_port **new_ports = xmalloc(sizeof *new_ports *
+                                                        (lr->n_ports + 1));
+    memcpy(new_ports, lr->ports, sizeof *new_ports * lr->n_ports);
+    new_ports[lr->n_ports] = CONST_CAST(struct nbrec_logical_router_port *,
+                                             lrp);
+    nbrec_logical_router_set_ports(lr, new_ports, lr->n_ports + 1);
+    free(new_ports);
+}
+
+/* Removes logical router port 'lr->ports[idx]'. */
+static void
+remove_lrp(const struct nbrec_logical_router *lr, size_t idx)
+{
+    const struct nbrec_logical_router_port *lrp = lr->ports[idx];
+
+    /* First remove 'lrp' from the array of ports.  This is what will
+     * actually cause the logical port to be deleted when the transaction is
+     * sent to the database server (due to garbage collection). */
+    struct nbrec_logical_router_port **new_ports
+        = xmemdup(lr->ports, sizeof *new_ports * lr->n_ports);
+    new_ports[idx] = new_ports[lr->n_ports - 1];
+    nbrec_logical_router_verify_ports(lr);
+    nbrec_logical_router_set_ports(lr, new_ports, lr->n_ports - 1);
+    free(new_ports);
+
+    /* Delete 'lrp' from the IDL.  This won't have a real effect on
+     * the database server (the IDL will suppress it in fact) but it
+     * means that it won't show up when we iterate with
+     * NBREC_LOGICAL_ROUTER_PORT_FOR_EACH later. */
+    nbrec_logical_router_port_delete(lrp);
+}
+
+static void
+nbctl_lrp_del(struct ctl_context *ctx)
+{
+    bool must_exist = !shash_find(&ctx->options, "--if-exists");
+    const struct nbrec_logical_router_port *lrp;
+
+    lrp = lrp_by_name_or_uuid(ctx, ctx->argv[1], must_exist);
+    if (!lrp) {
+        return;
+    }
+
+    /* Find the router that contains 'lrp', then delete it. */
+    const struct nbrec_logical_router *lr;
+    NBREC_LOGICAL_ROUTER_FOR_EACH (lr, ctx->idl) {
+        for (size_t i = 0; i < lr->n_ports; i++) {
+            if (lr->ports[i] == lrp) {
+                remove_lrp(lr, i);
+                return;
+            }
+        }
+    }
+
+    /* Can't happen because of the database schema. */
+    ctl_fatal("logical port %s is not part of any logical router",
+              ctx->argv[1]);
+}
+
+/* Print a list of logical router ports. */
+static void
+nbctl_lrp_list(struct ctl_context *ctx)
+{
+    const char *id = ctx->argv[1];
+    const struct nbrec_logical_router *lr;
+    struct smap lrps;
+    size_t i;
+
+    lr = lr_by_name_or_uuid(ctx, id, true);
+
+    smap_init(&lrps);
+    for (i = 0; i < lr->n_ports; i++) {
+        const struct nbrec_logical_router_port *lrp = lr->ports[i];
+        smap_add_format(&lrps, lrp->name, UUID_FMT " (%s)",
+                        UUID_ARGS(&lrp->header_.uuid), lrp->name);
+    }
+    const struct smap_node **nodes = smap_sort(&lrps);
+    for (i = 0; i < smap_count(&lrps); i++) {
+        const struct smap_node *node = nodes[i];
+        ds_put_format(&ctx->output, "%s\n", node->value);
+    }
+    smap_destroy(&lrps);
+    free(nodes);
+}
+
+/* Set the logical router port admin-enabled state. */
+static void
+nbctl_lrp_set_enabled(struct ctl_context *ctx)
+{
+    const char *id = ctx->argv[1];
+    const char *state = ctx->argv[2];
+    const struct nbrec_logical_router_port *lrp;
+
+    lrp = lrp_by_name_or_uuid(ctx, id, true);
+    if (!lrp) {
+        return;
+    }
+
+    bool enabled = parse_enabled(state);
+    nbrec_logical_router_port_set_enabled(lrp, &enabled, 1);
+}
+
+/* Print admin-enabled state for logical router port. */
+static void
+nbctl_lrp_get_enabled(struct ctl_context *ctx)
+{
+    const char *id = ctx->argv[1];
+    const struct nbrec_logical_router_port *lrp;
+
+    lrp = lrp_by_name_or_uuid(ctx, id, true);
+    if (!lrp) {
+        return;
+    }
+
+    ds_put_format(&ctx->output, "%s\n",
+                  !lrp->enabled ||
+                  *lrp->enabled ? "enabled" : "disabled");
+}
+
 static const struct ctl_table_class tables[] = {
     {&nbrec_table_logical_switch,
      {{&nbrec_table_logical_switch, &nbrec_logical_switch_col_name, NULL},
@@ -1649,105 +1730,6 @@ nbctl_exit(int status)
     exit(status);
 }
 
-/* Print a list of lrports. */
-static void
-nbctl_lrport_list(struct ctl_context *ctx)
-{
-    const char *id = ctx->argv[1];
-    const struct nbrec_logical_router *lr;
-    struct smap lports;
-    size_t i;
-
-    lr = lr_by_name_or_uuid(ctx, id, true);
-
-    smap_init(&lports);
-    for (i = 0; i < lr->n_ports; i++) {
-        const struct nbrec_logical_router_port *lport = lr->ports[i];
-        smap_add_format(&lports, lport->name, UUID_FMT " (%s)",
-                        UUID_ARGS(&lport->header_.uuid), lport->name);
-    }
-    const struct smap_node **nodes = smap_sort(&lports);
-    for (i = 0; i < smap_count(&lports); i++) {
-        const struct smap_node *node = nodes[i];
-        ds_put_format(&ctx->output, "%s\n", node->value);
-    }
-    smap_destroy(&lports);
-    free(nodes);
-}
-
-/* Add an lrport to the logical router. */
-static void
-nbctl_lrport_add(struct ctl_context *ctx)
-{
-    bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL;
-
-    const struct nbrec_logical_router *lr;
-    lr = lr_by_name_or_uuid(ctx, ctx->argv[1], true);
-
-    const char *lrport_name = ctx->argv[2];
-    const struct nbrec_logical_router_port *lrport;
-
-    lrport = lrport_by_name_or_uuid(ctx, lrport_name, false);
-    if (lrport) {
-        if (!may_exist) {
-            ctl_fatal("%s: an lrport with this name already exists",
-                      lrport_name);
-        }
-
-        const struct nbrec_logical_router *bound_lr;
-        bound_lr = lrport_to_lr(ctx->idl, lrport);
-        if (bound_lr != lr) {
-            char uuid_s[UUID_LEN + 1];
-            ctl_fatal("%s: lrport already exists but in router %s",
-                      lrport_name,
-                      lr_get_name(bound_lr, uuid_s, sizeof uuid_s));
-        }
-
-        return;
-    }
-
-    /* Create the logical router port. */
-    lrport = nbrec_logical_router_port_insert(ctx->txn);
-    nbrec_logical_router_port_set_name(lrport, ctx->argv[2]);
-
-    /* Insert the logical port into the logical router. */
-    nbrec_logical_router_verify_ports(lr);
-    struct nbrec_logical_router_port **new_ports = xmalloc(sizeof *new_ports *
-                                                    (lr->n_ports + 1));
-    memcpy(new_ports, lr->ports, sizeof *new_ports * lr->n_ports);
-    new_ports[lr->n_ports] = CONST_CAST(
-        struct nbrec_logical_router_port *, lrport);
-    nbrec_logical_router_set_ports(lr, new_ports, lr->n_ports + 1);
-    free(new_ports);
-}
-
-/* Deletes an lrport from a logical router. */
-static void
-nbctl_lrport_del(struct ctl_context *ctx)
-{
-    bool must_exist = !shash_find(&ctx->options, "--if-exists");
-    const struct nbrec_logical_router_port *lrport;
-
-    lrport = lrport_by_name_or_uuid(ctx, ctx->argv[1], must_exist);
-    if (!lrport) {
-        return;
-    }
-
-    /* Find the router that contains 'lrport', then delete it. */
-    const struct nbrec_logical_router *lr;
-    NBREC_LOGICAL_ROUTER_FOR_EACH (lr, ctx->idl) {
-        for (size_t i = 0; i < lr->n_ports; i++) {
-            if (lr->ports[i] == lrport) {
-                remove_lrport(lr, i);
-                return;
-            }
-        }
-    }
-
-    ctl_fatal("logical router port %s is not part of any logical router",
-              ctx->argv[1]);
-}
-
 static const struct ctl_command_syntax nbctl_commands[] = {
     { "show", 0, 1, "[LSWITCH]", NULL, nbctl_show, NULL, "", RO },
 
@@ -1765,21 +1747,6 @@ static const struct ctl_command_syntax nbctl_commands[] = {
       nbctl_acl_del, NULL, "", RW },
     { "acl-list", 1, 1, "LSWITCH", NULL, nbctl_acl_list, NULL, "", RO },
 
-    /* lrport commands. */
-    { "lrport-add", 2, 2, "ROUTER LRPORT", NULL, nbctl_lrport_add,
-      NULL, "--may-exist", RW },
-    { "lrport-del", 1, 1, "LRPORT", NULL, nbctl_lrport_del, NULL, "", RO },
-    { "lrport-list", 1, 1, "ROUTER", NULL, nbctl_lrport_list, NULL, "", RO },
-    { "lrport-set-mac-address", 1, 2, "LRPORT [ADDRESS]", NULL,
-      nbctl_lrport_set_mac, NULL, "", RW },
-    { "lrport-get-mac-address", 1, 1, "LRPORT", NULL,
-      nbctl_lrport_get_mac, NULL,
-      "", RO },
-    { "lrport-set-enabled", 2, 2, "LRPORT STATE", NULL,
-      nbctl_lrport_set_enabled, NULL, "", RW },
-    { "lrport-get-enabled", 1, 1, "LRPORT", NULL,
-      nbctl_lrport_get_enabled, NULL, "", RO },
-
     /* lport commands. */
     { "lport-add", 2, 4, "LSWITCH LPORT [PARENT] [TAG]", NULL, nbctl_lport_add,
       NULL, "--may-exist", RW },
@@ -1819,6 +1786,16 @@ static const struct ctl_command_syntax nbctl_commands[] = {
     { "lr-del", 1, 1, "ROUTER", NULL, nbctl_lr_del, NULL, "--if-exists", RW },
     { "lr-list", 0, 0, "", NULL, nbctl_lr_list, NULL, "", RO },
 
+    /* logical router port commands. */
+    { "lrp-add", 4, 5, "ROUTER PORT MAC NETWORK [PEER]", NULL, nbctl_lrp_add,
+      NULL, "--may-exist", RW },
+    { "lrp-del", 1, 1, "LPORT", NULL, nbctl_lrp_del, NULL, "--if-exists", RW },
+    { "lrp-list", 1, 1, "ROUTER", NULL, nbctl_lrp_list, NULL, "", RO },
+    { "lrp-set-enabled", 2, 2, "PORT STATE", NULL, nbctl_lrp_set_enabled,
+      NULL, "", RW },
+    { "lrp-get-enabled", 1, 1, "PORT", NULL, nbctl_lrp_get_enabled,
+      NULL, "", RO },
+
     {NULL, 0, 0, NULL, NULL, NULL, NULL, "", RO},
 };
 
diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at
index 50d2723..2e8fc17 100644
--- a/tests/ovn-nbctl.at
+++ b/tests/ovn-nbctl.at
@@ -292,35 +292,35 @@ AT_CLEANUP
 
 dnl ---------------------------------------------------------------------
 
-AT_SETUP([ovn-nbctl - basic lrport commands])
+AT_SETUP([ovn-nbctl - basic logical router port commands])
 OVN_NBCTL_TEST_START
 
 AT_CHECK([ovn-nbctl lr-add lr0])
-AT_CHECK([ovn-nbctl lrport-add lr0 lrp0])
-AT_CHECK([ovn-nbctl lrport-add lr0 lrp0], [1], [],
-  [ovn-nbctl: lrp0: an lrport with this name already exists
+AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24])
+AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24], [1], [],
+  [ovn-nbctl: lrp0: a port with this name already exists
 ])
-AT_CHECK([ovn-nbctl --may-exist lrport-add lr0 lrp0])
-AT_CHECK([ovn-nbctl lrport-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
+AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24])
+AT_CHECK([ovn-nbctl lrp-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
 <0> (lrp0)
 ])
 
-AT_CHECK([ovn-nbctl lrport-add lr0 lrp1])
-AT_CHECK([ovn-nbctl lrport-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
+AT_CHECK([ovn-nbctl lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24])
+AT_CHECK([ovn-nbctl lrp-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
 <0> (lrp0)
 <1> (lrp1)
 ])
 
 AT_CHECK([ovn-nbctl lr-add lr1])
-AT_CHECK([ovn-nbctl lrport-add lr0 lrp1], [1], [],
-  [ovn-nbctl: lrp1: an lrport with this name already exists
+AT_CHECK([ovn-nbctl lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24], [1], [],
+  [ovn-nbctl: lrp1: a port with this name already exists
 ])
-AT_CHECK([ovn-nbctl --may-exist lrport-add lr1 lrp1], [1], [],
-  [ovn-nbctl: lrp1: lrport already exists but in router lr0
+AT_CHECK([ovn-nbctl --may-exist lrp-add lr1 lrp1 00:00:00:01:02:03 192.168.1.1/24], [1], [],
+  [ovn-nbctl: lrp1: port already exists but in router lr0
 ])
 
-AT_CHECK([ovn-nbctl lrport-del lrp1])
-AT_CHECK([ovn-nbctl lrport-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
+AT_CHECK([ovn-nbctl lrp-del lrp1])
+AT_CHECK([ovn-nbctl lrp-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
 <0> (lrp0)
 ])
 
@@ -329,44 +329,23 @@ AT_CLEANUP
 
 dnl ---------------------------------------------------------------------
 
-AT_SETUP([ovn-nbctl - lrport addresses])
+AT_SETUP([ovn-nbctl - logical router port enable and disable])
 OVN_NBCTL_TEST_START
 
 AT_CHECK([ovn-nbctl lr-add lr0])
-AT_CHECK([ovn-nbctl lrport-add lr0 lrp0])
-AT_CHECK([ovn-nbctl lrport-get-mac-address lrp0], [0], [
+AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24])
+AT_CHECK([ovn-nbctl lrp-get-enabled lrp0], [0], [enabled
 ])
 
-AT_CHECK([ovn-nbctl lrport-set-mac-address lrp0 00:11:22:33:44:55])
-AT_CHECK([ovn-nbctl lrport-get-mac-address lrp0], [0], [00:11:22:33:44:55
+AT_CHECK([ovn-nbctl lrp-set-enabled lrp0 disabled])
+AT_CHECK([ovn-nbctl lrp-get-enabled lrp0], [0], [disabled
 ])
 
-AT_CHECK([ovn-nbctl lrport-set-mac-address lrp0])
-AT_CHECK([ovn-nbctl lrport-get-mac-address lrp0], [0], [
+AT_CHECK([ovn-nbctl lrp-set-enabled lrp0 enabled])
+AT_CHECK([ovn-nbctl lrp-get-enabled lrp0], [0], [enabled
 ])
 
-OVN_NBCTL_TEST_STOP
-AT_CLEANUP
-
-dnl ---------------------------------------------------------------------
-
-AT_SETUP([ovn-nbctl - lrport enable and disable])
-OVN_NBCTL_TEST_START
-
-AT_CHECK([ovn-nbctl lr-add lr0])
-AT_CHECK([ovn-nbctl lrport-add lr0 lrp0])
-AT_CHECK([ovn-nbctl lrport-get-enabled lrp0], [0], [enabled
-])
-
-AT_CHECK([ovn-nbctl lrport-set-enabled lrp0 disabled])
-AT_CHECK([ovn-nbctl lrport-get-enabled lrp0], [0], [disabled
-])
-
-AT_CHECK([ovn-nbctl lrport-set-enabled lrp0 enabled])
-AT_CHECK([ovn-nbctl lrport-get-enabled lrp0], [0], [enabled
-])
-
-AT_CHECK([ovn-nbctl lrport-set-enabled lrp0 xyzzy], [1], [],
+AT_CHECK([ovn-nbctl lrp-set-enabled lrp0 xyzzy], [1], [],
   [ovn-nbctl: xyzzy: state must be "enabled" or "disabled"
 ])
 
diff --git a/tests/ovn.at b/tests/ovn.at
index af92904..0b9d3d1 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -1266,13 +1266,11 @@ done
 ovn-nbctl lr-add lr0
 for i in 1 2 3; do
     for j in 1 2 3; do
-	lrp_uuid=`ovn-nbctl \
-	    -- --id=@lrp create Logical_Router_Port name=lrp$i$j \
-	       network=192.168.$i$j.254/24 mac='"00:00:00:00:ff:'$i$j'"' \
-	    -- add Logical_Router lr0 ports @lrp \
-	    -- lport-add ls$i lrp$i$j-attachment`
-	ovn-nbctl \
-	    set Logical_Port lrp$i$j-attachment type=router \
+	    ovn-nbctl lrp-add lr0 lrp$i$j 00:00:00:00:ff:$i$j \
+            192.168.$i$j.254/24 lrp$i$j-attachment
+	    ovn-nbctl \
+            -- lport-add ls$i lrp$i$j-attachment \
+	        -- set Logical_Port lrp$i$j-attachment type=router \
                              options:router-port=lrp$i$j \
                              addresses='"00:00:00:00:ff:'$i$j'"'
     done
@@ -2084,32 +2082,20 @@ ovn-nbctl lswitch-add ls1
 ovn-nbctl lswitch-add ls2
 
 # Connect ls1 to R1
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=ls1 \
-network=192.168.1.1/24 mac=\"00:00:00:01:02:03\" -- add Logical_Router R1 \
-ports @lrp -- lport-add ls1 rp-ls1
+ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:03 192.168.1.1/24 rp-ls1
 
-ovn-nbctl set Logical_port rp-ls1 type=router options:router-port=ls1 \
-addresses=\"00:00:00:01:02:03\"
+ovn-nbctl lport-add ls1 rp-ls1 -- set Logical_port rp-ls1 type=router \
+  options:router-port=ls1 addresses=\"00:00:00:01:02:03\"
 
 # Connect ls2 to R2
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=ls2 \
-network=172.16.1.1/24 mac=\"00:00:00:01:02:04\" -- add Logical_Router R2 \
-ports @lrp -- lport-add ls2 rp-ls2
+ovn-nbctl lrp-add R2 ls2 00:00:00:01:02:04 172.16.1.1/24 rp-ls2
 
-ovn-nbctl set Logical_port rp-ls2 type=router options:router-port=ls2 \
-addresses=\"00:00:00:01:02:04\"
+ovn-nbctl lport-add ls2 rp-ls2 -- set Logical_port rp-ls2 type=router \
+  options:router-port=ls2 addresses=\"00:00:00:01:02:04\"
 
 # Connect R1 to R2
-lrp1_uuid=`ovn-nbctl -- --id=@lrp create Logical_Router_port name=R1_R2 \
-network="20.0.0.1/24" mac=\"00:00:00:02:03:04\" \
--- add Logical_Router R1 ports @lrp`
-
-lrp2_uuid=`ovn-nbctl -- --id=@lrp create Logical_Router_port name=R2_R1 \
-network="20.0.0.2/24" mac=\"00:00:00:02:03:05\" \
--- add Logical_Router R2 ports @lrp`
-
-ovn-nbctl set logical_router_port $lrp1_uuid peer="R2_R1"
-ovn-nbctl set logical_router_port $lrp2_uuid peer="R1_R2"
+ovn-nbctl lrp-add R1 R1_R2 00:00:00:02:03:04 20.0.0.1/24 R2_R1
+ovn-nbctl lrp-add R2 R2_R1 00:00:00:02:03:05 20.0.0.2/24 R1_R2
 
 ovn-nbctl set Logical_Router R1 default_gw="20.0.0.2"
 ovn-nbctl set Logical_Router R2 default_gw="20.0.0.1"
@@ -2240,20 +2226,14 @@ ovn-nbctl lswitch-add ls1
 ovn-nbctl lswitch-add ls2
 
 # Connect ls1 to R1
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=ls1 \
-network=192.168.1.1/24 mac=\"00:00:00:01:02:03\" -- add Logical_Router R1 \
-ports @lrp -- lport-add ls1 rp-ls1
-
-ovn-nbctl set Logical_port rp-ls1 type=router options:router-port=ls1 \
-addresses=\"00:00:00:01:02:03\"
+ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:03 192.168.1.1/24 rp-ls1
+ovn-nbctl lport-add ls1 rp-ls1 -- set Logical_port rp-ls1 type=router \
+          options:router-port=ls1 addresses=\"00:00:00:01:02:03\"
 
 # Connect ls2 to R1
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=ls2 \
-network=172.16.1.1/24 mac=\"00:00:00:01:02:04\" -- add Logical_Router R1 \
-ports @lrp -- lport-add ls2 rp-ls2
-
-ovn-nbctl set Logical_port rp-ls2 type=router options:router-port=ls2 \
-addresses=\"00:00:00:01:02:04\"
+ovn-nbctl lrp-add R1 ls2 00:00:00:01:02:04 172.16.1.1/24 rp-ls2
+ovn-nbctl lport-add ls2 rp-ls2 -- set Logical_port rp-ls2 type=router \
+          options:router-port=ls2 addresses=\"00:00:00:01:02:04\"
 
 # Create logical port ls1-lp1 in ls1
 ovn-nbctl lport-add ls1 ls1-lp1 \
@@ -2385,40 +2365,23 @@ ovn-nbctl lswitch-add alice
 ovn-nbctl lswitch-add bob
 
 # Connect foo to R1
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=foo \
-network=192.168.1.1/24 mac=\"00:00:00:01:02:03\" -- add Logical_Router R1 \
-ports @lrp -- lport-add foo rp-foo
-
-ovn-nbctl set Logical_port rp-foo type=router options:router-port=foo \
-addresses=\"00:00:00:01:02:03\"
+ovn-nbctl lrp-add R1 foo 00:00:00:01:02:03 192.168.1.1/24 rp-foo
+ovn-nbctl lport-add foo rp-foo -- set Logical_port rp-foo type=router \
+          options:router-port=foo addresses=\"00:00:00:01:02:03\"
 
 # Connect alice to R2
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=alice \
-network=172.16.1.1/24 mac=\"00:00:00:01:02:04\" -- add Logical_Router R2 \
-ports @lrp -- lport-add alice rp-alice
-
-ovn-nbctl set Logical_port rp-alice type=router options:router-port=alice \
-addresses=\"00:00:00:01:02:04\"
+ovn-nbctl lrp-add R2 alice 00:00:00:01:02:04 172.16.1.1/24 rp-alice
+ovn-nbctl lport-add alice rp-alice -- set Logical_port rp-alice type=router \
+          options:router-port=alice addresses=\"00:00:00:01:02:04\"
 
 # Connect bob to R2
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=bob \
-network=172.16.2.1/24 mac=\"00:00:00:01:02:05\" -- add Logical_Router R2 \
-ports @lrp -- lport-add bob rp-bob
-
-ovn-nbctl set Logical_port rp-bob type=router options:router-port=bob \
-addresses=\"00:00:00:01:02:05\"
+ovn-nbctl lrp-add R2 bob 00:00:00:01:02:05 172.16.2.1/24 rp-bob
+ovn-nbctl lport-add bob rp-bob -- set Logical_port rp-bob type=router \
+          options:router-port=bob addresses=\"00:00:00:01:02:05\"
 
 # Connect R1 to R2
-lrp1_uuid=`ovn-nbctl -- --id=@lrp create Logical_Router_port name=R1_R2 \
-network="20.0.0.1/24" mac=\"00:00:00:02:03:04\" \
--- add Logical_Router R1 ports @lrp`
-
-lrp2_uuid=`ovn-nbctl -- --id=@lrp create Logical_Router_port name=R2_R1 \
-network="20.0.0.2/24" mac=\"00:00:00:02:03:05\" \
--- add Logical_Router R2 ports @lrp`
-
-ovn-nbctl set logical_router_port $lrp1_uuid peer="R2_R1"
-ovn-nbctl set logical_router_port $lrp2_uuid peer="R1_R2"
+ovn-nbctl lrp-add R1 R1_R2 00:00:00:02:03:04 20.0.0.1/24 R2_R1
+ovn-nbctl lrp-add R2 R2_R1 00:00:00:02:03:05 20.0.0.2/24 R1_R2
 
 #install static routes
 ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \
@@ -2655,53 +2618,35 @@ ovn-nbctl lswitch-add bob
 ovn-nbctl lswitch-add join
 
 # Connect foo to R1
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=foo \
-network=192.168.1.1/24 mac=\"00:00:01:01:02:03\" -- add Logical_Router R1 \
-ports @lrp -- lport-add foo rp-foo
-
-ovn-nbctl set Logical_port rp-foo type=router options:router-port=foo \
-addresses=\"00:00:01:01:02:03\"
+ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24
+ovn-nbctl lport-add foo rp-foo -- set Logical_port rp-foo type=router \
+    options:router-port=foo addresses=\"00:00:01:01:02:03\"
 
 # Connect alice to R2
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=alice \
-network=172.16.1.1/24 mac=\"00:00:02:01:02:03\" -- add Logical_Router R2 \
-ports @lrp -- lport-add alice rp-alice
-
-ovn-nbctl set Logical_port rp-alice type=router options:router-port=alice \
-addresses=\"00:00:02:01:02:03\"
+ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24
+ovn-nbctl lport-add alice rp-alice -- set Logical_port rp-alice type=router \
+    options:router-port=alice addresses=\"00:00:02:01:02:03\"
 
 # Connect bob to R3
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=bob \
-network=10.32.1.1/24 mac=\"00:00:03:01:02:03\" -- add Logical_Router R3 \
-ports @lrp -- lport-add bob rp-bob
-
-ovn-nbctl set Logical_port rp-bob type=router options:router-port=bob \
-addresses=\"00:00:03:01:02:03\"
+ovn-nbctl lrp-add R3 bob 00:00:03:01:02:03 10.32.1.1/24
+ovn-nbctl lport-add bob rp-bob -- set Logical_port rp-bob type=router \
+    options:router-port=bob addresses=\"00:00:03:01:02:03\"
 
 # Connect R1 to join
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=R1_join \
-network=20.0.0.1/24 mac=\"00:00:04:01:02:03\" -- add Logical_Router R1 \
-ports @lrp -- lport-add join r1-join
-
-ovn-nbctl set Logical_port r1-join type=router options:router-port=R1_join \
-addresses='"00:00:04:01:02:03"'
+ovn-nbctl lrp-add R1 R1_join 00:00:04:01:02:03 20.0.0.1/24
+ovn-nbctl lport-add join r1-join -- set Logical_port r1-join type=router \
+    options:router-port=R1_join addresses='"00:00:04:01:02:03"'
 
 # Connect R2 to join
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=R2_join \
-network=20.0.0.2/24 mac=\"00:00:04:01:02:04\" -- add Logical_Router R2 \
-ports @lrp -- lport-add join r2-join
-
-ovn-nbctl set Logical_port r2-join type=router options:router-port=R2_join \
-addresses='"00:00:04:01:02:04"'
+ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24
+ovn-nbctl lport-add join r2-join -- set Logical_port r2-join type=router \
+    options:router-port=R2_join addresses='"00:00:04:01:02:04"'
 
 
 # Connect R3 to join
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=R3_join \
-network=20.0.0.3/24 mac=\"00:00:04:01:02:05\" -- add Logical_Router R3 \
-ports @lrp -- lport-add join r3-join
-
-ovn-nbctl set Logical_port r3-join type=router options:router-port=R3_join \
-addresses='"00:00:04:01:02:05"'
+ovn-nbctl lrp-add R3 R3_join 00:00:04:01:02:05 20.0.0.3/24
+ovn-nbctl lport-add join r3-join -- set Logical_port r3-join type=router \
+    options:router-port=R3_join addresses='"00:00:04:01:02:05"'
 
 #install static routes
 ovn-nbctl -- --id=@lrt create Logical_Router_Static_Route \
@@ -2922,37 +2867,24 @@ ovn-nbctl lswitch-add alice
 ovn-nbctl lswitch-add join
 
 # Connect foo to R1
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=foo \
-network=192.168.1.1/24 mac=\"00:00:01:01:02:03\" -- add Logical_Router R1 \
-ports @lrp -- lport-add foo rp-foo
-
-ovn-nbctl set Logical_port rp-foo type=router options:router-port=foo \
-addresses=\"00:00:01:01:02:03\"
+ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24
+ovn-nbctl lport-add foo rp-foo -- set Logical_port rp-foo type=router \
+    options:router-port=foo addresses=\"00:00:01:01:02:03\"
 
 # Connect alice to R2
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=alice \
-network=172.16.1.1/24 mac=\"00:00:02:01:02:03\" -- add Logical_Router R2 \
-ports @lrp -- lport-add alice rp-alice
-
-ovn-nbctl set Logical_port rp-alice type=router options:router-port=alice \
-addresses=\"00:00:02:01:02:03\"
-
+ovn-nbctl lrp-add R2 alice 00:00:02:01:02:03 172.16.1.1/24
+ovn-nbctl lport-add alice rp-alice -- set Logical_port rp-alice type=router \
+    options:router-port=alice addresses=\"00:00:02:01:02:03\"
 
 # Connect R1 to join
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=R1_join \
-network=20.0.0.1/24 mac=\"00:00:04:01:02:03\" -- add Logical_Router R1 \
-ports @lrp -- lport-add join r1-join
-
-ovn-nbctl set Logical_port r1-join type=router options:router-port=R1_join \
-addresses='"00:00:04:01:02:03"'
+ovn-nbctl lrp-add R1 R1_join 00:00:04:01:02:03 20.0.0.1/24
+ovn-nbctl lport-add join r1-join -- set Logical_port r1-join type=router \
+    options:router-port=R1_join addresses='"00:00:04:01:02:03"'
 
 # Connect R2 to join
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=R2_join \
-network=20.0.0.2/24 mac=\"00:00:04:01:02:04\" -- add Logical_Router R2 \
-ports @lrp -- lport-add join r2-join
-
-ovn-nbctl set Logical_port r2-join type=router options:router-port=R2_join \
-addresses='"00:00:04:01:02:04"'
+ovn-nbctl lrp-add R2 R2_join 00:00:04:01:02:04 20.0.0.2/24
+ovn-nbctl lport-add join r2-join -- set Logical_port r2-join type=router \
+    options:router-port=R2_join addresses='"00:00:04:01:02:04"'
 
 
 #install static routes
@@ -3070,20 +3002,14 @@ ovn-nbctl lswitch-add ls1
 ovn-nbctl lswitch-add ls2
 
 # Connect ls1 to R1
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=ls1 \
-network=192.168.1.1/24 mac=\"00:00:00:01:02:f1\" -- add Logical_Router R1 \
-ports @lrp -- lport-add ls1 rp-ls1
-
-ovn-nbctl set Logical_port rp-ls1 type=router options:router-port=ls1 \
-addresses=\"00:00:00:01:02:f1\"
+ovn-nbctl lrp-add R1 ls1 00:00:00:01:02:f1 192.168.1.1/24
+ovn-nbctl lport-add ls1 rp-ls1 -- set Logical_port rp-ls1 type=router \
+    options:router-port=ls1 addresses=\"00:00:00:01:02:f1\"
 
 # Connect ls2 to R1
-ovn-nbctl -- --id=@lrp create Logical_Router_port name=ls2 \
-network=172.16.1.1/24 mac=\"00:00:00:01:02:f2\" -- add Logical_Router R1 \
-ports @lrp -- lport-add ls2 rp-ls2
-
-ovn-nbctl set Logical_port rp-ls2 type=router options:router-port=ls2 \
-addresses=\"00:00:00:01:02:f2\"
+ovn-nbctl lrp-add R1 ls2 00:00:00:01:02:f2 172.16.1.1/24
+ovn-nbctl lport-add ls2 rp-ls2 -- set Logical_port rp-ls2 type=router \
+    options:router-port=ls2 addresses=\"00:00:00:01:02:f2\"
 
 # Create logical port ls1-lp1 in ls1
 ovn-nbctl lport-add ls1 ls1-lp1 \
-- 
1.9.1





More information about the dev mailing list