mirror of https://github.com/apache/cloudstack.git
plugin-swift: handle null cache store (#11380)
Fixes https://github.com/apache/cloudstack/pull/11315#pullrequestreview-3074036751 Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
parent
1bfebd550c
commit
3134efb971
|
|
@ -24,11 +24,6 @@ import java.util.UUID;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import com.cloud.configuration.Config;
|
|
||||||
import com.cloud.utils.SwiftUtil;
|
|
||||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
import org.apache.cloudstack.api.ApiConstants;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
|
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||||
|
|
@ -38,18 +33,21 @@ import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.StorageCacheManager;
|
import org.apache.cloudstack.engine.subsystem.api.storage.StorageCacheManager;
|
||||||
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
|
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
|
||||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||||
|
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||||
import org.apache.cloudstack.storage.command.DownloadCommand;
|
import org.apache.cloudstack.storage.command.DownloadCommand;
|
||||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
|
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
|
||||||
import org.apache.cloudstack.storage.image.BaseImageStoreDriverImpl;
|
import org.apache.cloudstack.storage.image.BaseImageStoreDriverImpl;
|
||||||
import org.apache.cloudstack.storage.image.store.ImageStoreImpl;
|
import org.apache.cloudstack.storage.image.store.ImageStoreImpl;
|
||||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.agent.api.storage.DownloadAnswer;
|
import com.cloud.agent.api.storage.DownloadAnswer;
|
||||||
import com.cloud.agent.api.to.DataObjectType;
|
import com.cloud.agent.api.to.DataObjectType;
|
||||||
import com.cloud.agent.api.to.DataStoreTO;
|
import com.cloud.agent.api.to.DataStoreTO;
|
||||||
import com.cloud.agent.api.to.SwiftTO;
|
import com.cloud.agent.api.to.SwiftTO;
|
||||||
|
import com.cloud.configuration.Config;
|
||||||
import com.cloud.storage.Storage.ImageFormat;
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
import com.cloud.template.VirtualMachineTemplate;
|
import com.cloud.utils.SwiftUtil;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
public class SwiftImageStoreDriverImpl extends BaseImageStoreDriverImpl {
|
public class SwiftImageStoreDriverImpl extends BaseImageStoreDriverImpl {
|
||||||
|
|
@ -101,8 +99,13 @@ public class SwiftImageStoreDriverImpl extends BaseImageStoreDriverImpl {
|
||||||
@Override
|
@Override
|
||||||
public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
|
public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
|
||||||
Long maxTemplateSizeInBytes = getMaxTemplateSizeInBytes();
|
Long maxTemplateSizeInBytes = getMaxTemplateSizeInBytes();
|
||||||
VirtualMachineTemplate tmpl = _templateDao.findById(data.getId());
|
|
||||||
DataStore cacheStore = cacheManager.getCacheStorage(dataStore.getScope());
|
DataStore cacheStore = cacheManager.getCacheStorage(dataStore.getScope());
|
||||||
|
if (cacheStore == null) {
|
||||||
|
String errMsg = String.format("No cache store found for scope: %s",
|
||||||
|
dataStore.getScope().getScopeType().name());
|
||||||
|
s_logger.error(errMsg);
|
||||||
|
throw new CloudRuntimeException(errMsg);
|
||||||
|
}
|
||||||
DownloadCommand dcmd = new DownloadCommand((TemplateObjectTO)(data.getTO()), maxTemplateSizeInBytes);
|
DownloadCommand dcmd = new DownloadCommand((TemplateObjectTO)(data.getTO()), maxTemplateSizeInBytes);
|
||||||
dcmd.setCacheStore(cacheStore.getTO());
|
dcmd.setCacheStore(cacheStore.getTO());
|
||||||
dcmd.setProxy(getHttpProxy());
|
dcmd.setProxy(getHttpProxy());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue