Commit 029c5563cde6c3d63f7a3c7de760450c66a61f4b
Aded StoragePool apis from 0.7.3, and better tests for Storage Pools
| |   |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
| * Determine if the storage pool is currently running |
| * @see <a href="http://www.libvirt.org/html/libvirt-libvirt.html#virStoragePoolIsActive">Libvirt Documentation</a> |
| * @return 1 if running, 0 if inactive, -1 on error |
| * @throws LibvirtException |
| */ |
| public int isActive() throws LibvirtException { |
| int returnValue = libvirt.virStoragePoolIsActive(VSPP) ; |
| processError() ; |
| return returnValue ; |
| } |
| |
| /** |
| * Determine if the storage pool has a persistent configuration which means |
| * it will still exist after shutting down |
| * @see <a href="http://www.libvirt.org/html/libvirt-libvirt.html#virStoragePoolIsPersistent">Libvirt Documentation</a> |
| * @return 1 if persistent, 0 if transient, -1 on error |
| * @throws LibvirtException |
| */ |
| public int isPersistent() throws LibvirtException { |
| int returnValue = libvirt.virStoragePoolIsPersistent(VSPP) ; |
| processError() ; |
| return returnValue ; |
| } |
| |
| /** |
| 238 | 263 | * Fetch list of storage volume names |
| 239 | 264 | * |
| 240 | 265 | * @return an Array of Strings that contains the names of the storage |
| |   |
| 252 | 252 | public int virStoragePoolGetUUIDString(StoragePoolPointer storagePoolPtr, byte[] uuidString); |
| 253 | 253 | public String virStoragePoolGetXMLDesc(StoragePoolPointer storagePoolPtr, int flags); |
| 254 | 254 | public int virStoragePoolListVolumes(StoragePoolPointer storagePoolPtr, String[] names, int maxnames); |
| public int virStoragePoolIsActive(StoragePoolPointer storagePoolPtr); |
| public int virStoragePoolIsPersistent(StoragePoolPointer storagePoolPtr); |
| 255 | 257 | public StoragePoolPointer virStoragePoolLookupByName(ConnectionPointer virConnectPtr, String name); |
| 256 | 258 | public StoragePoolPointer virStoragePoolLookupByUUID(ConnectionPointer virConnectPtr, byte[] uuidBytes); |
| 257 | 259 | public StoragePoolPointer virStoragePoolLookupByUUIDString(ConnectionPointer virConnectPtr, String uuidstr); |
| |   |
| 194 | 194 | // eat it |
| 195 | 195 | } |
| 196 | 196 | } |
| |
| public void testStoragePool() throws Exception { |
| Connect conn = new Connect("test:///default", false); |
| StoragePool pool1 = conn.storagePoolDefineXML("<pool type='dir'>" |
| + " <name>pool1</name>" |
| + " <target>" |
| + " <path>/pool1</path>" |
| + " </target>" |
| + " <uuid>004c96e1-2d78-c30f-5aa5-f03c87d21e67</uuid>" |
| + "</pool>", 0) ; |
| StoragePool defaultPool = conn.storagePoolLookupByName("default-pool"); |
| assertEquals("numOfStoragePools:", 1, conn.numOfStoragePools()); |
| assertEquals("numOfDefinedStoragePools:", 1, conn.numOfDefinedStoragePools()); |
| assertNotNull("The pool should not be null", pool1); |
| assertNotNull("The default pool should not be null", defaultPool); |
| assertEquals("The names should match", defaultPool.getName(), "default-pool"); |
| assertEquals("The uids should match", pool1.getUUIDString(), "004c96e1-2d78-c30f-5aa5-f03c87d21e67"); |
| assertTrue("pool1 should be persistent", pool1.isPersistent() == 1); |
| assertTrue("pool1 should not be active", pool1.isActive() == 0); |
| assertTrue("Domain2 should be active", defaultPool.isActive() == 1); |
| } |
| 197 | 218 | } |