Search in sources :

Example 6 with ModifyStoragePoolAnswer

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

the class SolidFireHostListener method sendModifyStoragePoolCommand.

private void sendModifyStoragePoolCommand(ModifyStoragePoolCommand cmd, StoragePool storagePool, long hostId) {
    Answer answer = _agentMgr.easySend(hostId, cmd);
    if (answer == null) {
        throw new CloudRuntimeException("Unable to get an answer to the modify storage pool command (" + storagePool.getId() + ")");
    }
    if (!answer.getResult()) {
        String msg = "Unable to attach storage pool " + storagePool.getId() + " to host " + hostId;
        _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, storagePool.getDataCenterId(), storagePool.getPodId(), msg, msg);
        throw new CloudRuntimeException("Unable to establish a connection from agent to storage pool " + storagePool.getId() + " due to " + answer.getDetails() + " (" + storagePool.getId() + ")");
    }
    assert (answer instanceof ModifyStoragePoolAnswer) : "ModifyStoragePoolAnswer expected ; Pool = " + storagePool.getId() + " Host = " + hostId;
    s_logger.info("Connection established between storage pool " + storagePool + " and host + " + hostId);
}
Also used : ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) Answer(com.cloud.agent.api.Answer) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer)

Example 7 with ModifyStoragePoolAnswer

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

the class SolidFireSharedHostListener method hostConnect.

@Override
public boolean hostConnect(long hostId, long storagePoolId) {
    StoragePool storagePool = (StoragePool) dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary);
    ModifyStoragePoolCommand cmd = new ModifyStoragePoolCommand(true, storagePool);
    ModifyStoragePoolAnswer answer = sendModifyStoragePoolCommand(cmd, storagePool, hostId);
    StoragePoolHostVO storagePoolHost = storagePoolHostDao.findByPoolHost(storagePoolId, hostId);
    if (storagePoolHost != null) {
        storagePoolHost.setLocalPath(answer.getPoolInfo().getLocalPath().replaceAll("//", "/"));
    } else {
        storagePoolHost = new StoragePoolHostVO(storagePoolId, hostId, answer.getPoolInfo().getLocalPath().replaceAll("//", "/"));
        storagePoolHostDao.persist(storagePoolHost);
    }
    StoragePoolVO storagePoolVO = storagePoolDao.findById(storagePoolId);
    storagePoolVO.setCapacityBytes(answer.getPoolInfo().getCapacityBytes());
    storagePoolVO.setUsedBytes(answer.getPoolInfo().getCapacityBytes() - answer.getPoolInfo().getAvailableBytes());
    storagePoolDao.update(storagePoolId, storagePoolVO);
    return true;
}
Also used : StoragePool(com.cloud.storage.StoragePool) StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) ModifyStoragePoolCommand(com.cloud.agent.api.ModifyStoragePoolCommand)

Example 8 with ModifyStoragePoolAnswer

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

the class SolidFireSharedHostListener method sendModifyStoragePoolCommand.

private ModifyStoragePoolAnswer sendModifyStoragePoolCommand(ModifyStoragePoolCommand cmd, StoragePool storagePool, long hostId) {
    Answer answer = agentMgr.easySend(hostId, cmd);
    if (answer == null) {
        throw new CloudRuntimeException("Unable to get an answer to the modify storage pool command for storage pool: " + storagePool.getId());
    }
    if (!answer.getResult()) {
        String msg = "Unable to attach storage pool " + storagePool.getId() + " to the host " + hostId;
        alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, storagePool.getDataCenterId(), storagePool.getPodId(), msg, msg);
        throw new CloudRuntimeException(msg);
    }
    assert (answer instanceof ModifyStoragePoolAnswer) : "ModifyStoragePoolAnswer not returned from ModifyStoragePoolCommand; Storage pool = " + storagePool.getId() + "; Host = " + hostId;
    LOGGER.info("Connection established between storage pool " + storagePool + " and host " + hostId);
    return (ModifyStoragePoolAnswer) answer;
}
Also used : ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) Answer(com.cloud.agent.api.Answer) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer)

Example 9 with ModifyStoragePoolAnswer

use of com.cloud.agent.api.ModifyStoragePoolAnswer in project CloudStack-archive by CloudStack-extras.

the class LibvirtComputingResource method execute.

