#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.ComponentModel;
using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using SolidFire.Core;
using SolidFire.Element.Api;
#endregion
namespace SolidFire.Cluster.Set
{
///
/// SetSnmpACL is used to configure SNMP access permissions on the cluster nodes. The values set with this interface apply to
/// all nodes in the cluster, and the values that are passed replace, in whole, all values set in any previous call to SetSnmpACL.
/// Also note that the values set with this interface replace all “network” or “usmUsers” values set with the older SetSnmpInfo.
///
[Cmdlet(VerbsCommon.Set, "SFSnmpAcl", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.High)]
public class SetSFSnmpAcl : SFCmdlet
{
#region Private Data
///
/// Member used to host a nested Pipeline for calling other CmdLets
///
private Pipeline pipeline = null;
#endregion
#region Parameters
///
/// List of networks and what type of access they have to the SNMP servers running on the cluster nodes.
/// See SNMP Network Object for possible "networks" values. SNMP v2 only.
///
[Parameter(Position = 0, Mandatory = false, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "List of networks and what type of access they have to the SNMP servers running on the cluster nodes. See SNMP Network Object for possible 'networks' values. SNMP v2 only.")]
public SnmpNetwork[] Networks { get; set; }
///
/// If SNMP v3 is enabled, this value must be passed in place of the "networks" parameter. SNMP v3 only.
///
[Parameter(Position = 3, Mandatory = false, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "If SNMP v3 is enabled, this value must be passed in place of the 'networks' parameter. SNMP v3 only.")]
public SnmpV3UsmUser[] UsmUsers { get; set; }
#endregion
#region Cmdlet Overrides
protected override void BeginProcessing()
{
base.BeginProcessing();
CheckConnection(minVersionNumber: 8.0f);
pipeline = Runspace.DefaultRunspace.CreateNestedPipeline();
}
protected override void EndProcessing()
{
base.EndProcessing();
var command = new Command("Get-SFSnmpAcl");
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 SetSnmpACLRequest();
request.Networks = Networks == null ? new SnmpNetwork[0] : Networks.Distinct().ToArray();
request.UsmUsers = UsmUsers == null ? new SnmpV3UsmUser[0] : UsmUsers.Distinct().ToArray();
SendRequest("SetSnmpACL", request);
}
#endregion
}
}