Search in sources :

Example 71 with VolumeVO

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

the class VMSnapshotHelperImpl method getVolumeTOList.

@Override
public List<VolumeObjectTO> getVolumeTOList(Long vmId) {
    List<VolumeObjectTO> volumeTOs = new ArrayList<VolumeObjectTO>();
    List<VolumeVO> volumeVos = volumeDao.findByInstance(vmId);
    VolumeInfo volumeInfo = null;
    for (VolumeVO volume : volumeVos) {
        volumeInfo = volumeDataFactory.getVolume(volume.getId());
        volumeTOs.add((VolumeObjectTO) volumeInfo.getTO());
    }
    return volumeTOs;
}
Also used : VolumeVO(com.cloud.storage.VolumeVO) ArrayList(java.util.ArrayList) VolumeObjectTO(org.apache.cloudstack.storage.to.VolumeObjectTO) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo)

Example 72 with VolumeVO

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

the class DefaultVMSnapshotStrategy method updateVolumePath.

private void updateVolumePath(List<VolumeObjectTO> volumeTOs) {
    for (VolumeObjectTO volume : volumeTOs) {
        if (volume.getPath() != null) {
            VolumeVO volumeVO = volumeDao.findById(volume.getId());
            volumeVO.setPath(volume.getPath());
            volumeVO.setVmSnapshotChainSize(volume.getSize());
            volumeDao.persist(volumeVO);
        }
    }
}
Also used : VolumeVO(com.cloud.storage.VolumeVO) VolumeObjectTO(org.apache.cloudstack.storage.to.VolumeObjectTO)

Example 73 with VolumeVO

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

the class ManagementServerImpl method searchForSystemVm.

