mirror of https://github.com/apache/cloudstack.git
KVM: Change new volume/template downloads to use UUID in database
rather than creating a fresh random UUID, so admins can match volumes frontend to backend
This commit is contained in:
parent
47dd1c1e95
commit
b344bb4cf3
|
|
@ -1457,19 +1457,18 @@ ServerResource {
|
|||
|
||||
if (cmd.getTemplateUrl() != null) {
|
||||
if(primaryPool.getType() == StoragePoolType.CLVM) {
|
||||
vol = templateToPrimaryDownload(cmd.getTemplateUrl(),primaryPool);
|
||||
vol = templateToPrimaryDownload(cmd.getTemplateUrl(),primaryPool, dskch.getPath());
|
||||
} else {
|
||||
BaseVol = primaryPool.getPhysicalDisk(cmd.getTemplateUrl());
|
||||
vol = _storagePoolMgr.createDiskFromTemplate(BaseVol, UUID
|
||||
.randomUUID().toString(), primaryPool, 0);
|
||||
vol = _storagePoolMgr.createDiskFromTemplate(BaseVol,
|
||||
dskch.getPath(), primaryPool, 0);
|
||||
}
|
||||
if (vol == null) {
|
||||
return new Answer(cmd, false,
|
||||
" Can't create storage volume on storage pool");
|
||||
}
|
||||
} else {
|
||||
vol = primaryPool.createPhysicalDisk(UUID.randomUUID()
|
||||
.toString(), dskch.getSize());
|
||||
vol = primaryPool.createPhysicalDisk(dskch.getPath(), dskch.getSize());
|
||||
}
|
||||
VolumeTO volume = new VolumeTO(cmd.getVolumeId(), dskch.getType(),
|
||||
pool.getType(), pool.getUuid(), pool.getPath(),
|
||||
|
|
@ -1486,7 +1485,7 @@ ServerResource {
|
|||
}
|
||||
|
||||
// this is much like PrimaryStorageDownloadCommand, but keeping it separate
|
||||
protected KVMPhysicalDisk templateToPrimaryDownload(String templateUrl, KVMStoragePool primaryPool) {
|
||||
protected KVMPhysicalDisk templateToPrimaryDownload(String templateUrl, KVMStoragePool primaryPool, String volUuid) {
|
||||
int index = templateUrl.lastIndexOf("/");
|
||||
String mountpoint = templateUrl.substring(0, index);
|
||||
String templateName = null;
|
||||
|
|
@ -1522,7 +1521,7 @@ ServerResource {
|
|||
|
||||
/* Copy volume to primary storage */
|
||||
|
||||
KVMPhysicalDisk primaryVol = _storagePoolMgr.copyPhysicalDisk(templateVol, UUID.randomUUID().toString(), primaryPool, 0);
|
||||
KVMPhysicalDisk primaryVol = _storagePoolMgr.copyPhysicalDisk(templateVol, volUuid, primaryPool, 0);
|
||||
return primaryVol;
|
||||
} catch (CloudRuntimeException e) {
|
||||
s_logger.error("Failed to download template to primary storage",e);
|
||||
|
|
|
|||
|
|
@ -192,8 +192,19 @@ public class KVMStorageProcessor implements StorageProcessor {
|
|||
KVMStoragePool primaryPool = storagePoolMgr.getStoragePool(primaryStore.getPoolType(),
|
||||
primaryStore.getUuid());
|
||||
|
||||
KVMPhysicalDisk primaryVol = storagePoolMgr.copyPhysicalDisk(tmplVol, UUID.randomUUID().toString(),
|
||||
KVMPhysicalDisk primaryVol = null;
|
||||
if (destData instanceof VolumeObjectTO) {
|
||||
VolumeObjectTO volume = (VolumeObjectTO) destData;
|
||||
primaryVol = storagePoolMgr.copyPhysicalDisk(tmplVol, volume.getUuid(),
|
||||
primaryPool, cmd.getWaitInMillSeconds());
|
||||
} else if (destData instanceof TemplateObjectTO) {
|
||||
TemplateObjectTO destTempl = (TemplateObjectTO) destData;
|
||||
primaryVol = storagePoolMgr.copyPhysicalDisk(tmplVol, destTempl.getUuid(),
|
||||
primaryPool, cmd.getWaitInMillSeconds());
|
||||
} else {
|
||||
primaryVol = storagePoolMgr.copyPhysicalDisk(tmplVol, UUID.randomUUID().toString(),
|
||||
primaryPool, cmd.getWaitInMillSeconds());
|
||||
}
|
||||
|
||||
|
||||
DataTO data = null;
|
||||
|
|
@ -230,8 +241,8 @@ public class KVMStorageProcessor implements StorageProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
// this is much like PrimaryStorageDownloadCommand, but keeping it separate
|
||||
private KVMPhysicalDisk templateToPrimaryDownload(String templateUrl, KVMStoragePool primaryPool, int timeout) {
|
||||
// this is much like PrimaryStorageDownloadCommand, but keeping it separate. copies template direct to root disk
|
||||
private KVMPhysicalDisk templateToPrimaryDownload(String templateUrl, KVMStoragePool primaryPool, String volUuid, int timeout) {
|
||||
int index = templateUrl.lastIndexOf("/");
|
||||
String mountpoint = templateUrl.substring(0, index);
|
||||
String templateName = null;
|
||||
|
|
@ -267,7 +278,7 @@ public class KVMStorageProcessor implements StorageProcessor {
|
|||
|
||||
/* Copy volume to primary storage */
|
||||
|
||||
KVMPhysicalDisk primaryVol = storagePoolMgr.copyPhysicalDisk(templateVol, UUID.randomUUID().toString(),
|
||||
KVMPhysicalDisk primaryVol = storagePoolMgr.copyPhysicalDisk(templateVol, volUuid,
|
||||
primaryPool, timeout);
|
||||
return primaryVol;
|
||||
} catch (CloudRuntimeException e) {
|
||||
|
|
@ -299,14 +310,14 @@ public class KVMStorageProcessor implements StorageProcessor {
|
|||
|
||||
if (primaryPool.getType() == StoragePoolType.CLVM) {
|
||||
templatePath = ((NfsTO)imageStore).getUrl() + File.separator + templatePath;
|
||||
vol = templateToPrimaryDownload(templatePath, primaryPool, cmd.getWaitInMillSeconds());
|
||||
vol = templateToPrimaryDownload(templatePath, primaryPool, volume.getUuid(), cmd.getWaitInMillSeconds());
|
||||
} else {
|
||||
if (templatePath.contains("/mnt")) {
|
||||
//upgrade issue, if the path contains path, need to extract the volume uuid from path
|
||||
templatePath = templatePath.substring(templatePath.lastIndexOf(File.separator) + 1);
|
||||
}
|
||||
BaseVol = storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(), primaryStore.getUuid(), templatePath);
|
||||
vol = storagePoolMgr.createDiskFromTemplate(BaseVol, UUID.randomUUID().toString(), BaseVol.getPool(), cmd.getWaitInMillSeconds());
|
||||
vol = storagePoolMgr.createDiskFromTemplate(BaseVol, volume.getUuid(), BaseVol.getPool(), cmd.getWaitInMillSeconds());
|
||||
}
|
||||
if (vol == null) {
|
||||
return new CopyCmdAnswer(" Can't create storage volume on storage pool");
|
||||
|
|
@ -1009,7 +1020,7 @@ public class KVMStorageProcessor implements StorageProcessor {
|
|||
primaryPool = storagePoolMgr.getStoragePool(primaryStore.getPoolType(), primaryStore.getUuid());
|
||||
disksize = volume.getSize();
|
||||
|
||||
vol = primaryPool.createPhysicalDisk(UUID.randomUUID().toString(), disksize);
|
||||
vol = primaryPool.createPhysicalDisk(volume.getUuid(), disksize);
|
||||
|
||||
VolumeObjectTO newVol = new VolumeObjectTO();
|
||||
newVol.setPath(vol.getName());
|
||||
|
|
|
|||
|
|
@ -768,7 +768,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||
public KVMPhysicalDisk createDiskFromTemplate(KVMPhysicalDisk template,
|
||||
String name, PhysicalDiskFormat format, long size, KVMStoragePool destPool, int timeout) {
|
||||
|
||||
String newUuid = UUID.randomUUID().toString();
|
||||
String newUuid = name;
|
||||
KVMStoragePool srcPool = template.getPool();
|
||||
KVMPhysicalDisk disk = null;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue