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);
}
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;
}
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;
}
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;
}
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);
}
}
Aggregations