Skip to content

Commit 57d5daa

Browse files
committed
Merge pull request #12 from AzCiS/parvezah
Adding Device Id inputs to the Clone cmdlets.
2 parents 766658a + 9a243c6 commit 57d5daa

File tree

4 files changed

+40
-17
lines changed

4 files changed

+40
-17
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

src/ServiceManagement/StorSimple/Commands.StorSimple/Properties/Resources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ServiceManagement/StorSimple/Commands.StorSimple/Properties/Resources.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@
490490
<value>Volume Container Group \"{0}\" is not eligible for failover due to the reason: {1}</value>
491491
</data>
492492
<data name="SuccessMessageSubmitDeviceJob" xml:space="preserve">
493-
<value>The {0} job is triggered successfully. Please use the command Get-AzureStorSimpleJob -InstanceId {1} for tracking the job's status</value>
493+
<value>The {0} job is triggered successfully. Please use the command Get-AzureStorSimpleJob -JobId {1} for tracking the job's status</value>
494494
</data>
495495
<data name="StartASSBackupCloneJobMessage" xml:space="preserve">
496496
<value>Cloning backup with backupId {0}...</value>

0 commit comments

Comments
 (0)