[PATCH v2 06/11] virsh: Add option --title for nwfilter-list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: K Shiva Kiran <shiva_kr@xxxxxxxxxx>
---
 docs/manpages/virsh.rst |  5 ++++-
 tools/virsh-nwfilter.c  | 36 ++++++++++++++++++++++++++++++------
 2 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index e15f1832e7..5e03ce1e18 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -8083,10 +8083,13 @@ nwfilter-list
 
 ::
 
-   nwfilter-list
+   nwfilter-list [--title]
 
 List all of the available network filters.
 
+If *--title* is specified, then the short network filter description
+(title) is printed in an extra column.
+
 
 nwfilter-dumpxml
 ----------------
diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c
index 801a52746e..ca803865bf 100644
--- a/tools/virsh-nwfilter.c
+++ b/tools/virsh-nwfilter.c
@@ -407,6 +407,10 @@ static const vshCmdInfo info_nwfilter_list[] = {
 };
 
 static const vshCmdOptDef opts_nwfilter_list[] = {
+    {.name = "title",
+     .type = VSH_OT_BOOL,
+     .help = N_("show network filter title")
+    },
     {.name = NULL}
 };
 
@@ -416,13 +420,18 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     size_t i;
     char uuid[VIR_UUID_STRING_BUFLEN];
     bool ret = false;
+    bool optTitle = vshCommandOptBool(cmd, "title");
     struct virshNWFilterList *list = NULL;
     g_autoptr(vshTable) table = NULL;
 
     if (!(list = virshNWFilterListCollect(ctl, 0)))
         return false;
 
-    table = vshTableNew(_("UUID"), _("Name"), NULL);
+    if (optTitle)
+        table = vshTableNew(_("UUID"), _("Name"), _("Title"), NULL);
+    else
+        table = vshTableNew(_("UUID"), _("Name"), NULL);
+
     if (!table)
         goto cleanup;
 
@@ -430,11 +439,26 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
         virNWFilterPtr nwfilter = list->filters[i];
 
         virNWFilterGetUUIDString(nwfilter, uuid);
-        if (vshTableRowAppend(table,
-                              uuid,
-                              virNWFilterGetName(nwfilter),
-                              NULL) < 0)
-            goto cleanup;
+
+        if (optTitle) {
+            g_autofree char *title = NULL;
+            if (!(title = virshGetNWFilterDescription(ctl, nwfilter, true, 0, 0)))
+                goto cleanup;
+
+            if (vshTableRowAppend(table,
+                        uuid,
+                        virNWFilterGetName(nwfilter),
+                        title,
+                        NULL) < 0)
+                goto cleanup;
+
+        } else {
+            if (vshTableRowAppend(table,
+                        uuid,
+                        virNWFilterGetName(nwfilter),
+                        NULL) < 0)
+                goto cleanup;
+        }
     }
 
     vshTablePrintToStdout(table, ctl);
-- 
2.42.0





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux