Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,42 @@ public class UpdateDiskOfferingCmd extends BaseCmd {
description = "an optional field, whether to display the offering to the end user or not.")
private Boolean displayOffering;

@Parameter(name = ApiConstants.BYTES_READ_RATE, type = CommandType.LONG, required = false, description = "bytes read rate of the disk offering, long")
private Long diskBytesReadRate;

@Parameter(name = ApiConstants.BYTES_READ_RATE_MAX, type = CommandType.LONG, required = false, description = "maximum bytes read rate of the disk offering, long")
private Long diskBytesReadRateMax;

@Parameter(name = ApiConstants.BYTES_READ_RATE_MAX_LENGTH, type = CommandType.LONG, required = false, description = "maximum bytes read rate length of the disk offering, long")
private Long diskBytesReadRateMaxLength;

@Parameter(name = ApiConstants.BYTES_WRITE_RATE, type = CommandType.LONG, required = false, description = "bytes write rate of the disk offering, long")
private Long diskBytesWriteRate;

@Parameter(name = ApiConstants.BYTES_WRITE_RATE_MAX, type = CommandType.LONG, required = false, description = "maximum bytes write rate of the disk offering, long")
private Long diskBytesWriteRateMax;

@Parameter(name = ApiConstants.BYTES_WRITE_RATE_MAX_LENGTH, type = CommandType.LONG, required = false, description = "maximum bytes write rate length of the disk offering, long")
private Long diskBytesWriteRateMaxLength;

@Parameter(name = ApiConstants.IOPS_READ_RATE, type = CommandType.LONG, required = false, description = "iops read rate of the disk offering, long")
private Long diskIopsReadRate;

@Parameter(name = ApiConstants.IOPS_READ_RATE_MAX, type = CommandType.LONG, required = false, description = "maximum iops read rate of the disk offering, long")
private Long diskIopsReadRateMax;

@Parameter(name = ApiConstants.IOPS_READ_RATE_MAX_LENGTH, type = CommandType.LONG, required = false, description = "maximum iops read rate length of the disk offering, long")
private Long diskIopsReadRateMaxLength;

@Parameter(name = ApiConstants.IOPS_WRITE_RATE, type = CommandType.LONG, required = false, description = "iops write rate of the disk offering, long")
private Long diskIopsWriteRate;

@Parameter(name = ApiConstants.IOPS_WRITE_RATE_MAX, type = CommandType.LONG, required = false, description = "maximum iops write rate of the disk offering, long")
private Long diskIopsWriteRateMax;

@Parameter(name = ApiConstants.IOPS_WRITE_RATE_MAX_LENGTH, type = CommandType.LONG, required = false, description = "maximum iops write rate length of the disk offering, long")
private Long diskIopsWriteRateMaxLength;

