use of com.cloud.legacymodel.communication.command.DeleteStoragePoolCommand in project cosmic by MissionCriticalCloud.
the class CloudStackPrimaryDataStoreLifeCycleImpl method deleteDataStore.
@DB
@Override
public boolean deleteDataStore(final DataStore store) {
final List<StoragePoolHostVO> hostPoolRecords = _storagePoolHostDao.listByPoolId(store.getId());
final 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 (final StoragePoolHostVO host : hostPoolRecords) {
final 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.legacymodel.communication.command.DeleteStoragePoolCommand in project cosmic by MissionCriticalCloud.
the class LibvirtComputingResourceTest method testDeleteStoragePoolCommandException.
@Test
public void testDeleteStoragePoolCommandException() {
final StoragePool storagePool = Mockito.mock(StoragePool.class);
final KvmStoragePoolManager storagePoolMgr = Mockito.mock(KvmStoragePoolManager.class);
final DeleteStoragePoolCommand command = new DeleteStoragePoolCommand(storagePool);
final StorageFilerTO pool = command.getPool();
when(this.libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr);
when(storagePoolMgr.deleteStoragePool(pool.getType(), pool.getUuid())).thenThrow(CloudRuntimeException.class);
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
assertFalse(answer.getResult());
verify(this.libvirtComputingResource, times(1)).getStoragePoolMgr();
verify(storagePoolMgr, times(1)).deleteStoragePool(pool.getType(), pool.getUuid());
}
use of com.cloud.legacymodel.communication.command.DeleteStoragePoolCommand in project cosmic by MissionCriticalCloud.
the class LibvirtComputingResourceTest method testDeleteStoragePoolCommand.
@Test
public void testDeleteStoragePoolCommand() {
final StoragePool storagePool = Mockito.mock(StoragePool.class);
final KvmStoragePoolManager storagePoolMgr = Mockito.mock(KvmStoragePoolManager.class);
final DeleteStoragePoolCommand command = new DeleteStoragePoolCommand(storagePool);
final StorageFilerTO pool = command.getPool();
when(this.libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr);
when(storagePoolMgr.deleteStoragePool(pool.getType(), pool.getUuid())).thenReturn(true);
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
assertTrue(answer.getResult());
verify(this.libvirtComputingResource, times(1)).getStoragePoolMgr();
verify(storagePoolMgr, times(1)).deleteStoragePool(pool.getType(), pool.getUuid());
}
use of com.cloud.legacymodel.communication.command.DeleteStoragePoolCommand in project cosmic by MissionCriticalCloud.
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(this.citrixResourceBase.getHost()).thenReturn(xsHost);
final Answer answer = wrapper.execute(deleteStorageCommand, this.citrixResourceBase);
verify(this.citrixResourceBase, times(1)).getConnection();
assertTrue(answer.getResult());
}
Aggregations