Skip to content

Commit 882a98a

Browse files
shwstpprdhslove
authored andcommitted
plugin-swift: handle null cache store (apache#11380)
Fixes apache#11315 (review) Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 300c3c0 commit 882a98a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

plugins/storage/image/swift/src/main/java/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424

2525
import javax.inject.Inject;
2626

27-
import com.cloud.configuration.Config;
28-
import com.cloud.utils.SwiftUtil;
29-
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
30-
3127
import org.apache.cloudstack.api.ApiConstants;
3228
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
3329
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
@@ -37,18 +33,21 @@
3733
import org.apache.cloudstack.engine.subsystem.api.storage.StorageCacheManager;
3834
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
3935
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
36+
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
4037
import org.apache.cloudstack.storage.command.DownloadCommand;
4138
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
4239
import org.apache.cloudstack.storage.image.BaseImageStoreDriverImpl;
4340
import org.apache.cloudstack.storage.image.store.ImageStoreImpl;
4441
import org.apache.cloudstack.storage.to.TemplateObjectTO;
42+
import org.apache.log4j.Logger;
4543

4644
import com.cloud.agent.api.storage.DownloadAnswer;
4745
import com.cloud.agent.api.to.DataObjectType;
4846
import com.cloud.agent.api.to.DataStoreTO;
4947
import com.cloud.agent.api.to.SwiftTO;
48+
import com.cloud.configuration.Config;
5049
import com.cloud.storage.Storage.ImageFormat;
51-
import com.cloud.template.VirtualMachineTemplate;
50+
import com.cloud.utils.SwiftUtil;
5251
import com.cloud.utils.exception.CloudRuntimeException;
5352

5453
public class SwiftImageStoreDriverImpl extends BaseImageStoreDriverImpl {
@@ -99,8 +98,13 @@ public String createEntityExtractUrl(DataStore store, String installPath, ImageF
9998
@Override
10099
public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
101100
Long maxTemplateSizeInBytes = getMaxTemplateSizeInBytes();
102-
VirtualMachineTemplate tmpl = _templateDao.findById(data.getId());
103101
DataStore cacheStore = cacheManager.getCacheStorage(dataStore.getScope());
102+
if (cacheStore == null) {
103+
String errMsg = String.format("No cache store found for scope: %s",
104+
dataStore.getScope().getScopeType().name());
105+
s_logger.error(errMsg);
106+
throw new CloudRuntimeException(errMsg);
107+
}
104108
DownloadCommand dcmd = new DownloadCommand((TemplateObjectTO)(data.getTO()), maxTemplateSizeInBytes);
105109
dcmd.setCacheStore(cacheStore.getTO());
106110
dcmd.setProxy(getHttpProxy());

0 commit comments

Comments
 (0)