Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions api/src/main/java/com/cloud/offering/DiskOffering.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public String toString() {

boolean isCustomized();

boolean isShared();

void setDiskSize(long diskSize);

long getDiskSize();
Expand Down Expand Up @@ -99,7 +101,6 @@ public String toString() {

Long getBytesReadRateMaxLength();


void setBytesWriteRate(Long bytesWriteRate);

Long getBytesWriteRate();
Expand All @@ -112,7 +113,6 @@ public String toString() {

Long getBytesWriteRateMaxLength();


void setIopsReadRate(Long iopsReadRate);

Long getIopsReadRate();
Expand All @@ -133,7 +133,6 @@ public String toString() {

Long getIopsWriteRateMax();


void setIopsWriteRateMaxLength(Long iopsWriteRateMaxLength);

Long getIopsWriteRateMaxLength();
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/java/com/cloud/storage/VolumeApiService.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ Volume updateVolume(long volumeId, String path, String state, Long storageId,
*/
boolean doesStoragePoolSupportDiskOfferingTags(StoragePool destPool, String diskOfferingTags);

boolean validateConditionsToReplaceDiskOfferingOfVolume(Volume volume, DiskOffering newDiskOffering, StoragePool destPool);

Volume destroyVolume(long volumeId, Account caller, boolean expunge, boolean forceExpunge);

void destroyVolume(long volumeId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Set;

import com.cloud.exception.ResourceAllocationException;
import com.cloud.storage.Storage;
import com.cloud.utils.Pair;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
Expand Down Expand Up @@ -182,10 +183,10 @@ List<DiskProfile> allocateTemplatedVolumes(Type type, String name, DiskOffering
*/
DiskProfile importVolume(Type type, String name, DiskOffering offering, Long sizeInBytes, Long minIops, Long maxIops,
Long zoneId, HypervisorType hypervisorType, VirtualMachine vm, VirtualMachineTemplate template,
Account owner, Long deviceId, Long poolId, String path, String chainInfo);
Account owner, Long deviceId, Long poolId, Storage.StoragePoolType poolType, String path, String chainInfo);

DiskProfile updateImportedVolume(Type type, DiskOffering offering, VirtualMachine vm, VirtualMachineTemplate template,
Long deviceId, Long poolId, String path, String chainInfo, DiskProfile diskProfile);
Long deviceId, Long poolId, Storage.StoragePoolType poolType, String path, String chainInfo, DiskProfile diskProfile);

/**
* Unmanage VM volumes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.cloudstack.engine.subsystem.api.storage;

import com.cloud.storage.ScopeType;
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;

public class ClusterScope extends AbstractScope {
private ScopeType type = ScopeType.CLUSTER;
Expand Down Expand Up @@ -51,4 +52,9 @@ public Long getZoneId() {
return this.zoneId;
}

@Override
public String toString() {
return String.format("ClusterScope %s", ReflectionToStringBuilderUtils.reflectOnlySelectedFields(
this, "zoneId", "clusterId", "podId"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
package org.apache.cloudstack.engine.subsystem.api.storage;

import com.cloud.storage.ScopeType;
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;

public class HostScope extends AbstractScope {
private ScopeType type = ScopeType.HOST;
private Long hostId;
private Long clusterId;
private Long zoneId;
Expand All @@ -34,7 +36,7 @@ public HostScope(Long hostId, Long clusterId, Long zoneId) {

@Override
public ScopeType getScopeType() {
return ScopeType.HOST;
return this.type;
}

@Override
Expand All @@ -49,4 +51,10 @@ public Long getClusterId() {
public Long getZoneId() {
return zoneId;
}

@Override
public String toString() {
return String.format("HostScope %s", ReflectionToStringBuilderUtils.reflectOnlySelectedFields(
this, "zoneId", "clusterId", "hostId"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.cloudstack.engine.subsystem.api.storage;

import com.cloud.storage.ScopeType;
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;

public class ZoneScope extends AbstractScope {
private ScopeType type = ScopeType.ZONE;
Expand All @@ -39,4 +40,9 @@ public Long getScopeId() {
return this.zoneId;
}

@Override
public String toString() {
return String.format("ZoneScope %s", ReflectionToStringBuilderUtils.reflectOnlySelectedFields(
this, "zoneId"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2792,6 +2792,7 @@ private void markVolumesInPool(VMInstanceVO vm, Answer[] hypervisorMigrationResu
}
volume.setPath(result.getPath());
volume.setPoolId(pool.getId());
volume.setPoolType(pool.getPoolType());
if (result.getChainInfo() != null) {
volume.setChainInfo(result.getChainInfo());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ public Volume migrateVolume(Volume volume, StoragePool destPool) throws StorageU
String volumeToString = getVolumeIdentificationInfos(volume);

VolumeInfo vol = volFactory.getVolume(volume.getId());
if (vol == null){
if (vol == null) {
throw new CloudRuntimeException(String.format("Volume migration failed because volume [%s] is null.", volumeToString));
}
if (destPool == null) {
Expand Down Expand Up @@ -2308,6 +2308,7 @@ public void updateVolumeDiskChain(long volumeId, String path, String chainInfo,
StoragePoolVO pool = _storagePoolDao.findByUuid(updatedDataStoreUUID);
if (pool != null) {
vol.setPoolId(pool.getId());
vol.setPoolType(pool.getPoolType());
}
}
_volsDao.update(volumeId, vol);
Expand All @@ -2317,7 +2318,7 @@ public void updateVolumeDiskChain(long volumeId, String path, String chainInfo,
@Override
public DiskProfile importVolume(Type type, String name, DiskOffering offering, Long sizeInBytes, Long minIops, Long maxIops,
Long zoneId, HypervisorType hypervisorType, VirtualMachine vm, VirtualMachineTemplate template, Account owner,
Long deviceId, Long poolId, String path, String chainInfo) {
Long deviceId, Long poolId, Storage.StoragePoolType poolType, String path, String chainInfo) {
if (sizeInBytes == null) {
sizeInBytes = offering.getDiskSize();
}
Expand Down Expand Up @@ -2358,6 +2359,7 @@ public DiskProfile importVolume(Type type, String name, DiskOffering offering, L

vol.setFormat(getSupportedImageFormatForCluster(hypervisorType));
vol.setPoolId(poolId);
vol.setPoolType(poolType);
vol.setPath(path);
vol.setChainInfo(chainInfo);
vol.setState(Volume.State.Ready);
Expand All @@ -2367,7 +2369,7 @@ public DiskProfile importVolume(Type type, String name, DiskOffering offering, L

@Override
public DiskProfile updateImportedVolume(Type type, DiskOffering offering, VirtualMachine vm, VirtualMachineTemplate template,
Long deviceId, Long poolId, String path, String chainInfo, DiskProfile diskProfile) {
Long deviceId, Long poolId, Storage.StoragePoolType poolType, String path, String chainInfo, DiskProfile diskProfile) {

VolumeVO vol = _volsDao.findById(diskProfile.getVolumeId());
if (vm != null) {
Expand Down Expand Up @@ -2401,6 +2403,7 @@ public DiskProfile updateImportedVolume(Type type, DiskOffering offering, Virtua

vol.setFormat(getSupportedImageFormatForCluster(vm.getHypervisorType()));
vol.setPoolId(poolId);
vol.setPoolType(poolType);
vol.setPath(path);
vol.setChainInfo(chainInfo);
vol.setSize(diskProfile.getSize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public void testImportVolume() {

volumeOrchestrator.importVolume(volumeType, name, diskOffering, sizeInBytes, null, null,
zoneId, hypervisorType, null, null, owner,
deviceId, poolId, path, chainInfo);
deviceId, poolId, Storage.StoragePoolType.NetworkFilesystem, path, chainInfo);

VolumeVO volume = volumeVOMockedConstructionConstruction.constructed().get(0);
Mockito.verify(volume, Mockito.never()).setInstanceId(Mockito.anyLong());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,11 @@ public Integer getHypervisorSnapshotReserve() {
@Override
public void setEncrypt(boolean encrypt) { this.encrypt = encrypt; }

@Override
public boolean isShared() {
return !useLocalStorage;
}


public boolean getDiskSizeStrictness() {
return diskSizeStrictness;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public interface DiskOfferingDao extends GenericDao<DiskOfferingVO, Long> {
List<DiskOfferingVO> listAllBySizeAndProvisioningType(long size, Storage.ProvisioningType provisioningType);

List<DiskOfferingVO> findCustomDiskOfferings();

List<DiskOfferingVO> listByStorageTag(String tag);

List<DiskOfferingVO> listAllActiveAndNonComputeDiskOfferings();
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import javax.inject.Inject;
import javax.persistence.EntityExistsException;

import com.cloud.offering.DiskOffering;
import org.apache.cloudstack.resourcedetail.dao.DiskOfferingDetailsDao;
import org.springframework.stereotype.Component;

Expand All @@ -45,6 +46,8 @@ public class DiskOfferingDaoImpl extends GenericDaoBase<DiskOfferingVO, Long> im
protected DiskOfferingDetailsDao detailsDao;

protected final SearchBuilder<DiskOfferingVO> UniqueNameSearch;
protected final SearchBuilder<DiskOfferingVO> ActiveAndNonComputeSearch;

private final String SizeDiskOfferingSearch = "SELECT * FROM disk_offering WHERE " +
"disk_size = ? AND provisioning_type = ? AND removed IS NULL";

Expand All @@ -56,6 +59,11 @@ protected DiskOfferingDaoImpl() {
UniqueNameSearch.and("name", UniqueNameSearch.entity().getUniqueName(), SearchCriteria.Op.EQ);
UniqueNameSearch.done();

ActiveAndNonComputeSearch = createSearchBuilder();
ActiveAndNonComputeSearch.and("state", ActiveAndNonComputeSearch.entity().getState(), SearchCriteria.Op.EQ);
ActiveAndNonComputeSearch.and("computeOnly", ActiveAndNonComputeSearch.entity().isComputeOnly(), SearchCriteria.Op.EQ);
ActiveAndNonComputeSearch.done();

_computeOnlyAttr = _allAttributes.get("computeOnly");
}

Expand Down Expand Up @@ -164,4 +172,12 @@ public List<DiskOfferingVO> listByStorageTag(String tag) {
sc.setParameters("tagEndLike", "%," + tag);
return listBy(sc);
}

@Override
public List<DiskOfferingVO> listAllActiveAndNonComputeDiskOfferings() {
SearchCriteria<DiskOfferingVO> sc = ActiveAndNonComputeSearch.create();
sc.setParameters("state", DiskOffering.State.Active);
sc.setParameters("computeOnly", false);
return listBy(sc);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ public void updateAndRemoveVolume(VolumeVO volume) {
if (volume.getState() != Volume.State.Destroy) {
volume.setState(Volume.State.Destroy);
volume.setPoolId(null);
volume.setPoolType(null);
volume.setInstanceId(null);
update(volume.getId(), volume);
remove(volume.getId());
Expand Down
Loading
Loading