Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,42 @@ public KVMStoragePool createStoragePool(String name, String host, int port, Stri
}
}

@Override
public boolean deleteStoragePool(String uuid) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pearl1594 , sonar has a good point here; this either returns true or throws an exception. I realise it is an override but is the return needed at all? (here or in undefineInactiveClvmPool(..))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the same pattern we follow for most the storageAdaptors too - LibvirtStorageAdaptor

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As said the override may not be helped, but that doesn't mean the private method has to as well. Also the pattern might well need an anti-pattern.

logger.info("Attempting to remove CLVM/CLVM_NG storage pool {} from libvirt", uuid);

if (decStoragePoolRefCount(uuid)) {
logger.info("deleteStoragePool: CLVM/CLVM_NG storage pool {} still in use", uuid);
return true;
}

try {
return undefineInactiveClvmPool(LibvirtConnection.getConnection(), uuid);
} catch (LibvirtException e) {
throw new CloudRuntimeException(e.toString(), e);
}
}
Comment on lines +109 to +127

private boolean undefineInactiveClvmPool(Connect conn, String uuid) throws LibvirtException {
StoragePool sp;
try {
sp = conn.storagePoolLookupByUUIDString(uuid);
} catch (LibvirtException e) {
logger.warn("CLVM/CLVM_NG storage pool {} doesn't exist in libvirt. Assuming it is already removed", uuid);
return true;
}
Comment thread
Copilot marked this conversation as resolved.
Outdated

if (sp.isActive() == 1) {
sp.destroy();
}
if (sp.isPersistent() == 1) {
sp.undefine();
}
sp.free();
Comment thread
Copilot marked this conversation as resolved.
Outdated
logger.info("CLVM/CLVM_NG storage pool {} was successfully removed from libvirt", uuid);
return true;
}

@Override
public KVMStoragePool getStoragePool(String uuid, boolean refreshInfo) {
logger.info("Fetching CLVM/CLVM_NG storage pool {} ", uuid);
Expand Down Expand Up @@ -290,7 +326,6 @@ private StoragePool createCLVMStoragePool(Connect conn, String uuid, String host
try {
StoragePool pool = conn.storagePoolDefineXML(poolDef.toString(), 0);
logger.info("Created libvirt pool definition for CLVM/CLVM_NG VG: {} (pool will remain inactive)", volgroupName);
pool.setAutostart(1);
return pool;
Comment thread
Pearl1594 marked this conversation as resolved.
} catch (LibvirtException e) {
logger.warn("Failed to define CLVM/CLVM_NG pool in libvirt: {}", e.getMessage());
Expand Down
Loading