# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1251232703 25200
# Node ID 2ca94acaa955045c3438053f3fa8f1277945f839
# Parent d047a30a9ea367e729cb265434c4dba89c11f495
Add delete_resource() to pool_parsing.c - this will call libvirt APIs...
To delete a storage volume within a storage pool.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r d047a30a9ea3 -r 2ca94acaa955 libxkutil/pool_parsing.c
--- a/libxkutil/pool_parsing.c Tue Aug 25 13:38:23 2009 -0700
+++ b/libxkutil/pool_parsing.c Tue Aug 25 13:38:23 2009 -0700
@@ -358,6 +358,34 @@
return ret;
}
+
+int delete_resource(virConnectPtr conn,
+ const char *rname,
+ int res_type)
+{
+ int ret = 0;
+
+ if (res_type == CIM_RES_TYPE_IMAGE) {
+ virStorageVolPtr ptr = virStorageVolLookupByPath(conn, rname);
+ if (ptr == NULL) {
+ CU_DEBUG("Storage volume %s is not defined", rname);
+ goto out;
+ }
+
+ ret = virStorageVolDelete(ptr, 0);
+ if (ret != 0) {
+ CU_DEBUG("Unable to delete storage volume %s", rname);
+ } else {
+ ret = 1;
+ }
+
+ virStorageVolFree(ptr);
+ }
+
+ out:
+
+ return ret;
+}
#else
int create_resource(virConnectPtr conn,
const char *pname,
@@ -367,6 +395,14 @@
CU_DEBUG("Creating resources within libvirt pools not supported");
return 0;
}
+
+int delete_resource(virConnectPtr conn,
+ const char *rname,
+ int res_type)
+{
+ CU_DEBUG("Deleting resources within libvirt pools not supported");
+ return 0;
+}
#endif
/*
diff -r d047a30a9ea3 -r 2ca94acaa955 libxkutil/pool_parsing.h
--- a/libxkutil/pool_parsing.h Tue Aug 25 13:38:23 2009 -0700
+++ b/libxkutil/pool_parsing.h Tue Aug 25 13:38:23 2009 -0700
@@ -92,6 +92,8 @@
int create_resource(virConnectPtr conn, const char *pname,
const char *xml, int res_type);
+int delete_resource(virConnectPtr conn, const char *rname, int res_type);
+
#endif
/*