#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;
using System.ComponentModel;
using System.Management.Automation;
using SolidFire.Core;
using SolidFire.Element.Api;
using System.Linq;
using SolidFire.Core.Helpers;
#endregion
namespace SolidFire.Test
{
///
/// Used to validate the connection to all nodes in the cluster on both 1G and 10G interfaces using ICMP packets. The test uses the appropriate MTU sizes for each packet based on the MTU settings in the network configuration.
///
[Cmdlet(VerbsDiagnostic.Test, "SFPing")]
public class TestSFPing : SFCmdlet
{
#region Private Fields
private long? _attempts;
private long? _totalTimeoutSec;
private long? _packetSize;
private long? _pingTimeoutMsec;
#endregion
#region CmdLet Parameters
[Parameter(HelpMessage = "Specifies the number of times the system should repeat the test ping. Default is 5.")]
public long Attempts
{
get { return _attempts.HasValue ? _attempts.Value : 0; }
set { _attempts = value; }
}
[Parameter(HelpMessage = "Specify address or hostnames of devices to ping.")]
public string[] Hosts { get; set; }
[Parameter(HelpMessage = "Specifies the length of time the ping should wait for a system response before issuing the next ping attempt or ending the process.")]
public long TotalTimeoutSec
{
get { return _totalTimeoutSec.HasValue ? _totalTimeoutSec.Value : 0; }
set { _totalTimeoutSec = value; }
}
[Parameter(HelpMessage = "Specify the number of bytes to send in the ICMP packet sent to each IP. Number be less than the maximum MTU specified in the network configuration.")]
public long PacketSize
{
get { return _packetSize.HasValue ? _packetSize.Value : 0; }
set { _packetSize = value; }
}
[Parameter(HelpMessage = "Specify the number of milliseconds to wait for each individual ping response. Default is 500ms.")]
public long PingTimeoutMsec
{
get { return _pingTimeoutMsec.HasValue ? _pingTimeoutMsec.Value : 0; }
set { _pingTimeoutMsec = value; }
}
#endregion
#region Cmdlet Overrides
protected override void BeginProcessing()
{
base.BeginProcessing();
CheckConnection(endPoint: SolidFireUtilities.SFEndPoint.Node);
}
protected override void ProcessRecord()
{
base.ProcessRecord();
var request = new TestPingRequest()
{
Attempts = _attempts,
PacketSize = _packetSize,
PingTimeoutMsec = _pingTimeoutMsec,
TotalTimeoutSec = _totalTimeoutSec
};
if (Hosts != null)
{
request.Hosts = string.Join(",", Hosts);
}
var objsFromAPI = SendRequest("TestPing", request);
WriteObject(objsFromAPI.Select(o => o.Result), true);
}
#endregion
}
}