#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.Collections.Generic; using System.ComponentModel; using System.Management.Automation; using SolidFire.Core.Validation; using System.Management.Automation.Runspaces; using SolidFire.Core; using SolidFire.Element.Api; #endregion namespace SolidFire.Volume.Set { /// /// ModifyGroupSnapshot is used to change the attributes currently assigned to snapshots in a group. Use this API method to enable the /// snapshots created on the Read/Write (source) volume to be remotely replicated to a target SolidFire storage system. /// [Cmdlet(VerbsCommon.Set, "SFGroupSnapshot", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)] public class SetSFGroupSnapshot : SFCmdlet { #region Private Data private List _processedIDs = new List(); private bool? _enableRemoteReplication; private Pipeline pipeline; #endregion #region Parameters [Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Unique ID(s) of the Group Snapshot.")] [ValidatePattern(SolidFireValidations.Numeric)] public Int64[] GroupSnapshotID { get; set; } [Parameter(Position = 1, Mandatory = false, HelpMessage = "Use to enable the snapshot created to be replicated to a remote SolidFire cluster.")] public bool EnableRemoteReplication { get { return _enableRemoteReplication.HasValue ? _enableRemoteReplication.Value : false; } set { _enableRemoteReplication = value; } } [Parameter(Position = 2, Mandatory = false, HelpMessage = "Use to set the time when the snapshot should be removed. Must be an ISO-8601 date string.")] [SFValidatePattern(SolidFireValidations.ISO8601DateTimeOrEmptyString, "The argument is not in the format of an ISO-8601 Date String.")] public string ExpirationTime { get; set; } #endregion #region Cmdlet Overrides /// /// Implementation for validation the status of the connection before /// allowing the cmdlet to continue processing. /// protected override void BeginProcessing() { base.BeginProcessing(); CheckConnection(minVersionNumber: 8.0f); pipeline = Runspace.DefaultRunspace.CreateNestedPipeline(); } /// /// Implementation for collecting the volume IDs. /// Note: This method is called multiple times per execution of the /// CmdLet for pipelined objects. /// protected override void ProcessRecord() { base.ProcessRecord(); foreach (var id in GroupSnapshotID) { var request = new ModifyGroupSnapshotRequest(); request.GroupSnapshotID = id; request.EnableRemoteReplication = _enableRemoteReplication; request.ExpirationTime = ExpirationTime; SendRequest("ModifyGroupSnapshot", request); _processedIDs.Add(id); } } /// /// Implementation for executing the input against the API. /// protected override void EndProcessing() { base.EndProcessing(); if (_processedIDs.Count > 0) { var command = new Command("Get-SFGroupSnapshot"); command.Parameters.Add("GroupSnapshotID", _processedIDs); if (SFConnection != null) { command.Parameters.Add("SFConnection", SFConnection); } else if (Target != null) { command.Parameters.Add("Target", Target); } pipeline.Commands.Add(command); WriteObject(pipeline.Invoke(), true); _processedIDs.Clear(); } pipeline = null; } #endregion } }