CLOUDSTACK-1301: VM Disk I/O Throttling

This commit is contained in:
Wei Zhou 2013-06-18 10:02:55 +02:00
parent 9e2eeb21ab
commit 882220e802
32 changed files with 1007 additions and 15 deletions

View File

@ -37,6 +37,10 @@ public class VolumeTO implements InternalIdentity {
private long deviceId;
private String chainInfo;
private String guestOsType;
private Long bytesReadRate;
private Long bytesWriteRate;
private Long iopsReadRate;
private Long iopsWriteRate;
public VolumeTO(long id, Volume.Type type, StoragePoolType poolType, String poolUuid, String name, String mountPoint, String path, long size, String chainInfo) {
this.id = id;
@ -133,4 +137,37 @@ public class VolumeTO implements InternalIdentity {
public String toString() {
return new StringBuilder("Vol[").append(id).append("|").append(type).append("|").append(path).append("|").append(size).append("]").toString();
}
public void setBytesReadRate(Long bytesReadRate) {
this.bytesReadRate = bytesReadRate;
}
public Long getBytesReadRate() {
return bytesReadRate;
}
public void setBytesWriteRate(Long bytesWriteRate) {
this.bytesWriteRate = bytesWriteRate;
}
public Long getBytesWriteRate() {
return bytesWriteRate;
}
public void setIopsReadRate(Long iopsReadRate) {
this.iopsReadRate = iopsReadRate;
}
public Long getIopsReadRate() {
return iopsReadRate;
}
public void setIopsWriteRate(Long iopsWriteRate) {
this.iopsWriteRate = iopsWriteRate;
}
public Long getIopsWriteRate() {
return iopsWriteRate;
}
}

View File

@ -52,4 +52,20 @@ public interface DiskOffering extends InfrastructureEntity, Identity, InternalId
boolean isCustomized();
void setDiskSize(long diskSize);
void setBytesReadRate(Long bytesReadRate);
Long getBytesReadRate();
void setBytesWriteRate(Long bytesWriteRate);
Long getBytesWriteRate();
void setIopsReadRate(Long iopsReadRate);
Long getIopsReadRate();
void setIopsWriteRate(Long iopsWriteRate);
Long getIopsWriteRate();
}

View File

@ -35,6 +35,10 @@ public class DiskProfile {
private Long templateId;
private long volumeId;
private String path;
private Long bytesReadRate;
private Long bytesWriteRate;
private Long iopsReadRate;
private Long iopsWriteRate;
private HypervisorType hyperType;
@ -154,4 +158,36 @@ public class DiskProfile {
public void setSize(long size) {
this.size = size;
}
public void setBytesReadRate(Long bytesReadRate) {
this.bytesReadRate = bytesReadRate;
}
public Long getBytesReadRate() {
return bytesReadRate;
}
public void setBytesWriteRate(Long bytesWriteRate) {
this.bytesWriteRate = bytesWriteRate;
}
public Long getBytesWriteRate() {
return bytesWriteRate;
}
public void setIopsReadRate(Long iopsReadRate) {
this.iopsReadRate = iopsReadRate;
}
public Long getIopsReadRate() {
return iopsReadRate;
}
public void setIopsWriteRate(Long iopsWriteRate) {
this.iopsWriteRate = iopsWriteRate;
}
public Long getIopsWriteRate() {
return iopsWriteRate;
}
}

View File

@ -31,6 +31,8 @@ public class ApiConstants {
public static final String BOOTABLE = "bootable";
public static final String BIND_DN = "binddn";
public static final String BIND_PASSWORD = "bindpass";
public static final String BYTES_READ_RATE = "bytesreadrate";
public static final String BYTES_WRITE_RATE = "byteswriterate";
public static final String CATEGORY = "category";
public static final String CERTIFICATE = "certificate";
public static final String PRIVATE_KEY = "privatekey";
@ -104,6 +106,8 @@ public class ApiConstants {
public static final String INTERNAL_DNS1 = "internaldns1";
public static final String INTERNAL_DNS2 = "internaldns2";
public static final String INTERVAL_TYPE = "intervaltype";
public static final String IOPS_READ_RATE = "iopsreadrate";
public static final String IOPS_WRITE_RATE = "iopswriterate";
public static final String IP_ADDRESS = "ipaddress";
public static final String IP6_ADDRESS = "ip6address";
public static final String IP_ADDRESS_ID = "ipaddressid";

View File

@ -62,6 +62,18 @@ public class CreateDiskOfferingCmd extends BaseCmd {
@Parameter(name=ApiConstants.STORAGE_TYPE, type=CommandType.STRING, description="the storage type of the disk offering. Values are local and shared.")
private String storageType = ServiceOffering.StorageType.shared.toString();
@Parameter(name=ApiConstants.BYTES_READ_RATE, type=CommandType.LONG, required=false, description="bytes read rate of the disk offering")
private Long bytesReadRate;
@Parameter(name=ApiConstants.BYTES_WRITE_RATE, type=CommandType.LONG, required=false, description="bytes write rate of the disk offering")
private Long bytesWriteRate;
@Parameter(name=ApiConstants.IOPS_READ_RATE, type=CommandType.LONG, required=false, description="io requests read rate of the disk offering")
private Long iopsReadRate;
@Parameter(name=ApiConstants.IOPS_WRITE_RATE, type=CommandType.LONG, required=false, description="io requests write rate of the disk offering")
private Long iopsWriteRate;
@Parameter(name=ApiConstants.DISPLAY_OFFERING, type=CommandType.BOOLEAN, description="an optional field, whether to display the offering to the end user or not.")
private Boolean displayOffering;
@ -93,6 +105,22 @@ public class CreateDiskOfferingCmd extends BaseCmd {
return domainId;
}
public Long getBytesReadRate() {
return bytesReadRate;
}
public Long getBytesWriteRate() {
return bytesWriteRate;
}
public Long getIopsReadRate() {
return iopsReadRate;
}
public Long getIopsWriteRate() {
return iopsWriteRate;
}
public String getStorageType() {
return storageType;
}

View File

@ -93,6 +93,18 @@ public class CreateServiceOfferingCmd extends BaseCmd {
@Parameter(name = ApiConstants.SERVICE_OFFERING_DETAILS, type = CommandType.MAP, description = "details for planner, used to store specific parameters")
private Map<String, String> details;
@Parameter(name=ApiConstants.BYTES_READ_RATE, type=CommandType.LONG, required=false, description="bytes read rate of the disk offering")
private Long bytesReadRate;
@Parameter(name=ApiConstants.BYTES_WRITE_RATE, type=CommandType.LONG, required=false, description="bytes write rate of the disk offering")
private Long bytesWriteRate;
@Parameter(name=ApiConstants.IOPS_READ_RATE, type=CommandType.LONG, required=false, description="io requests read rate of the disk offering")
private Long iopsReadRate;
@Parameter(name=ApiConstants.IOPS_WRITE_RATE, type=CommandType.LONG, required=false, description="io requests write rate of the disk offering")
private Long iopsWriteRate;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -171,6 +183,22 @@ public class CreateServiceOfferingCmd extends BaseCmd {
return params;
}
public Long getBytesReadRate() {
return bytesReadRate;
}
public Long getBytesWriteRate() {
return bytesWriteRate;
}
public Long getIopsReadRate() {
return iopsReadRate;
}
public Long getIopsWriteRate() {
return iopsWriteRate;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -58,6 +58,18 @@ public class DiskOfferingResponse extends BaseResponse {
@SerializedName("storagetype") @Param(description="the storage type for this disk offering")
private String storageType;
@SerializedName("diskBytesReadRate") @Param(description="bytes read rate of the disk offering")
private Long bytesReadRate;
@SerializedName("diskBytesWriteRate") @Param(description="bytes write rate of the disk offering")
private Long bytesWriteRate;
@SerializedName("diskIopsReadRate") @Param(description="io requests read rate of the disk offering")
private Long iopsReadRate;
@SerializedName("diskIopsWriteRate") @Param(description="io requests write rate of the disk offering")
private Long iopsWriteRate;
@SerializedName("displayoffering") @Param(description="whether to display the offering to the end user or not.")
private Boolean displayOffering;
@ -149,4 +161,20 @@ public class DiskOfferingResponse extends BaseResponse {
public void setStorageType(String storageType) {
this.storageType = storageType;
}
public void setBytesReadRate(Long bytesReadRate) {
this.bytesReadRate = bytesReadRate;
}
public void setBytesWriteRate(Long bytesWriteRate) {
this.bytesWriteRate = bytesWriteRate;
}
public void setIopsReadRate(Long iopsReadRate) {
this.iopsReadRate = iopsReadRate;
}
public void setIopsWriteRate(Long iopsWriteRate) {
this.iopsWriteRate = iopsWriteRate;
}
}

View File

@ -87,6 +87,18 @@ public class ServiceOfferingResponse extends BaseResponse {
@SerializedName(ApiConstants.NETWORKRATE) @Param(description="data transfer rate in megabits per second allowed.")
private Integer networkRate;
@SerializedName("diskBytesReadRate") @Param(description="bytes read rate of the service offering")
private Long bytesReadRate;
@SerializedName("diskBytesWriteRate") @Param(description="bytes write rate of the service offering")
private Long bytesWriteRate;
@SerializedName("diskIopsReadRate") @Param(description="io requests read rate of the service offering")
private Long iopsReadRate;
@SerializedName("diskIopsWriteRate") @Param(description="io requests write rate of the service offering")
private Long iopsWriteRate;
@SerializedName(ApiConstants.DEPLOYMENT_PLANNER) @Param(description="deployment strategy used to deploy VM.")
private String deploymentPlanner;
@ -248,4 +260,20 @@ public class ServiceOfferingResponse extends BaseResponse {
public void setVolatileVm(boolean isVolatile) {
this.isVolatile = isVolatile;
}
public void setBytesReadRate(Long bytesReadRate) {
this.bytesReadRate = bytesReadRate;
}
public void setBytesWriteRate(Long bytesWriteRate) {
this.bytesWriteRate = bytesWriteRate;
}
public void setIopsReadRate(Long iopsReadRate) {
this.iopsReadRate = iopsReadRate;
}
public void setIopsWriteRate(Long iopsWriteRate) {
this.iopsWriteRate = iopsWriteRate;
}
}

View File

@ -110,6 +110,18 @@ public class VolumeResponse extends BaseResponse implements ControlledViewEntity
@Param(description = "shared or local storage")
private String storageType;
@SerializedName("diskBytesReadRate") @Param(description="bytes read rate of the disk volume")
private Long bytesReadRate;
@SerializedName("diskBytesWriteRate") @Param(description="bytes write rate of the disk volume")
private Long bytesWriteRate;
@SerializedName("diskIopsReadRate") @Param(description="io requests read rate of the disk volume")
private Long iopsReadRate;
@SerializedName("diskIopsWriteRate") @Param(description="io requests write rate of the disk volume")
private Long iopsWriteRate;
@SerializedName(ApiConstants.HYPERVISOR)
@Param(description = "Hypervisor the volume belongs to")
private String hypervisor;
@ -258,6 +270,38 @@ public class VolumeResponse extends BaseResponse implements ControlledViewEntity
this.storageType = storageType;
}
public void setBytesReadRate(Long bytesReadRate) {
this.bytesReadRate = bytesReadRate;
}
public Long getBytesReadRate() {
return bytesReadRate;
}
public void setBytesWriteRate(Long bytesWriteRate) {
this.bytesWriteRate = bytesWriteRate;
}
public Long getBytesWriteRate() {
return bytesWriteRate;
}
public void setIopsReadRate(Long iopsReadRate) {
this.iopsReadRate = iopsReadRate;
}
public Long getIopsReadRate() {
return iopsReadRate;
}
public void setIopsWriteRate(Long iopsWriteRate) {
this.iopsWriteRate = iopsWriteRate;
}
public Long getIopsWriteRate() {
return iopsWriteRate;
}
public void setHypervisor(String hypervisor) {
this.hypervisor = hypervisor;
}

View File

@ -466,6 +466,10 @@ label.disable.vpn=Disable VPN
label.disabled=Disabled
label.disabling.vpn.access=Disabling VPN Access
label.disk.allocated=Disk Allocated
label.disk.bytes.read.rate=Disk Read Rate (BPS)
label.disk.bytes.write.rate=Disk Write Rate (BPS)
label.disk.iops.read.rate=Disk Read Rate (IOPS)
label.disk.iops.write.rate=Disk Write Rate (IOPS)
label.disk.offering=Disk Offering
label.disk.read.bytes=Disk Read (Bytes)
label.disk.read.io=Disk Read (IO)

View File

@ -29,6 +29,10 @@ public class AttachVolumeCommand extends Command {
String volumeName;
Long deviceId;
String chainInfo;
Long bytesReadRate;
Long bytesWriteRate;
Long iopsReadRate;
Long iopsWriteRate;
protected AttachVolumeCommand() {
}
@ -96,4 +100,36 @@ public class AttachVolumeCommand extends Command {
public String getChainInfo() {
return chainInfo;
}
public void setBytesReadRate(Long bytesReadRate) {
this.bytesReadRate = bytesReadRate;
}
public Long getBytesReadRate() {
return bytesReadRate;
}
public void setBytesWriteRate(Long bytesWriteRate) {
this.bytesWriteRate = bytesWriteRate;
}
public Long getBytesWriteRate() {
return bytesWriteRate;
}
public void setIopsReadRate(Long iopsReadRate) {
this.iopsReadRate = iopsReadRate;
}
public Long getIopsReadRate() {
return iopsReadRate;
}
public void setIopsWriteRate(Long iopsWriteRate) {
this.iopsWriteRate = iopsWriteRate;
}
public Long getIopsWriteRate() {
return iopsWriteRate;
}
}

View File

@ -100,6 +100,18 @@ public class DiskOfferingVO implements DiskOffering {
@Column(name="sort_key")
int sortKey;
@Column(name="bytes_read_rate")
Long bytesReadRate;
@Column(name="bytes_write_rate")
Long bytesWriteRate;
@Column(name="iops_read_rate")
Long iopsReadRate;
@Column(name="iops_write_rate")
Long iopsWriteRate;
@Column(name="display_offering")
boolean displayOffering;
@ -327,4 +339,36 @@ public class DiskOfferingVO implements DiskOffering {
public void setDisplayOffering(boolean displayOffering) {
this.displayOffering = displayOffering;
}
public void setBytesReadRate(Long bytesReadRate) {
this.bytesReadRate = bytesReadRate;
}
public Long getBytesReadRate() {
return bytesReadRate;
}
public void setBytesWriteRate(Long bytesWriteRate) {
this.bytesWriteRate = bytesWriteRate;
}
public Long getBytesWriteRate() {
return bytesWriteRate;
}
public void setIopsReadRate(Long iopsReadRate) {
this.iopsReadRate = iopsReadRate;
}
public Long getIopsReadRate() {
return iopsReadRate;
}
public void setIopsWriteRate(Long iopsWriteRate) {
this.iopsWriteRate = iopsWriteRate;
}
public Long getIopsWriteRate() {
return iopsWriteRate;
}
}

View File

@ -336,6 +336,8 @@ ServerResource {
protected HypervisorType _hypervisorType;
protected String _hypervisorURI;
protected long _hypervisorLibvirtVersion;
protected long _hypervisorQemuVersion;
protected String _hypervisorPath;
protected String _networkDirectSourceMode;
protected String _networkDirectDevice;
@ -735,6 +737,8 @@ ServerResource {
try {
_hvVersion = conn.getVersion();
_hvVersion = (_hvVersion % 1000000) / 1000;
_hypervisorLibvirtVersion = conn.getLibVirVersion();
_hypervisorQemuVersion = conn.getVersion();
} catch (LibvirtException e) {
s_logger.trace("Ignoring libvirt error.", e);
}
@ -1411,6 +1415,10 @@ ServerResource {
VolumeTO volume = new VolumeTO(cmd.getVolumeId(), dskch.getType(),
pool.getType(), pool.getUuid(), pool.getPath(),
vol.getName(), vol.getName(), disksize, null);
volume.setBytesReadRate(dskch.getBytesReadRate());
volume.setBytesWriteRate(dskch.getBytesWriteRate());
volume.setIopsReadRate(dskch.getIopsReadRate());
volume.setIopsWriteRate(dskch.getIopsWriteRate());
return new CreateAnswer(cmd, volume);
} catch (CloudRuntimeException e) {
s_logger.debug("Failed to create volume: " + e.toString());
@ -2626,7 +2634,7 @@ ServerResource {
cmd.getPoolUuid());
KVMPhysicalDisk disk = primary.getPhysicalDisk(cmd.getVolumePath());
attachOrDetachDisk(conn, cmd.getAttach(), cmd.getVmName(), disk,
cmd.getDeviceId().intValue());
cmd.getDeviceId().intValue(), cmd.getBytesReadRate(), cmd.getBytesWriteRate(), cmd.getIopsReadRate(), cmd.getIopsWriteRate());
} catch (LibvirtException e) {
return new AttachVolumeAnswer(cmd, e.toString());
} catch (InternalErrorException e) {
@ -3224,6 +3232,8 @@ ServerResource {
} else {
guest.setGuestType(GuestDef.guestType.KVM);
vm.setHvsType(HypervisorType.KVM.toString().toLowerCase());
vm.setLibvirtVersion(_hypervisorLibvirtVersion);
vm.setQemuVersion(_hypervisorQemuVersion);
}
guest.setGuestArch(vmTO.getArch());
guest.setMachineType("pc");
@ -3497,6 +3507,15 @@ ServerResource {
}
if ((volume.getBytesReadRate() != null) && (volume.getBytesReadRate() > 0))
disk.setBytesReadRate(volume.getBytesReadRate());
if ((volume.getBytesWriteRate() != null) && (volume.getBytesWriteRate() > 0))
disk.setBytesWriteRate(volume.getBytesWriteRate());
if ((volume.getIopsReadRate() != null) && (volume.getIopsReadRate() > 0))
disk.setIopsReadRate(volume.getIopsReadRate());
if ((volume.getIopsWriteRate() != null) && (volume.getIopsWriteRate() > 0))
disk.setIopsWriteRate(volume.getIopsWriteRate());
vm.getDevices().addDevice(disk);
}
@ -3630,7 +3649,7 @@ ServerResource {
protected synchronized String attachOrDetachDisk(Connect conn,
boolean attach, String vmName, KVMPhysicalDisk attachingDisk,
int devId) throws LibvirtException, InternalErrorException {
int devId, Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate) throws LibvirtException, InternalErrorException {
List<DiskDef> disks = null;
Domain dm = null;
DiskDef diskdef = null;
@ -3670,6 +3689,14 @@ ServerResource {
diskdef.defBlockBasedDisk(attachingDisk.getPath(), devId,
DiskDef.diskBus.VIRTIO);
}
if ((bytesReadRate != null) && (bytesReadRate > 0))
diskdef.setBytesReadRate(bytesReadRate);
if ((bytesWriteRate != null) && (bytesWriteRate > 0))
diskdef.setBytesWriteRate(bytesWriteRate);
if ((iopsReadRate != null) && (iopsReadRate > 0))
diskdef.setIopsReadRate(iopsReadRate);
if ((iopsWriteRate != null) && (iopsWriteRate > 0))
diskdef.setIopsWriteRate(iopsWriteRate);
}
String xml = diskdef.toString();

View File

@ -105,6 +105,31 @@ public class LibvirtDomainXMLParser {
DiskDef.diskBus.valueOf(bus.toUpperCase()));
}
}
NodeList iotune = disk.getElementsByTagName("iotune");
if ((iotune != null) && (iotune.getLength() !=0)) {
String bytesReadRateStr = getTagValue("read_bytes_sec", (Element)iotune.item(0));
if (bytesReadRateStr != null) {
Long bytesReadRate = Long.parseLong(bytesReadRateStr);
def.setBytesReadRate(bytesReadRate);
}
String bytesWriteRateStr = getTagValue("write_bytes_sec", (Element)iotune.item(0));
if (bytesWriteRateStr != null) {
Long bytesWriteRate = Long.parseLong(bytesWriteRateStr);
def.setBytesWriteRate(bytesWriteRate);
}
String iopsReadRateStr = getTagValue("read_iops_sec", (Element)iotune.item(0));
if (iopsReadRateStr != null) {
Long iopsReadRate = Long.parseLong(iopsReadRateStr);
def.setIopsReadRate(iopsReadRate);
}
String iopsWriteRateStr = getTagValue("write_iops_sec", (Element)iotune.item(0));
if (iopsWriteRateStr != null) {
Long iopsWriteRate = Long.parseLong(iopsWriteRateStr);
def.setIopsWriteRate(iopsWriteRate);
}
}
diskDefs.add(def);
}

View File

@ -22,8 +22,12 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import com.cloud.utils.script.Script;
public class LibvirtVMDef {
private String _hvsType;
private static long _libvirtVersion;
private static long _qemuVersion;
private String _domName;
private String _domUUID;
private String _desc;
@ -439,6 +443,10 @@ public class LibvirtVMDef {
private boolean _readonly = false;
private boolean _shareable = false;
private boolean _deferAttach = false;
private Long _bytesReadRate;
private Long _bytesWriteRate;
private Long _iopsReadRate;
private Long _iopsWriteRate;
public void setDeviceType(deviceType deviceType) {
_deviceType = deviceType;
@ -584,6 +592,22 @@ public class LibvirtVMDef {
return suffix - 'a';
}
public void setBytesReadRate(Long bytesReadRate) {
_bytesReadRate = bytesReadRate;
}
public void setBytesWriteRate(Long bytesWriteRate) {
_bytesWriteRate = bytesWriteRate;
}
public void setIopsReadRate(Long iopsReadRate) {
_iopsReadRate = iopsReadRate;
}
public void setIopsWriteRate(Long iopsWriteRate) {
_iopsWriteRate = iopsWriteRate;
}
@Override
public String toString() {
StringBuilder diskBuilder = new StringBuilder();
@ -627,6 +651,22 @@ public class LibvirtVMDef {
diskBuilder.append(" bus='" + _bus + "'");
}
diskBuilder.append("/>\n");
if ((_deviceType != deviceType.CDROM) && (_libvirtVersion >= 9008) && (_qemuVersion >= 1001000)
&& (((_bytesReadRate != null) && (_bytesReadRate > 0)) || ((_bytesWriteRate != null) && (_bytesWriteRate > 0))
|| ((_iopsReadRate != null) && (_iopsReadRate > 0)) || ((_iopsWriteRate != null) && (_iopsWriteRate > 0)) )) { // not CDROM, from libvirt 0.9.8 and QEMU 1.1.0
diskBuilder.append("<iotune>\n");
if ((_bytesReadRate != null) && (_bytesReadRate > 0))
diskBuilder.append("<read_bytes_sec>" + _bytesReadRate + "</read_bytes_sec>\n");
if ((_bytesWriteRate != null) && (_bytesWriteRate > 0))
diskBuilder.append("<write_bytes_sec>" + _bytesWriteRate + "</write_bytes_sec>\n");
if ((_iopsReadRate != null) && (_iopsReadRate > 0))
diskBuilder.append("<read_iops_sec>" + _iopsReadRate + "</read_iops_sec>\n");
if ((_iopsWriteRate != null) && (_iopsWriteRate > 0))
diskBuilder.append("<write_iops_sec>" + _iopsWriteRate + "</write_iops_sec>\n");
diskBuilder.append("</iotune>\n");
}
diskBuilder.append("</disk>\n");
return diskBuilder.toString();
}
@ -1012,6 +1052,14 @@ public class LibvirtVMDef {
return _hvsType;
}
public void setLibvirtVersion(long libvirtVersion) {
_libvirtVersion = libvirtVersion;
}
public void setQemuVersion(long qemuVersion) {
_qemuVersion = qemuVersion;
}
public void setDomainName(String domainName) {
_domName = domainName;
}

View File

@ -75,7 +75,12 @@ public class DiskOfferingJoinDaoImpl extends GenericDaoBase<DiskOfferingJoinVO,
diskOfferingResponse.setTags(offering.getTags());
diskOfferingResponse.setCustomized(offering.isCustomized());
diskOfferingResponse.setStorageType(offering.isUseLocalStorage() ? ServiceOffering.StorageType.local.toString() : ServiceOffering.StorageType.shared.toString());
diskOfferingResponse.setBytesReadRate(offering.getBytesReadRate());
diskOfferingResponse.setBytesWriteRate(offering.getBytesWriteRate());
diskOfferingResponse.setIopsReadRate(offering.getIopsReadRate());
diskOfferingResponse.setIopsWriteRate(offering.getIopsWriteRate());
diskOfferingResponse.setObjectName("diskoffering");
return diskOfferingResponse;
}

View File

@ -75,6 +75,10 @@ public class ServiceOfferingJoinDaoImpl extends GenericDaoBase<ServiceOfferingJo
offeringResponse.setNetworkRate(offering.getRateMbps());
offeringResponse.setHostTag(offering.getHostTag());
offeringResponse.setDeploymentPlanner(offering.getDeploymentPlanner());
offeringResponse.setBytesReadRate(offering.getBytesReadRate());
offeringResponse.setBytesWriteRate(offering.getBytesWriteRate());
offeringResponse.setIopsReadRate(offering.getIopsReadRate());
offeringResponse.setIopsWriteRate(offering.getIopsWriteRate());
offeringResponse.setObjectName("serviceoffering");
return offeringResponse;

View File

@ -160,6 +160,11 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO, Long> implem
}
volResponse.setStorageType(volume.isUseLocalStorage() ? ServiceOffering.StorageType.local.toString() : ServiceOffering.StorageType.shared
.toString());
volResponse.setBytesReadRate(volume.getBytesReadRate());
volResponse.setBytesWriteRate(volume.getBytesReadRate());
volResponse.setIopsReadRate(volume.getIopsWriteRate());
volResponse.setIopsWriteRate(volume.getIopsWriteRate());
}
Long poolId = volume.getPoolId();
String poolName = (poolId == null) ? "none" : volume.getPoolName();

View File

@ -64,6 +64,18 @@ public class DiskOfferingJoinVO extends BaseViewVO implements InternalIdentity,
@Column(name="sort_key")
int sortKey;
@Column(name="bytes_read_rate")
Long bytesReadRate;
@Column(name="bytes_write_rate")
Long bytesWriteRate;
@Column(name="iops_read_rate")
Long iopsReadRate;
@Column(name="iops_write_rate")
Long iopsWriteRate;
@Column(name="type")
Type type;
@ -239,6 +251,36 @@ public class DiskOfferingJoinVO extends BaseViewVO implements InternalIdentity,
this.type = type;
}
public void setBytesReadRate(Long bytesReadRate) {
this.bytesReadRate = bytesReadRate;
}
public Long getBytesReadRate() {
return bytesReadRate;
}
public void setBytesWriteRate(Long bytesWriteRate) {
this.bytesWriteRate = bytesWriteRate;
}
public Long getBytesWriteRate() {
return bytesWriteRate;
}
public void setIopsReadRate(Long iopsReadRate) {
this.iopsReadRate = iopsReadRate;
}
public Long getIopsReadRate() {
return iopsReadRate;
}
public void setIopsWriteRate(Long iopsWriteRate) {
this.iopsWriteRate = iopsWriteRate;
}
public Long getIopsWriteRate() {
return iopsWriteRate;
}
}

View File

@ -90,6 +90,17 @@ public class ServiceOfferingJoinVO extends BaseViewVO implements InternalIdentit
@Column(name="sort_key")
int sortKey;
@Column(name="bytes_read_rate")
Long bytesReadRate;
@Column(name="bytes_write_rate")
Long bytesWriteRate;
@Column(name="iops_read_rate")
Long iopsReadRate;
@Column(name="iops_write_rate")
Long iopsWriteRate;
@Column(name=GenericDao.CREATED_COLUMN)
private Date created;
@ -329,5 +340,35 @@ public class ServiceOfferingJoinVO extends BaseViewVO implements InternalIdentit
this.volatileVm = volatileVm;
}
public void setBytesReadRate(Long bytesReadRate) {
this.bytesReadRate = bytesReadRate;
}
public Long getBytesReadRate() {
return bytesReadRate;
}
public void setBytesWriteRate(Long bytesWriteRate) {
this.bytesWriteRate = bytesWriteRate;
}
public Long getBytesWriteRate() {
return bytesWriteRate;
}
public void setIopsReadRate(Long iopsReadRate) {
this.iopsReadRate = iopsReadRate;
}
public Long getIopsReadRate() {
return iopsReadRate;
}
public void setIopsWriteRate(Long iopsWriteRate) {
this.iopsWriteRate = iopsWriteRate;
}
public Long getIopsWriteRate() {
return iopsWriteRate;
}
}

View File

@ -184,6 +184,18 @@ public class VolumeJoinVO extends BaseViewVO implements ControlledViewEntity {
@Column(name="use_local_storage")
private boolean useLocalStorage;
@Column(name="bytes_read_rate")
Long bytesReadRate;
@Column(name="bytes_write_rate")
Long bytesWriteRate;
@Column(name="iops_read_rate")
Long iopsReadRate;
@Column(name="iops_write_rate")
Long iopsWriteRate;
@Column(name="pool_id")
private long poolId;
@ -742,6 +754,37 @@ public class VolumeJoinVO extends BaseViewVO implements ControlledViewEntity {
}
public void setBytesReadRate(Long bytesReadRate) {
this.bytesReadRate = bytesReadRate;
}
public Long getBytesReadRate() {
return bytesReadRate;
}
public void setBytesWriteRate(Long bytesWriteRate) {
this.bytesWriteRate = bytesWriteRate;
}
public Long getBytesWriteRate() {
return bytesWriteRate;
}
public void setIopsReadRate(Long iopsReadRate) {
this.iopsReadRate = iopsReadRate;
}
public Long getIopsReadRate() {
return iopsReadRate;
}
public void setIopsWriteRate(Long iopsWriteRate) {
this.iopsWriteRate = iopsWriteRate;
}
public Long getIopsWriteRate() {
return iopsWriteRate;
}
public long getPoolId() {
return poolId;

View File

@ -239,6 +239,10 @@ public enum Config {
VmDiskStatsInterval("Advanced", ManagementServer.class, Integer.class, "vm.disk.stats.interval", "0", "Interval (in seconds) to report vm disk statistics.", null),
VmTransitionWaitInterval("Advanced", ManagementServer.class, Integer.class, "vm.tranisition.wait.interval", "3600", "Time (in seconds) to wait before taking over a VM in transition state", null),
VmDestroyForcestop("Advanced", ManagementServer.class, Boolean.class, "vm.destroy.forcestop", "false", "On destroy, force-stop takes this value ", null),
VmDiskThrottlingIopsReadRate("Advanced", ManagementServer.class, Integer.class, "vm.disk.throttling.iops_read_rate", "0", "Default disk I/O read rate in requests per second allowed in User vm's disk.", null),
VmDiskThrottlingIopsWriteRate("Advanced", ManagementServer.class, Integer.class, "vm.disk.throttling.iops_write_rate", "0", "Default disk I/O writerate in requests per second allowed in User vm's disk.", null),
VmDiskThrottlingBytesReadRate("Advanced", ManagementServer.class, Integer.class, "vm.disk.throttling.bytes_read_rate", "0", "Default disk I/O read rate in bytes per second allowed in User vm's disk.", null),
VmDiskThrottlingBytesWriteRate("Advanced", ManagementServer.class, Integer.class, "vm.disk.throttling.bytes_write_rate", "0", "Default disk I/O writerate in bytes per second allowed in User vm's disk.", null),
ControlCidr("Advanced", ManagementServer.class, String.class, "control.cidr", "169.254.0.0/16", "Changes the cidr for the control network traffic. Defaults to using link local. Must be unique within pods", null),
ControlGateway("Advanced", ManagementServer.class, String.class, "control.gateway", "169.254.0.1", "gateway for the control network traffic", null),

View File

@ -81,10 +81,15 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
* @param useVirtualNetwork
* @param deploymentPlanner
* @param details
* @param bytesReadRate
* @param bytesWriteRate
* @param iopsReadRate
* @param iopsWriteRate
* @return ID
*/
ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, VirtualMachine.Type vm_typeType, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired,
boolean offerHA, boolean limitResourceUse, boolean volatileVm, String tags, Long domainId, String hostTag, Integer networkRate, String deploymentPlanner, Map<String, String> details);
boolean offerHA, boolean limitResourceUse, boolean volatileVm, String tags, Long domainId, String hostTag, Integer networkRate, String deploymentPlanner, Map<String, String> details,
Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate);
/**
* Creates a new disk offering
@ -97,9 +102,14 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
* @param isCustomized
* @param localStorageRequired
* @param isDisplayOfferingEnabled
* @param bytesReadRate
* @param bytesWriteRate
* @param iopsReadRate
* @param iopsWriteRate
* @return newly created disk offering
*/
DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired, boolean isDisplayOfferingEnabled);
DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired, boolean isDisplayOfferingEnabled,
Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate);
/**
* Creates a new pod

View File

@ -2031,7 +2031,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
return createServiceOffering(userId, cmd.getIsSystem(), vmType, cmd.getServiceOfferingName(),
cpuNumber.intValue(), memory.intValue(), cpuSpeed.intValue(), cmd.getDisplayText(),
localStorageRequired, offerHA, limitCpuUse, volatileVm, cmd.getTags(), cmd.getDomainId(),
cmd.getHostTag(), cmd.getNetworkRate(), cmd.getDeploymentPlanner(), cmd.getDetails());
cmd.getHostTag(), cmd.getNetworkRate(), cmd.getDeploymentPlanner(), cmd.getDetails(),
cmd.getBytesReadRate(), cmd.getBytesWriteRate(), cmd.getIopsReadRate(), cmd.getIopsWriteRate());
}
@Override
@ -2039,11 +2040,20 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
public ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, VirtualMachine.Type vm_type,
String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired,
boolean offerHA, boolean limitResourceUse, boolean volatileVm, String tags, Long domainId, String hostTag,
Integer networkRate, String deploymentPlanner, Map<String, String> details) {
Integer networkRate, String deploymentPlanner, Map<String, String> details, Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate) {
tags = cleanupTags(tags);
ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, networkRate, null, offerHA, limitResourceUse, volatileVm, displayText, localStorageRequired, false, tags, isSystem, vm_type,
domainId, hostTag, deploymentPlanner);
if ((bytesReadRate != null) && (bytesReadRate > 0))
offering.setBytesReadRate(bytesReadRate);
if ((bytesWriteRate != null) && (bytesWriteRate > 0))
offering.setBytesWriteRate(bytesWriteRate);
if ((iopsReadRate != null) && (iopsReadRate > 0))
offering.setIopsReadRate(iopsReadRate);
if ((iopsWriteRate != null) && (iopsWriteRate > 0))
offering.setIopsWriteRate(iopsWriteRate);
if ((offering = _serviceOfferingDao.persist(offering)) != null) {
if (details != null) {
_serviceOfferingDetailsDao.persist(offering.getId(), details);
@ -2129,7 +2139,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
@Override
@ActionEvent(eventType = EventTypes.EVENT_DISK_OFFERING_CREATE, eventDescription = "creating disk offering")
public DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired, boolean isDisplayOfferingEnabled) {
public DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired, boolean isDisplayOfferingEnabled,
Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate) {
long diskSize = 0;// special case for custom disk offerings
if (numGibibytes != null && (numGibibytes <= 0)) {
throw new InvalidParameterValueException("Please specify a disk size of at least 1 Gb.");
@ -2149,6 +2160,16 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
DiskOfferingVO newDiskOffering = new DiskOfferingVO(domainId, name, description, diskSize, tags, isCustomized);
newDiskOffering.setUseLocalStorage(localStorageRequired);
newDiskOffering.setDisplayOffering(isDisplayOfferingEnabled);
if (bytesReadRate != null && (bytesReadRate > 0))
newDiskOffering.setBytesReadRate(bytesReadRate);
if (bytesWriteRate != null && (bytesWriteRate > 0))
newDiskOffering.setBytesWriteRate(bytesWriteRate);
if (iopsReadRate != null && (iopsReadRate > 0))
newDiskOffering.setIopsReadRate(iopsReadRate);
if (iopsWriteRate != null && (iopsWriteRate > 0))
newDiskOffering.setIopsWriteRate(iopsWriteRate);
UserContext.current().setEventDetails("Disk offering id=" + newDiskOffering.getId());
DiskOfferingVO offering = _diskOfferingDao.persist(newDiskOffering);
if (offering != null) {
@ -2189,7 +2210,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
}
}
return createDiskOffering(domainId, name, description, numGibibytes, tags, isCustomized, localStorageRequired, isDisplayOfferingEnabled);
Long bytesReadRate = cmd.getBytesReadRate();
Long bytesWriteRate = cmd.getBytesWriteRate();
Long iopsReadRate = cmd.getIopsReadRate();
Long iopsWriteRate = cmd.getIopsWriteRate();
return createDiskOffering(domainId, name, description, numGibibytes, tags, isCustomized, localStorageRequired, isDisplayOfferingEnabled, bytesReadRate, bytesWriteRate, iopsReadRate, iopsWriteRate);
}
@Override

View File

@ -35,6 +35,8 @@ import com.cloud.exception.ConnectionException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.host.Host;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.utils.Pair;
import com.cloud.vm.DiskProfile;
@ -122,4 +124,12 @@ public interface StorageManager extends StorageService {
DataStore createLocalStorage(Host host, StoragePoolInfo poolInfo) throws ConnectionException;
BigDecimal getStorageOverProvisioningFactor(Long dcId);
Long getDiskBytesReadRate(ServiceOfferingVO offering, DiskOfferingVO diskOffering);
Long getDiskBytesWriteRate(ServiceOfferingVO offering, DiskOfferingVO diskOffering);
Long getDiskIopsReadRate(ServiceOfferingVO offering, DiskOfferingVO diskOffering);
Long getDiskIopsWriteRate(ServiceOfferingVO offering, DiskOfferingVO diskOffering);
}

View File

@ -127,6 +127,7 @@ import com.cloud.resource.ResourceState;
import com.cloud.server.ManagementServer;
import com.cloud.server.StatsCollector;
import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.Volume.Type;
@ -142,6 +143,7 @@ import com.cloud.storage.dao.VMTemplateS3Dao;
import com.cloud.storage.dao.VMTemplateSwiftDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.storage.dao.VolumeHostDao;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.download.DownloadMonitor;
import com.cloud.storage.listener.StoragePoolMonitor;
import com.cloud.storage.listener.VolumeStateListener;
@ -1886,4 +1888,67 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
return null;
}
// get bytesReadRate from service_offering, disk_offering and vm.disk.throttling.bytes_read_rate
@Override
public Long getDiskBytesReadRate(ServiceOfferingVO offering, DiskOfferingVO diskOffering) {
if ((offering != null) && (offering.getBytesReadRate() != null) && (offering.getBytesReadRate() > 0)) {
return offering.getBytesReadRate();
} else if ((diskOffering != null) && (diskOffering.getBytesReadRate() != null) && (diskOffering.getBytesReadRate() > 0)) {
return diskOffering.getBytesReadRate();
} else {
Long bytesReadRate = Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingBytesReadRate.key()));
if ((bytesReadRate > 0) && ((offering == null) || (! offering.getSystemUse()))) {
return bytesReadRate;
}
}
return 0L;
}
// get bytesWriteRate from service_offering, disk_offering and vm.disk.throttling.bytes_write_rate
@Override
public Long getDiskBytesWriteRate(ServiceOfferingVO offering, DiskOfferingVO diskOffering) {
if ((offering != null) && (offering.getBytesWriteRate() != null) && (offering.getBytesWriteRate() > 0)) {
return offering.getBytesWriteRate();
} else if ((diskOffering != null) && (diskOffering.getBytesWriteRate() != null) && (diskOffering.getBytesWriteRate() > 0)) {
return diskOffering.getBytesWriteRate();
} else {
Long bytesWriteRate = Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingBytesWriteRate.key()));
if ((bytesWriteRate > 0) && ((offering == null) || (! offering.getSystemUse()))) {
return bytesWriteRate;
}
}
return 0L;
}
// get iopsReadRate from service_offering, disk_offering and vm.disk.throttling.iops_read_rate
@Override
public Long getDiskIopsReadRate(ServiceOfferingVO offering, DiskOfferingVO diskOffering) {
if ((offering != null) && (offering.getIopsReadRate() != null) && (offering.getIopsReadRate() > 0)) {
return offering.getIopsReadRate();
} else if ((diskOffering != null) && (diskOffering.getIopsReadRate() != null) && (diskOffering.getIopsReadRate() > 0)) {
return diskOffering.getIopsReadRate();
} else {
Long iopsReadRate = Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingIopsReadRate.key()));
if ((iopsReadRate > 0) && ((offering == null) || (! offering.getSystemUse()))) {
return iopsReadRate;
}
}
return 0L;
}
// get iopsWriteRate from service_offering, disk_offering and vm.disk.throttling.iops_write_rate
@Override
public Long getDiskIopsWriteRate(ServiceOfferingVO offering, DiskOfferingVO diskOffering) {
if ((offering != null) && (offering.getIopsWriteRate() != null) && (offering.getIopsWriteRate() > 0)) {
return offering.getIopsWriteRate();
} else if ((diskOffering != null) && (diskOffering.getIopsWriteRate() != null) && (diskOffering.getIopsWriteRate() > 0)) {
return diskOffering.getIopsWriteRate();
} else {
Long iopsWriteRate = Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingIopsWriteRate.key()));
if ((iopsWriteRate > 0) && ((offering == null) || (! offering.getSystemUse()))) {
return iopsWriteRate;
}
}
return 0L;
}
}

View File

@ -115,6 +115,7 @@ import com.cloud.server.ManagementServer;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.StorageManager;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.Volume.Event;
import com.cloud.storage.Volume.Type;
@ -336,6 +337,11 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
diskOffering.getUseLocalStorage(),
diskOffering.isRecreatable(), null);
dskCh.setHyperType(dataDiskHyperType);
dskCh.setBytesReadRate(storageMgr.getDiskBytesReadRate(null, diskOffering));
dskCh.setBytesWriteRate(storageMgr.getDiskBytesWriteRate(null, diskOffering));
dskCh.setIopsReadRate(storageMgr.getDiskIopsReadRate(null, diskOffering));
dskCh.setIopsWriteRate(storageMgr.getDiskIopsWriteRate(null, diskOffering));
DataCenterVO destPoolDataCenter = _dcDao.findById(destPoolDcId);
HostPodVO destPoolPod = _podDao.findById(destPoolPodId);
@ -511,6 +517,10 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
DataCenterVO dc = _dcDao.findById(volume.getDataCenterId());
DiskProfile dskCh = new DiskProfile(volume, diskOffering,
snapshot.getHypervisorType());
dskCh.setBytesReadRate(storageMgr.getDiskBytesReadRate(null, diskOffering));
dskCh.setBytesWriteRate(storageMgr.getDiskBytesWriteRate(null, diskOffering));
dskCh.setIopsReadRate(storageMgr.getDiskIopsReadRate(null, diskOffering));
dskCh.setIopsWriteRate(storageMgr.getDiskIopsWriteRate(null, diskOffering));
// Determine what pod to store the volume in
while ((pod = _resourceMgr.findPod(null, null, dc, account.getId(),
@ -611,6 +621,11 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
DiskProfile dskCh = createDiskCharacteristics(volume, template, dc,
diskOffering);
dskCh.setHyperType(vm.getHypervisorType());
dskCh.setBytesReadRate(storageMgr.getDiskBytesReadRate(null, diskOffering));
dskCh.setBytesWriteRate(storageMgr.getDiskBytesWriteRate(null, diskOffering));
dskCh.setIopsReadRate(storageMgr.getDiskIopsReadRate(null, diskOffering));
dskCh.setIopsWriteRate(storageMgr.getDiskIopsWriteRate(null, diskOffering));
// Find a suitable storage to create volume on
StoragePool destPool = storageMgr.findStoragePool(dskCh, dc, pod,
clusterId, null, vm, avoidPools);
@ -649,13 +664,21 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
if (volume.getVolumeType() == Type.ROOT
&& Storage.ImageFormat.ISO != template.getFormat()) {
dskCh = createDiskCharacteristics(volume, template, dc, offering);
dskCh.setBytesReadRate(storageMgr.getDiskBytesReadRate(offering, diskOffering));
dskCh.setBytesWriteRate(storageMgr.getDiskBytesWriteRate(offering, diskOffering));
dskCh.setIopsReadRate(storageMgr.getDiskIopsReadRate(offering, diskOffering));
dskCh.setIopsWriteRate(storageMgr.getDiskIopsWriteRate(offering, diskOffering));
} else {
dskCh = createDiskCharacteristics(volume, template, dc,
diskOffering);
dskCh.setBytesReadRate(storageMgr.getDiskBytesReadRate(null, diskOffering));
dskCh.setBytesWriteRate(storageMgr.getDiskBytesWriteRate(null, diskOffering));
dskCh.setIopsReadRate(storageMgr.getDiskIopsReadRate(null, diskOffering));
dskCh.setIopsWriteRate(storageMgr.getDiskIopsWriteRate(null, diskOffering));
}
dskCh.setHyperType(hyperType);
final HashSet<StoragePool> avoidPools = new HashSet<StoragePool>(
avoids);
@ -1546,6 +1569,11 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
volume.getFolder(), volume.getPath(), volume.getName(),
deviceId, volume.getChainInfo());
cmd.setPoolUuid(volumePool.getUuid());
DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
cmd.setBytesReadRate(storageMgr.getDiskBytesReadRate(null, diskOffering));
cmd.setBytesWriteRate(storageMgr.getDiskBytesWriteRate(null, diskOffering));
cmd.setIopsReadRate(storageMgr.getDiskIopsReadRate(null, diskOffering));
cmd.setIopsWriteRate(storageMgr.getDiskIopsWriteRate(null, diskOffering));
try {
answer = (AttachVolumeAnswer) _agentMgr.send(hostId, cmd);
@ -1906,6 +1934,11 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
StoragePoolVO volumePool = _storagePoolDao.findById(volume
.getPoolId());
cmd.setPoolUuid(volumePool.getUuid());
DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
cmd.setBytesReadRate(storageMgr.getDiskBytesReadRate(null, diskOffering));
cmd.setBytesWriteRate(storageMgr.getDiskBytesWriteRate(null, diskOffering));
cmd.setIopsReadRate(storageMgr.getDiskIopsReadRate(null, diskOffering));
cmd.setIopsWriteRate(storageMgr.getDiskIopsWriteRate(null, diskOffering));
// Collect vm disk statistics from host before stopping Vm
_userVmMgr.collectVmDiskStatistics(vm);
@ -2233,7 +2266,21 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
for (VolumeVO vol : vols) {
PrimaryDataStoreInfo pool = (PrimaryDataStoreInfo)this.dataStoreMgr.getDataStore(vol.getPoolId(), DataStoreRole.Primary);
vm.addDisk(new VolumeTO(vol, pool));
ServiceOfferingVO offering = _offeringDao.findById(vm.getServiceOfferingId());
DiskOfferingVO diskOffering = _diskOfferingDao.findById(vol.getDiskOfferingId());
VolumeTO newVolume = new VolumeTO(vol, pool);
if (vol.getVolumeType() == Type.ROOT) {
newVolume.setBytesReadRate(storageMgr.getDiskBytesReadRate(offering, diskOffering));
newVolume.setBytesWriteRate(storageMgr.getDiskBytesWriteRate(offering, diskOffering));
newVolume.setIopsReadRate(storageMgr.getDiskIopsReadRate(offering, diskOffering));
newVolume.setIopsWriteRate(storageMgr.getDiskIopsWriteRate(offering, diskOffering));
} else {
newVolume.setBytesReadRate(storageMgr.getDiskBytesReadRate(null, diskOffering));
newVolume.setBytesWriteRate(storageMgr.getDiskBytesWriteRate(null, diskOffering));
newVolume.setIopsReadRate(storageMgr.getDiskIopsReadRate(null, diskOffering));
newVolume.setIopsWriteRate(storageMgr.getDiskIopsWriteRate(null, diskOffering));
}
vm.addDisk(newVolume);
}
if (vm.getType() == VirtualMachine.Type.User) {
@ -2463,7 +2510,21 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
pool = (StoragePool)dataStoreMgr.getDataStore(result.second().getId(), DataStoreRole.Primary);
vol = result.first();
}
vm.addDisk(new VolumeTO(vol, pool));
ServiceOfferingVO offering = _offeringDao.findById(vm.getServiceOfferingId());
DiskOfferingVO diskOffering = _diskOfferingDao.findById(vol.getDiskOfferingId());
VolumeTO newVolume = new VolumeTO(vol, pool);
if (vol.getVolumeType() == Type.ROOT) {
newVolume.setBytesReadRate(storageMgr.getDiskBytesReadRate(offering, diskOffering));
newVolume.setBytesWriteRate(storageMgr.getDiskBytesWriteRate(offering, diskOffering));
newVolume.setIopsReadRate(storageMgr.getDiskIopsReadRate(offering, diskOffering));
newVolume.setIopsWriteRate(storageMgr.getDiskIopsWriteRate(offering, diskOffering));
} else {
newVolume.setBytesReadRate(storageMgr.getDiskBytesReadRate(null, diskOffering));
newVolume.setBytesWriteRate(storageMgr.getDiskBytesWriteRate(null, diskOffering));
newVolume.setIopsReadRate(storageMgr.getDiskIopsReadRate(null, diskOffering));
newVolume.setIopsWriteRate(storageMgr.getDiskIopsWriteRate(null, diskOffering));
}
vm.addDisk(newVolume);
}
}

View File

@ -918,6 +918,20 @@ public class DatabaseConfig {
}
ServiceOfferingVO serviceOffering = new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, ha, displayText, useLocalStorage, false, null, false, null, false);
Long bytesReadRate = Long.parseLong(_currentObjectParams.get("bytesReadRate"));
if ((bytesReadRate != null) && (bytesReadRate > 0))
serviceOffering.setBytesReadRate(bytesReadRate);
Long bytesWriteRate = Long.parseLong(_currentObjectParams.get("bytesWriteRate"));
if ((bytesWriteRate != null) && (bytesWriteRate > 0))
serviceOffering.setBytesWriteRate(bytesWriteRate);
Long iopsReadRate = Long.parseLong(_currentObjectParams.get("iopsReadRate"));
if ((iopsReadRate != null) && (iopsReadRate > 0))
serviceOffering.setIopsReadRate(iopsReadRate);
Long iopsWriteRate = Long.parseLong(_currentObjectParams.get("iopsWriteRate"));
if ((iopsWriteRate != null) && (iopsWriteRate > 0))
serviceOffering.setIopsWriteRate(iopsWriteRate);
ServiceOfferingDaoImpl dao = ComponentContext.inject(ServiceOfferingDaoImpl.class);
try {
dao.persist(serviceOffering);
@ -967,6 +981,20 @@ public class DatabaseConfig {
}
DiskOfferingVO diskOffering = new DiskOfferingVO(domainId, name, displayText, diskSpace , tags, false);
diskOffering.setUseLocalStorage(local);
Long bytesReadRate = Long.parseLong(_currentObjectParams.get("bytesReadRate"));
if (bytesReadRate != null && (bytesReadRate > 0))
diskOffering.setBytesReadRate(bytesReadRate);
Long bytesWriteRate = Long.parseLong(_currentObjectParams.get("bytesWriteRate"));
if (bytesWriteRate != null && (bytesWriteRate > 0))
diskOffering.setBytesWriteRate(bytesWriteRate);
Long iopsReadRate = Long.parseLong(_currentObjectParams.get("iopsReadRate"));
if (iopsReadRate != null && (iopsReadRate > 0))
diskOffering.setIopsReadRate(iopsReadRate);
Long iopsWriteRate = Long.parseLong(_currentObjectParams.get("iopsWriteRate"));
if (iopsWriteRate != null && (iopsWriteRate > 0))
diskOffering.setIopsWriteRate(iopsWriteRate);
DiskOfferingDaoImpl offering = ComponentContext.inject(DiskOfferingDaoImpl.class);
try {
offering.persist(diskOffering);

View File

@ -489,7 +489,8 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu
*/
@Override
public ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, Type vm_typeType, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, boolean offerHA,
boolean limitResourceUse, boolean volatileVm, String tags, Long domainId, String hostTag, Integer networkRate, String deploymentPlanner, Map<String, String> details) {
boolean limitResourceUse, boolean volatileVm, String tags, Long domainId, String hostTag, Integer networkRate, String deploymentPlanner, Map<String, String> details,
Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate) {
// TODO Auto-generated method stub
return null;
}
@ -654,7 +655,8 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu
* @see com.cloud.configuration.ConfigurationManager#createDiskOffering(java.lang.Long, java.lang.String, java.lang.String, java.lang.Long, java.lang.String, boolean, boolean, boolean)
*/
@Override
public DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired, boolean isDisplayOfferingEnabled) {
public DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired, boolean isDisplayOfferingEnabled,
Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate) {
// TODO Auto-generated method stub
return null;
}

View File

@ -290,6 +290,14 @@ ALTER TABLE `cloud`.`nics` ADD COLUMN `display_nic` tinyint(1) NOT NULL DEFAULT
ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `display_offering` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should disk offering be displayed to the end user';
ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `bytes_read_rate` bigint(20);
ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `bytes_write_rate` bigint(20);
ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `iops_read_rate` bigint(20);
ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `iops_write_rate` bigint(20);
CREATE TABLE `cloud`.`volume_details` (
`id` bigint unsigned NOT NULL auto_increment,
`volume_id` bigint unsigned NOT NULL COMMENT 'volume id',
@ -762,6 +770,10 @@ CREATE VIEW `cloud`.`volume_view` AS
disk_offering.display_text disk_offering_display_text,
disk_offering.use_local_storage,
disk_offering.system_use,
disk_offering.bytes_read_rate,
disk_offering.bytes_write_rate,
disk_offering.iops_read_rate,
disk_offering.iops_write_rate,
storage_pool.id pool_id,
storage_pool.uuid pool_uuid,
storage_pool.name pool_name,
@ -1070,6 +1082,10 @@ CREATE VIEW `cloud`.`service_offering_view` AS
disk_offering.removed,
disk_offering.use_local_storage,
disk_offering.system_use,
disk_offering.bytes_read_rate,
disk_offering.bytes_write_rate,
disk_offering.iops_read_rate,
disk_offering.iops_write_rate,
service_offering.cpu,
service_offering.speed,
service_offering.ram_size,
@ -1376,6 +1392,10 @@ CREATE VIEW `cloud`.`disk_offering_view` AS
disk_offering.removed,
disk_offering.use_local_storage,
disk_offering.system_use,
disk_offering.bytes_read_rate,
disk_offering.bytes_write_rate,
disk_offering.iops_read_rate,
disk_offering.iops_write_rate,
disk_offering.sort_key,
disk_offering.type,
disk_offering.display_offering,
@ -1616,6 +1636,10 @@ CREATE VIEW `cloud`.`volume_view` AS
disk_offering.display_text disk_offering_display_text,
disk_offering.use_local_storage,
disk_offering.system_use,
disk_offering.bytes_read_rate,
disk_offering.bytes_write_rate,
disk_offering.iops_read_rate,
disk_offering.iops_write_rate,
storage_pool.id pool_id,
storage_pool.uuid pool_uuid,
storage_pool.name pool_name,
@ -1846,7 +1870,10 @@ CREATE TABLE `cloud_usage`.`usage_vm_disk` (
) ENGINE=InnoDB CHARSET=utf8;
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'vm.disk.stats.interval', 0, 'Interval (in seconds) to report vm disk statistics.');
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'vm.disk.throttling.iops_read_rate', 0, 'Default disk I/O read rate in requests per second allowed in User vm\'s disk. ');
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'vm.disk.throttling.iops_write_rate', 0, 'Default disk I/O write rate in requests per second allowed in User vm\'s disk. ');
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'vm.disk.throttling.bytes_read_rate', 0, 'Default disk I/O read rate in bytes per second allowed in User vm\'s disk. ');
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'vm.disk.throttling.bytes_write_rate', 0, 'Default disk I/O write rate in bytes per second allowed in User vm\'s disk. ');
-- Re-enable foreign key checking, at the end of the upgrade path
SET foreign_key_checks = 1;

