#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.Linq; using System.Management.Automation; using SolidFire.Core.Validation; using SolidFire.Core; using SolidFire.Element.Api; #endregion namespace SolidFire.Drive.Request { /// /// Used to remove any residual data from drives that have a status of "available." For example, when replacing a /// drive at its end-of-life that contained sensitive data. It uses a Security Erase Unit command to write a predetermined pattern to the /// drive and resets the encryption key on the drive. The method may take up to two minutes to complete, so it is an asynchronous /// method. /// [Cmdlet(VerbsLifecycle.Invoke, "SFSecureEraseDrive", DefaultParameterSetName = "DriveIDs", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.High)] public class InvokeSFSecureEraseDrive : SFCmdlet { #region Private Data #endregion #region Parameters [Parameter(Position = 0, ParameterSetName = "DriveIDs", Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, ValueFromRemainingArguments = false, HelpMessage = "Please enter a drive ID or list of drive IDs")] [ValidateNotNullOrEmpty] [ValidatePattern(SolidFireValidations.Numeric)] public Int64[] DriveID { get; set; } [Parameter(Position = 0, ParameterSetName = "Drives", Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, ValueFromRemainingArguments = false, HelpMessage = "Please pass in a SFDrive or list of SFDrives")] [ValidateNotNullOrEmpty] public DriveInfo[] Drive { get; set; } #endregion #region Cmdlet Overrides protected override void BeginProcessing() { base.BeginProcessing(); CheckConnection(); } /// /// /// protected override void ProcessRecord() { base.ProcessRecord(); if (ParameterSetName == "DriveIDs") { var request = new SecureEraseDrivesRequest(); request.Drives = DriveID; var objsFromAPI = SendRequest("SecureEraseDrives", request, false); foreach (var obj in objsFromAPI) { WriteObject(obj.Result, true); } } if (ParameterSetName == "Drives") { var request = new SecureEraseDrivesRequest(); // populate the drives object from the SFDrive collection that has been passed in request.Drives = Drive.Select(drv => drv.DriveID).ToArray(); var objsFromAPI = SendRequest("SecureEraseDrives", request, false); foreach (var obj in objsFromAPI) { WriteObject(obj.Result, true); } } } #endregion } }