@Parameter(name = ApiConstants.DOMAIN_ID,
type = CommandType.STRING,
description = "the ID of the containing domain(s) as comma separated string, public for public offerings",
Expand Down Expand Up @@ -101,6 +137,54 @@ public Boolean getDisplayOffering() {
return displayOffering;
}

public Long getDiskBytesReadRate() {
return diskBytesReadRate;
}

public Long getDiskBytesReadRateMax() {
return diskBytesReadRateMax;
}

public Long getDiskBytesReadRateMaxLength() {
return diskBytesReadRateMaxLength;
}

public Long getDiskBytesWriteRate() {
return diskBytesWriteRate;
}

public Long getDiskBytesWriteRateMax() {
return diskBytesWriteRateMax;
}

public Long getDiskBytesWriteRateMaxLength() {
return diskBytesWriteRateMaxLength;
}

public Long getDiskIopsReadRate() {
return diskIopsReadRate;
}

public Long getDiskIopsReadRateMax() {
return diskIopsReadRateMax;
}

public Long getDiskIopsReadRateMaxLength() {
return diskIopsReadRateMaxLength;
}

public Long getDiskIopsWriteRate() {
return diskIopsWriteRate;
}

public Long getDiskIopsWriteRateMax() {
return diskIopsWriteRateMax;
}

public Long getDiskIopsWriteRateMaxLength() {
return diskIopsWriteRateMaxLength;
}

public List<Long> getDomainIds() {
List<Long> validDomainIds = new ArrayList<>();
if (!Strings.isNullOrEmpty(domainIds)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,42 @@ public class UpdateServiceOfferingCmd extends BaseCmd {
@Parameter(name = ApiConstants.SORT_KEY, type = CommandType.INTEGER, description = "sort key of the service offering, integer")
private Integer sortKey;

@Parameter(name = ApiConstants.BYTES_READ_RATE, type = CommandType.LONG, required = false, description = "bytes read rate of the disk offering, long")
private Long diskBytesReadRate;

@Parameter(name = ApiConstants.BYTES_READ_RATE_MAX, type = CommandType.LONG, required = false, description = "maximum bytes read rate of the disk offering, long")
private Long diskBytesReadRateMax;

@Parameter(name = ApiConstants.BYTES_READ_RATE_MAX_LENGTH, type = CommandType.LONG, required = false, description = "maximum bytes read rate length of the disk offering, long")
private Long diskBytesReadRateMaxLength;

@Parameter(name = ApiConstants.BYTES_WRITE_RATE, type = CommandType.LONG, required = false, description = "bytes write rate of the disk offering, long")
private Long diskBytesWriteRate;

@Parameter(name = ApiConstants.BYTES_WRITE_RATE_MAX, type = CommandType.LONG, required = false, description = "maximum bytes write rate of the disk offering, long")
private Long diskBytesWriteRateMax;

@Parameter(name = ApiConstants.BYTES_WRITE_RATE_MAX_LENGTH, type = CommandType.LONG, required = false, description = "maximum bytes write rate length of the disk offering, long")
private Long diskBytesWriteRateMaxLength;

@Parameter(name = ApiConstants.IOPS_READ_RATE, type = CommandType.LONG, required = false, description = "iops read rate of the disk offering, long")
private Long diskIopsReadRate;

@Parameter(name = ApiConstants.IOPS_READ_RATE_MAX, type = CommandType.LONG, required = false, description = "maximum iops read rate of the disk offering, long")
private Long diskIopsReadRateMax;

@Parameter(name = ApiConstants.IOPS_READ_RATE_MAX_LENGTH, type = CommandType.LONG, required = false, description = "maximum iops read rate length of the disk offering, long")
private Long diskIopsReadRateMaxLength;

@Parameter(name = ApiConstants.IOPS_WRITE_RATE, type = CommandType.LONG, required = false, description = "iops write rate of the disk offering, long")
private Long diskIopsWriteRate;

@Parameter(name = ApiConstants.IOPS_WRITE_RATE_MAX, type = CommandType.LONG, required = false, description = "maximum iops write rate of the disk offering, long")
private Long diskIopsWriteRateMax;

@Parameter(name = ApiConstants.IOPS_WRITE_RATE_MAX_LENGTH, type = CommandType.LONG, required = false, description = "maximum iops write rate length of the disk offering, long")
private Long diskIopsWriteRateMaxLength;

@Parameter(name = ApiConstants.DOMAIN_ID,
type = CommandType.STRING,
description = "the ID of the containing domain(s) as comma separated string, public for public offerings")
Expand Down Expand Up @@ -91,6 +127,54 @@ public Integer getSortKey() {
return sortKey;
}

public Long getDiskBytesReadRate() {
return diskBytesReadRate;
}

public Long getDiskBytesReadRateMax() {
return diskBytesReadRateMax;
}

public Long getDiskBytesReadRateMaxLength() {
return diskBytesReadRateMaxLength;
}

public Long getDiskBytesWriteRate() {
return diskBytesWriteRate;
}

public Long getDiskBytesWriteRateMax() {
return diskBytesWriteRateMax;
}

public Long getDiskBytesWriteRateMaxLength() {
return diskBytesWriteRateMaxLength;
}

public Long getDiskIopsReadRate() {
return diskIopsReadRate;
}

public Long getDiskIopsReadRateMax() {
return diskIopsReadRateMax;
}

public Long getDiskIopsReadRateMaxLength() {
return diskIopsReadRateMaxLength;
}

public Long getDiskIopsWriteRate() {
return diskIopsWriteRate;
}

public Long getDiskIopsWriteRateMax() {
return diskIopsWriteRateMax;
}

public Long getDiskIopsWriteRateMaxLength() {
return diskIopsWriteRateMaxLength;
}

public List<Long> getDomainIds() {
List<Long> validDomainIds = new ArrayList<>();
if (!Strings.isNullOrEmpty(domainIds)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2661,6 +2661,9 @@ public synchronized String attachOrDetachDisk(final Connect conn,
if (iopsWriteRateMax != null && iopsWriteRateMax > 0) {
diskdef.setIopsWriteRateMax(iopsWriteRateMax);
}
if(iopsWriteRateMaxLength != null && iopsWriteRateMaxLength >0){
diskdef.setIopsWriteRateMaxLength(iopsWriteRateMaxLength);
}

if (cacheMode != null) {
diskdef.setCacheMode(DiskDef.DiskCacheMode.valueOf(cacheMode.toUpperCase()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2659,7 +2659,24 @@ public ServiceOffering updateServiceOffering(final UpdateServiceOfferingCmd cmd)
throw new InvalidParameterValueException(String.format("Unable to update service offering: %s by id user: %s because it is not root-admin or domain-admin", offeringHandle.getUuid(), user.getUuid()));
}

final boolean updateNeeded = name != null || displayText != null || sortKey != null;
final Long diskBytesReadRate = cmd.getDiskBytesReadRate();
final Long diskBytesReadRateMax = cmd.getDiskBytesReadRateMax();
final Long diskBytesReadRateMaxLength = cmd.getDiskBytesReadRateMaxLength();
final Long diskBytesWriteRate = cmd.getDiskBytesWriteRate();
final Long diskBytesWriteRateMax = cmd.getDiskBytesWriteRateMax();
final Long diskBytesWriteRateMaxLength = cmd.getDiskBytesWriteRateMaxLength();
final Long diskIopsReadRate = cmd.getDiskIopsReadRate();
final Long diskIopsReadRateMax = cmd.getDiskIopsReadRateMax();
final Long diskIopsReadRateMaxLength = cmd.getDiskIopsReadRateMaxLength();
final Long diskIopsWriteRate = cmd.getDiskIopsWriteRate();
final Long diskIopsWriteRateMax = cmd.getDiskIopsWriteRateMax();
final Long diskIopsWriteRateMaxLength = cmd.getDiskIopsWriteRateMaxLength();

final boolean updateNeeded = name != null || displayText != null || sortKey != null
|| diskBytesReadRate != null || diskBytesReadRateMax != null || diskBytesReadRateMaxLength != null
|| diskBytesWriteRate != null || diskBytesWriteRateMax != null || diskBytesWriteRateMaxLength != null
|| diskIopsReadRate != null || diskIopsReadRateMax != null || diskIopsReadRateMaxLength != null
|| diskIopsWriteRate != null || diskIopsWriteRateMax != null || diskIopsWriteRateMaxLength != null;
final boolean detailsUpdateNeeded = !filteredDomainIds.equals(existingDomainIds) || !filteredZoneIds.equals(existingZoneIds);
if (!updateNeeded && !detailsUpdateNeeded) {
return _serviceOfferingDao.findById(id);
Expand All @@ -2679,6 +2696,23 @@ public ServiceOffering updateServiceOffering(final UpdateServiceOfferingCmd cmd)
offering.setSortKey(sortKey);
}

// BPS Read Rate
offering.setBytesReadRate(checkValue(offeringHandle.getBytesReadRate(), diskBytesReadRate));
offering.setBytesReadRateMax(checkValue(offeringHandle.getBytesReadRateMax(), diskBytesReadRateMax));
offering.setBytesReadRateMaxLength(checkValue(offeringHandle.getBytesReadRateMaxLength(), diskBytesReadRateMaxLength));
// BPS Write Rate
offering.setBytesWriteRate(checkValue(offeringHandle.getBytesWriteRate(), diskBytesWriteRate));
offering.setBytesWriteRateMax(checkValue(offeringHandle.getBytesWriteRateMax(), diskBytesWriteRateMax));
offering.setBytesWriteRateMaxLength(checkValue(offeringHandle.getBytesWriteRateMaxLength(), diskBytesWriteRateMaxLength));
// IOPS Read Rate
offering.setIopsReadRate(checkValue(offeringHandle.getIopsReadRate(), diskIopsReadRate));
offering.setIopsReadRateMax(checkValue(offeringHandle.getIopsReadRateMax(), diskIopsReadRateMax));
offering.setIopsReadRateMaxLength(checkValue(offeringHandle.getIopsReadRateMaxLength(), diskIopsReadRateMaxLength));
// IOPS Write Rate
offering.setIopsWriteRate(checkValue(offeringHandle.getIopsWriteRate(), diskIopsWriteRate));
offering.setIopsWriteRateMax(checkValue(offeringHandle.getIopsWriteRateMax(), diskIopsWriteRateMax));
offering.setIopsWriteRateMaxLength(checkValue(offeringHandle.getIopsWriteRateMaxLength(), diskIopsWriteRateMaxLength));

// Note: tag editing commented out for now; keeping the code intact,
// might need to re-enable in next releases
// if (tags != null)
Expand Down Expand Up @@ -3062,8 +3096,26 @@ public DiskOffering updateDiskOffering(final UpdateDiskOfferingCmd cmd) {
throw new InvalidParameterValueException(String.format("Unable to update disk offering: %s by id user: %s because it is not root-admin or domain-admin", diskOfferingHandle.getUuid(), user.getUuid()));
}

final boolean updateNeeded = name != null || displayText != null || sortKey != null || displayDiskOffering != null;
final Long diskBytesReadRate = cmd.getDiskBytesReadRate();
final Long diskBytesReadRateMax = cmd.getDiskBytesReadRateMax();
final Long diskBytesReadRateMaxLength = cmd.getDiskBytesReadRateMaxLength();
final Long diskBytesWriteRate = cmd.getDiskBytesWriteRate();
final Long diskBytesWriteRateMax = cmd.getDiskBytesWriteRateMax();
final Long diskBytesWriteRateMaxLength = cmd.getDiskBytesWriteRateMaxLength();
final Long diskIopsReadRate = cmd.getDiskIopsReadRate();
final Long diskIopsReadRateMax = cmd.getDiskIopsReadRateMax();
final Long diskIopsReadRateMaxLength = cmd.getDiskIopsReadRateMaxLength();
final Long diskIopsWriteRate = cmd.getDiskIopsWriteRate();
final Long diskIopsWriteRateMax = cmd.getDiskIopsWriteRateMax();
final Long diskIopsWriteRateMaxLength = cmd.getDiskIopsWriteRateMaxLength();

final boolean updateNeeded = name != null || displayText != null || sortKey != null || displayDiskOffering != null
|| diskBytesReadRate != null || diskBytesReadRateMax != null || diskBytesReadRateMaxLength != null
|| diskBytesWriteRate != null || diskBytesWriteRateMax != null || diskBytesWriteRateMaxLength != null
|| diskIopsReadRate != null || diskIopsReadRateMax != null || diskIopsReadRateMaxLength != null
|| diskIopsWriteRate != null || diskIopsWriteRateMax != null || diskIopsWriteRateMaxLength != null;
final boolean detailsUpdateNeeded = !filteredDomainIds.equals(existingDomainIds) || !filteredZoneIds.equals(existingZoneIds);

if (!updateNeeded && !detailsUpdateNeeded) {
return _diskOfferingDao.findById(diskOfferingId);
}
Expand All @@ -3086,6 +3138,23 @@ public DiskOffering updateDiskOffering(final UpdateDiskOfferingCmd cmd) {
diskOffering.setDisplayOffering(displayDiskOffering);
}

// BPS Read Rate
diskOffering.setBytesReadRate(checkValue(diskOfferingHandle.getBytesReadRate(), diskBytesReadRate));
diskOffering.setBytesReadRateMax(checkValue(diskOfferingHandle.getBytesReadRateMax(), diskBytesReadRateMax));
diskOffering.setBytesReadRateMaxLength(checkValue(diskOfferingHandle.getBytesReadRateMaxLength(), diskBytesReadRateMaxLength));
// BPS Write Rate
diskOffering.setBytesWriteRate(checkValue(diskOfferingHandle.getBytesWriteRate(), diskBytesWriteRate));
diskOffering.setBytesWriteRateMax(checkValue(diskOfferingHandle.getBytesWriteRateMax(), diskBytesWriteRateMax));
diskOffering.setBytesWriteRateMaxLength(checkValue(diskOfferingHandle.getBytesWriteRateMaxLength(), diskBytesWriteRateMaxLength));
// IOPS Read Rate
diskOffering.setIopsReadRate(checkValue(diskOfferingHandle.getIopsReadRate(), diskIopsReadRate));
diskOffering.setIopsReadRateMax(checkValue(diskOfferingHandle.getIopsReadRateMax(), diskIopsReadRateMax));
diskOffering.setIopsReadRateMaxLength(checkValue(diskOfferingHandle.getIopsReadRateMaxLength(), diskIopsReadRateMaxLength));
// IOPS Write Rate
diskOffering.setIopsWriteRate(checkValue(diskOfferingHandle.getIopsWriteRate(), diskIopsWriteRate));
diskOffering.setIopsWriteRateMax(checkValue(diskOfferingHandle.getIopsWriteRateMax(), diskIopsWriteRateMax));
diskOffering.setIopsWriteRateMaxLength(checkValue(diskOfferingHandle.getIopsWriteRateMaxLength(), diskIopsWriteRateMaxLength));

// Note: tag editing commented out for now;keeping the code intact,
// might need to re-enable in next releases
// if (tags != null)
Expand Down Expand Up @@ -6250,4 +6319,26 @@ public String getConfigComponentName() {
public ConfigKey<?>[] getConfigKeys() {
return new ConfigKey<?>[] {SystemVMUseLocalStorage};
}

/**
* Check if newValue is different than oldValue
* If true return newValue. Else return oldValue
* @param oldValue
* @param newValue
* @return
*/
public Long checkValue(Long oldValue, Long newValue){
//negative value
if(newValue != null && newValue < 0)
throw new InvalidParameterValueException("Negative values are not allowed for disk read/write parameters.");
//the value has been changed to null
else if(newValue != null && newValue == 0)
return null;
//the value has not been changed
else if(newValue == null)
return oldValue;
//the value has been changed
else
return newValue;
}
}
Loading