CLOUDSTACK-4625:Snapshots and templates should be deleted from staging

storage after create template from snapshot on S3.
This commit is contained in:
Min Chen 2013-09-06 17:27:30 -07:00
parent a05ec6df33
commit b11a8e12e8
3 changed files with 31 additions and 2 deletions

View File

@ -440,6 +440,11 @@ public class
CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _createprivatetemplatefromsnapshotwait, _mgmtServer.getExecuteInSequence());
EndPoint ep = selector.select(srcData, destData);
Answer answer = ep.sendMessage(cmd);
// clean up snapshot copied to staging
if (srcData != null) {
cacheMgr.deleteCacheObject(srcData);
}
return answer;
}

View File

@ -102,7 +102,15 @@ public class VmwareStorageSubsystemCommandHandler extends StorageSubsystemComman
TemplateObjectTO template = (TemplateObjectTO)answer.getNewData();
template.setDataStore(srcDataStore);
CopyCommand newCmd = new CopyCommand(template, destData, cmd.getWait(), cmd.executeInSequence());
return storageResource.defaultAction(newCmd);
Answer result = storageResource.defaultAction(newCmd);
//clean up template data on staging area
try {
DeleteCommand deleteCommand = new DeleteCommand(template);
storageResource.defaultAction(deleteCommand);
} catch (Exception e) {
s_logger.debug("Failed to clean up staging area:", e);
}
return result;
}
needDelegation = true;
}

View File

@ -526,6 +526,14 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
SwiftUtil.putObject(swift, properties, containterName, _tmpltpp);
}
//clean up template data on staging area
try {
DeleteCommand deleteCommand = new DeleteCommand(newTemplate);
execute(deleteCommand);
} catch (Exception e) {
s_logger.debug("Failed to clean up staging area:", e);
}
TemplateObjectTO template = new TemplateObjectTO();
template.setPath(swiftPath);
template.setSize(templateFile.length());
@ -543,7 +551,15 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
TemplateObjectTO newTemplate = (TemplateObjectTO)answer.getNewData();
newTemplate.setDataStore(srcDataStore);
CopyCommand newCpyCmd = new CopyCommand(newTemplate, destData, cmd.getWait(), cmd.executeInSequence());
return copyFromNfsToS3(newCpyCmd);
Answer result = copyFromNfsToS3(newCpyCmd);
//clean up template data on staging area
try {
DeleteCommand deleteCommand = new DeleteCommand(newTemplate);
execute(deleteCommand);
} catch (Exception e) {
s_logger.debug("Failed to clean up staging area:", e);
}
return result;
}
}
s_logger.debug("Failed to create templat from snapshot");