Issue #: 5935, 5937

Status 5935: resolved fixed
Status 5937: resolved fixed
This commit is contained in:
edison 2010-08-26 13:15:18 -07:00
parent c2682bc6b6
commit bf1b35b3dd
1 changed files with 22 additions and 0 deletions

View File

@ -124,6 +124,7 @@ import com.cloud.agent.api.storage.CreateAnswer;
import com.cloud.agent.api.storage.CreateCommand;
import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer;
import com.cloud.agent.api.storage.CreatePrivateTemplateCommand;
import com.cloud.agent.api.storage.DestroyCommand;
import com.cloud.agent.api.storage.DownloadAnswer;
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
import com.cloud.agent.api.to.DiskCharacteristicsTO;
@ -1045,6 +1046,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
return execute((MaintainCommand) cmd);
} else if (cmd instanceof CreateCommand) {
return execute((CreateCommand) cmd);
} else if (cmd instanceof DestroyCommand) {
return execute((DestroyCommand) cmd);
} else if (cmd instanceof PrimaryStorageDownloadCommand) {
return execute((PrimaryStorageDownloadCommand) cmd);
} else if (cmd instanceof CreatePrivateTemplateCommand) {
@ -1144,6 +1147,25 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
}
}
}
public Answer execute(DestroyCommand cmd) {
VolumeTO vol = cmd.getVolume();
StorageVol volume = getVolume(vol.getPath());
if (volume == null) {
s_logger.debug("Failed to find the volume: " + vol.getPath());
return new Answer(cmd, true, "Success");
}
try {
volume.delete(0);
volume.free();
} catch (LibvirtException e) {
s_logger.debug("Failed to delete volume: " + e.toString());
return new Answer(cmd, false, e.toString());
}
return new Answer(cmd, true, "Success");
}
protected ManageSnapshotAnswer execute(final ManageSnapshotCommand cmd) {
/*TODO: no snapshot support for KVM right now, but create_private_template needs us to return true here*/
return new ManageSnapshotAnswer(cmd, cmd.getSnapshotId(), cmd.getVolumePath(), true, null);