提交 eff43d9a 编写于 作者: J John Ferlan

Add secretObjFromSecret

Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 0e3e00a1
...@@ -184,6 +184,23 @@ secretAssignDef(virSecretObjPtr *list, ...@@ -184,6 +184,23 @@ secretAssignDef(virSecretObjPtr *list,
return secret; return secret;
} }
static virSecretObjPtr
secretObjFromSecret(virSecretPtr secret)
{
virSecretObjPtr obj;
char uuidstr[VIR_UUID_STRING_BUFLEN];
if (!(obj = secretFindByUUID(secret->uuid))) {
virUUIDFormat(secret->uuid, uuidstr);
virReportError(VIR_ERR_NO_SECRET,
_("no secret with matching uuid '%s'"), uuidstr);
return NULL;
}
return obj;
}
/* Permament secret storage */ /* Permament secret storage */
/* Secrets are stored in virSecretDriverStatePtr->configDir. Each secret /* Secrets are stored in virSecretDriverStatePtr->configDir. Each secret
...@@ -858,13 +875,8 @@ secretGetXMLDesc(virSecretPtr obj, ...@@ -858,13 +875,8 @@ secretGetXMLDesc(virSecretPtr obj,
secretDriverLock(); secretDriverLock();
if (!(secret = secretFindByUUID(obj->uuid))) { if (!(secret = secretObjFromSecret(obj)))
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(obj->uuid, uuidstr);
virReportError(VIR_ERR_NO_SECRET,
_("no secret with matching uuid '%s'"), uuidstr);
goto cleanup; goto cleanup;
}
if (virSecretGetXMLDescEnsureACL(obj->conn, secret->def) < 0) if (virSecretGetXMLDescEnsureACL(obj->conn, secret->def) < 0)
goto cleanup; goto cleanup;
...@@ -895,13 +907,8 @@ secretSetValue(virSecretPtr obj, ...@@ -895,13 +907,8 @@ secretSetValue(virSecretPtr obj,
secretDriverLock(); secretDriverLock();
if (!(secret = secretFindByUUID(obj->uuid))) { if (!(secret = secretObjFromSecret(obj)))
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(obj->uuid, uuidstr);
virReportError(VIR_ERR_NO_SECRET,
_("no secret with matching uuid '%s'"), uuidstr);
goto cleanup; goto cleanup;
}
if (virSecretSetValueEnsureACL(obj->conn, secret->def) < 0) if (virSecretSetValueEnsureACL(obj->conn, secret->def) < 0)
goto cleanup; goto cleanup;
...@@ -953,13 +960,8 @@ secretGetValue(virSecretPtr obj, ...@@ -953,13 +960,8 @@ secretGetValue(virSecretPtr obj,
secretDriverLock(); secretDriverLock();
if (!(secret = secretFindByUUID(obj->uuid))) { if (!(secret = secretObjFromSecret(obj)))
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(obj->uuid, uuidstr);
virReportError(VIR_ERR_NO_SECRET,
_("no secret with matching uuid '%s'"), uuidstr);
goto cleanup; goto cleanup;
}
if (virSecretGetValueEnsureACL(obj->conn, secret->def) < 0) if (virSecretGetValueEnsureACL(obj->conn, secret->def) < 0)
goto cleanup; goto cleanup;
...@@ -998,13 +1000,8 @@ secretUndefine(virSecretPtr obj) ...@@ -998,13 +1000,8 @@ secretUndefine(virSecretPtr obj)
secretDriverLock(); secretDriverLock();
if (!(secret = secretFindByUUID(obj->uuid))) { if (!(secret = secretObjFromSecret(obj)))
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(obj->uuid, uuidstr);
virReportError(VIR_ERR_NO_SECRET,
_("no secret with matching uuid '%s'"), uuidstr);
goto cleanup; goto cleanup;
}
if (virSecretUndefineEnsureACL(obj->conn, secret->def) < 0) if (virSecretUndefineEnsureACL(obj->conn, secret->def) < 0)
goto cleanup; goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册