bug 6932: add create private template from volume command support for KVM

status 6932: resolved fixed
This commit is contained in:
edison 2010-11-04 10:58:33 -07:00
parent fec75973db
commit 5a173ad363
2 changed files with 8 additions and 7 deletions

View File

@ -78,6 +78,7 @@ import com.cloud.agent.api.CheckVirtualMachineAnswer;
import com.cloud.agent.api.CheckVirtualMachineCommand;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand;
import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
import com.cloud.agent.api.CreateVolumeFromSnapshotAnswer;
import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
import com.cloud.agent.api.DeleteSnapshotBackupAnswer;
@ -1181,8 +1182,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
return execute((DestroyCommand) cmd);
} else if (cmd instanceof PrimaryStorageDownloadCommand) {
return execute((PrimaryStorageDownloadCommand) cmd);
} else if (cmd instanceof CreatePrivateTemplateCommand) {
return execute((CreatePrivateTemplateCommand) cmd);
} else if (cmd instanceof CreatePrivateTemplateFromVolumeCommand) {
return execute((CreatePrivateTemplateFromVolumeCommand) cmd);
} else if (cmd instanceof GetStorageStatsCommand) {
return execute((GetStorageStatsCommand) cmd);
} else if (cmd instanceof ManageSnapshotCommand) {
@ -1535,7 +1536,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
return new GetStorageStatsAnswer(cmd, e.toString());
}
}
protected CreatePrivateTemplateAnswer execute(CreatePrivateTemplateCommand cmd) {
protected CreatePrivateTemplateAnswer execute(CreatePrivateTemplateFromVolumeCommand cmd) {
String secondaryStorageURL = cmd.getSecondaryStorageURL();
StoragePool secondaryStorage = null;
@ -1549,11 +1551,10 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
_storage.mkdirs(tmpltPath);
Script command = new Script(_createTmplPath, _timeout, s_logger);
command.add("-f", cmd.getSnapshotPath());
command.add("-c", cmd.getSnapshotName());
command.add("-f", cmd.getVolumePath());
command.add("-t", tmpltPath);
command.add("-n", cmd.getUniqueName() + ".qcow2");
command.add("-s");
String result = command.execute();
if (result != null) {

View File

@ -2674,7 +2674,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
if( !vmState.equals(State.Stopped) && !vmState.equals(State.Destroyed)) {
throw new CloudRuntimeException("Please put VM " + vm.getHostName() + " into Stopped state first");
}
cmd = new CreatePrivateTemplateFromVolumeCommand(secondaryStorageURL, templateId, volume.getAccountId(),
command.getTemplateName(), uniqueName, volume.getPath(), vmName);