Search in sources :

Example 26 with ZoneScope

use of org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope in project cloudstack by apache.

the class S3TemplateTest method copyTemplateToCache.

@Test(priority = 2)
public void copyTemplateToCache() {
    TemplateInfo template = templateFactory.getTemplate(templateId, DataStoreRole.Image);
    DataObject cacheObj = this.cacheMgr.createCacheObject(template, new ZoneScope(dcId));
    assertNotNull(cacheObj, "failed to create cache object");
}
Also used : ZoneScope(org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope) TemplateInfo(org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo) DataObject(org.apache.cloudstack.engine.subsystem.api.storage.DataObject) Test(org.testng.annotations.Test)

Example 27 with ZoneScope

use of org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope in project cloudstack by apache.

the class PrimaryDataStoreImpl method getScope.

@Override
public Scope getScope() {
    StoragePoolVO vo = dataStoreDao.findById(pdsv.getId());
    if (vo.getScope() == ScopeType.CLUSTER) {
        return new ClusterScope(vo.getClusterId(), vo.getPodId(), vo.getDataCenterId());
    } else if (vo.getScope() == ScopeType.ZONE) {
        return new ZoneScope(vo.getDataCenterId());
    } else if (vo.getScope() == ScopeType.HOST) {
        List<StoragePoolHostVO> poolHosts = poolHostDao.listByPoolId(vo.getId());
        if (poolHosts.size() > 0) {
            return new HostScope(poolHosts.get(0).getHostId(), vo.getClusterId(), vo.getDataCenterId());
        }
        s_logger.debug("can't find a local storage in pool host table: " + vo.getId());
    }
    return null;
}
Also used : ZoneScope(org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope) ClusterScope(org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope) StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO) VMTemplateStoragePoolVO(com.cloud.storage.VMTemplateStoragePoolVO) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) HostScope(org.apache.cloudstack.engine.subsystem.api.storage.HostScope)

Example 28 with ZoneScope

use of org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope in project cloudstack by apache.

the class TemplateDataStoreDaoImpl method findByTemplateZoneReady.

@Override
public TemplateDataStoreVO findByTemplateZoneReady(long templateId, Long zoneId) {
    List<DataStore> imgStores = null;
    imgStores = _storeMgr.getImageStoresByScope(new ZoneScope(zoneId));
    if (imgStores != null) {
        Collections.shuffle(imgStores);
        for (DataStore store : imgStores) {
            List<TemplateDataStoreVO> sRes = listByTemplateStoreStatus(templateId, store.getId(), State.Ready);
            if (sRes != null && sRes.size() > 0) {
                return sRes.get(0);
            }
        }
    }
    return null;
}
Also used : ZoneScope(org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) TemplateDataStoreVO(org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO)

Aggregations

ZoneScope (org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope)28 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)20 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)8 TemplateInfo (org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo)7 TemplateDataStoreVO (org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO)6 HostVO (com.cloud.host.HostVO)5 ClusterScope (org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope)5 PrimaryDataStore (org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore)5 NfsTO (com.cloud.agent.api.to.NfsTO)4 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)4 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)4 VMTemplateVO (com.cloud.storage.VMTemplateVO)4 ArrayList (java.util.ArrayList)4 DataObject (org.apache.cloudstack.engine.subsystem.api.storage.DataObject)4 Answer (com.cloud.agent.api.Answer)3 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)3 ConnectionException (com.cloud.exception.ConnectionException)3 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)3 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)3 URISyntaxException (java.net.URISyntaxException)3