CLOUDSTACK-5653:S3 object store as Secondary Storage, the template

created from different zone is not available for the other zones.
This commit is contained in:
Min Chen 2014-01-09 16:12:16 -08:00
parent 3af4cf4488
commit 9f03150a4f
5 changed files with 24 additions and 4 deletions

View File

@ -37,4 +37,6 @@ public interface DataStoreManager {
DataStore getImageCacheStore(long zoneId);
List<DataStore> listImageStores();
boolean isRegionStore(DataStore store);
}

View File

@ -62,5 +62,7 @@ public interface TemplateService {
void addSystemVMTemplatesToSecondary(DataStore store);
void associateTemplateToZone(long templateId, Long zoneId);
void associateCrosszoneTemplatesToZone(long dcId);
}

View File

@ -465,7 +465,8 @@ public class TemplateServiceImpl implements TemplateService {
// persist entry in template_zone_ref table. zoneId can be empty for
// region-wide image store, in that case,
// we will associate the template to all the zones.
private void associateTemplateToZone(long templateId, Long zoneId) {
@Override
public void associateTemplateToZone(long templateId, Long zoneId) {
List<Long> dcs = new ArrayList<Long>();
if (zoneId != null) {
dcs.add(zoneId);

View File

@ -19,6 +19,7 @@
package org.apache.cloudstack.storage.datastore;
import com.cloud.storage.DataStoreRole;
import com.cloud.storage.ScopeType;
import com.cloud.utils.exception.CloudRuntimeException;
import edu.emory.mathcs.backport.java.util.Collections;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
@ -79,6 +80,14 @@ public class DataStoreManagerImpl implements DataStoreManager {
return stores.get(0);
}
@Override
public boolean isRegionStore(DataStore store) {
if (store.getScope().getScopeType() == ScopeType.ZONE && store.getScope().getScopeId() == null)
return true;
else
return false;
}
@Override
public DataStore getPrimaryDataStore(long storeId) {
return primaryStoreMgr.getPrimaryDataStore(storeId);

View File

@ -1400,9 +1400,15 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
throw new CloudRuntimeException("Failed to create template" + result.getResult());
}
VMTemplateZoneVO templateZone = new VMTemplateZoneVO(zoneId, templateId, new Date());
this._tmpltZoneDao.persist(templateZone);
// create entries in template_zone_ref table
if (_dataStoreMgr.isRegionStore(store)) {
// template created on region store
_tmpltSvr.associateTemplateToZone(templateId, null);
} else {
VMTemplateZoneVO templateZone = new VMTemplateZoneVO(zoneId, templateId, new Date());
_tmpltZoneDao.persist(templateZone);
}
privateTemplate = this._tmpltDao.findById(templateId);
if (snapshotId != null) {
//getting the prent volume