#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; using System.ComponentModel; using System.Management.Automation; using SolidFire.Core.Validation; using SolidFire.Core; using SolidFire.Element.Api; #endregion namespace SolidFire.Volume.New { /// /// ListActiveVolumes is used to return the list of active volumes currently in the system. /// The list of volumes is returned sorted in VolumeID order and can be returned in multiple parts (pages). /// [Cmdlet(VerbsCommon.New, "SFClone", ConfirmImpact = ConfirmImpact.Medium)] public class NewSFClone : SFCmdlet { #region Private Data private Int64 volumeID; private string name; private Int64? newAccountID = null; private Int64? newSize = null; private string access = null; private Int64? snapshotID = null; #endregion #region Parameters /// /// /// [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Volume ID for the volume to be cloned")] [ValidatePattern(SolidFireValidations.Numeric)] public Int64 VolumeID { get { return volumeID; } set { volumeID = value; } } /// /// /// [Parameter(Mandatory = true, Position = 1, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Name of the new cloned volume")] [ValidatePattern(SolidFireValidations.UpperAndLowerCase)] [ValidateLength(1, 64)] public String Name { get { return name; } set { name = value; } } /// /// /// [Parameter(Mandatory = false, Position = 2, HelpMessage = "AccountID of the owner of the volume")] [ValidatePattern(SolidFireValidations.Numeric)] public Int64 NewAccountID { get { return newAccountID.Value; } set { newAccountID = value; } } /// /// /// [Parameter(Mandatory = false, Position = 3, HelpMessage = "New size of the volume in Gigabytes")] [ValidatePattern(SolidFireValidations.GreaterThanZero)] public Int64 NewSize { get { return newSize.Value; } set { newSize = value; } } /// /// /// [Parameter(Mandatory = false, Position = 4, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Access allowed for the new volume")] [ValidatePattern(SolidFireValidations.UpperAndLowerCase)] [ValidateSet("readOnly", "readWrite", "replicationTarget", IgnoreCase = true)] public String Access { get { return access; } set { access = value; } } /// /// /// [Parameter(Mandatory = false, Position = 5, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "ID of the snapshot that is used as the source of the clone")] [ValidatePattern(SolidFireValidations.Numeric)] public Int64 SnapshotID { get { return snapshotID ?? 0; } set { snapshotID = value; } } /// /// /// [Parameter(Mandatory = false, Position = 6, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "List of Name/Value pairs as a hashtable")] public Hashtable Attributes { get; set; } #endregion #region Cmdlet Overrides protected override void BeginProcessing() { base.BeginProcessing(); CheckConnection(); } /// /// /// protected override void ProcessRecord() { base.ProcessRecord(); // Assemble our request var request = new CloneVolumeRequest(); request.VolumeID = volumeID; request.Name = name; request.NewAccountID = newAccountID; request.NewSize = newSize; request.Access = access; request.Attributes = Attributes; request.SnapshotID = snapshotID; var objsFromAPI = SendRequest("CloneVolume", request); foreach (var obj in objsFromAPI) { WriteObject(obj.Result, true); } } #endregion } }