use of com.cloud.storage.StoragePoolHostVO in project cloudstack by apache.
the class CloudStackPrimaryDataStoreLifeCycleImpl method deleteDataStore.
@DB
@Override
public boolean deleteDataStore(DataStore store) {
List<StoragePoolHostVO> hostPoolRecords = _storagePoolHostDao.listByPoolId(store.getId());
StoragePool pool = (StoragePool) store;
boolean deleteFlag = false;
// find the hypervisor where the storage is attached to.
HypervisorType hType = null;
if (hostPoolRecords.size() > 0) {
hType = getHypervisorType(hostPoolRecords.get(0).getHostId());
}
// Remove the SR associated with the Xenserver
for (StoragePoolHostVO host : hostPoolRecords) {
DeleteStoragePoolCommand deleteCmd = new DeleteStoragePoolCommand(pool);
final Answer answer = agentMgr.easySend(host.getHostId(), deleteCmd);
if (answer != null && answer.getResult()) {
deleteFlag = true;
// if host is KVM hypervisor then send deleteStoragepoolcmd to all the kvm hosts.
if (HypervisorType.KVM != hType) {
break;
}
} else {
if (answer != null) {
s_logger.debug("Failed to delete storage pool: " + answer.getResult());
}
}
}
if (!hostPoolRecords.isEmpty() && !deleteFlag) {
throw new CloudRuntimeException("Failed to delete storage pool on host");
}
return dataStoreHelper.deletePrimaryDataStore(store);
}
use of com.cloud.storage.StoragePoolHostVO in project cloudstack by apache.
the class ScaleIOPrimaryDataStoreLifeCycle method deleteDataStore.
@Override
public boolean deleteDataStore(DataStore dataStore) {
StoragePool storagePool = (StoragePool) dataStore;
StoragePoolVO storagePoolVO = primaryDataStoreDao.findById(storagePool.getId());
if (storagePoolVO == null) {
return false;
}
List<VMTemplateStoragePoolVO> unusedTemplatesInPool = templateMgr.getUnusedTemplatesInPool(storagePoolVO);
for (VMTemplateStoragePoolVO templatePoolVO : unusedTemplatesInPool) {
if (templatePoolVO.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
templateMgr.evictTemplateFromStoragePool(templatePoolVO);
}
}
List<StoragePoolHostVO> poolHostVOs = storagePoolHostDao.listByPoolId(dataStore.getId());
for (StoragePoolHostVO poolHostVO : poolHostVOs) {
DeleteStoragePoolCommand deleteStoragePoolCommand = new DeleteStoragePoolCommand(storagePool);
final Answer answer = agentMgr.easySend(poolHostVO.getHostId(), deleteStoragePoolCommand);
if (answer != null && answer.getResult()) {
LOGGER.info("Successfully deleted storage pool: " + storagePool.getId() + " from host: " + poolHostVO.getHostId());
} else {
if (answer != null) {
LOGGER.error("Failed to delete storage pool: " + storagePool.getId() + " from host: " + poolHostVO.getHostId() + " , result: " + answer.getResult());
} else {
LOGGER.error("Failed to delete storage pool: " + storagePool.getId() + " from host: " + poolHostVO.getHostId());
}
}
}
ScaleIOGatewayClientConnectionPool.getInstance().removeClient(dataStore.getId());
return dataStoreHelper.deletePrimaryDataStore(dataStore);
}
use of com.cloud.storage.StoragePoolHostVO in project cloudstack by apache.
the class DeploymentPlanningManagerImpl method hostCanAccessSPool.
protected boolean hostCanAccessSPool(Host host, StoragePool pool) {
boolean hostCanAccessSPool = false;
StoragePoolHostVO hostPoolLinkage = _poolHostDao.findByPoolHost(pool.getId(), host.getId());
if (hostPoolLinkage != null && _storageMgr.canHostAccessStoragePool(host, pool)) {
hostCanAccessSPool = true;
}
s_logger.debug("Host: " + host.getId() + (hostCanAccessSPool ? " can" : " cannot") + " access pool: " + pool.getId());
return hostCanAccessSPool;
}
use of com.cloud.storage.StoragePoolHostVO in project cloudstack by apache.
the class ElastistorPrimaryDataStoreLifeCycle method deleteDataStore.
@SuppressWarnings("finally")
@Override
public boolean deleteDataStore(DataStore store) {
List<StoragePoolHostVO> hostPoolRecords = _storagePoolHostDao.listByPoolId(store.getId());
StoragePool pool = (StoragePool) store;
// find the hypervisor where the storage is attached to.
HypervisorType hType = null;
if (hostPoolRecords.size() > 0) {
hType = getHypervisorType(hostPoolRecords.get(0).getHostId());
}
StoragePoolVO storagePoolVO = _storagePoolDao.findById(store.getId());
if (!(storagePoolVO.isManaged())) {
// Remove the SR associated with the Xenserver
for (StoragePoolHostVO host : hostPoolRecords) {
DeleteStoragePoolCommand deleteCmd = new DeleteStoragePoolCommand(pool);
final Answer answer = agentMgr.easySend(host.getHostId(), deleteCmd);
if (answer != null && answer.getResult()) {
// to all the kvm hosts.
if (HypervisorType.KVM != hType) {
break;
}
} else {
if (answer != null) {
s_logger.error("Failed to delete storage pool: " + answer.getResult());
}
}
}
}
// delete the Elastistor volume at backend
deleteElastistorVolume(pool, storagePoolVO.isManaged());
return _dataStoreHelper.deletePrimaryDataStore(store);
}
use of com.cloud.storage.StoragePoolHostVO 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;
}
Aggregations