Commit 029c5563cde6c3d63f7a3c7de760450c66a61f4b

  • avatar
  • Bryan Kearney <bkearney @red…at.com>
  • Tue May 18 21:41:05 CEST 2010
Aded StoragePool apis from 0.7.3, and better tests for Storage Pools
  
235235 }
236236
237237 /**
238 * Determine if the storage pool is currently running
239 * @see <a href="http://www.libvirt.org/html/libvirt-libvirt.html#virStoragePoolIsActive">Libvirt Documentation</a>
240 * @return 1 if running, 0 if inactive, -1 on error
241 * @throws LibvirtException
242 */
243 public int isActive() throws LibvirtException {
244 int returnValue = libvirt.virStoragePoolIsActive(VSPP) ;
245 processError() ;
246 return returnValue ;
247 }
248
249 /**
250 * Determine if the storage pool has a persistent configuration which means
251 * it will still exist after shutting down
252 * @see <a href="http://www.libvirt.org/html/libvirt-libvirt.html#virStoragePoolIsPersistent">Libvirt Documentation</a>
253 * @return 1 if persistent, 0 if transient, -1 on error
254 * @throws LibvirtException
255 */
256 public int isPersistent() throws LibvirtException {
257 int returnValue = libvirt.virStoragePoolIsPersistent(VSPP) ;
258 processError() ;
259 return returnValue ;
260 }
261
262 /**
238263 * Fetch list of storage volume names
239264 *
240265 * @return an Array of Strings that contains the names of the storage
  
252252 public int virStoragePoolGetUUIDString(StoragePoolPointer storagePoolPtr, byte[] uuidString);
253253 public String virStoragePoolGetXMLDesc(StoragePoolPointer storagePoolPtr, int flags);
254254 public int virStoragePoolListVolumes(StoragePoolPointer storagePoolPtr, String[] names, int maxnames);
255 public int virStoragePoolIsActive(StoragePoolPointer storagePoolPtr);
256 public int virStoragePoolIsPersistent(StoragePoolPointer storagePoolPtr);
255257 public StoragePoolPointer virStoragePoolLookupByName(ConnectionPointer virConnectPtr, String name);
256258 public StoragePoolPointer virStoragePoolLookupByUUID(ConnectionPointer virConnectPtr, byte[] uuidBytes);
257259 public StoragePoolPointer virStoragePoolLookupByUUIDString(ConnectionPointer virConnectPtr, String uuidstr);
  
194194 // eat it
195195 }
196196 }
197
198 public void testStoragePool() throws Exception {
199 Connect conn = new Connect("test:///default", false);
200 StoragePool pool1 = conn.storagePoolDefineXML("<pool type='dir'>"
201 + " <name>pool1</name>"
202 + " <target>"
203 + " <path>/pool1</path>"
204 + " </target>"
205 + " <uuid>004c96e1-2d78-c30f-5aa5-f03c87d21e67</uuid>"
206 + "</pool>", 0) ;
207 StoragePool defaultPool = conn.storagePoolLookupByName("default-pool");
208 assertEquals("numOfStoragePools:", 1, conn.numOfStoragePools());
209 assertEquals("numOfDefinedStoragePools:", 1, conn.numOfDefinedStoragePools());
210 assertNotNull("The pool should not be null", pool1);
211 assertNotNull("The default pool should not be null", defaultPool);
212 assertEquals("The names should match", defaultPool.getName(), "default-pool");
213 assertEquals("The uids should match", pool1.getUUIDString(), "004c96e1-2d78-c30f-5aa5-f03c87d21e67");
214 assertTrue("pool1 should be persistent", pool1.isPersistent() == 1);
215 assertTrue("pool1 should not be active", pool1.isActive() == 0);
216 assertTrue("Domain2 should be active", defaultPool.isActive() == 1);
217 }
197218}