@Override
public Pair<List<? extends VirtualMachine>, Integer> searchForSystemVm(final ListSystemVMsCmd cmd) {
    final String type = cmd.getSystemVmType();
    final Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), cmd.getZoneId());
    final Long id = cmd.getId();
    final String name = cmd.getSystemVmName();
    final String state = cmd.getState();
    final String keyword = cmd.getKeyword();
    final Long podId = cmd.getPodId();
    final Long hostId = cmd.getHostId();
    final Long storageId = cmd.getStorageId();
    final Filter searchFilter = new Filter(VMInstanceVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
    final SearchBuilder<VMInstanceVO> sb = _vmInstanceDao.createSearchBuilder();
    sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
    sb.and("hostName", sb.entity().getHostName(), SearchCriteria.Op.LIKE);
    sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
    sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
    sb.and("podId", sb.entity().getPodIdToDeployIn(), SearchCriteria.Op.EQ);
    sb.and("hostId", sb.entity().getHostId(), SearchCriteria.Op.EQ);
    sb.and("type", sb.entity().getType(), SearchCriteria.Op.EQ);
    sb.and("nulltype", sb.entity().getType(), SearchCriteria.Op.IN);
    if (storageId != null) {
        final SearchBuilder<VolumeVO> volumeSearch = _volumeDao.createSearchBuilder();
        volumeSearch.and("poolId", volumeSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
        sb.join("volumeSearch", volumeSearch, sb.entity().getId(), volumeSearch.entity().getInstanceId(), JoinBuilder.JoinType.INNER);
    }
    final SearchCriteria<VMInstanceVO> sc = sb.create();
    if (keyword != null) {
        final SearchCriteria<VMInstanceVO> ssc = _vmInstanceDao.createSearchCriteria();
        ssc.addOr("hostName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
        ssc.addOr("state", SearchCriteria.Op.LIKE, "%" + keyword + "%");
        sc.addAnd("hostName", SearchCriteria.Op.SC, ssc);
    }
    if (id != null) {
        sc.setParameters("id", id);
    }
    if (name != null) {
        sc.setParameters("hostName", name);
    }
    if (state != null) {
        sc.setParameters("state", state);
    }
    if (zoneId != null) {
        sc.setParameters("dataCenterId", zoneId);
    }
    if (podId != null) {
        sc.setParameters("podId", podId);
    }
    if (hostId != null) {
        sc.setParameters("hostId", hostId);
    }
    if (type != null) {
        sc.setParameters("type", type);
    } else {
        sc.setParameters("nulltype", VirtualMachine.Type.SecondaryStorageVm, VirtualMachine.Type.ConsoleProxy);
    }
    if (storageId != null) {
        sc.setJoinParameters("volumeSearch", "poolId", storageId);
    }
    final Pair<List<VMInstanceVO>, Integer> result = _vmInstanceDao.searchAndCount(sc, searchFilter);
    return new Pair<List<? extends VirtualMachine>, Integer>(result.first(), result.second());
}
Also used : VolumeVO(com.cloud.storage.VolumeVO) Filter(com.cloud.utils.db.Filter) VMInstanceVO(com.cloud.vm.VMInstanceVO) ArrayList(java.util.ArrayList) ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) List(java.util.List) Pair(com.cloud.utils.Pair) SSHKeyPair(com.cloud.user.SSHKeyPair)

Example 74 with VolumeVO

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

the class ConfigurationManagerTest method checkIfZoneIsDeletableFailureOnHostTest.

@Test(expected = CloudRuntimeException.class)
public void checkIfZoneIsDeletableFailureOnHostTest() {
    HostVO hostVO = Mockito.mock(HostVO.class);
    ArrayList<HostVO> arrayList = new ArrayList<HostVO>();
    arrayList.add(hostVO);
    Mockito.when(_hostDao.listByDataCenterId(anyLong())).thenReturn(arrayList);
    Mockito.when(_podDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostPodVO>());
    Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
    Mockito.when(_publicIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
    Mockito.when(_vmInstanceDao.listByZoneId(anyLong())).thenReturn(new ArrayList<VMInstanceVO>());
    Mockito.when(_volumeDao.findByDc(anyLong())).thenReturn(new ArrayList<VolumeVO>());
    Mockito.when(_physicalNetworkDao.listByZone(anyLong())).thenReturn(new ArrayList<PhysicalNetworkVO>());
    configurationMgr.checkIfZoneIsDeletable(new Random().nextLong());
}
Also used : VolumeVO(com.cloud.storage.VolumeVO) Random(java.util.Random) ArrayList(java.util.ArrayList) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) VMInstanceVO(com.cloud.vm.VMInstanceVO) HostPodVO(com.cloud.dc.HostPodVO) HostVO(com.cloud.host.HostVO) Test(org.junit.Test)

Example 75 with VolumeVO

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

the class ConfigurationManagerTest method checkIfPodIsDeletableSuccessTest.

@Test
public void checkIfPodIsDeletableSuccessTest() {
    HostPodVO hostPodVO = Mockito.mock(HostPodVO.class);
    Mockito.when(hostPodVO.getDataCenterId()).thenReturn(new Random().nextLong());
    Mockito.when(_podDao.findById(anyLong())).thenReturn(hostPodVO);
    Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyLong(), anyBoolean())).thenReturn(0);
    Mockito.when(_volumeDao.findByPod(anyLong())).thenReturn(new ArrayList<VolumeVO>());
    Mockito.when(_hostDao.findByPodId(anyLong())).thenReturn(new ArrayList<HostVO>());
    Mockito.when(_vmInstanceDao.listByPodId(anyLong())).thenReturn(new ArrayList<VMInstanceVO>());
    Mockito.when(_clusterDao.listByPodId(anyLong())).thenReturn(new ArrayList<ClusterVO>());
    configurationMgr.checkIfPodIsDeletable(new Random().nextLong());
}
Also used : ClusterVO(com.cloud.dc.ClusterVO) Random(java.util.Random) VolumeVO(com.cloud.storage.VolumeVO) VMInstanceVO(com.cloud.vm.VMInstanceVO) HostPodVO(com.cloud.dc.HostPodVO) HostVO(com.cloud.host.HostVO) Test(org.junit.Test)

Aggregations

VolumeVO (com.cloud.storage.VolumeVO)156 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)44 ArrayList (java.util.ArrayList)39 VolumeInfo (org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo)36 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)30 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)26 HostVO (com.cloud.host.HostVO)24 VMInstanceVO (com.cloud.vm.VMInstanceVO)24 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)22 Account (com.cloud.user.Account)19 HashMap (java.util.HashMap)17 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)16 VolumeApiResult (org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult)16 StoragePool (com.cloud.storage.StoragePool)15 HostPodVO (com.cloud.dc.HostPodVO)14 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)13 Pair (com.cloud.utils.Pair)13 ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)11 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)11 DiskOfferingVO (com.cloud.storage.DiskOfferingVO)11