Search in sources :

Example 1 with StoragePoolDetailVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO in project cloudstack by apache.

the class StorageAllocatorTest method testClusterAllocatorWithTags.

@Test
public void testClusterAllocatorWithTags() {
    try {
        createDb();
        StoragePoolDetailVO detailVO = new StoragePoolDetailVO(this.storagePoolId, "high", "true", true);
        poolDetailsDao.persist(detailVO);
        DiskOfferingVO diskOff = this.diskOfferingDao.findById(diskOffering.getId());
        List<String> tags = new ArrayList<String>();
        tags.add("high");
        diskOff.setTagsArray(tags);
        diskOfferingDao.update(diskOff.getId(), diskOff);
        DiskProfile profile = new DiskProfile(volume, diskOff, HypervisorType.XenServer);
        VirtualMachineProfile vmProfile = Mockito.mock(VirtualMachineProfile.class);
        Mockito.when(storageMgr.storagePoolHasEnoughSpace(Matchers.anyListOf(Volume.class), Matchers.any(StoragePool.class))).thenReturn(true);
        DeploymentPlan plan = new DataCenterDeployment(dcId, podId, clusterId, null, null, null);
        int foundAcct = 0;
        for (StoragePoolAllocator allocator : allocators) {
            List<StoragePool> pools = allocator.allocateToPool(profile, vmProfile, plan, new ExcludeList(), 1);
            if (!pools.isEmpty()) {
                Assert.assertEquals(pools.get(0).getId(), storage.getId());
                foundAcct++;
            }
        }
        if (foundAcct > 1 || foundAcct == 0) {
            Assert.fail();
        }
    } catch (Exception e) {
        cleanDb();
        Assert.fail();
    }
}
Also used : ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) StoragePool(com.cloud.storage.StoragePool) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) ArrayList(java.util.ArrayList) StoragePoolDetailVO(org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO) DiskProfile(com.cloud.vm.DiskProfile) Volume(com.cloud.storage.Volume) DiskOfferingVO(com.cloud.storage.DiskOfferingVO) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) DeploymentPlan(com.cloud.deploy.DeploymentPlan) StoragePoolAllocator(org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator) Test(org.junit.Test)

Example 2 with StoragePoolDetailVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO in project cloudstack by apache.

the class SolidFirePrimaryDataStoreDriver method getDefaultMaxIops.

private long getDefaultMaxIops(long storagePoolId) {
    StoragePoolDetailVO storagePoolDetail = storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.CLUSTER_DEFAULT_MAX_IOPS);
    String clusterDefaultMaxIops = storagePoolDetail.getValue();
    return Long.parseLong(clusterDefaultMaxIops);
}
Also used : StoragePoolDetailVO(org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO)

Example 3 with StoragePoolDetailVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO in project cloudstack by apache.

the class SolidFireSharedPrimaryDataStoreLifeCycle method getIopsValue.

private long getIopsValue(long storagePoolId, String iopsKey) {
    StoragePoolDetailVO storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePoolId, iopsKey);
    String iops = storagePoolDetail.getValue();
    return Long.parseLong(iops);
}
Also used : StoragePoolDetailVO(org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO)

Example 4 with StoragePoolDetailVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO in project cloudstack by apache.

the class SolidFireSharedHostListener method handleVMware.

