#region Copyright
/*
* Copyright © 2014-2016 NetApp, Inc. All Rights Reserved.
*
* CONFIDENTIALITY NOTICE: THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION OF
* NETAPP, INC. USE, DISCLOSURE OR REPRODUCTION IS PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF NETAPP, INC.
*/
#endregion
#region Using Directives
using System.Linq;
using System.Management.Automation;
using SolidFire.Core;
using SolidFire.Element.Api;
#endregion
namespace SolidFire.Volume.Set
{
[Cmdlet(VerbsCommon.Set, "SFQoSPolicy", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)]
public class SetSFQoSPolicy : SFCmdlet
{
#region Private Data
///
/// Member for saving the optional minimum iops setting. Implemented
/// as a nullable to help decide if the setting needs to be sent
/// to the api call as JSON data.
///
private int? minIOPS;
///
/// Member for saving the optional maximum iops setting. Implemented
/// as a nullable to help decide if the setting needs to be sent
/// to the api call as JSON data.
///
private int? maxIOPS;
///
/// Member for saving the optional burst iops setting. Implemented
/// as a nullable to help decide if the setting needs to be sent
/// to the api call as JSON data.
///
private int? burstIOPS;
///
/// Member for saving the optional burst iops setting. Implemented
/// as a nullable to help decide if the setting needs to be sent
/// to the api call as JSON data.
///
private int? burstTime;
#endregion
#region Parameters
[Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true,
HelpMessage = "The ID of the policy to be modified.")]
public int QoSPolicyID { get; set; }
[Parameter(Position = 1, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true,
HelpMessage = "The name of the QoS policy.")]
public string Name { get; set; }
///
/// Minimum iops to set for the volume.
///
[Parameter(Mandatory = false, Position = 8, HelpMessage = "The desired minimum 4KB IOPS to guarantee")]
public int MinIOPS
{
get { return minIOPS.HasValue ? minIOPS.Value : 0; }
set { minIOPS = value; }
}
///
/// Maximum iops to set for the volume.
///
[Parameter(Mandatory = false, Position = 9, HelpMessage = "The desired maximum 4KB IOPS to guarantee")]
public int MaxIOPS
{
get { return maxIOPS ?? 0; }
set { maxIOPS = value; }
}
///
/// Burst iops to set for the volume.
///
[Parameter(Mandatory = false, Position = 10, HelpMessage = "The maximum 4KB IOPS allowed for a short time")]
public int BurstIOPS
{
get { return burstIOPS ?? 0; }
set { burstIOPS = value; }
}
///
/// Burst iops to set for the volume.
///
[Parameter(Mandatory = false, Position = 11, HelpMessage = "The time to allow a burst of maximum 4KB IOPS")]
public int BurstTime
{
get { return burstTime ?? 0; }
set { burstTime = value; }
}
#endregion
#region Cmdlet Overrides
protected override void BeginProcessing()
{
base.BeginProcessing();
CheckConnection();
}
protected override void ProcessRecord()
{
base.ProcessRecord();
var request = new ModifyQoSPolicyRequest
{
QosPolicyID = QoSPolicyID
};
if (minIOPS.HasValue || maxIOPS.HasValue || burstIOPS.HasValue || burstTime.HasValue)
{
request.Qos = new QoS
{
BurstIOPS = burstIOPS,
MaxIOPS = maxIOPS,
MinIOPS = minIOPS,
BurstTime = burstTime
};
}
if (!string.IsNullOrEmpty(Name))
{
request.Name = Name;
}
WriteObject(SendRequest("ModifyQoSPolicy", request).Select(r => r.Result.QosPolicy));
}
#endregion
}
}