]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Report secret usage error message similarly
authorJohn Ferlan <jferlan@redhat.com>
Tue, 6 Aug 2013 11:52:46 +0000 (07:52 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 20 Aug 2013 17:27:44 +0000 (13:27 -0400)
Each of the modules handled reporting error messages from the secret fetching
slightly differently with respect to the error. Provide a similar message
for each error case and provide as much data as possible.

src/qemu/qemu_command.c
src/storage/storage_backend_iscsi.c
src/storage/storage_backend_rbd.c

index 71c220f19d48c6237ee8cd3412658b41014ae1f6..f1511732417984afbd9f82e6db6c95ee3f45d451 100644 (file)
@@ -3043,18 +3043,32 @@ qemuGetSecretString(virConnectPtr conn,
     }
 
     if (!sec) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("%s username '%s' specified but secret not found"),
-                       scheme, username);
+        if (diskSecretType == VIR_DOMAIN_DISK_SECRET_TYPE_UUID) {
+            virReportError(VIR_ERR_NO_SECRET,
+                           _("%s no secret matches uuid '%s'"),
+                           scheme, uuid);
+        } else {
+            virReportError(VIR_ERR_NO_SECRET,
+                           _("%s no secret matches usage value '%s'"),
+                           scheme, usage);
+        }
         goto cleanup;
     }
 
     secret = (char *)conn->secretDriver->secretGetValue(sec, &secret_size, 0,
                                                         VIR_SECRET_GET_VALUE_INTERNAL_CALL);
     if (!secret) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("could not get value of the secret for username %s"),
-                       username);
+        if (diskSecretType == VIR_DOMAIN_DISK_SECRET_TYPE_UUID) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("could not get value of the secret for "
+                             "username '%s' using uuid '%s'"),
+                           username, uuid);
+        } else {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("could not get value of the secret for "
+                             "username '%s' using usage value '%s'"),
+                           username, usage);
+        }
         goto cleanup;
     }
 
index ee8dd2e7272c5d44b7c88b4451cf0ad481e05b09..e71ea46aaa5d75fb7c325b7e6e371a53a406ed91 100644 (file)
@@ -732,15 +732,29 @@ virStorageBackendISCSISetAuth(const char *portal,
             conn->secretDriver->secretGetValue(secret, &secret_size, 0,
                                                VIR_SECRET_GET_VALUE_INTERNAL_CALL);
         if (!secret_value) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("could not get the value of the secret "
-                             "for username %s"), chap.username);
+            if (chap.secret.uuidUsable) {
+                virReportError(VIR_ERR_INTERNAL_ERROR,
+                               _("could not get the value of the secret "
+                                 "for username %s using uuid '%s'"),
+                                 chap.username, chap.secret.uuid);
+            } else {
+                virReportError(VIR_ERR_INTERNAL_ERROR,
+                               _("could not get the value of the secret "
+                                 "for username %s using usage value '%s'"),
+                                 chap.username, chap.secret.usage);
+            }
             goto cleanup;
         }
     } else {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("username '%s' specified but secret not found"),
-                       chap.username);
+        if (chap.secret.uuidUsable) {
+            virReportError(VIR_ERR_NO_SECRET,
+                           _("no secret matches uuid '%s'"),
+                           chap.secret.uuid);
+        } else {
+            virReportError(VIR_ERR_NO_SECRET,
+                           _("no secret matches usage value '%s'"),
+                           chap.secret.usage);
+        }
         goto cleanup;
     }
 
index e3340f63f412c22d025f615beb7cfed25f00107b..d9e17890413cc91da4945c7196e42a0a980832fb 100644 (file)
@@ -91,8 +91,15 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr *ptr,
         }
 
         if (secret == NULL) {
-            virReportError(VIR_ERR_NO_SECRET, "%s",
-                           _("failed to find the secret"));
+            if (pool->def->source.auth.cephx.secret.uuidUsable) {
+                virReportError(VIR_ERR_NO_SECRET,
+                               _("no secret matches uuid '%s'"),
+                                 pool->def->source.auth.cephx.secret.uuid);
+            } else {
+                virReportError(VIR_ERR_NO_SECRET,
+                               _("no secret matches usage value '%s'"),
+                                 pool->def->source.auth.cephx.secret.usage);
+            }
             goto cleanup;
         }
 
@@ -100,10 +107,19 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr *ptr,
                                                           VIR_SECRET_GET_VALUE_INTERNAL_CALL);
 
         if (!secret_value) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("could not get the value of the secret "
-                             "for username %s"),
-                           pool->def->source.auth.cephx.username);
+            if (pool->def->source.auth.cephx.secret.uuidUsable) {
+                virReportError(VIR_ERR_INTERNAL_ERROR,
+                               _("could not get the value of the secret "
+                                 "for username '%s' using uuid '%s'"),
+                               pool->def->source.auth.cephx.username,
+                               pool->def->source.auth.cephx.secret.uuid);
+            } else {
+                virReportError(VIR_ERR_INTERNAL_ERROR,
+                               _("could not get the value of the secret "
+                                 "for username '%s' using usage value '%s'"),
+                               pool->def->source.auth.cephx.username,
+                               pool->def->source.auth.cephx.secret.usage);
+            }
             goto cleanup;
         }