Skip to content

Commit

Permalink
Adding Device Id inputs to the clone cmdlet
Browse files Browse the repository at this point in the history
  • Loading branch information
parvezah committed Feb 27, 2015
1 parent 41f02f9 commit 9a243c6
Showing 1 changed file with 38 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,39 @@ namespace Microsoft.AzureStorSimpleDeviceCmdlets.Commands
/// Given a backupId, snapshot and a targetDeviceName , this commandlet will
/// clone it on the given target device.
/// </summary>
[Cmdlet(VerbsLifecycle.Start, "AzureStorSimpleBackupCloneJob")]
[Cmdlet(VerbsLifecycle.Start, "AzureStorSimpleBackupCloneJob", DefaultParameterSetName = StorSimpleCmdletParameterSet.Empty)]
public class StartAzureStorSimpleBackupCloneJob : StorSimpleCmdletBase
{
[Parameter(Mandatory = true, Position = 0, HelpMessage = StorSimpleCmdletHelpMessage.SourceDeviceName)]
[Parameter(Mandatory = true, Position = 0, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyByName, HelpMessage = StorSimpleCmdletHelpMessage.SourceDeviceName)]
[ValidateNotNullOrEmpty]
public string SourceDeviceName { get; set; }

[Parameter(Mandatory = true, Position = 1, HelpMessage = StorSimpleCmdletHelpMessage.TargetDeviceName)]
[Parameter(Mandatory = true, Position = 0, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyById, HelpMessage = StorSimpleCmdletHelpMessage.SourceDeviceId)]
[ValidateNotNullOrEmpty]
public string SourceDeviceId { get; set; }

[Parameter(Mandatory = true, Position = 1, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyByName, HelpMessage = StorSimpleCmdletHelpMessage.TargetDeviceName)]
[ValidateNotNullOrEmpty]
public string TargetDeviceName { get; set; }

[Parameter(Mandatory = true, Position = 1, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyById, HelpMessage = StorSimpleCmdletHelpMessage.TargetDeviceId)]
[ValidateNotNullOrEmpty]
public string TargetDeviceId { get; set; }

[Parameter(Mandatory = true, Position = 2, HelpMessage = StorSimpleCmdletHelpMessage.BackupIdToClone)]
[ValidateNotNullOrEmpty]
public string BackupId { get; set; }

[Parameter(Mandatory = true, Position = 3, ValueFromPipeline = true, HelpMessage = StorSimpleCmdletHelpMessage.SnapshotToClone)]
[ValidateNotNull]
public Snapshot Snapshot { get; set; }

[Parameter(Mandatory = false, Position = 4, ValueFromPipeline = true, HelpMessage = StorSimpleCmdletHelpMessage.VolumeAcrList)]
[ValidateNotNull]
public List<AccessControlRecord> TargetAccessControlRecords { get; set; }

[Parameter(Mandatory = false, Position = 5, HelpMessage = StorSimpleCmdletHelpMessage.CloneVolumeName)]
[ValidateNotNullOrEmpty]
public string CloneVolumeName { get; set; }

[Parameter(Mandatory = false, Position = 6, HelpMessage = StorSimpleCmdletHelpMessage.Force)]
Expand Down Expand Up @@ -83,22 +97,31 @@ public override void ExecuteCmdlet()

private bool ProcessParameters()
{
this.sourceDeviceId = StorSimpleClient.GetDeviceId(SourceDeviceName);

if (this.sourceDeviceId == null)
switch (ParameterSetName)
{
WriteVerbose(Resources.NoDeviceFoundWithGivenNameInResourceMessage);
return false;
}
case StorSimpleCmdletParameterSet.IdentifyById:
this.sourceDeviceId = SourceDeviceId;
this.targetDeviceId = TargetDeviceId;
break;
case StorSimpleCmdletParameterSet.IdentifyByName:
this.sourceDeviceId = StorSimpleClient.GetDeviceId(SourceDeviceName);

if (this.sourceDeviceId == null)
{
WriteVerbose(Resources.NoDeviceFoundWithGivenNameInResourceMessage);
return false;
}

this.targetDeviceId = StorSimpleClient.GetDeviceId(TargetDeviceName);
this.targetDeviceId = StorSimpleClient.GetDeviceId(TargetDeviceName);

if (this.targetDeviceId == null)
{
WriteVerbose(Resources.NoDeviceFoundWithGivenNameInResourceMessage);
return false;
if (this.targetDeviceId == null)
{
WriteVerbose(Resources.NoDeviceFoundWithGivenNameInResourceMessage);
return false;
}
break;
}

return true;
}

Expand Down

0 comments on commit 9a243c6

Please sign in to comment.