PATCH: CLOUDSTACK-6254

Fixes the cleanup process to only remove the Template symlink, instead of delete the template from Secondary Storage.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
David Bierce 2014-08-27 09:31:18 -05:00 committed by Rohit Yadav
parent 14b846877e
commit 7edde4a5c7
6 changed files with 24 additions and 12 deletions

View File

@ -27,6 +27,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
import com.cloud.storage.ImageStore;
import com.cloud.storage.Upload;
import com.cloud.storage.Storage.ImageFormat;
public interface ImageStoreEntity extends DataStore, ImageStore {
@ -44,5 +45,5 @@ public interface ImageStoreEntity extends DataStore, ImageStore {
String createEntityExtractUrl(String installPath, ImageFormat format, DataObject dataObject); // get the entity download URL
void deleteExtractUrl(String installPath, String url);
void deleteExtractUrl(String installPath, String url, Upload.Type volume);
}

View File

@ -45,6 +45,7 @@ import com.cloud.agent.api.to.DataStoreTO;
import com.cloud.storage.DataStoreRole;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.Upload;
import com.cloud.utils.component.ComponentContext;
public class ImageStoreImpl implements ImageStoreEntity {
@ -195,8 +196,8 @@ public class ImageStoreImpl implements ImageStoreEntity {
}
@Override
public void deleteExtractUrl(String installPath, String url) {
driver.deleteEntityExtractUrl(this, installPath, url);
public void deleteExtractUrl(String installPath, String url, Upload.Type entityType ) {
driver.deleteEntityExtractUrl(this, installPath, url, entityType);
}
}

View File

@ -30,6 +30,7 @@ import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.storage.download.DownloadMonitor;
import com.cloud.storage.Upload;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
@ -261,7 +262,7 @@ public abstract class BaseImageStoreDriverImpl implements ImageStoreDriver {
}
@Override
public void deleteEntityExtractUrl(DataStore store, String installPath, String url){
public void deleteEntityExtractUrl(DataStore store, String installPath, String url, Upload.Type entityType){
}
}

View File

@ -23,11 +23,13 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Upload;
import com.cloud.storage.Upload.Type;
public interface ImageStoreDriver extends DataStoreDriver {
String createEntityExtractUrl(DataStore store, String installPath, ImageFormat format, DataObject dataObject);
void deleteEntityExtractUrl(DataStore store, String installPath, String url);
void deleteEntityExtractUrl(DataStore store, String installPath, String downloadUrl, Upload.Type entityType);
}

View File

@ -81,14 +81,21 @@ public class CloudStackImageStoreDriverImpl extends BaseImageStoreDriverImpl {
}
@Override
public void deleteEntityExtractUrl(DataStore store, String installPath, String downloadUrl) {
public void deleteEntityExtractUrl(DataStore store, String installPath, String downloadUrl, Upload.Type entityType) {
// find an endpoint to send command
EndPoint ep = _epSelector.select(store);
// Create Symlink at ssvm
//CreateEntityDownloadURLCommand cmd = new CreateEntityDownloadURLCommand(((ImageStoreEntity) store).getMountPoint(), installPath, uuid);
DeleteEntityDownloadURLCommand cmd = new DeleteEntityDownloadURLCommand(installPath, Upload.Type.VOLUME, downloadUrl, ((ImageStoreEntity) store).getMountPoint());
Answer ans = ep.sendMessage(cmd);
// Delete Symlink at ssvm. In case of volume also delete the volume.
DeleteEntityDownloadURLCommand cmd = new DeleteEntityDownloadURLCommand(installPath, entityType, downloadUrl, ((ImageStoreEntity) store).getMountPoint());
Answer ans = null;
if (ep == null) {
String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
s_logger.error(errMsg);
ans = new Answer(cmd, false, errMsg);
} else {
ans = ep.sendMessage(cmd);
}
if (ans == null || !ans.getResult()) {
String errorString = "Unable to delete the url " + downloadUrl + " for path " + installPath + " on ssvm, " + ans.getDetails();
s_logger.error(errorString);

View File

@ -1214,7 +1214,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
// Remove it from image store
ImageStoreEntity secStore = (ImageStoreEntity) _dataStoreMgr.getDataStore(volumeOnImageStore.getDataStoreId(), DataStoreRole.Image);
secStore.deleteExtractUrl(volumeOnImageStore.getInstallPath(), volumeOnImageStore.getExtractUrl());
secStore.deleteExtractUrl(volumeOnImageStore.getInstallPath(), volumeOnImageStore.getExtractUrl(), Upload.Type.VOLUME);
// Now remove it from DB.
volumeOnImageStore.setExtractUrl(null);
@ -1240,7 +1240,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
// Remove it from image store
ImageStoreEntity secStore = (ImageStoreEntity) _dataStoreMgr.getDataStore(templateOnImageStore.getDataStoreId(), DataStoreRole.Image);
secStore.deleteExtractUrl(templateOnImageStore.getInstallPath(), templateOnImageStore.getExtractUrl());
secStore.deleteExtractUrl(templateOnImageStore.getInstallPath(), templateOnImageStore.getExtractUrl(), Upload.Type.TEMPLATE);
// Now remove it from DB.
templateOnImageStore.setExtractUrl(null);