public boolean disconnectPhysicalDisk(KVMStoragePool pool, String mountpoint) throws LibvirtException { LibvirtStoragePool libvirtPool = (LibvirtStoragePool) pool; StoragePool sp = libvirtPool.getPool(); // destroy the pool sp.destroy(); return true; }
private StoragePool createCLVMStoragePool(Connect conn, String uuid, String host, String path) { String volgroupPath = "/dev/" + path; String volgroupName = path; volgroupName = volgroupName.replaceFirst("/", ""); LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(PoolType.LOGICAL, volgroupName, uuid, host, volgroupPath, volgroupPath); StoragePool sp = null; try { s_logger.debug(spd.toString()); sp = conn.storagePoolCreateXML(spd.toString(), 0); return sp; } catch (LibvirtException e) { s_logger.error(e.toString()); if (sp != null) { try { if (sp.isPersistent() == 1) { sp.destroy(); sp.undefine(); } else { sp.destroy(); } sp.free(); } catch (LibvirtException l) { s_logger.debug("Failed to define clvm storage pool with: " + l.toString()); } } return null; } }
private StoragePool createSharedStoragePool(Connect conn, String uuid, String host, String path) { String mountPoint = path; if (!_storageLayer.exists(mountPoint)) { s_logger.error(mountPoint + " does not exists. Check local.storage.path in agent.properties."); return null; } LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(PoolType.DIR, uuid, uuid, host, path, path); StoragePool sp = null; try { s_logger.debug(spd.toString()); sp = conn.storagePoolCreateXML(spd.toString(), 0); return sp; } catch (LibvirtException e) { s_logger.error(e.toString()); if (sp != null) { try { if (sp.isPersistent() == 1) { sp.destroy(); sp.undefine(); } else { sp.destroy(); } sp.free(); } catch (LibvirtException l) { s_logger.debug("Failed to define shared mount point storage pool with: " + l.toString()); } } return null; } }