#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.Management.Automation; using System.Management.Automation.Runspaces; using SolidFire.Core; using SolidFire.Element.Api; #endregion namespace SolidFire.Cluster.Enable { /// /// EnableSnmp is used to enable SNMP 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 EnableSnmp. /// [Cmdlet(VerbsLifecycle.Enable, "SFSnmp", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)] public class EnableSFSnmp : SFCmdlet { #region Private Data /// /// Member used to host a nested Pipeline for calling other CmdLets /// private Pipeline pipeline = null; #endregion #region Parameters /// /// If set to "true", then SNMP v3 is enabled on each node in the cluster. If set to "false", then SNMP v2 is enabled. /// [Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "If set to 'true', then SNMP v3 is enabled on each node in the cluster. If set to 'false', then SNMP v2 is enabled.")] public bool SnmpV3Enabled { get; set; } #endregion #region Cmdlet Overrides /// /// Verify the connection is Oxygen or less. /// Create a nested pipeline that can be written to after processing /// protected override void BeginProcessing() { base.BeginProcessing(); CheckConnection(); pipeline = Runspace.DefaultRunspace.CreateNestedPipeline(); } /// /// After processing, invoke the Get-SFSnmpState CmdLet to pass the new SNMPState into the pipeline. /// protected override void EndProcessing() { base.EndProcessing(); var command = new Command("Get-SFSnmpState"); 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 EnableSnmpRequest(); request.SnmpV3Enabled = SnmpV3Enabled; SendRequest("EnableSnmp", request); } #endregion } }