v1.0.0
This commit is contained in:
@@ -7,25 +7,70 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for limit IO
|
||||
type LimitIORequest struct {
|
||||
DiskID uint64 `url:"diskId"`
|
||||
IOps uint64 `url:"iops"`
|
||||
TotalBytesSec uint64 `url:"total_bytes_sec"`
|
||||
ReadBytesSec uint64 `url:"read_bytes_sec"`
|
||||
WriteBytesSec uint64 `url:"write_bytes_sec"`
|
||||
TotalIOpsSec uint64 `url:"total_iops_sec"`
|
||||
ReadIOpsSec uint64 `url:"read_iops_sec"`
|
||||
WriteIOpsSec uint64 `url:"write_iops_sec"`
|
||||
TotalBytesSecMax uint64 `url:"total_bytes_sec_max"`
|
||||
ReadBytesSecMax uint64 `url:"read_bytes_sec_max"`
|
||||
WriteBytesSecMax uint64 `url:"write_bytes_sec_max"`
|
||||
TotalIOpsSecMax uint64 `url:"total_iops_sec_max"`
|
||||
ReadIOpsSecMax uint64 `url:"read_iops_sec_max"`
|
||||
WriteIOpsSecMax uint64 `url:"write_iops_sec_max"`
|
||||
SizeIOpsSec uint64 `url:"size_iops_sec"`
|
||||
// ID of the disk to limit
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId"`
|
||||
|
||||
// Alias for total_iops_sec for backwards compatibility
|
||||
// Required: false
|
||||
IOPS uint64 `url:"iops,omitempty"`
|
||||
|
||||
// TotalBytesSec
|
||||
// Required: false
|
||||
TotalBytesSec uint64 `url:"total_bytes_sec,omitempty"`
|
||||
|
||||
// ReadBytesSec
|
||||
// Required: false
|
||||
ReadBytesSec uint64 `url:"read_bytes_sec,omitempty"`
|
||||
|
||||
// WriteBytesSec
|
||||
// Required: false
|
||||
WriteBytesSec uint64 `url:"write_bytes_sec,omitempty"`
|
||||
|
||||
// TotalIOPSSec
|
||||
// Required: false
|
||||
TotalIOPSSec uint64 `url:"total_iops_sec,omitempty"`
|
||||
|
||||
// ReadIOPSSec
|
||||
// Required: false
|
||||
ReadIOPSSec uint64 `url:"read_iops_sec,omitempty"`
|
||||
|
||||
// WriteIOPSSec
|
||||
// Required: false
|
||||
WriteIOPSSec uint64 `url:"write_iops_sec,omitempty"`
|
||||
|
||||
// TotalBytesSecMax
|
||||
// Required: false
|
||||
TotalBytesSecMax uint64 `url:"total_bytes_sec_max,omitempty"`
|
||||
|
||||
// ReadBytesSecMax
|
||||
// Required: false
|
||||
ReadBytesSecMax uint64 `url:"read_bytes_sec_max,omitempty"`
|
||||
|
||||
// WriteBytesSecMax
|
||||
// Required: false
|
||||
WriteBytesSecMax uint64 `url:"write_bytes_sec_max,omitempty"`
|
||||
|
||||
// TotalIOPSSecMax
|
||||
// Required: false
|
||||
TotalIOPSSecMax uint64 `url:"total_iops_sec_max,omitempty"`
|
||||
|
||||
// ReadIOPSSecMax
|
||||
// Required: false
|
||||
ReadIOPSSecMax uint64 `url:"read_iops_sec_max,omitempty"`
|
||||
|
||||
// WriteIOPSSecMax
|
||||
// Required: false
|
||||
WriteIOPSSecMax uint64 `url:"write_iops_sec_max,omitempty"`
|
||||
|
||||
// SizeIOPSSec
|
||||
// Required: false
|
||||
SizeIOPSSec uint64 `url:"size_iops_sec,omitempty"`
|
||||
}
|
||||
|
||||
func (drq LimitIORequest) Validate() error {
|
||||
func (drq LimitIORequest) validate() error {
|
||||
if drq.DiskID == 0 {
|
||||
return errors.New("validation-error: field DiskID can not be empty or equal to 0")
|
||||
}
|
||||
@@ -33,8 +78,11 @@ func (drq LimitIORequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// LimitIO limit IO for a certain disk
|
||||
// total and read/write options are not allowed to be combined
|
||||
// see http://libvirt.org/formatdomain.html#elementsDisks iotune section for more details
|
||||
func (d Disks) LimitIO(ctx context.Context, req LimitIORequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -52,5 +100,4 @@ func (d Disks) LimitIO(ctx context.Context, req LimitIORequest) (bool, error) {
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user