Search in sources :

Example 1 with ZoneHostInfo

use of com.cloud.info.RunningHostInfoAgregator.ZoneHostInfo in project cloudstack by apache.

the class ConsoleProxyManagerImpl method isZoneReady.

public boolean isZoneReady(Map<Long, ZoneHostInfo> zoneHostInfoMap, long dataCenterId) {
    ZoneHostInfo zoneHostInfo = zoneHostInfoMap.get(dataCenterId);
    if (zoneHostInfo != null && isZoneHostReady(zoneHostInfo)) {
        VMTemplateVO template = _templateDao.findSystemVMReadyTemplate(dataCenterId, HypervisorType.Any);
        if (template == null) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("System vm template is not ready at data center " + dataCenterId + ", wait until it is ready to launch console proxy vm");
            }
            return false;
        }
        TemplateDataStoreVO templateHostRef = _vmTemplateStoreDao.findByTemplateZoneDownloadStatus(template.getId(), dataCenterId, Status.DOWNLOADED);
        if (templateHostRef != null) {
            boolean useLocalStorage = false;
            Boolean useLocal = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId);
            if (useLocal != null) {
                useLocalStorage = useLocal.booleanValue();
            }
            List<Pair<Long, Integer>> l = _consoleProxyDao.getDatacenterStoragePoolHostInfo(dataCenterId, useLocalStorage);
            if (l != null && l.size() > 0 && l.get(0).second().intValue() > 0) {
                return true;
            } else {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("Primary storage is not ready, wait until it is ready to launch console proxy");
                }
            }
        } else {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Zone host is ready, but console proxy template: " + template.getId() + " is not ready on secondary storage.");
            }
        }
    }
    return false;
}
Also used : ZoneHostInfo(com.cloud.info.RunningHostInfoAgregator.ZoneHostInfo) VMTemplateVO(com.cloud.storage.VMTemplateVO) TemplateDataStoreVO(org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO) Pair(com.cloud.utils.Pair)

Example 2 with ZoneHostInfo

use of com.cloud.info.RunningHostInfoAgregator.ZoneHostInfo in project cloudstack by apache.

the class SecondaryStorageManagerImpl method isZoneReady.

public boolean isZoneReady(Map<Long, ZoneHostInfo> zoneHostInfoMap, long dataCenterId) {
    ZoneHostInfo zoneHostInfo = zoneHostInfoMap.get(dataCenterId);
    if (zoneHostInfo != null && (zoneHostInfo.getFlags() & RunningHostInfoAgregator.ZoneHostInfo.ROUTING_HOST_MASK) != 0) {
        VMTemplateVO template = _templateDao.findSystemVMReadyTemplate(dataCenterId, HypervisorType.Any);
        if (template == null) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("System vm template is not ready at data center " + dataCenterId + ", wait until it is ready to launch secondary storage vm");
            }
            return false;
        }
        List<DataStore> stores = _dataStoreMgr.getImageStoresByScope(new ZoneScope(dataCenterId));
        if (stores.size() < 1) {
            s_logger.debug("No image store added  in zone " + dataCenterId + ", wait until it is ready to launch secondary storage vm");
            return false;
        }
        DataStore store = templateMgr.getImageStore(dataCenterId, template.getId());
        if (store == null) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("No secondary storage available in zone " + dataCenterId + ", wait until it is ready to launch secondary storage vm");
            }
            return false;
        }
        boolean useLocalStorage = false;
        Boolean useLocal = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId);
        if (useLocal != null) {
            useLocalStorage = useLocal.booleanValue();
        }
        List<Pair<Long, Integer>> l = _storagePoolHostDao.getDatacenterStoragePoolHostInfo(dataCenterId, !useLocalStorage);
        if (l != null && l.size() > 0 && l.get(0).second().intValue() > 0) {
            return true;
        } else {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Primary storage is not ready, wait until it is ready to launch secondary storage vm. dcId: " + dataCenterId + ", " + ConfigurationManagerImpl.SystemVMUseLocalStorage.key() + ": " + useLocalStorage + ". " + "If you want to use local storage to start SSVM, need to set " + ConfigurationManagerImpl.SystemVMUseLocalStorage.key() + " to true");
            }
        }
    }
    return false;
}
Also used : ZoneScope(org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope) ZoneHostInfo(com.cloud.info.RunningHostInfoAgregator.ZoneHostInfo) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) VMTemplateVO(com.cloud.storage.VMTemplateVO) Pair(com.cloud.utils.Pair)

Aggregations

ZoneHostInfo (com.cloud.info.RunningHostInfoAgregator.ZoneHostInfo)2 VMTemplateVO (com.cloud.storage.VMTemplateVO)2 Pair (com.cloud.utils.Pair)2 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)1 ZoneScope (org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope)1 TemplateDataStoreVO (org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO)1