Skip to content

Commit 9a243c6

Browse files
committed
Adding Device Id inputs to the clone cmdlet
1 parent 41f02f9 commit 9a243c6

File tree

1 file changed

+38
-15
lines changed

1 file changed

+38
-15
lines changed

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/Clone/StartAzureStorSimpleBackupCloneJob.cs

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,39 @@ namespace Microsoft.AzureStorSimpleDeviceCmdlets.Commands
1616
/// Given a backupId, snapshot and a targetDeviceName , this commandlet will
1717
/// clone it on the given target device.
1818
/// </summary>
19-
[Cmdlet(VerbsLifecycle.Start, "AzureStorSimpleBackupCloneJob")]
19+
[Cmdlet(VerbsLifecycle.Start, "AzureStorSimpleBackupCloneJob", DefaultParameterSetName = StorSimpleCmdletParameterSet.Empty)]
2020
public class StartAzureStorSimpleBackupCloneJob : StorSimpleCmdletBase
2121
{
22-
[Parameter(Mandatory = true, Position = 0, HelpMessage = StorSimpleCmdletHelpMessage.SourceDeviceName)]
22+
[Parameter(Mandatory = true, Position = 0, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyByName, HelpMessage = StorSimpleCmdletHelpMessage.SourceDeviceName)]
23+
[ValidateNotNullOrEmpty]
2324
public string SourceDeviceName { get; set; }
2425

25-
[Parameter(Mandatory = true, Position = 1, HelpMessage = StorSimpleCmdletHelpMessage.TargetDeviceName)]
26+
[Parameter(Mandatory = true, Position = 0, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyById, HelpMessage = StorSimpleCmdletHelpMessage.SourceDeviceId)]
27+
[ValidateNotNullOrEmpty]
28+
public string SourceDeviceId { get; set; }
29+
30+
[Parameter(Mandatory = true, Position = 1, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyByName, HelpMessage = StorSimpleCmdletHelpMessage.TargetDeviceName)]
31+
[ValidateNotNullOrEmpty]
2632
public string TargetDeviceName { get; set; }
2733

34+
[Parameter(Mandatory = true, Position = 1, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyById, HelpMessage = StorSimpleCmdletHelpMessage.TargetDeviceId)]
35+
[ValidateNotNullOrEmpty]
36+
public string TargetDeviceId { get; set; }
37+
2838
[Parameter(Mandatory = true, Position = 2, HelpMessage = StorSimpleCmdletHelpMessage.BackupIdToClone)]
39+
[ValidateNotNullOrEmpty]
2940
public string BackupId { get; set; }
3041

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

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

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

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

8498
private bool ProcessParameters()
8599
{
86-
this.sourceDeviceId = StorSimpleClient.GetDeviceId(SourceDeviceName);
87-
88-
if (this.sourceDeviceId == null)
100+
switch (ParameterSetName)
89101
{
90-
WriteVerbose(Resources.NoDeviceFoundWithGivenNameInResourceMessage);
91-
return false;
92-
}
102+
case StorSimpleCmdletParameterSet.IdentifyById:
103+
this.sourceDeviceId = SourceDeviceId;
104+
this.targetDeviceId = TargetDeviceId;
105+
break;
106+
case StorSimpleCmdletParameterSet.IdentifyByName:
107+
this.sourceDeviceId = StorSimpleClient.GetDeviceId(SourceDeviceName);
108+
109+
if (this.sourceDeviceId == null)
110+
{
111+
WriteVerbose(Resources.NoDeviceFoundWithGivenNameInResourceMessage);
112+
return false;
113+
}
93114

94-
this.targetDeviceId = StorSimpleClient.GetDeviceId(TargetDeviceName);
115+
this.targetDeviceId = StorSimpleClient.GetDeviceId(TargetDeviceName);
95116

96-
if (this.targetDeviceId == null)
97-
{
98-
WriteVerbose(Resources.NoDeviceFoundWithGivenNameInResourceMessage);
99-
return false;
117+
if (this.targetDeviceId == null)
118+
{
119+
WriteVerbose(Resources.NoDeviceFoundWithGivenNameInResourceMessage);
120+
return false;
121+
}
122+
break;
100123
}
101-
124+
102125
return true;
103126
}
104127

0 commit comments

Comments
 (0)