Create Template from volume and snapshot for vmware

This commit is contained in:
Kelven Yang 2010-11-03 19:18:34 -07:00
parent 003b0e4a23
commit d748010da3
3 changed files with 11 additions and 6 deletions

View File

@ -18,7 +18,8 @@
package com.cloud.agent.api;
public class CreatePrivateTemplateFromVolumeCommand extends SnapshotCommand {
public class CreatePrivateTemplateFromVolumeCommand extends SnapshotCommand {
private String _vmName;
private String _volumePath;
private String _userSpecifiedName;
private String _uniqueName;
@ -30,14 +31,14 @@ public class CreatePrivateTemplateFromVolumeCommand extends SnapshotCommand {
public CreatePrivateTemplateFromVolumeCommand() {}
public CreatePrivateTemplateFromVolumeCommand(String secondaryStorageURL, long templateId, long accountId, String userSpecifiedName, String uniqueName, String volumePath) {
public CreatePrivateTemplateFromVolumeCommand(String secondaryStorageURL, long templateId, long accountId, String userSpecifiedName, String uniqueName, String volumePath, String vmName) {
_secondaryStorageURL = secondaryStorageURL;
_templateId = templateId;
_accountId = accountId;
_userSpecifiedName = userSpecifiedName;
_uniqueName = uniqueName;
_volumePath = volumePath;
_volumePath = volumePath;
_vmName = vmName;
}
@Override
@ -61,6 +62,10 @@ public class CreatePrivateTemplateFromVolumeCommand extends SnapshotCommand {
return _templateId;
}
public String getVmName() {
return _vmName;
}
public void setVolumePath(String _volumePath) {
this._volumePath = _volumePath;
}

View File

@ -5480,7 +5480,6 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
return new CreatePrivateTemplateAnswer(cmd, result, details);
}
protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromSnapshotCommand cmd) {
String primaryStorageNameLabel = cmd.getPrimaryStoragePoolNameLabel();
Long dcId = cmd.getDataCenterId();

View File

@ -2615,6 +2615,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
// The volume below could be destroyed or removed.
VolumeVO volume = _volsDao.findById(volumeId);
String vmName = _storageMgr.getVmNameOnVolume(volume);
// If private template is created from Volume, check that the volume will not be active when the private template is created
if (snapshotId == null && !_storageMgr.volumeInactive(volume)) {
@ -2675,7 +2676,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
}
cmd = new CreatePrivateTemplateFromVolumeCommand(secondaryStorageURL, templateId, volume.getAccountId(),
command.getTemplateName(), uniqueName, volume.getPath());
command.getTemplateName(), uniqueName, volume.getPath(), vmName);
} else {
throw new CloudRuntimeException("Creating private Template need to specify snapshotId or volumeId");