private void handleVMware(long hostId, boolean add) {
    HostVO host = hostDao.findById(hostId);
    if (HypervisorType.VMware.equals(host.getHypervisorType())) {
        List<StoragePoolVO> storagePools = storagePoolDao.findPoolsByProvider(SolidFireUtil.SHARED_PROVIDER_NAME);
        if (storagePools != null && storagePools.size() > 0) {
            List<Map<String, String>> targets = new ArrayList<>();
            for (StoragePoolVO storagePool : storagePools) {
                if (storagePool.getClusterId().equals(host.getClusterId())) {
                    long storagePoolId = storagePool.getId();
                    StoragePoolDetailVO storagePoolDetail = storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.IQN);
                    String iqn = storagePoolDetail.getValue();
                    storagePoolDetail = storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.STORAGE_VIP);
                    String sVip = storagePoolDetail.getValue();
                    storagePoolDetail = storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.STORAGE_PORT);
                    String sPort = storagePoolDetail.getValue();
                    Map<String, String> details = new HashMap<>();
                    details.put(ModifyTargetsCommand.IQN, iqn);
                    details.put(ModifyTargetsCommand.STORAGE_HOST, sVip);
                    details.put(ModifyTargetsCommand.STORAGE_PORT, sPort);
                    targets.add(details);
                }
            }
            if (targets.size() > 0) {
                ModifyTargetsCommand cmd = new ModifyTargetsCommand();
                cmd.setAdd(add);
                cmd.setTargets(targets);
                sendModifyTargetsCommand(cmd, hostId);
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) ModifyTargetsCommand(com.cloud.agent.api.ModifyTargetsCommand) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) ArrayList(java.util.ArrayList) StoragePoolDetailVO(org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO) HashMap(java.util.HashMap) Map(java.util.Map) HostVO(com.cloud.host.HostVO) StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO)

Example 5 with StoragePoolDetailVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO in project cloudstack by apache.

the class StorageAllocatorTest method testClusterAllocatorWithWrongTag.

@Test
public void testClusterAllocatorWithWrongTag() {
    try {
        createDb();
        StoragePoolDetailVO detailVO = new StoragePoolDetailVO(this.storagePoolId, "high", "true", true);
        poolDetailsDao.persist(detailVO);
        DiskOfferingVO diskOff = this.diskOfferingDao.findById(diskOffering.getId());
        List<String> tags = new ArrayList<String>();
        tags.add("low");
        diskOff.setTagsArray(tags);
        diskOfferingDao.update(diskOff.getId(), diskOff);
        DiskProfile profile = new DiskProfile(volume, diskOff, HypervisorType.XenServer);
        VirtualMachineProfile vmProfile = Mockito.mock(VirtualMachineProfile.class);
        Mockito.when(storageMgr.storagePoolHasEnoughSpace(Matchers.anyListOf(Volume.class), Matchers.any(StoragePool.class))).thenReturn(true);
        DeploymentPlan plan = new DataCenterDeployment(dcId, podId, clusterId, null, null, null);
        int foundAcct = 0;
        for (StoragePoolAllocator allocator : allocators) {
            List<StoragePool> pools = allocator.allocateToPool(profile, vmProfile, plan, new ExcludeList(), 1);
            if (!pools.isEmpty()) {
                foundAcct++;
            }
        }
        if (foundAcct != 0) {
            Assert.fail();
        }
    } catch (Exception e) {
        cleanDb();
        Assert.fail();
    }
}
Also used : ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) StoragePool(com.cloud.storage.StoragePool) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) ArrayList(java.util.ArrayList) StoragePoolDetailVO(org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO) DiskProfile(com.cloud.vm.DiskProfile) Volume(com.cloud.storage.Volume) DiskOfferingVO(com.cloud.storage.DiskOfferingVO) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) DeploymentPlan(com.cloud.deploy.DeploymentPlan) StoragePoolAllocator(org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator) Test(org.junit.Test)

Aggregations

StoragePoolDetailVO (org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO)11 StoragePool (com.cloud.storage.StoragePool)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Answer (com.cloud.agent.api.Answer)2 DataCenterDeployment (com.cloud.deploy.DataCenterDeployment)2 DeploymentPlan (com.cloud.deploy.DeploymentPlan)2 ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)2 HostVO (com.cloud.host.HostVO)2 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)2 DiskOfferingVO (com.cloud.storage.DiskOfferingVO)2 StoragePoolHostVO (com.cloud.storage.StoragePoolHostVO)2 Volume (com.cloud.storage.Volume)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 DiskProfile (com.cloud.vm.DiskProfile)2 VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)2 StoragePoolAllocator (org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator)2 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)2 Test (org.junit.Test)2 CreateStoragePoolCommand (com.cloud.agent.api.CreateStoragePoolCommand)1