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