volume-upload: Attaching uploaded volume to an instance failing while copying from secondary to primary storage

The volume/template size and install path was not getting updated properly.
The upload status response should return these properties on completion of upload.
This commit is contained in:
Koushik Das 2015-01-30 17:36:13 +05:30
parent 6ff8752fd0
commit 121ff19cba
2 changed files with 34 additions and 0 deletions

View File

@ -27,6 +27,9 @@ public class UploadStatusAnswer extends Answer {
}
private UploadStatus status;
private long virtualSize = 0;
private long physicalSize = 0;
private String installPath = null;
protected UploadStatusAnswer() {
}
@ -50,4 +53,27 @@ public class UploadStatusAnswer extends Answer {
return status;
}
public long getVirtualSize() {
return virtualSize;
}
public void setVirtualSize(long virtualSize) {
this.virtualSize = virtualSize;
}
public long getPhysicalSize() {
return physicalSize;
}
public void setPhysicalSize(long physicalSize) {
this.physicalSize = physicalSize;
}
public String getInstallPath() {
return installPath;
}
public void setInstallPath(String installPath) {
this.installPath = installPath;
}
}

View File

@ -262,6 +262,10 @@ public class ImageStoreUploadMonitorImpl extends ManagerBase implements ImageSto
case COMPLETED:
tmpVolumeDataStore.setDownloadState(VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
tmpVolumeDataStore.setState(State.Ready);
tmpVolumeDataStore.setInstallPath(answer.getInstallPath());
tmpVolumeDataStore.setPhysicalSize(answer.getPhysicalSize());
tmpVolumeDataStore.setSize(answer.getVirtualSize());
tmpVolumeDataStore.setDownloadPercent(100);
stateMachine.transitTo(tmpVolume, Event.OperationSucceeded, null, _volumeDao);
if (s_logger.isDebugEnabled()) {
s_logger.debug("Volume " + tmpVolume.getUuid() + " uploaded successfully");
@ -322,6 +326,10 @@ public class ImageStoreUploadMonitorImpl extends ManagerBase implements ImageSto
case COMPLETED:
tmpTemplateDataStore.setDownloadState(VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
tmpTemplateDataStore.setState(State.Ready);
tmpTemplateDataStore.setInstallPath(answer.getInstallPath());
tmpTemplateDataStore.setPhysicalSize(answer.getPhysicalSize());
tmpTemplateDataStore.setSize(answer.getVirtualSize());
tmpTemplateDataStore.setDownloadPercent(100);
stateMachine.transitTo(tmpTemplate, VirtualMachineTemplate.Event.OperationSucceeded, null, _templateDao);
if (s_logger.isDebugEnabled()) {
s_logger.debug("Template " + tmpTemplate.getUuid() + " uploaded successfully");