#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 System.Management.Automation.Runspaces;
using SolidFire.Core;
using SolidFire.Element.Api;
#endregion
namespace SolidFire.Cluster.Set
{
///
/// SetNtpInfo is used to configure the NTP on cluster nodes. The values set with this interface apply to all nodes in the cluster.
/// The nodes can only be configured as a server where a host is selected to administrate the networking and/or a broadcast
/// client where each host sends each message to each peer.
///
[Cmdlet(VerbsCommon.Set, "SFNtpInfo", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.High)]
public class SetSFNtpInfo : SFCmdlet
{
#region Private Data
///
/// Member used to host a nested Pipeline for calling other CmdLets
///
private Pipeline pipeline = null;
#endregion
#region Parameters
///
/// List of NTP servers to add to each node’s NTP configuration.
///
[Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "List of NTP servers to add to each node’s NTP configuration.")]
public String[] Servers { get; set; }
///
/// Boolean to determine if every node in the cluster is enabled as a broadcast client.
///
[Parameter(Position = 1, Mandatory = false, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Enable every node in the cluster as a broadcast client. Default is false.")]
public bool BroadcastClient { get; set; }
#endregion
#region Cmdlet Overrides
protected override void BeginProcessing()
{
base.BeginProcessing();
CheckConnection();
pipeline = Runspace.DefaultRunspace.CreateNestedPipeline();
}
protected override void EndProcessing()
{
base.EndProcessing();
var command = new Command("Get-SFNtpInfo");
pipeline.Commands.Add(command);
// Send it to the pipline
WriteObject(pipeline.Invoke(), true);
pipeline = null;
}
///
/// Implementation for processing the execution of the cmdlet.
///
protected override void ProcessRecord()
{
base.ProcessRecord();
// Assemble the parameters object
var request = new SetNtpInfoRequest();
request.Broadcastclient = BroadcastClient;
request.Servers = Servers;
SendRequest("SetNtpInfo", request);
}
#endregion
}
}