|
26 | 26 |
|
27 | 27 | import com.cloud.configuration.Config;
|
28 | 28 | import com.cloud.utils.SwiftUtil;
|
29 |
| -import org.apache.cloudstack.framework.config.dao.ConfigurationDao; |
30 | 29 |
|
31 | 30 | import org.apache.cloudstack.api.ApiConstants;
|
32 | 31 | import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
|
|
37 | 36 | import org.apache.cloudstack.engine.subsystem.api.storage.StorageCacheManager;
|
38 | 37 | import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
|
39 | 38 | import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
| 39 | +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; |
40 | 40 | import org.apache.cloudstack.storage.command.DownloadCommand;
|
41 | 41 | import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
|
42 | 42 | import org.apache.cloudstack.storage.image.BaseImageStoreDriverImpl;
|
43 | 43 | import org.apache.cloudstack.storage.image.store.ImageStoreImpl;
|
44 | 44 | import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
| 45 | +import org.apache.log4j.Logger; |
45 | 46 |
|
46 | 47 | import com.cloud.agent.api.storage.DownloadAnswer;
|
47 | 48 | import com.cloud.agent.api.to.DataObjectType;
|
48 | 49 | import com.cloud.agent.api.to.DataStoreTO;
|
49 | 50 | import com.cloud.agent.api.to.SwiftTO;
|
| 51 | +import com.cloud.configuration.Config; |
50 | 52 | import com.cloud.storage.Storage.ImageFormat;
|
51 |
| -import com.cloud.template.VirtualMachineTemplate; |
| 53 | +import com.cloud.utils.SwiftUtil; |
52 | 54 | import com.cloud.utils.exception.CloudRuntimeException;
|
53 | 55 |
|
54 | 56 | public class SwiftImageStoreDriverImpl extends BaseImageStoreDriverImpl {
|
@@ -99,8 +101,13 @@ public String createEntityExtractUrl(DataStore store, String installPath, ImageF
|
99 | 101 | @Override
|
100 | 102 | public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
|
101 | 103 | Long maxTemplateSizeInBytes = getMaxTemplateSizeInBytes();
|
102 |
| - VirtualMachineTemplate tmpl = _templateDao.findById(data.getId()); |
103 | 104 | DataStore cacheStore = cacheManager.getCacheStorage(dataStore.getScope());
|
| 105 | + if (cacheStore == null) { |
| 106 | + String errMsg = String.format("No cache store found for scope: %s", |
| 107 | + dataStore.getScope().getScopeType().name()); |
| 108 | + logger.error(errMsg); |
| 109 | + throw new CloudRuntimeException(errMsg); |
| 110 | + } |
104 | 111 | DownloadCommand dcmd = new DownloadCommand((TemplateObjectTO)(data.getTO()), maxTemplateSizeInBytes);
|
105 | 112 | dcmd.setCacheStore(cacheStore.getTO());
|
106 | 113 | dcmd.setProxy(getHttpProxy());
|
|
0 commit comments