use of com.cloud.engine.subsystem.api.storage.TemplateInfo in project cosmic by MissionCriticalCloud.
the class TemplateServiceImpl method syncToRegionStoreAsync.
private AsyncCallFuture<TemplateApiResult> syncToRegionStoreAsync(final TemplateInfo template, final DataStore store) {
final AsyncCallFuture<TemplateApiResult> future = new AsyncCallFuture<>();
// no need to create entry on template_store_ref here, since entries are already created when prepareSecondaryStorageForMigration is invoked.
// But we need to set default install path so that sync can be done in the right s3 path
final TemplateInfo templateOnStore = _templateFactory.getTemplate(template, store);
final String installPath = TemplateConstants.DEFAULT_TMPLT_ROOT_DIR + "/" + TemplateConstants.DEFAULT_TMPLT_FIRST_LEVEL_DIR + template.getAccountId() + "/" + template.getId() + "/" + template.getUniqueName();
((TemplateObject) templateOnStore).setInstallPath(installPath);
final TemplateOpContext<TemplateApiResult> context = new TemplateOpContext<>(null, (TemplateObject) templateOnStore, future);
final AsyncCallbackDispatcher<TemplateServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
caller.setCallback(caller.getTarget().syncTemplateCallBack(null, null)).setContext(context);
_motionSrv.copyAsync(template, templateOnStore, caller);
return future;
}
use of com.cloud.engine.subsystem.api.storage.TemplateInfo in project cosmic by MissionCriticalCloud.
the class StorageSystemDataMotionStrategy method copyAsync.
@Override
public Void copyAsync(final DataObject srcData, final DataObject destData, final Host destHost, final AsyncCompletionCallback<CopyCommandResult> callback) {
if (srcData instanceof SnapshotInfo) {
final SnapshotInfo snapshotInfo = (SnapshotInfo) srcData;
validate(snapshotInfo);
final boolean canHandleSrc = canHandle(srcData.getDataStore());
if (canHandleSrc && destData instanceof TemplateInfo && (destData.getDataStore().getRole() == DataStoreRole.Image || destData.getDataStore().getRole() == DataStoreRole.ImageCache)) {
return handleCreateTemplateFromSnapshot(snapshotInfo, (TemplateInfo) destData, callback);
}
if (destData instanceof VolumeInfo) {
final VolumeInfo volumeInfo = (VolumeInfo) destData;
final boolean canHandleDest = canHandle(destData.getDataStore());
if (canHandleSrc && canHandleDest) {
return handleCreateVolumeFromSnapshotBothOnStorageSystem(snapshotInfo, volumeInfo, callback);
}
if (canHandleSrc) {
throw new UnsupportedOperationException("This operation is not supported (DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT " + "not supported by destination storage plug-in).");
}
if (canHandleDest) {
throw new UnsupportedOperationException("This operation is not supported (DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT " + "not supported by source storage plug-in).");
}
}
}
throw new UnsupportedOperationException("This operation is not supported.");
}
use of com.cloud.engine.subsystem.api.storage.TemplateInfo in project cosmic by MissionCriticalCloud.
the class AncientDataMotionStrategy method needCacheStorage.
protected boolean needCacheStorage(final DataObject srcData, final DataObject destData) {
final DataTO srcTO = srcData.getTO();
final DataStoreTO srcStoreTO = srcTO.getDataStore();
if (srcStoreTO instanceof NfsTO || srcStoreTO.getRole() == DataStoreRole.ImageCache) {
// (srcStoreTO instanceof PrimaryDataStoreTO && ((PrimaryDataStoreTO)srcStoreTO).getPoolType() == StoragePoolType.NetworkFilesystem)) {
return false;
}
final DataTO destTO = destData.getTO();
final DataStoreTO destStoreTO = destTO.getDataStore();
if (destStoreTO instanceof NfsTO || destStoreTO.getRole() == DataStoreRole.ImageCache) {
return false;
}
if (srcData.getType() == DataObjectType.TEMPLATE) {
final TemplateInfo template = (TemplateInfo) srcData;
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("needCacheStorage true, dest at " + destTO.getPath() + " dest role " + destStoreTO.getRole().toString() + srcTO.getPath() + " src role " + srcStoreTO.getRole().toString());
}
return true;
}
use of com.cloud.engine.subsystem.api.storage.TemplateInfo in project cosmic by MissionCriticalCloud.
the class TemplateDataFactoryImpl method listTemplateOnCache.
@Override
public List<TemplateInfo> listTemplateOnCache(final long templateId) {
final List<TemplateDataStoreVO> cacheTmpls = templateStoreDao.listOnCache(templateId);
final List<TemplateInfo> tmplObjs = new ArrayList<>();
for (final TemplateDataStoreVO cacheTmpl : cacheTmpls) {
final long storeId = cacheTmpl.getDataStoreId();
final DataStore store = storeMgr.getDataStore(storeId, DataStoreRole.ImageCache);
final TemplateInfo tmplObj = getTemplate(templateId, store);
tmplObjs.add(tmplObj);
}
return tmplObjs;
}
use of com.cloud.engine.subsystem.api.storage.TemplateInfo in project cosmic by MissionCriticalCloud.
the class TemplateServiceImpl method handleSysTemplateDownload.
@Override
public void handleSysTemplateDownload(final HypervisorType hostHyper, final Long dcId) {
final Set<VMTemplateVO> toBeDownloaded = new HashSet<>();
final List<DataStore> stores = _storeMgr.getImageStoresByScope(new ZoneScope(dcId));
if (stores == null || stores.isEmpty()) {
return;
}
/* Download all the templates in zone with the same hypervisortype */
for (final DataStore store : stores) {
final List<VMTemplateVO> rtngTmplts = _templateDao.listAllSystemVMTemplates();
final List<VMTemplateVO> defaultBuiltin = _templateDao.listDefaultBuiltinTemplates();
for (final VMTemplateVO rtngTmplt : rtngTmplts) {
if (rtngTmplt.getHypervisorType() == hostHyper) {
toBeDownloaded.add(rtngTmplt);
}
}
for (final VMTemplateVO builtinTmplt : defaultBuiltin) {
if (builtinTmplt.getHypervisorType() == hostHyper) {
toBeDownloaded.add(builtinTmplt);
}
}
for (final VMTemplateVO template : toBeDownloaded) {
final TemplateDataStoreVO tmpltHost = _vmTemplateStoreDao.findByStoreTemplate(store.getId(), template.getId());
if (tmpltHost == null || tmpltHost.getState() != ObjectInDataStoreStateMachine.State.Ready) {
associateTemplateToZone(template.getId(), dcId);
s_logger.info("Downloading builtin template " + template.getUniqueName() + " to data center: " + dcId);
final TemplateInfo tmplt = _templateFactory.getTemplate(template.getId(), DataStoreRole.Image);
createTemplateAsync(tmplt, store, null);
}
}
}
}
Aggregations