@@ -16,25 +16,39 @@ namespace Microsoft.AzureStorSimpleDeviceCmdlets.Commands
16
16
/// Given a backupId, snapshot and a targetDeviceName , this commandlet will
17
17
/// clone it on the given target device.
18
18
/// </summary>
19
- [ Cmdlet ( VerbsLifecycle . Start , "AzureStorSimpleBackupCloneJob" ) ]
19
+ [ Cmdlet ( VerbsLifecycle . Start , "AzureStorSimpleBackupCloneJob" , DefaultParameterSetName = StorSimpleCmdletParameterSet . Empty ) ]
20
20
public class StartAzureStorSimpleBackupCloneJob : StorSimpleCmdletBase
21
21
{
22
- [ Parameter ( Mandatory = true , Position = 0 , HelpMessage = StorSimpleCmdletHelpMessage . SourceDeviceName ) ]
22
+ [ Parameter ( Mandatory = true , Position = 0 , ParameterSetName = StorSimpleCmdletParameterSet . IdentifyByName , HelpMessage = StorSimpleCmdletHelpMessage . SourceDeviceName ) ]
23
+ [ ValidateNotNullOrEmpty ]
23
24
public string SourceDeviceName { get ; set ; }
24
25
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 ]
26
32
public string TargetDeviceName { get ; set ; }
27
33
34
+ [ Parameter ( Mandatory = true , Position = 1 , ParameterSetName = StorSimpleCmdletParameterSet . IdentifyById , HelpMessage = StorSimpleCmdletHelpMessage . TargetDeviceId ) ]
35
+ [ ValidateNotNullOrEmpty ]
36
+ public string TargetDeviceId { get ; set ; }
37
+
28
38
[ Parameter ( Mandatory = true , Position = 2 , HelpMessage = StorSimpleCmdletHelpMessage . BackupIdToClone ) ]
39
+ [ ValidateNotNullOrEmpty ]
29
40
public string BackupId { get ; set ; }
30
41
31
42
[ Parameter ( Mandatory = true , Position = 3 , ValueFromPipeline = true , HelpMessage = StorSimpleCmdletHelpMessage . SnapshotToClone ) ]
43
+ [ ValidateNotNull ]
32
44
public Snapshot Snapshot { get ; set ; }
33
45
34
46
[ Parameter ( Mandatory = false , Position = 4 , ValueFromPipeline = true , HelpMessage = StorSimpleCmdletHelpMessage . VolumeAcrList ) ]
47
+ [ ValidateNotNull ]
35
48
public List < AccessControlRecord > TargetAccessControlRecords { get ; set ; }
36
49
37
50
[ Parameter ( Mandatory = false , Position = 5 , HelpMessage = StorSimpleCmdletHelpMessage . CloneVolumeName ) ]
51
+ [ ValidateNotNullOrEmpty ]
38
52
public string CloneVolumeName { get ; set ; }
39
53
40
54
[ Parameter ( Mandatory = false , Position = 6 , HelpMessage = StorSimpleCmdletHelpMessage . Force ) ]
@@ -83,22 +97,31 @@ public override void ExecuteCmdlet()
83
97
84
98
private bool ProcessParameters ( )
85
99
{
86
- this . sourceDeviceId = StorSimpleClient . GetDeviceId ( SourceDeviceName ) ;
87
-
88
- if ( this . sourceDeviceId == null )
100
+ switch ( ParameterSetName )
89
101
{
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
+ }
93
114
94
- this . targetDeviceId = StorSimpleClient . GetDeviceId ( TargetDeviceName ) ;
115
+ this . targetDeviceId = StorSimpleClient . GetDeviceId ( TargetDeviceName ) ;
95
116
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 ;
100
123
}
101
-
124
+
102
125
return true ;
103
126
}
104
127
0 commit comments