render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
43fe83
From e387f0a8337a7a9acb0aec433f1f90a1c4cdeb80 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <e387f0a8337a7a9acb0aec433f1f90a1c4cdeb80.1377873641.git.jdenemar@redhat.com>
43fe83
From: John Ferlan <jferlan@redhat.com>
43fe83
Date: Thu, 22 Aug 2013 16:56:23 -0400
43fe83
Subject: [PATCH] virsh: Print cephx and iscsi usage
43fe83
43fe83
https://bugzilla.redhat.com/show_bug.cgi?id=1000155
43fe83
43fe83
When using virsh secret-list - if the secret types are cephx or iscsi,
43fe83
then allow fetch/print of the usage information. Prior to the change
43fe83
the following would print:
43fe83
43fe83
UUID                                 Usage
43fe83
-----------------------------------------------------------
43fe83
1b40a534-8301-45d5-b1aa-11894ebb1735 Unused
43fe83
a5ba3efe-6adf-4a6a-b243-f010a043e314 Unused
43fe83
43fe83
Afterwards:
43fe83
43fe83
UUID                                 Usage
43fe83
-----------------------------------------------------------
43fe83
1b40a534-8301-45d5-b1aa-11894ebb1735 ceph ceph_example
43fe83
a5ba3efe-6adf-4a6a-b243-f010a043e314 iscsi libvirtiscsi
43fe83
43fe83
(cherry picked from commit db1382f322841a7f8c877151644f49c147664fec)
43fe83
---
43fe83
 tools/virsh-secret.c | 14 +++++---------
43fe83
 1 file changed, 5 insertions(+), 9 deletions(-)
43fe83
43fe83
diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c
43fe83
index c4763e3..e849a79 100644
43fe83
--- a/tools/virsh-secret.c
43fe83
+++ b/tools/virsh-secret.c
43fe83
@@ -38,6 +38,7 @@
43fe83
 #include "virfile.h"
43fe83
 #include "virutil.h"
43fe83
 #include "virxml.h"
43fe83
+#include "conf/secret_conf.h"
43fe83
 
43fe83
 static virSecretPtr
43fe83
 vshCommandOptSecret(vshControl *ctl, const vshCmd *cmd, const char **name)
43fe83
@@ -536,15 +537,10 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
43fe83
 
43fe83
     for (i = 0; i < list->nsecrets; i++) {
43fe83
         virSecretPtr sec = list->secrets[i];
43fe83
-        const char *usageType = NULL;
43fe83
-
43fe83
-        switch (virSecretGetUsageType(sec)) {
43fe83
-        case VIR_SECRET_USAGE_TYPE_VOLUME:
43fe83
-            usageType = _("Volume");
43fe83
-            break;
43fe83
-        }
43fe83
-
43fe83
+        int usageType = virSecretGetUsageType(sec);
43fe83
+        const char *usageStr = virSecretUsageTypeTypeToString(usageType);
43fe83
         char uuid[VIR_UUID_STRING_BUFLEN];
43fe83
+
43fe83
         if (virSecretGetUUIDString(list->secrets[i], uuid) < 0) {
43fe83
             vshError(ctl, "%s", _("Failed to get uuid of secret"));
43fe83
             goto cleanup;
43fe83
@@ -552,7 +548,7 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
43fe83
 
43fe83
         if (usageType) {
43fe83
             vshPrint(ctl, "%-36s %s %s\n",
43fe83
-                     uuid, usageType,
43fe83
+                     uuid, usageStr,
43fe83
                      virSecretGetUsageID(sec));
43fe83
         } else {
43fe83
             vshPrint(ctl, "%-36s %s\n",
43fe83
-- 
43fe83
1.8.3.2
43fe83