View File

@ -472,6 +472,10 @@ dictionary = {
'label.disable.vpn': '<fmt:message key="label.disable.vpn" />',
'label.disabling.vpn.access': '<fmt:message key="label.disabling.vpn.access" />',
'label.disk.allocated': '<fmt:message key="label.disk.allocated" />',
'label.disk.bytes.read.rate': '<fmt:message key="label.disk.bytes.read.rate" />',
'label.disk.bytes.write.rate': '<fmt:message key="label.disk.bytes.write.rate" />',
'label.disk.iops.write.rate': '<fmt:message key="label.disk.iops.write.rate" />',
'label.disk.iops.read.rate': '<fmt:message key="label.disk.iops.read.rate" />',
'label.disk.read.bytes': '<fmt:message key="label.disk.read.bytes" />',
'label.disk.read.io': '<fmt:message key="label.disk.read.io" />',
'label.disk.offering': '<fmt:message key="label.disk.offering" />',

View File

@ -109,6 +109,34 @@
number: true
}
},
diskBytesReadRate: {
label: 'label.disk.bytes.read.rate',
validation: {
required: false, //optional
number: true
}
},
diskBytesWriteRate: {
label: 'label.disk.bytes.write.rate',
validation: {
required: false, //optional
number: true
}
},
diskIopsReadRate: {
label: 'label.disk.iops.read.rate',
validation: {
required: false, //optional
number: true
}
},
diskIopsWriteRate: {
label: 'label.disk.iops.write.rate',
validation: {
required: false, //optional
number: true
}
},
offerHA: {
label: 'label.offer.ha',
docID: 'helpComputeOfferingHA',
@ -227,7 +255,26 @@
networkrate: args.data.networkRate
});
}
if(args.data.diskBytesReadRate != null && args.data.diskBytesReadRate.length > 0) {
$.extend(data, {
bytesreadrate: args.data.diskBytesReadRate
});
}
if(args.data.diskBytesWriteRate != null && args.data.diskBytesWriteRate.length > 0) {
$.extend(data, {
byteswriterate: args.data.diskBytesWriteRate
});
}
if(args.data.diskIopsReadRate != null && args.data.diskIopsReadRate.length > 0) {
$.extend(data, {
iopsreadrate: args.data.diskIopsReadRate
});
}
if(args.data.diskIopsWriteRate != null && args.data.diskIopsWriteRate.length > 0) {
$.extend(data, {
iopswriterate: args.data.diskIopsWriteRate
});
}
$.extend(data, {
offerha: (args.data.offerHA == "on")
});
@ -396,6 +443,10 @@
}
},
networkrate: { label: 'label.network.rate' },
diskBytesReadRate: { label: 'label.disk.bytes.read.rate' },
diskBytesWriteRate: { label: 'label.disk.bytes.write.rate' },
diskIopsReadRate: { label: 'label.disk.iops.read.rate' },
diskIopsWriteRate: { label: 'label.disk.iops.write.rate' },
offerha: {
label: 'label.offer.ha',
converter: cloudStack.converters.toBooleanText
@ -534,6 +585,34 @@
number: true
}
},
diskBytesReadRate: {
label: 'label.disk.bytes.read.rate',
validation: {
required: false, //optional
number: true
}
},
diskBytesWriteRate: {
label: 'label.disk.bytes.write.rate',
validation: {
required: false, //optional
number: true
}
},
diskIopsReadRate: {
label: 'label.disk.iops.read.rate',
validation: {
required: false, //optional
number: true
}
},
diskIopsWriteRate: {
label: 'label.disk.iops.write.rate',
validation: {
required: false, //optional
number: true
}
},
offerHA: {
label: 'label.offer.ha',
docID: 'helpSystemOfferingHA',
@ -602,6 +681,26 @@
networkrate: args.data.networkRate
});
}
if(args.data.diskBytesReadRate != null && args.data.diskBytesReadRate.length > 0) {
$.extend(data, {
bytesreadrate: args.data.diskBytesReadRate
});
}
if(args.data.diskBytesWriteRate != null && args.data.diskBytesWriteRate.length > 0) {
$.extend(data, {
byteswriterate: args.data.diskBytesWriteRate
});
}
if(args.data.diskIopsReadRate != null && args.data.diskIopsReadRate.length > 0) {
$.extend(data, {
iopsreadrate: args.data.diskIopsReadRate
});
}
if(args.data.diskIopsWriteRate != null && args.data.diskIopsWriteRate.length > 0) {
$.extend(data, {
iopswriterate: args.data.diskIopsWriteRate
});
}
$.extend(data, {
offerha: (args.data.offerHA == "on")
@ -781,6 +880,10 @@
}
},
networkrate: { label: 'label.network.rate' },
diskBytesReadRate: { label: 'label.disk.bytes.write.rate' },
diskBytesWriteRate: { label: 'label.disk.bytes.write.rate' },
diskIopsReadRate: { label: 'label.disk.iops.write.rate' },
diskIopsWriteRate: { label: 'label.disk.iops.write.rate' },
offerha: {
label: 'label.offer.ha',
converter: cloudStack.converters.toBooleanText
@ -840,6 +943,34 @@
else
return "N/A";
}
},
diskBytesReadRate: {
label: 'label.disk.bytes.read.rate',
validation: {
required: false, //optional
number: true
}
},
diskBytesWriteRate: {
label: 'label.disk.bytes.write.rate',
validation: {
required: false, //optional
number: true
}
},
diskIopsReadRate: {
label: 'label.disk.iops.read.rate',
validation: {
required: false, //optional
number: true
}
},
diskIopsWriteRate: {
label: 'label.disk.iops.write.rate',
validation: {
required: false, //optional
number: true
}
}
},
@ -911,6 +1042,34 @@
dependsOn: 'isCustomized',
validation: { required: true, number: true }
},
diskBytesReadRate: {
label: 'label.disk.bytes.read.rate',
validation: {
required: false, //optional
number: true
}
},
diskBytesWriteRate: {
label: 'label.disk.bytes.write.rate',
validation: {
required: false, //optional
number: true
}
},
diskIopsReadRate: {
label: 'label.disk.iops.read.rate',
validation: {
required: false, //optional
number: true
}
},
diskIopsWriteRate: {
label: 'label.disk.iops.write.rate',
validation: {
required: false, //optional
number: true
}
},
tags: {
label: 'label.storage.tags',
docID: 'helpDiskOfferingStorageTags'
@ -972,6 +1131,26 @@
domainid: args.data.domainId
});
}
if(args.data.diskBytesReadRate != null && args.data.diskBytesReadRate.length > 0) {
$.extend(data, {
bytesreadrate: args.data.diskBytesReadRate
});
}
if(args.data.diskBytesWriteRate != null && args.data.diskBytesWriteRate.length > 0) {
$.extend(data, {
byteswriterate: args.data.diskBytesWriteRate
});
}
if(args.data.diskIopsReadRate != null && args.data.diskIopsReadRate.length > 0) {
$.extend(data, {
iopsreadrate: args.data.diskIopsReadRate
});
}
if(args.data.diskIopsWriteRate != null && args.data.diskIopsWriteRate.length > 0) {
$.extend(data, {
iopswriterate: args.data.diskIopsWriteRate
});
}
$.ajax({
url: createURL('createDiskOffering'),
@ -1084,6 +1263,10 @@
return "N/A";
}
},
diskBytesReadRate: { label: 'label.disk.bytes.write.rate' },
diskBytesWriteRate: { label: 'label.disk.bytes.write.rate' },
diskIopsReadRate: { label: 'label.disk.iops.write.rate' },
diskIopsWriteRate: { label: 'label.disk.iops.write.rate' },
tags: { label: 'label.storage.tags' },
domain: { label: 'label.domain' },
storagetype: { label: 'label.storage.type' }