Skip to content

Commit ebb4935

Browse files
committed
Merge pull request #17 from AzCiS/onesdk-avirupch
Updates in Start-AzureStorSimpleDeviceFailoverJob
2 parents 8c38ae8 + 36f63e4 commit ebb4935

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/Failover/StartAzureStorSimpleDeviceFailoverJob.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
2222
{
2323
[Cmdlet(VerbsLifecycle.Start, "AzureStorSimpleDeviceFailoverJob", DefaultParameterSetName = StorSimpleCmdletParameterSet.Empty),
24-
OutputType(typeof(TaskResponse), typeof(TaskStatusInfo))]
24+
OutputType(typeof(string))]
2525
public class StartAzureStorSimpleDeviceFailoverJob : StorSimpleCmdletBase
2626
{
2727
[Parameter(Position = 0, Mandatory = true, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyById, HelpMessage = StorSimpleCmdletHelpMessage.DeviceId)]
@@ -32,7 +32,7 @@ public class StartAzureStorSimpleDeviceFailoverJob : StorSimpleCmdletBase
3232
[ValidateNotNullOrEmpty]
3333
public string DeviceName { get; set; }
3434

35-
[Parameter(Position = 1, Mandatory = true, HelpMessage = StorSimpleCmdletHelpMessage.VolumeContainerGroups)]
35+
[Parameter(Position = 1, Mandatory = true, ValueFromPipeline = true, HelpMessage = StorSimpleCmdletHelpMessage.VolumeContainerGroups)]
3636
[ValidateNotNull]
3737
public List<DataContainerGroup> VolumecontainerGroups { get; set; }
3838

@@ -93,9 +93,8 @@ public override void ExecuteCmdlet()
9393
return;
9494
}
9595

96-
if(deviceId.Equals(targetDeviceId, StringComparison.InvariantCultureIgnoreCase))
96+
if (!ValidTargetDeviceForFailover(deviceId, targetDeviceId))
9797
{
98-
WriteVerbose(Resources.DeviceFailoverSourceAndTargetDeviceSameError);
9998
WriteObject(null);
10099
return;
101100
}

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

Lines changed: 2 additions & 2 deletions
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
@@ -487,7 +487,7 @@
487487
<value>Are you sure you want to failover the selected volume containers from device {0} to device {1}?</value>
488488
</data>
489489
<data name="VolumeContainerGroupNotEligibleForFailoverError" xml:space="preserve">
490-
<value>Volume Container Group \"{0}\" is not eligible for failover due to the reason: {1}</value>
490+
<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">
493493
<value>The {0} job is triggered successfully. Please use the command Get-AzureStorSimpleJob -InstanceId {1} for tracking the job's status</value>

src/ServiceManagement/StorSimple/Commands.StorSimple/StorSimpleCmdletBase.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,16 @@ internal virtual void HandleException(Exception exception)
193193
}
194194
else if (exType == typeof(ArgumentNullException))
195195
{
196-
var argEx = ex as ArgumentNullException;
196+
var argNullEx = ex as ArgumentNullException;
197+
if (argNullEx == null)
198+
break;
199+
WriteVerbose(string.Format(Resources.InvalidInputMessage, ex.Message));
200+
errorRecord = new ErrorRecord(argNullEx, string.Empty, ErrorCategory.InvalidData, null);
201+
break;
202+
}
203+
else if (exType == typeof(ArgumentException))
204+
{
205+
var argEx = ex as ArgumentException;
197206
if (argEx == null)
198207
break;
199208
WriteVerbose(string.Format(Resources.InvalidInputMessage, ex.Message));
@@ -479,5 +488,21 @@ internal bool ValidParamsForFirstDeviceConfiguration(NetworkConfig[] netConfigs,
479488
}
480489
return true;
481490
}
491+
492+
/// <summary>
493+
/// Validate that the target device is eligible for failover
494+
/// </summary>
495+
/// <param name="sourceDeviceName">The source device identifier</param>
496+
/// <param name="targetDeviceName">The target device identifier</param>
497+
/// <returns></returns>
498+
internal bool ValidTargetDeviceForFailover(string sourceDeviceId, string targetDeviceId)
499+
{
500+
if (sourceDeviceId.Equals(targetDeviceId, StringComparison.InvariantCultureIgnoreCase))
501+
{
502+
throw new ArgumentException(Resources.DeviceFailoverSourceAndTargetDeviceSameError);
503+
}
504+
505+
return true;
506+
}
482507
}
483508
}

0 commit comments

Comments
 (0)