bug 10456: fixed NPE - get account info from the volume when create private template from volume

status 10456: resolved fixed
This commit is contained in:
alena 2011-06-27 09:36:14 -07:00
parent 18417305ed
commit a4dbcf4880
1 changed files with 5 additions and 1 deletions

View File

@ -1455,9 +1455,13 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
origTemplateInstallPath, templateId, name);
} else if (volumeId != null) {
VolumeVO volume = _volsDao.findById(volumeId);
if( volume == null ) {
throw new CloudRuntimeException("Unable to find volume for Id " + volumeId);
}
accountId = volume.getAccountId();
if( volume.getPoolId() == null ) {
_templateDao.remove(templateId);
throw new CloudRuntimeException("Volume " + volumeId + " is empty, can't create template on it");
@ -1471,7 +1475,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
String secondaryStorageURL = secondaryStorageHost.getStorageUrl();
pool = _storagePoolDao.findById(volume.getPoolId());
cmd = new CreatePrivateTemplateFromVolumeCommand(secondaryStorageURL, templateId, volume.getAccountId(),
cmd = new CreatePrivateTemplateFromVolumeCommand(secondaryStorageURL, templateId, accountId,
command.getTemplateName(), uniqueName, volume.getPath(), vmName);
} else {