This wraps the virSecretGetUsageType libvirt function available since
version 0.7.1.
Signed-off-by: Claudio Bley <cbley(a)av-test.de>
---
src/main/java/org/libvirt/Secret.java | 5 +++++
src/main/java/org/libvirt/SecretUsageType.java | 23 +++++++++++++++++++++++
src/main/java/org/libvirt/jna/Libvirt.java | 1 +
3 files changed, 29 insertions(+)
create mode 100644 src/main/java/org/libvirt/SecretUsageType.java
diff --git a/src/main/java/org/libvirt/Secret.java
b/src/main/java/org/libvirt/Secret.java
index 868fcc8..e0ded73 100644
--- a/src/main/java/org/libvirt/Secret.java
+++ b/src/main/java/org/libvirt/Secret.java
@@ -64,6 +64,11 @@ public class Secret {
return processError(libvirt.virSecretGetUsageID(VSP));
}
+ public SecretUsageType getUsageType() throws LibvirtException {
+ final int ret = processError(libvirt.virSecretGetUsageType(this.VSP));
+ return Library.getConstant(SecretUsageType.class, ret);
+ }
+
/**
* Get the UUID for this secret.
*
diff --git a/src/main/java/org/libvirt/SecretUsageType.java
b/src/main/java/org/libvirt/SecretUsageType.java
new file mode 100644
index 0000000..3907bdb
--- /dev/null
+++ b/src/main/java/org/libvirt/SecretUsageType.java
@@ -0,0 +1,23 @@
+package org.libvirt;
+
+/**
+ * An enumeration of constants identifying the type of
+ * the owner of a secret.
+ *
+ * @see Secret#getUsageType
+ */
+public enum SecretUsageType {
+ /** No one uses the secret */
+ NONE,
+
+ /** A volume uses the secret */
+ VOLUME,
+
+ /** A CEPH object uses the secret */
+ CEPH,
+
+ /** A ISCSI object uses the secret */
+ ISCSI,
+
+ UNKNOWN
+}
diff --git a/src/main/java/org/libvirt/jna/Libvirt.java
b/src/main/java/org/libvirt/jna/Libvirt.java
index 28fbff1..21ee2c2 100644
--- a/src/main/java/org/libvirt/jna/Libvirt.java
+++ b/src/main/java/org/libvirt/jna/Libvirt.java
@@ -416,6 +416,7 @@ public interface Libvirt extends Library {
int virSecretGetUUID(SecretPointer virSecretPtr, byte[] uuidString);
int virSecretGetUUIDString(SecretPointer virSecretPtr, byte[] uuidString);
String virSecretGetUsageID(SecretPointer virSecretPtr);
+ int virSecretGetUsageType(SecretPointer virSecretPtr);
Pointer virSecretGetValue(SecretPointer virSecretPtr, SizeTByReference value_size,
int flags);
String virSecretGetXMLDesc(SecretPointer virSecretPtr, int flags);
SecretPointer virSecretLookupByUsage(ConnectionPointer virConnectPtr, int usageType,
String usageID);
--
1.7.9.5