Search in sources :

Example 1 with StorageManagerImpl

use of com.cloud.storage.StorageManagerImpl in project cloudstack by apache.

the class CloudStackPrimaryDataStoreLifeCycleImplTest method initMocks.

@Before
public void initMocks() {
    MockitoAnnotations.initMocks(this);
    List<HostVO> hostList = new ArrayList<HostVO>();
    HostVO host1 = new HostVO(1L, "aa01", Host.Type.Routing, "192.168.1.1", "255.255.255.0", null, null, null, null, null, null, null, null, null, null, UUID.randomUUID().toString(), Status.Up, "1.0", null, null, 1L, null, 0, 0, "aa", 0, Storage.StoragePoolType.NetworkFilesystem);
    HostVO host2 = new HostVO(1L, "aa02", Host.Type.Routing, "192.168.1.1", "255.255.255.0", null, null, null, null, null, null, null, null, null, null, UUID.randomUUID().toString(), Status.Up, "1.0", null, null, 1L, null, 0, 0, "aa", 0, Storage.StoragePoolType.NetworkFilesystem);
    host1.setResourceState(ResourceState.Enabled);
    host2.setResourceState(ResourceState.Disabled);
    hostList.add(host1);
    hostList.add(host2);
    when(_dataStoreMgr.getDataStore(anyLong(), eq(DataStoreRole.Primary))).thenReturn(store);
    when(store.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem);
    when(store.isShared()).thenReturn(true);
    when(store.getName()).thenReturn("newPool");
    when(_dataStoreProviderMgr.getDataStoreProvider(anyString())).thenReturn(dataStoreProvider);
    when(dataStoreProvider.getName()).thenReturn("default");
    ((StorageManagerImpl) storageMgr).registerHostListener("default", hostListener);
    when(_resourceMgr.listAllUpHosts(eq(Host.Type.Routing), anyLong(), anyLong(), anyLong())).thenReturn(hostList);
    when(agentMgr.easySend(anyLong(), Mockito.any(ModifyStoragePoolCommand.class))).thenReturn(answer);
    when(answer.getResult()).thenReturn(true);
    when(answer.getPoolInfo()).thenReturn(info);
    when(info.getLocalPath()).thenReturn("/mnt/1");
    when(info.getCapacityBytes()).thenReturn(0L);
    when(info.getAvailableBytes()).thenReturn(0L);
    when(storagePoolHostDao.findByPoolHost(anyLong(), anyLong())).thenReturn(null);
    when(primaryStoreDao.findById(anyLong())).thenReturn(storagePool);
    when(primaryStoreDao.update(anyLong(), Mockito.any(StoragePoolVO.class))).thenReturn(true);
    when(primaryDataStoreHelper.attachCluster(Mockito.any(DataStore.class))).thenReturn(null);
}
Also used : PrimaryDataStore(org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) ArrayList(java.util.ArrayList) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) HostVO(com.cloud.host.HostVO) StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO) StorageManagerImpl(com.cloud.storage.StorageManagerImpl) ModifyStoragePoolCommand(com.cloud.agent.api.ModifyStoragePoolCommand) Before(org.junit.Before)

Aggregations

ModifyStoragePoolCommand (com.cloud.agent.api.ModifyStoragePoolCommand)1 HostVO (com.cloud.host.HostVO)1 StorageManagerImpl (com.cloud.storage.StorageManagerImpl)1 StoragePoolHostVO (com.cloud.storage.StoragePoolHostVO)1 ArrayList (java.util.ArrayList)1 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)1 PrimaryDataStore (org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore)1 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)1 Before (org.junit.Before)1