|
24 | 24 |
|
25 | 25 | import javax.inject.Inject; |
26 | 26 |
|
27 | | -import com.cloud.configuration.Config; |
28 | | -import com.cloud.utils.SwiftUtil; |
29 | | -import org.apache.cloudstack.framework.config.dao.ConfigurationDao; |
30 | | - |
31 | 27 | import org.apache.cloudstack.api.ApiConstants; |
32 | 28 | import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult; |
33 | 29 | import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; |
|
37 | 33 | import org.apache.cloudstack.engine.subsystem.api.storage.StorageCacheManager; |
38 | 34 | import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher; |
39 | 35 | import org.apache.cloudstack.framework.async.AsyncCompletionCallback; |
| 36 | +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; |
40 | 37 | import org.apache.cloudstack.storage.command.DownloadCommand; |
41 | 38 | import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao; |
42 | 39 | import org.apache.cloudstack.storage.image.BaseImageStoreDriverImpl; |
43 | 40 | import org.apache.cloudstack.storage.image.store.ImageStoreImpl; |
44 | 41 | import org.apache.cloudstack.storage.to.TemplateObjectTO; |
| 42 | +import org.apache.log4j.Logger; |
45 | 43 |
|
46 | 44 | import com.cloud.agent.api.storage.DownloadAnswer; |
47 | 45 | import com.cloud.agent.api.to.DataObjectType; |
48 | 46 | import com.cloud.agent.api.to.DataStoreTO; |
49 | 47 | import com.cloud.agent.api.to.SwiftTO; |
| 48 | +import com.cloud.configuration.Config; |
50 | 49 | import com.cloud.storage.Storage.ImageFormat; |
51 | | -import com.cloud.template.VirtualMachineTemplate; |
| 50 | +import com.cloud.utils.SwiftUtil; |
52 | 51 | import com.cloud.utils.exception.CloudRuntimeException; |
53 | 52 |
|
54 | 53 | public class SwiftImageStoreDriverImpl extends BaseImageStoreDriverImpl { |
@@ -99,8 +98,13 @@ public String createEntityExtractUrl(DataStore store, String installPath, ImageF |
99 | 98 | @Override |
100 | 99 | public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) { |
101 | 100 | Long maxTemplateSizeInBytes = getMaxTemplateSizeInBytes(); |
102 | | - VirtualMachineTemplate tmpl = _templateDao.findById(data.getId()); |
103 | 101 | 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 | + } |
104 | 108 | DownloadCommand dcmd = new DownloadCommand((TemplateObjectTO)(data.getTO()), maxTemplateSizeInBytes); |
105 | 109 | dcmd.setCacheStore(cacheStore.getTO()); |
106 | 110 | dcmd.setProxy(getHttpProxy()); |
|
0 commit comments