Search in sources :

Example 1 with DeleteSnapshotBackupAnswer

use of com.cloud.agent.api.DeleteSnapshotBackupAnswer in project CloudStack-archive by CloudStack-extras.

the class LibvirtComputingResource method execute.

protected DeleteSnapshotBackupAnswer execute(final DeleteSnapshotBackupCommand cmd) {
    Long dcId = cmd.getDataCenterId();
    Long accountId = cmd.getAccountId();
    Long volumeId = cmd.getVolumeId();
    KVMStoragePool secondaryStoragePool = null;
    try {
        secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(cmd.getSecondaryStorageUrl());
        String ssPmountPath = secondaryStoragePool.getLocalPath();
        String snapshotDestPath = ssPmountPath + File.separator + "snapshots" + File.separator + dcId + File.separator + accountId + File.separator + volumeId;
        final Script command = new Script(_manageSnapshotPath, _cmdsTimeout, s_logger);
        command.add("-d", snapshotDestPath);
        command.add("-n", cmd.getSnapshotName());
        command.execute();
    } catch (CloudRuntimeException e) {
        return new DeleteSnapshotBackupAnswer(cmd, false, e.toString());
    } finally {
        if (secondaryStoragePool != null) {
            secondaryStoragePool.delete();
        }
    }
    return new DeleteSnapshotBackupAnswer(cmd, true, null);
}
Also used : Script(com.cloud.utils.script.Script) KVMStoragePool(com.cloud.agent.storage.KVMStoragePool) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) DeleteSnapshotBackupAnswer(com.cloud.agent.api.DeleteSnapshotBackupAnswer)

Aggregations

DeleteSnapshotBackupAnswer (com.cloud.agent.api.DeleteSnapshotBackupAnswer)1 KVMStoragePool (com.cloud.agent.storage.KVMStoragePool)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 Script (com.cloud.utils.script.Script)1