protected Answer execute(ModifyStoragePoolCommand cmd) {
    KVMStoragePool storagepool = _storagePoolMgr.createStoragePool(cmd.getPool().getUuid(), cmd.getPool().getHost(), cmd.getPool().getPath(), cmd.getPool().getType());
    if (storagepool == null) {
        return new Answer(cmd, false, " Failed to create storage pool");
    }
    Map<String, TemplateInfo> tInfo = new HashMap<String, TemplateInfo>();
    ModifyStoragePoolAnswer answer = new ModifyStoragePoolAnswer(cmd, storagepool.getCapacity(), storagepool.getUsed(), tInfo);
    return answer;
}
Also used : FenceAnswer(com.cloud.agent.api.FenceAnswer) ConsoleProxyLoadAnswer(com.cloud.agent.api.proxy.ConsoleProxyLoadAnswer) DeleteSnapshotBackupAnswer(com.cloud.agent.api.DeleteSnapshotBackupAnswer) MaintainAnswer(com.cloud.agent.api.MaintainAnswer) GetHostStatsAnswer(com.cloud.agent.api.GetHostStatsAnswer) CheckSshAnswer(com.cloud.agent.api.check.CheckSshAnswer) GetVncPortAnswer(com.cloud.agent.api.GetVncPortAnswer) RebootAnswer(com.cloud.agent.api.RebootAnswer) ManageSnapshotAnswer(com.cloud.agent.api.ManageSnapshotAnswer) CreatePrivateTemplateAnswer(com.cloud.agent.api.storage.CreatePrivateTemplateAnswer) AttachVolumeAnswer(com.cloud.agent.api.AttachVolumeAnswer) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) PrimaryStorageDownloadAnswer(com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer) CreateAnswer(com.cloud.agent.api.storage.CreateAnswer) StartAnswer(com.cloud.agent.api.StartAnswer) GetStorageStatsAnswer(com.cloud.agent.api.GetStorageStatsAnswer) MigrateAnswer(com.cloud.agent.api.MigrateAnswer) CreateVolumeFromSnapshotAnswer(com.cloud.agent.api.CreateVolumeFromSnapshotAnswer) CheckNetworkAnswer(com.cloud.agent.api.CheckNetworkAnswer) GetVmStatsAnswer(com.cloud.agent.api.GetVmStatsAnswer) StopAnswer(com.cloud.agent.api.StopAnswer) NetworkUsageAnswer(com.cloud.agent.api.NetworkUsageAnswer) Answer(com.cloud.agent.api.Answer) BackupSnapshotAnswer(com.cloud.agent.api.BackupSnapshotAnswer) CheckVirtualMachineAnswer(com.cloud.agent.api.CheckVirtualMachineAnswer) IpAssocAnswer(com.cloud.agent.api.routing.IpAssocAnswer) CheckHealthAnswer(com.cloud.agent.api.CheckHealthAnswer) CopyVolumeAnswer(com.cloud.agent.api.storage.CopyVolumeAnswer) ReadyAnswer(com.cloud.agent.api.ReadyAnswer) PrepareForMigrationAnswer(com.cloud.agent.api.PrepareForMigrationAnswer) SecurityGroupRuleAnswer(com.cloud.agent.api.SecurityGroupRuleAnswer) TemplateInfo(com.cloud.storage.template.TemplateInfo) KVMStoragePool(com.cloud.agent.storage.KVMStoragePool) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer)

Example 10 with ModifyStoragePoolAnswer

use of com.cloud.agent.api.ModifyStoragePoolAnswer in project CloudStack-archive by CloudStack-extras.

the class FakeComputingResource method execute.

private Answer execute(ModifyStoragePoolCommand cmd) {
    long capacity = getConfiguredProperty("local.storage.capacity", 10000000000L);
    long used = 10000000L;
    long available = capacity - used;
    if (cmd.getAdd()) {
        ModifyStoragePoolAnswer answer = new ModifyStoragePoolAnswer(cmd, capacity, used, new HashMap<String, TemplateInfo>());
        if (s_logger.isInfoEnabled())
            s_logger.info("Sending ModifyStoragePoolCommand answer with capacity: " + capacity + ", used: " + used + ", available: " + available);
        return answer;
    } else {
        if (s_logger.isInfoEnabled())
            s_logger.info("ModifyNetfsStoragePoolCmd is not add command, cmd: " + cmd.toString());
        return new Answer(cmd);
    }
}
Also used : StopAnswer(com.cloud.agent.api.StopAnswer) Answer(com.cloud.agent.api.Answer) GetHostStatsAnswer(com.cloud.agent.api.GetHostStatsAnswer) CheckVirtualMachineAnswer(com.cloud.agent.api.CheckVirtualMachineAnswer) RebootAnswer(com.cloud.agent.api.RebootAnswer) CheckHealthAnswer(com.cloud.agent.api.CheckHealthAnswer) CheckStateAnswer(com.cloud.agent.api.CheckStateAnswer) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) PrimaryStorageDownloadAnswer(com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer) CreateAnswer(com.cloud.agent.api.storage.CreateAnswer) ReadyAnswer(com.cloud.agent.api.ReadyAnswer) StartAnswer(com.cloud.agent.api.StartAnswer) GetStorageStatsAnswer(com.cloud.agent.api.GetStorageStatsAnswer) GetVmStatsAnswer(com.cloud.agent.api.GetVmStatsAnswer) SecurityGroupRuleAnswer(com.cloud.agent.api.SecurityGroupRuleAnswer) TemplateInfo(com.cloud.storage.template.TemplateInfo) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer)

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