#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 { /// /// SetSnmpTrapInfo is used to enable and disable the generation of SolidFire SNMP notifications (traps) and to specify the set of /// network host computers that are to receive the notifications. The values passed with each SetSnmpTrapInfo method replaces /// all values set in any previous method to SetSnmpTrapInfo. /// [Cmdlet(VerbsCommon.Set, "SFSnmpTrapInfo", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.High)] public class SetSFSnmpTrapInfo : SFCmdlet { #region Private Data /// /// Member used to host a nested Pipeline for calling other CmdLets /// private Pipeline pipeline = null; #endregion #region Parameters /// /// List of hosts that are to receive the traps generated by the Cluster Master. At least one object is required if any one of the trap types is enabled. /// [Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "List of hosts that are to receive the traps generated by the Cluster Master. At least one object is required if any one of the trap types is enabled.")] public SnmpTrapRecipient[] TrapRecipients { get; set; } /// /// If set to true, a corresponding solidFireClusterFaultNotification is sent to the configured list of trap recipients when a cluster fault is logged. /// [Parameter(Position = 1, Mandatory = false, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "If set to true, a corresponding solidFireClusterFaultNotification is sent to the configured list of trap recipients when a cluster fault is logged.")] public bool ClusterFaultTrapsEnabled { get; set; } /// /// If set to true, a corresponding solidFireClusterFaultNotification is sent to the configured list of trap recipients when a cluster fault is resolved. /// [Parameter(Position = 2, Mandatory = false, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "If set to true, a corresponding solidFireClusterFaultResolvedNotification is sent to the configured list of trap recipients when a cluster fault is resolved.")] public bool ClusterFaultResolvedTrapsEnabled { get; set; } /// /// If set to true, a corresponding solidFireClusterEventNotification is sent to the configured list of trap recipients when a cluster event is logged. /// [Parameter(Position = 3, Mandatory = false, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "If set to true, a corresponding solidFireClusterEventNotification is sent to the configured list of trap recipients when a cluster event is logged.")] public bool ClusterEventTrapsEnabled { 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-SFSnmpTrapInfo"); 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(); var request = new SetSnmpTrapInfoRequest(); request.ClusterEventTrapsEnabled = ClusterEventTrapsEnabled; request.ClusterFaultResolvedTrapsEnabled = ClusterFaultResolvedTrapsEnabled; request.ClusterFaultTrapsEnabled = ClusterFaultTrapsEnabled; request.TrapRecipients = TrapRecipients.Distinct().ToArray(); SendRequest("SetSnmpTrapInfo", request); } #endregion } }