#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 { /// /// SetSnmpInfo is used to configure SNMP v2 and v3 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 SetSnmpInfo. /// [Cmdlet(VerbsCommon.Set, "SFSnmpInfo", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.High)] public class SetSFSnmpInfo : 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 set to "true", then SNMP is enabled on each node in the cluster. /// [Parameter(Position = 1, Mandatory = false, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "If set to 'true', then SNMP is enabled on each node in the cluster.")] public bool Enabled { get; set; } /// /// If set to "true", then SNMP v3 is enabled on each node in the cluster. /// [Parameter(Position = 2, Mandatory = false, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "If set to 'true', then SNMP v3 is enabled on each node in the cluster.")] public bool SnmpV3Enabled { 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(); pipeline = Runspace.DefaultRunspace.CreateNestedPipeline(); } protected override void EndProcessing() { base.EndProcessing(); var command = new Command("Get-SFSnmpInfo"); 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 SetSnmpInfoRequest(); request.Enabled = Enabled; if (Networks != null) { request.Networks = Networks.Distinct().ToArray(); } request.SnmpV3Enabled = SnmpV3Enabled; if (UsmUsers != null) { request.UsmUsers = UsmUsers.Distinct().ToArray(); } SendRequest("SetSnmpInfo", request); } #endregion } }