|
29 | 29 | import com.cloud.storage.DataStoreRole; |
30 | 30 | import org.apache.cloudstack.storage.command.CopyCmdAnswer; |
31 | 31 | import org.apache.cloudstack.storage.command.CopyCommand; |
| 32 | +import org.apache.cloudstack.storage.command.DeleteCommand; |
32 | 33 | import org.apache.cloudstack.storage.to.SnapshotObjectTO; |
33 | 34 | import org.apache.cloudstack.storage.to.TemplateObjectTO; |
34 | 35 | import org.apache.cloudstack.storage.to.VolumeObjectTO; |
| 36 | +import org.apache.log4j.Logger; |
35 | 37 |
|
36 | 38 | import java.io.File; |
37 | 39 |
|
38 | 40 | public class VmwareStorageSubsystemCommandHandler extends StorageSubsystemCommandHandlerBase { |
39 | | - |
| 41 | + private static final Logger s_logger = Logger.getLogger(VmwareStorageSubsystemCommandHandler.class); |
40 | 42 | private VmwareStorageManager storageManager; |
41 | 43 | private PremiumSecondaryStorageResource storageResource; |
42 | 44 |
|
@@ -125,7 +127,17 @@ protected Answer execute(CopyCommand cmd) { |
125 | 127 | newSnapshot.setPath(newSnapshot.getPath() + ".ova"); |
126 | 128 | newSnapshot.setDataStore(cmd.getCacheTO().getDataStore()); |
127 | 129 | CopyCommand newCmd = new CopyCommand(newSnapshot, destData, cmd.getWait(), cmd.executeInSequence()); |
128 | | - return storageResource.defaultAction(newCmd); |
| 130 | + Answer result = storageResource.defaultAction(newCmd); |
| 131 | + |
| 132 | + //clean up data on staging area |
| 133 | + try { |
| 134 | + newSnapshot.setPath(path); |
| 135 | + DeleteCommand deleteCommand = new DeleteCommand(newSnapshot); |
| 136 | + storageResource.defaultAction(deleteCommand); |
| 137 | + } catch (Exception e) { |
| 138 | + s_logger.debug("Failed to clean up staging area:", e); |
| 139 | + } |
| 140 | + return result; |
129 | 141 | } |
130 | 142 | } |
131 | 143 |
|
|
0 commit comments