Search in sources :

Example 16 with ModifyStoragePoolAnswer

use of com.cloud.agent.api.ModifyStoragePoolAnswer in project cloudstack by apache.

the class ElastistorHostListener method hostConnect.

@Override
public boolean hostConnect(long hostId, long poolId) {
    StoragePool pool = (StoragePool) this.dataStoreMgr.getDataStore(poolId, DataStoreRole.Primary);
    StoragePoolHostVO storagePoolHost = storagePoolHostDao.findByPoolHost(poolId, hostId);
    HostVO host = _hostDao.findById(hostId);
    if (storagePoolHost == null) {
        storagePoolHost = new StoragePoolHostVO(poolId, hostId, "");
        storagePoolHostDao.persist(storagePoolHost);
    }
    StoragePoolVO poolVO = storagePoolDao.findById(pool.getId());
    if (poolVO.isManaged() && (host.getHypervisorType() != HypervisorType.KVM)) {
        return true;
    }
    ModifyStoragePoolCommand cmd = new ModifyStoragePoolCommand(true, pool);
    final Answer answer = agentMgr.easySend(hostId, cmd);
    if (answer == null) {
        throw new CloudRuntimeException("Unable to get an answer to the modify storage pool command" + pool.getId());
    }
    if (!answer.getResult()) {
        String msg = "Unable to attach storage pool" + poolId + " to the host" + hostId;
        alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, pool.getDataCenterId(), pool.getPodId(), msg, msg);
        throw new CloudRuntimeException("Unable establish connection from storage head to storage pool " + pool.getId() + " due to " + answer.getDetails() + pool.getId());
    }
    assert (answer instanceof ModifyStoragePoolAnswer) : "Well, now why won't you actually return the ModifyStoragePoolAnswer when it's ModifyStoragePoolCommand? Pool=" + pool.getId() + "Host=" + hostId;
    s_logger.info("Connection established between " + pool + " host + " + hostId);
    return true;
}
Also used : ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) Answer(com.cloud.agent.api.Answer) StoragePool(com.cloud.storage.StoragePool) StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO) HostVO(com.cloud.host.HostVO) ModifyStoragePoolCommand(com.cloud.agent.api.ModifyStoragePoolCommand)

Aggregations

ModifyStoragePoolAnswer (com.cloud.agent.api.ModifyStoragePoolAnswer)16 Answer (com.cloud.agent.api.Answer)11 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)10 StorageFilerTO (com.cloud.agent.api.to.StorageFilerTO)8 TemplateProp (com.cloud.storage.template.TemplateProp)7 HashMap (java.util.HashMap)6 GetStorageStatsAnswer (com.cloud.agent.api.GetStorageStatsAnswer)5 PrimaryStorageDownloadAnswer (com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer)5 ConfigurationException (javax.naming.ConfigurationException)5 CheckVirtualMachineAnswer (com.cloud.agent.api.CheckVirtualMachineAnswer)4 GetHostStatsAnswer (com.cloud.agent.api.GetHostStatsAnswer)4 GetVmStatsAnswer (com.cloud.agent.api.GetVmStatsAnswer)4 ReadyAnswer (com.cloud.agent.api.ReadyAnswer)4 RebootAnswer (com.cloud.agent.api.RebootAnswer)4 StartAnswer (com.cloud.agent.api.StartAnswer)4 StopAnswer (com.cloud.agent.api.StopAnswer)4 MockStoragePoolVO (com.cloud.simulator.MockStoragePoolVO)4 TemplateInfo (com.cloud.storage.template.TemplateInfo)4 CheckHealthAnswer (com.cloud.agent.api.CheckHealthAnswer)3 CheckNetworkAnswer (com.cloud.agent.api.CheckNetworkAnswer)3