mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-7315: Set LXC volumes format as DIR. Use rm command to delete LXC volumes. Libvirt delete volume does not handle directories
This commit is contained in:
parent
9ab78b7eb2
commit
30ecf935e8
@ -32,7 +32,8 @@ public class Storage {
|
||||
BAREMETAL(false, false, false, "BAREMETAL"),
|
||||
VMDK(true, true, false, "vmdk"),
|
||||
VDI(true, true, false, "vdi"),
|
||||
TAR(false, false, false, "tar");
|
||||
TAR(false, false, false, "tar"),
|
||||
DIR(false, false, false, "dir");
|
||||
|
||||
private final boolean supportThinProvisioning;
|
||||
private final boolean supportSparse;
|
||||
|
||||
@ -1908,10 +1908,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
|
||||
public Answer execute(DestroyCommand cmd) {
|
||||
VolumeTO vol = cmd.getVolume();
|
||||
|
||||
try {
|
||||
KVMStoragePool pool = _storagePoolMgr.getStoragePool(vol.getPoolType(), vol.getPoolUuid());
|
||||
pool.deletePhysicalDisk(vol.getPath());
|
||||
pool.deletePhysicalDisk(vol.getPath(), null);
|
||||
return new Answer(cmd, true, "Success");
|
||||
} catch (CloudRuntimeException e) {
|
||||
s_logger.debug("Failed to delete volume: " + e.toString());
|
||||
|
||||
@ -327,7 +327,7 @@ public class IscsiAdmStorageAdaptor implements StorageAdaptor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePhysicalDisk(String volumeUuid, KVMStoragePool pool) {
|
||||
public boolean deletePhysicalDisk(String volumeUuid, KVMStoragePool pool, Storage.ImageFormat format) {
|
||||
throw new UnsupportedOperationException("Deleting a physical disk is not supported.");
|
||||
}
|
||||
|
||||
|
||||
@ -115,8 +115,8 @@ public class IscsiAdmStoragePool implements KVMStoragePool {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePhysicalDisk(String volumeUuid) {
|
||||
return this._storageAdaptor.deletePhysicalDisk(volumeUuid, this);
|
||||
public boolean deletePhysicalDisk(String volumeUuid, Storage.ImageFormat format) {
|
||||
return this._storageAdaptor.deletePhysicalDisk(volumeUuid, this, format);
|
||||
}
|
||||
|
||||
// does not apply for iScsiAdmStoragePool
|
||||
|
||||
@ -35,7 +35,7 @@ public interface KVMStoragePool {
|
||||
|
||||
public boolean disconnectPhysicalDisk(String volumeUuid);
|
||||
|
||||
public boolean deletePhysicalDisk(String volumeUuid);
|
||||
public boolean deletePhysicalDisk(String volumeUuid, Storage.ImageFormat format);
|
||||
|
||||
public List<KVMPhysicalDisk> listPhysicalDisks();
|
||||
|
||||
|
||||
@ -347,6 +347,8 @@ public class KVMStorageProcessor implements StorageProcessor {
|
||||
newVol.setFormat(ImageFormat.RAW);
|
||||
} else if (vol.getFormat() == PhysicalDiskFormat.QCOW2) {
|
||||
newVol.setFormat(ImageFormat.QCOW2);
|
||||
} else if (vol.getFormat() == PhysicalDiskFormat.DIR) {
|
||||
newVol.setFormat(ImageFormat.DIR);
|
||||
}
|
||||
|
||||
return new CopyCmdAnswer(newVol);
|
||||
@ -1203,7 +1205,7 @@ public class KVMStorageProcessor implements StorageProcessor {
|
||||
s_logger.debug("can't find volume: " + vol.getPath() + ", return true");
|
||||
return new Answer(null);
|
||||
}
|
||||
pool.deletePhysicalDisk(vol.getPath());
|
||||
pool.deletePhysicalDisk(vol.getPath(), vol.getFormat());
|
||||
return new Answer(null);
|
||||
} catch (CloudRuntimeException e) {
|
||||
s_logger.debug("Failed to delete volume: ", e);
|
||||
|
||||
@ -796,7 +796,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePhysicalDisk(String uuid, KVMStoragePool pool) {
|
||||
public boolean deletePhysicalDisk(String uuid, KVMStoragePool pool, Storage.ImageFormat format) {
|
||||
|
||||
s_logger.info("Attempting to remove volume " + uuid + " from pool " + pool.getUuid());
|
||||
|
||||
@ -849,7 +849,11 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
try {
|
||||
StorageVol vol = getVolume(libvirtPool.getPool(), uuid);
|
||||
s_logger.debug("Instructing libvirt to remove volume " + uuid + " from pool " + pool.getUuid());
|
||||
deleteVol(libvirtPool, vol);
|
||||
if(Storage.ImageFormat.DIR.equals(format)){
|
||||
deleteDirVol(libvirtPool, vol);
|
||||
} else {
|
||||
deleteVol(libvirtPool, vol);
|
||||
}
|
||||
vol.free();
|
||||
return true;
|
||||
} catch (LibvirtException e) {
|
||||
@ -1315,4 +1319,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
vol.delete(0);
|
||||
}
|
||||
|
||||
private void deleteDirVol(LibvirtStoragePool pool, StorageVol vol) throws LibvirtException {
|
||||
Script.runSimpleBashScript("rm -r --interactive=never " + vol.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,8 +171,8 @@ public class LibvirtStoragePool implements KVMStoragePool {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePhysicalDisk(String uuid) {
|
||||
return this._storageAdaptor.deletePhysicalDisk(uuid, this);
|
||||
public boolean deletePhysicalDisk(String uuid, Storage.ImageFormat format) {
|
||||
return this._storageAdaptor.deletePhysicalDisk(uuid, this, format);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -49,7 +49,7 @@ public interface StorageAdaptor {
|
||||
// handled by your adaptor, return false if not. 2) clean up device, return true
|
||||
public boolean disconnectPhysicalDiskByPath(String localPath);
|
||||
|
||||
public boolean deletePhysicalDisk(String uuid, KVMStoragePool pool);
|
||||
public boolean deletePhysicalDisk(String uuid, KVMStoragePool pool, Storage.ImageFormat format);
|
||||
|
||||
public KVMPhysicalDisk createDiskFromTemplate(KVMPhysicalDisk template,
|
||||
String name, PhysicalDiskFormat format, Storage.ProvisioningType provisioningType, long size,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user