Add a command to get the 'up' state of a logical port.

Signed-off-by: Russell Bryant <rbry...@redhat.com>
---
 ovn/ovn-nbctl.8.xml |  1 +
 ovn/ovn-nbctl.c     | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/ovn/ovn-nbctl.8.xml b/ovn/ovn-nbctl.8.xml
index 03c8e13..7cdef00 100644
--- a/ovn/ovn-nbctl.8.xml
+++ b/ovn/ovn-nbctl.8.xml
@@ -24,6 +24,7 @@
     <p><code>lport-get-external-id</code> <var>lport</var> [<var>key</var>]</p>
     <p><code>lport-set-macs</code> <var>lport</var> [<var>mac</var>] 
[<var>mac</var>] [...]</p>
     <p><code>lport-get-macs</code> <var>lport</var></p>
+    <p><code>lport-get-up</code> <var>lport</var></p>
 
     <h1>Options</h1>
     <p><code>-d</code> <var>database</var> | <code>--db</code> 
<var>database</var></p>
diff --git a/ovn/ovn-nbctl.c b/ovn/ovn-nbctl.c
index 10fa5f8..f689ec4 100644
--- a/ovn/ovn-nbctl.c
+++ b/ovn/ovn-nbctl.c
@@ -67,6 +67,7 @@ Logical Port Commands:\n\
                             Set MAC addresses for the logical port. Specify\n\
                             more than one using additional arguments.\n\
   lport-get-macs <lport>    Get a list of MAC addresses on the port.\n\
+  lport-get-up <lport>      Get the 'up' state of the port.\n\
 \n\
 Options:\n\
   --db=DATABASE             connect to DATABASE\n\
@@ -408,6 +409,21 @@ do_lport_get_macs(struct ovs_cmdl_context *ctx)
         printf("%s\n", lport->macs[i]);
     }
 }
+
+static void
+do_lport_get_up(struct ovs_cmdl_context *ctx)
+{
+    struct nbctl_context *nb_ctx = ctx->pvt;
+    const char *id = ctx->argv[1];
+    const struct nbrec_logical_port *lport;
+
+    lport = lport_by_name_or_uuid(nb_ctx, id);
+    if (!lport) {
+        return;
+    }
+
+    printf("%s\n", (lport->up && *lport->up) ? "true" : "false");
+}
 
 static void
 parse_options(int argc, char *argv[])
@@ -552,6 +568,13 @@ static const struct ovs_cmdl_command all_commands[] = {
         .max_args = 1,
         .handler = do_lport_get_macs,
     },
+    {
+        .name = "lport-get-up",
+        .usage = "<lport>",
+        .min_args = 1,
+        .max_args = 1,
+        .handler = do_lport_get_up,
+    },
 
     {
         /* sentinel */
-- 
2.1.0

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to