use of com.cloud.agent.api.DeleteStoragePoolCommand in project cloudstack by apache.
the class NotAValidCommand method testDeleteStoragePoolCommand.
@Test
public void testDeleteStoragePoolCommand() {
final StoragePoolVO poolVO = Mockito.mock(StoragePoolVO.class);
final XsHost xsHost = Mockito.mock(XsHost.class);
final DeleteStoragePoolCommand deleteStorageCommand = new DeleteStoragePoolCommand(poolVO);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
when(citrixResourceBase.getHost()).thenReturn(xsHost);
final Answer answer = wrapper.execute(deleteStorageCommand, citrixResourceBase);
verify(citrixResourceBase, times(1)).getConnection();
assertTrue(answer.getResult());
}
use of com.cloud.agent.api.DeleteStoragePoolCommand 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.agent.api.DeleteStoragePoolCommand 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);
}
Aggregations